diff options
author | Ricardo Neri <ricardo.neri@ti.com> | 2012-05-18 02:42:36 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@ti.com> | 2012-05-22 12:33:23 -0400 |
commit | 2603915336352e5491c02b0befa3b890ea13d6ef (patch) | |
tree | 958b3d08bff774ef196b3e20331493c824a51613 /sound/soc | |
parent | 0ff5ee871ff18bb5b66a81353aac1db7e9399d95 (diff) |
ASoC: OMAP: HDMI: Create a structure for private data of the CPU DAI
Create a struct hdmi_priv to store the relevant data of the CPU DAI
driver. As more data is added to the driver, having all the data
in the same location eases its handling. At the moment, only the DMA
configuration parameters are included in the structure.
Also, the required memory is allocated using devm_kzalloc rather than
using a static global variable.
Signed-off-by: Ricardo Neri <ricardo.neri@ti.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/omap/omap-hdmi.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c index b889f7668c81..a6656b2a7353 100644 --- a/sound/soc/omap/omap-hdmi.c +++ b/sound/soc/omap/omap-hdmi.c | |||
@@ -37,9 +37,8 @@ | |||
37 | 37 | ||
38 | #define DRV_NAME "omap-hdmi-audio-dai" | 38 | #define DRV_NAME "omap-hdmi-audio-dai" |
39 | 39 | ||
40 | static struct omap_pcm_dma_data omap_hdmi_dai_dma_params = { | 40 | struct hdmi_priv { |
41 | .name = "HDMI playback", | 41 | struct omap_pcm_dma_data dma_params; |
42 | .sync_mode = OMAP_DMA_SYNC_PACKET, | ||
43 | }; | 42 | }; |
44 | 43 | ||
45 | static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream, | 44 | static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream, |
@@ -62,23 +61,24 @@ static int omap_hdmi_dai_hw_params(struct snd_pcm_substream *substream, | |||
62 | struct snd_pcm_hw_params *params, | 61 | struct snd_pcm_hw_params *params, |
63 | struct snd_soc_dai *dai) | 62 | struct snd_soc_dai *dai) |
64 | { | 63 | { |
64 | struct hdmi_priv *priv = snd_soc_dai_get_drvdata(dai); | ||
65 | int err = 0; | 65 | int err = 0; |
66 | 66 | ||
67 | switch (params_format(params)) { | 67 | switch (params_format(params)) { |
68 | case SNDRV_PCM_FORMAT_S16_LE: | 68 | case SNDRV_PCM_FORMAT_S16_LE: |
69 | omap_hdmi_dai_dma_params.packet_size = 16; | 69 | priv->dma_params.packet_size = 16; |
70 | break; | 70 | break; |
71 | case SNDRV_PCM_FORMAT_S24_LE: | 71 | case SNDRV_PCM_FORMAT_S24_LE: |
72 | omap_hdmi_dai_dma_params.packet_size = 32; | 72 | priv->dma_params.packet_size = 32; |
73 | break; | 73 | break; |
74 | default: | 74 | default: |
75 | err = -EINVAL; | 75 | err = -EINVAL; |
76 | } | 76 | } |
77 | 77 | ||
78 | omap_hdmi_dai_dma_params.data_type = OMAP_DMA_DATA_TYPE_S32; | 78 | priv->dma_params.data_type = OMAP_DMA_DATA_TYPE_S32; |
79 | 79 | ||
80 | snd_soc_dai_set_dma_data(dai, substream, | 80 | snd_soc_dai_set_dma_data(dai, substream, |
81 | &omap_hdmi_dai_dma_params); | 81 | &priv->dma_params); |
82 | 82 | ||
83 | return err; | 83 | return err; |
84 | } | 84 | } |
@@ -102,6 +102,13 @@ static __devinit int omap_hdmi_probe(struct platform_device *pdev) | |||
102 | { | 102 | { |
103 | int ret; | 103 | int ret; |
104 | struct resource *hdmi_rsrc; | 104 | struct resource *hdmi_rsrc; |
105 | struct hdmi_priv *hdmi_data; | ||
106 | |||
107 | hdmi_data = devm_kzalloc(&pdev->dev, sizeof(*hdmi_data), GFP_KERNEL); | ||
108 | if (hdmi_data == NULL) { | ||
109 | dev_err(&pdev->dev, "Cannot allocate memory for HDMI data\n"); | ||
110 | return -ENOMEM; | ||
111 | } | ||
105 | 112 | ||
106 | hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 113 | hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
107 | if (!hdmi_rsrc) { | 114 | if (!hdmi_rsrc) { |
@@ -109,7 +116,7 @@ static __devinit int omap_hdmi_probe(struct platform_device *pdev) | |||
109 | return -ENODEV; | 116 | return -ENODEV; |
110 | } | 117 | } |
111 | 118 | ||
112 | omap_hdmi_dai_dma_params.port_addr = hdmi_rsrc->start | 119 | hdmi_data->dma_params.port_addr = hdmi_rsrc->start |
113 | + OMAP_HDMI_AUDIO_DMA_PORT; | 120 | + OMAP_HDMI_AUDIO_DMA_PORT; |
114 | 121 | ||
115 | hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 122 | hdmi_rsrc = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
@@ -118,8 +125,11 @@ static __devinit int omap_hdmi_probe(struct platform_device *pdev) | |||
118 | return -ENODEV; | 125 | return -ENODEV; |
119 | } | 126 | } |
120 | 127 | ||
121 | omap_hdmi_dai_dma_params.dma_req = hdmi_rsrc->start; | 128 | hdmi_data->dma_params.dma_req = hdmi_rsrc->start; |
129 | hdmi_data->dma_params.name = "HDMI playback"; | ||
130 | hdmi_data->dma_params.sync_mode = OMAP_DMA_SYNC_PACKET; | ||
122 | 131 | ||
132 | dev_set_drvdata(&pdev->dev, hdmi_data); | ||
123 | ret = snd_soc_register_dai(&pdev->dev, &omap_hdmi_dai); | 133 | ret = snd_soc_register_dai(&pdev->dev, &omap_hdmi_dai); |
124 | return ret; | 134 | return ret; |
125 | } | 135 | } |