Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316128
b: refs/heads/master
c: d0b1252
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai committed Jun 15, 2012
1 parent 77ce2fc commit f1b520c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 127 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4f0110ced1b5d61e6df4871f6f800a9d3678bf26
refs/heads/master: d0b1252dd11549103a97a13aca25737b084c5618
191 changes: 65 additions & 126 deletions trunk/sound/pci/hda/patch_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct hdmi_spec {
* Non-generic ATI/NVIDIA specific
*/
struct hda_multi_out multiout;
const struct hda_pcm_stream *pcm_playback;
struct hda_pcm_stream pcm_playback;
};


Expand Down Expand Up @@ -1367,8 +1367,7 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
info->name = get_hdmi_pcm_name(i);
info->pcm_type = HDA_PCM_TYPE_HDMI;
pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
snd_BUG_ON(!spec->pcm_playback);
*pstr = *spec->pcm_playback;
*pstr = spec->pcm_playback;
pstr->nid = spec->cvts[i].cvt_nid;
if (pstr->channels_max <= 2 && chans && chans <= 16)
pstr->channels_max = chans;
Expand Down Expand Up @@ -1560,6 +1559,49 @@ static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
stream_tag, format, substream);
}

static const struct hda_pcm_stream simple_pcm_playback = {
.substreams = 1,
.channels_min = 2,
.channels_max = 2,
.ops = {
.open = simple_playback_pcm_open,
.close = simple_playback_pcm_close,
.prepare = simple_playback_pcm_prepare
},
};

static const struct hda_codec_ops simple_hdmi_patch_ops = {
.build_controls = simple_playback_build_controls,
.build_pcms = simple_playback_build_pcms,
.init = simple_playback_init,
.free = simple_playback_free,
};

static int patch_simple_hdmi(struct hda_codec *codec,
hda_nid_t cvt_nid, hda_nid_t pin_nid)
{
struct hdmi_spec *spec;

spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;

codec->spec = spec;

spec->multiout.num_dacs = 0; /* no analog */
spec->multiout.max_channels = 2;
spec->multiout.dig_out_nid = cvt_nid;
spec->num_cvts = 1;
spec->num_pins = 1;
spec->cvts[0].cvt_nid = cvt_nid;
spec->cvts[0].cvt_nid = pin_nid;
spec->pcm_playback = simple_pcm_playback;

codec->patch_ops = simple_hdmi_patch_ops;

return 0;
}

static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec,
int channels)
{
Expand Down Expand Up @@ -1732,68 +1774,32 @@ static const struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = {
},
};

static const struct hda_pcm_stream nvhdmi_pcm_playback_2ch = {
.substreams = 1,
.channels_min = 2,
.channels_max = 2,
.nid = nvhdmi_master_con_nid_7x,
.rates = SUPPORTED_RATES,
.maxbps = SUPPORTED_MAXBPS,
.formats = SUPPORTED_FORMATS,
.ops = {
.open = simple_playback_pcm_open,
.close = simple_playback_pcm_close,
.prepare = simple_playback_pcm_prepare
},
};

static const struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = {
.build_controls = simple_playback_build_controls,
.build_pcms = simple_playback_build_pcms,
.init = nvhdmi_7x_init,
.free = simple_playback_free,
};

static const struct hda_codec_ops nvhdmi_patch_ops_2ch = {
.build_controls = simple_playback_build_controls,
.build_pcms = simple_playback_build_pcms,
.init = nvhdmi_7x_init,
.free = simple_playback_free,
};

static int patch_nvhdmi_2ch(struct hda_codec *codec)
{
struct hdmi_spec *spec;
int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x,
nvhdmi_master_pin_nid_7x);
if (err < 0)
return err;

spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (spec == NULL)
return -ENOMEM;

codec->spec = spec;

spec->multiout.num_dacs = 0; /* no analog */
spec->multiout.max_channels = 2;
spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
spec->num_cvts = 1;
spec->cvts[0].cvt_nid = nvhdmi_master_con_nid_7x;
spec->pcm_playback = &nvhdmi_pcm_playback_2ch;

