4 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd.
7 * Released under the GPLv2 only.
12 #include <linux/kernel.h>
13 #include <linux/device.h>
14 #include <linux/interrupt.h>
15 #include <linux/module.h>
16 #include <linux/i2c.h>
17 #include <linux/platform_device.h>
18 #include <sound/soc.h>
22 #define GB_SAMPLE_RATE 48000
23 #define GB_RATES SNDRV_PCM_RATE_48000
24 #define GB_FMTS SNDRV_PCM_FMTBIT_S16_LE
25 #define PREALLOC_BUFFER (32 * 1024)
26 #define PREALLOC_BUFFER_MAX (32 * 1024)
28 /* assuming 1 ms samples @ 48KHz */
29 #define CONFIG_SAMPLES_PER_MSG 48L
30 #define CONFIG_PERIOD_NS 1000000 /* send msg every 1ms */
32 #define CONFIG_COUNT_MAX 20
34 /* Switch between dummy spdif and jetson rt5645 codec */
38 #define MAX_SEND_DATA_LEN (CONFIG_SAMPLES_PER_MSG * SAMPLE_SIZE)
39 #define SEND_DATA_BUF_LEN (sizeof(struct gb_i2s_send_data_request) + \
44 * This is the gb_snd structure which ties everything together
45 * and fakes DMA interrupts via a timer.
48 struct platform_device card;
49 struct platform_device cpu_dai;
50 struct platform_device *codec;
51 struct asoc_simple_card_info *simple_card_info;
52 struct i2c_client *rt5647;
53 struct gb_connection *mgmt_connection;
54 struct gb_connection *i2s_tx_connection;
55 struct gb_connection *i2s_rx_connection;
56 struct gb_i2s_mgmt_get_supported_configurations_response
58 char *send_data_req_buf;
59 long send_data_sample_count;
62 struct snd_pcm_substream *substream;
66 struct workqueue_struct *workqueue;
67 struct work_struct work;
70 struct list_head list;
76 * GB I2S cmd functions
78 int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
80 int gb_i2s_mgmt_deactivate_cport(struct gb_connection *connection,
82 int gb_i2s_mgmt_get_supported_configurations(
83 struct gb_connection *connection,
84 struct gb_i2s_mgmt_get_supported_configurations_response *get_cfg,
86 int gb_i2s_mgmt_set_configuration(struct gb_connection *connection,
87 struct gb_i2s_mgmt_set_configuration_request *set_cfg);
88 int gb_i2s_mgmt_set_samples_per_message(struct gb_connection *connection,
89 uint16_t samples_per_message);
90 int gb_i2s_mgmt_get_cfgs(struct gb_snd *snd_dev,
91 struct gb_connection *connection);
92 void gb_i2s_mgmt_free_cfgs(struct gb_snd *snd_dev);
93 int gb_i2s_mgmt_set_cfg(struct gb_snd *snd_dev, int rate, int chans,
94 int bytes_per_chan, int is_le);
95 int gb_i2s_send_data(struct gb_connection *connection, void *req_buf,
96 void *source_addr, size_t len, int sample_num);
102 void gb_pcm_hrtimer_start(struct gb_snd *snd_dev);
103 void gb_pcm_hrtimer_stop(struct gb_snd *snd_dev);
109 extern struct platform_driver gb_audio_pcm_driver;
110 extern struct platform_driver gb_audio_plat_driver;
113 #endif /* __GB_AUDIO_H */