Skip to content

Commit 515511a

Browse files
committed
Merge remote-tracking branch 'asoc/topic/hdmi' into asoc-next
2 parents 180bc41 + 8f65881 commit 515511a

File tree

13 files changed

+969
-41
lines changed

13 files changed

+969
-41
lines changed

include/sound/hdmi-codec.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* hdmi-codec.h - HDMI Codec driver API
3+
*
4+
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5+
*
6+
* Author: Jyri Sarha <[email protected]>
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License
10+
* version 2 as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful, but
13+
* WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* General Public License for more details.
16+
*/
17+
18+
#ifndef __HDMI_CODEC_H__
19+
#define __HDMI_CODEC_H__
20+
21+
#include <linux/hdmi.h>
22+
#include <drm/drm_edid.h>
23+
#include <sound/asoundef.h>
24+
#include <uapi/sound/asound.h>
25+
26+
/*
27+
* Protocol between ASoC cpu-dai and HDMI-encoder
28+
*/
29+
struct hdmi_codec_daifmt {
30+
enum {
31+
HDMI_I2S,
32+
HDMI_RIGHT_J,
33+
HDMI_LEFT_J,
34+
HDMI_DSP_A,
35+
HDMI_DSP_B,
36+
HDMI_AC97,
37+
HDMI_SPDIF,
38+
} fmt;
39+
int bit_clk_inv:1;
40+
int frame_clk_inv:1;
41+
int bit_clk_master:1;
42+
int frame_clk_master:1;
43+
};
44+
45+
/*
46+
* HDMI audio parameters
47+
*/
48+
struct hdmi_codec_params {
49+
struct hdmi_audio_infoframe cea;
50+
struct snd_aes_iec958 iec;
51+
int sample_rate;
52+
int sample_width;
53+
int channels;
54+
};
55+
56+
struct hdmi_codec_ops {
57+
/*
58+
* Called when ASoC starts an audio stream setup.
59+
* Optional
60+
*/
61+
int (*audio_startup)(struct device *dev);
62+
63+
/*
64+
* Configures HDMI-encoder for audio stream.
65+
* Mandatory
66+
*/
67+
int (*hw_params)(struct device *dev,
68+
struct hdmi_codec_daifmt *fmt,
69+
struct hdmi_codec_params *hparms);
70+
71+
/*
72+
* Shuts down the audio stream.
73+
* Mandatory
74+
*/
75+
void (*audio_shutdown)(struct device *dev);
76+
77+
/*
78+
* Mute/unmute HDMI audio stream.
79+
* Optional
80+
*/
81+
int (*digital_mute)(struct device *dev, bool enable);
82+
83+
/*
84+
* Provides EDID-Like-Data from connected HDMI device.
85+
* Optional
86+
*/
87+
int (*get_eld)(struct device *dev, uint8_t *buf, size_t len);
88+
};
89+
90+
/* HDMI codec initalization data */
91+
struct hdmi_codec_pdata {
92+
const struct hdmi_codec_ops *ops;
93+
uint i2s:1;
94+
uint spdif:1;
95+
int max_i2s_channels;
96+
};
97+
98+
#define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
99+
100+
#endif /* __HDMI_CODEC_H__ */

include/sound/pcm_iec958.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
77
size_t len);
88

9+
int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params,
10+
u8 *cs, size_t len);
911
#endif

sound/core/pcm_iec958.c

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,18 @@
99
#include <linux/types.h>
1010
#include <sound/asoundef.h>
1111
#include <sound/pcm.h>
12+
#include <sound/pcm_params.h>
1213
#include <sound/pcm_iec958.h>
1314