codec->patch_ops = nvhdmi_patch_ops_2ch;

codec->patch_ops.init = nvhdmi_7x_init;
/* override the PCM rates, etc, as the codec doesn't give full list */
spec = codec->spec;
spec->pcm_playback.rates = SUPPORTED_RATES;
spec->pcm_playback.maxbps = SUPPORTED_MAXBPS;
spec->pcm_playback.formats = SUPPORTED_FORMATS;
return 0;
}

static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
{
struct hdmi_spec *spec;
int err = patch_nvhdmi_2ch(codec);

if (err < 0)
return err;
spec = codec->spec;
spec->multiout.max_channels = 8;
spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x;

/* Initialize the audio infoframe channel mask and checksum to something
* valid */
Expand Down Expand Up @@ -1837,94 +1843,27 @@ static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
return 0;
}

static const struct hda_pcm_stream atihdmi_pcm_digital_playback = {
.substreams = 1,
.channels_min = 2,
.channels_max = 2,
.nid = ATIHDMI_CVT_NID,
.ops = {
.open = simple_playback_pcm_open,
.close = simple_playback_pcm_close,
.prepare = atihdmi_playback_pcm_prepare
},
};

static const struct hda_codec_ops atihdmi_patch_ops = {
.build_controls = simple_playback_build_controls,
.build_pcms = simple_playback_build_pcms,
.init = simple_playback_init,
.free = simple_playback_free,
};


static int patch_atihdmi(struct hda_codec *codec)
{
struct hdmi_spec *spec;

spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (spec == NULL)
return -ENOMEM;

codec->spec = spec;

spec->multiout.num_dacs = 0; /* no analog */
spec->multiout.max_channels = 2;
spec->multiout.dig_out_nid = ATIHDMI_CVT_NID;
spec->num_cvts = 1;
spec->num_pins = 1;
spec->cvts[0].cvt_nid = ATIHDMI_CVT_NID;
spec->pins[0].pin_nid = ATIHDMI_PIN_NID;
spec->pcm_playback = &atihdmi_pcm_digital_playback;

codec->patch_ops = atihdmi_patch_ops;

int err = patch_simple_hdmi(codec, ATIHDMI_CVT_NID, ATIHDMI_PIN_NID);
if (err < 0)
return err;
spec = codec->spec;
spec->pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare;
return 0;
}

/* VIA HDMI Implementation */
#define VIAHDMI_CVT_NID 0x02 /* audio converter1 */
#define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */

static const struct hda_codec_ops via_hdmi_patch_ops = {
.build_controls = simple_playback_build_controls,
.build_pcms = simple_playback_build_pcms,
.init = simple_playback_init,
.free = simple_playback_free,
.unsol_event = simple_hdmi_unsol_event,
};

static struct hda_pcm_stream via_hdmi_digital_playback = {
.substreams = 1,
.channels_min = 2,
.channels_max = 2,
.nid = VIAHDMI_CVT_NID, /* NID to query formats and rates*/
.ops = {
.open = simple_playback_pcm_open,
.close = simple_playback_pcm_close,
.prepare = simple_playback_pcm_prepare
},
};

static int patch_via_hdmi(struct hda_codec *codec)
{
struct hdmi_spec *spec;

spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (spec == NULL)
return -ENOMEM;

spec->multiout.num_dacs = 0; /* no analog */
spec->multiout.max_channels = 2;
spec->multiout.dig_out_nid = VIAHDMI_CVT_NID; /* pure-digital case */
spec->num_cvts = 1;
spec->num_pins = 1;
spec->cvts[0].cvt_nid = VIAHDMI_CVT_NID;
spec->pins[0].pin_nid = VIAHDMI_PIN_NID;
spec->pcm_playback = &via_hdmi_digital_playback;

codec->spec = spec;
codec->patch_ops = via_hdmi_patch_ops;

int err = patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID);
if (err < 0)
return err;
codec->patch_ops.unsol_event = simple_hdmi_unsol_event;
return 0;
}

Expand Down

0 comments on commit f1b520c

Please sign in to comment.