drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Extension
.c
Size
4953 bytes
Lines
201
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct snd_dw_hdmi {
	struct dw_hdmi_audio_data data;
	struct platform_device  *audio_pdev;
	unsigned int pos;
};

struct dw_hdmi_channel_conf {
	u8 conf1;
	u8 ca;
};

/*
 * The default mapping of ALSA channels to HDMI channels and speaker
 * allocation bits.  Note that we can't do channel remapping here -
 * channels must be in the same order.
 *
 * Mappings for alsa-lib pcm/surround*.conf files:
 *
 *		Front	Sur4.0	Sur4.1	Sur5.0	Sur5.1	Sur7.1
 * Channels	2	4	6	6	6	8
 *
 * Our mapping from ALSA channel to CEA686D speaker name and HDMI channel:
 *
 *				Number of ALSA channels
 * ALSA Channel	2	3	4	5	6	7	8
 * 0		FL:0	=	=	=	=	=	=
 * 1		FR:1	=	=	=	=	=	=
 * 2			FC:3	RL:4	LFE:2	=	=	=
 * 3				RR:5	RL:4	FC:3	=	=
 * 4					RR:5	RL:4	=	=
 * 5						RR:5	=	=
 * 6							RC:6	=
 * 7							RLC/FRC	RLC/FRC
 */
static struct dw_hdmi_channel_conf default_hdmi_channel_config[7] = {
	{ 0x03, 0x00 },	/* FL,FR */
	{ 0x0b, 0x02 },	/* FL,FR,FC */
	{ 0x33, 0x08 },	/* FL,FR,RL,RR */
	{ 0x37, 0x09 },	/* FL,FR,LFE,RL,RR */
	{ 0x3f, 0x0b },	/* FL,FR,LFE,FC,RL,RR */
	{ 0x7f, 0x0f },	/* FL,FR,LFE,FC,RL,RR,RC */
	{ 0xff, 0x13 },	/* FL,FR,LFE,FC,RL,RR,[FR]RC,[FR]LC */
};

static int audio_hw_params(struct device *dev,  void *data,
			   struct hdmi_codec_daifmt *daifmt,
			   struct hdmi_codec_params *params)
{
	struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
	u8 ca;

	dw_hdmi_set_sample_rate(dw->data.hdmi, params->sample_rate);

	ca = default_hdmi_channel_config[params->channels - 2].ca;

	dw_hdmi_set_channel_count(dw->data.hdmi, params->channels);
	dw_hdmi_set_channel_allocation(dw->data.hdmi, ca);

	dw_hdmi_set_sample_non_pcm(dw->data.hdmi,
				   params->iec.status[0] & IEC958_AES0_NONAUDIO);
	dw_hdmi_set_sample_width(dw->data.hdmi, params->sample_width);

	if (daifmt->bit_fmt == SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE)
		dw_hdmi_set_sample_iec958(dw->data.hdmi, 1);
	else
		dw_hdmi_set_sample_iec958(dw->data.hdmi, 0);

	return 0;
}

static void audio_shutdown(struct device *dev, void *data)
{
}

static int audio_mute_stream(struct device *dev, void *data,
			     bool enable, int direction)
{
	struct snd_dw_hdmi *dw = dev_get_drvdata(dev);

	if (!enable)
		dw_hdmi_audio_enable(dw->data.hdmi);
	else
		dw_hdmi_audio_disable(dw->data.hdmi);

	return 0;
}

static int audio_get_eld(struct device *dev, void *data,
			 u8 *buf, size_t len)
{

Annotation

Implementation Notes