14-
/**
15-
* snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status
16-
* @runtime: pcm runtime structure with ->rate filled in
17-
* @cs: channel status buffer, at least four bytes
18-
* @len: length of channel status buffer
19-
*
20-
* Create the consumer format channel status data in @cs of maximum size
21-
* @len corresponding to the parameters of the PCM runtime @runtime.
22-
*
23-
* Drivers may wish to tweak the contents of the buffer after creation.
24-
*
25-
* Returns: length of buffer, or negative error code if something failed.
26-
*/
27-
int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
28-
size_t len)
15+
static int create_iec958_consumer(uint rate, uint sample_width,
16+
u8 *cs, size_t len)
2917
{
3018
unsigned int fs, ws;
3119

3220
if (len < 4)
3321
return -EINVAL;
3422

35-
switch (runtime->rate) {
23+
switch (rate) {
3624
case 32000:
3725
fs = IEC958_AES3_CON_FS_32000;
3826
break;
@@ -59,7 +47,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
5947
}
6048

6149
if (len > 4) {
62-
switch (snd_pcm_format_width(runtime->format)) {
50+
switch (sample_width) {
6351
case 16:
6452
ws = IEC958_AES4_CON_WORDLEN_20_16;
6553
break;
@@ -71,6 +59,7 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
7159
IEC958_AES4_CON_MAX_WORDLEN_24;
7260
break;
7361
case 24:
62+
case 32: /* Assume 24-bit width for 32-bit samples. */
7463
ws = IEC958_AES4_CON_WORDLEN_24_20 |
7564
IEC958_AES4_CON_MAX_WORDLEN_24;
7665
break;
@@ -92,4 +81,46 @@ int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
9281

9382
return len;
9483
}
84+
85+
/**
86+
* snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status
87+
* @runtime: pcm runtime structure with ->rate filled in
88+
* @cs: channel status buffer, at least four bytes
89+
* @len: length of channel status buffer
90+
*
91+
* Create the consumer format channel status data in @cs of maximum size
92+
* @len corresponding to the parameters of the PCM runtime @runtime.
93+
*
94+
* Drivers may wish to tweak the contents of the buffer after creation.
95+
*
96+
* Returns: length of buffer, or negative error code if something failed.
97+
*/
98+
int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs,
99+
size_t len)
100+
{
101+
return create_iec958_consumer(runtime->rate,
102+
snd_pcm_format_width(runtime->format),
103+
cs, len);
104+
}
95105
EXPORT_SYMBOL(snd_pcm_create_iec958_consumer);
106+
107+
/**
108+
* snd_pcm_create_iec958_consumer_hw_params - create IEC958 channel status
109+
* @hw_params: the hw_params instance for extracting rate and sample format
110+
* @cs: channel status buffer, at least four bytes
111+
* @len: length of channel status buffer
112+
*
113+
* Create the consumer format channel status data in @cs of maximum size
114+
* @len corresponding to the parameters of the PCM runtime @runtime.
115+
*
116+
* Drivers may wish to tweak the contents of the buffer after creation.
117+
*
118+
* Returns: length of buffer, or negative error code if something failed.
119+
*/
120+
int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params,
121+
u8 *cs, size_t len)
122+
{
123+
return create_iec958_consumer(params_rate(params), params_width(params),
124+
cs, len);
125+
}
126+
EXPORT_SYMBOL(snd_pcm_create_iec958_consumer_hw_params);

sound/hda/local.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ static inline int get_wcaps_type(unsigned int wcaps)
1616
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1717
}
1818

19+
static inline unsigned int get_wcaps_channels(u32 wcaps)
20+
{
21+
unsigned int chans;
22+
23+
chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
24+
chans = (chans + 1) * 2;
25+
26+
return chans;
27+
}
28+
1929
extern const struct attribute_group *hdac_dev_attr_groups[];
2030
int hda_widget_sysfs_init(struct hdac_device *codec);
2131
void hda_widget_sysfs_exit(struct hdac_device *codec);

sound/soc/codecs/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ config SND_SOC_ALL_CODECS
8888
select SND_SOC_MC13783 if MFD_MC13XXX
8989
select SND_SOC_ML26124 if I2C
9090
select SND_SOC_NAU8825 if I2C
91+
select SND_SOC_HDMI_CODEC
9192
select SND_SOC_PCM1681 if I2C
9293
select SND_SOC_PCM179X_I2C if I2C
9394
select SND_SOC_PCM179X_SPI if SPI_MASTER
@@ -478,6 +479,11 @@ config SND_SOC_BT_SCO
478479
config SND_SOC_DMIC
479480
tristate
480481

482+
config SND_SOC_HDMI_CODEC
483+
tristate
484+
select SND_PCM_ELD
485+
select SND_PCM_IEC958
486+
481487
config SND_SOC_ES8328
482488
tristate "Everest Semi ES8328 CODEC"
483489

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ snd-soc-max9850-objs := max9850.o
8181
snd-soc-mc13783-objs := mc13783.o
8282
snd-soc-ml26124-objs := ml26124.o
8383
snd-soc-nau8825-objs := nau8825.o
84+
snd-soc-hdmi-codec-objs := hdmi-codec.o
8485
snd-soc-pcm1681-objs := pcm1681.o
8586
snd-soc-pcm179x-codec-objs := pcm179x.o
8687
snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o
@@ -291,6 +292,7 @@ obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
291292
obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
292293
obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
293294
obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o
295+
obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o
294296
obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o
295297
obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o
296298
obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o

0 commit comments

Comments
 (0)