]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/greybus/audio.h
greybus: audio: Drop get_version support
[karo-tx-linux.git] / drivers / staging / greybus / audio.h
1 /*
2  * Greybus audio
3  *
4  * Copyright 2015 Google Inc.
5  * Copyright 2015 Linaro Ltd.
6  *
7  * Released under the GPLv2 only.
8  */
9
10 #ifndef __GB_AUDIO_H
11 #define __GB_AUDIO_H
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>
19
20 #include "greybus.h"
21
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)
27
28 /* assuming 1 ms samples @ 48KHz */
29 #define CONFIG_SAMPLES_PER_MSG                  48L
30 #define CONFIG_PERIOD_NS                        1000000 /* send msg every 1ms */
31
32 #define CONFIG_COUNT_MAX                        20
33
34 /* Switch between dummy spdif and jetson rt5645 codec */
35 #define USE_RT5645                              0
36
37 #define SAMPLE_SIZE                             4
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) + \
40                                 MAX_SEND_DATA_LEN)
41
42
43 /*
44  * This is the gb_snd structure which ties everything together
45  * and fakes DMA interrupts via a timer.
46  */
47 struct gb_snd {
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
57                                         *i2s_configs;
58         char                            *send_data_req_buf;
59         long                            send_data_sample_count;
60         int                             gb_bundle_id;
61         int                             device_count;
62         struct snd_pcm_substream        *substream;
63         struct hrtimer                  timer;
64         atomic_t                        running;
65         bool                            cport_active;
66         struct workqueue_struct         *workqueue;
67         struct work_struct              work;
68         int                             hwptr_done;
69         int                             transfer_done;
70         struct list_head                list;
71         spinlock_t                      lock;
72 };
73
74
75 /*
76  * GB I2S cmd functions
77  */
78 int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
79                                       uint16_t cport);
80 int gb_i2s_mgmt_deactivate_cport(struct gb_connection *connection,
81                                         uint16_t cport);
82 int gb_i2s_mgmt_get_supported_configurations(
83         struct gb_connection *connection,
84         struct gb_i2s_mgmt_get_supported_configurations_response *get_cfg,
85         size_t size);
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);
97
98
99 /*
100  * GB PCM hooks
101  */
102 void gb_pcm_hrtimer_start(struct gb_snd *snd_dev);
103 void gb_pcm_hrtimer_stop(struct gb_snd *snd_dev);
104
105
106 /*
107  * Platform drivers
108  */
109 extern struct platform_driver gb_audio_pcm_driver;
110 extern struct platform_driver gb_audio_plat_driver;
111
112
113 #endif /* __GB_AUDIO_H */