View | Details | Raw Unified | Return to bug 156494
Collapse All | Expand All

(-)alsa-kernel/pci/hda/patch_sigmatel.c (+156 lines)
Lines 1148-1153 Link Here
1148
}
1148
}
1149
1149
1150
/*
1150
/*
1151
 * STAC7661
1152
 */
1153
1154
static hda_nid_t vaio_dacs[4] = { 0x2, 0x3, 0x4, 0x5 };
1155
static hda_nid_t vaio_adcs[2] = { 0x8, 0x6 };
1156
static hda_nid_t vaio_mux_nids[1] = { 0x15 };
1157
1158
static struct hda_input_mux vaio_mux = {
1159
	.num_items = 4,
1160
	.items = {
1161
		{ "HP", 0x0 },
1162
		{ "Unknown", 0x1 },
1163
		{ "Mic", 0x2 },
1164
		{ "PCM", 0x3 },
1165
	}
1166
};
1167
1168
static struct hda_verb vaio_init[] = {
1169
	{0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1170
	{0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1171
	{0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1172
	{0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1173
	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1174
	{0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1175
	{0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1176
	{0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1177
	{0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1178
	{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1179
	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1180
	{}
1181
};
1182
1183
/* bind volumes of both NID 0x02 and 0x05 */
1184
static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
1185
			       struct snd_ctl_elem_value *ucontrol)
1186
{
1187
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1188
	long *valp = ucontrol->value.integer.value;
1189
	int change;
1190
1191
	change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1192
					  0x7f, valp[0] & 0x7f);
1193
	change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1194
					   0x7f, valp[1] & 0x7f);
1195
	snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1196
				 0x7f, valp[0] & 0x7f);
1197
	snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1198
				 0x7f, valp[1] & 0x7f);
1199
	return change;
1200
}
1201
1202
/* bind volumes of both NID 0x02 and 0x05 */
1203
static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
1204
			      struct snd_ctl_elem_value *ucontrol)
1205
{
1206
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1207
	long *valp = ucontrol->value.integer.value;
1208
	int change;
1209
1210
	change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1211
					  0x80, valp[0] & 0x80);
1212
	change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1213
					   0x80, valp[1] & 0x80);
1214
	snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1215
				 0x80, valp[0] & 0x80);
1216
	snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1217
				 0x80, valp[1] & 0x80);
1218
	return change;
1219
}
1220
1221
static struct snd_kcontrol_new vaio_mixer[] = {
1222
	{
1223
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1224
		.name = "Master Playback Volume",
1225
		.info = snd_hda_mixer_amp_volume_info,
1226
		.get = snd_hda_mixer_amp_volume_get,
1227
		.put = vaio_master_vol_put,
1228
		.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1229
	},
1230
	{
1231
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1232
		.name = "Master Playback Switch",
1233
		.info = snd_hda_mixer_amp_switch_info,
1234
		.get = snd_hda_mixer_amp_switch_get,
1235
		.put = vaio_master_sw_put,
1236
		.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1237
	},
1238
	HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT),
1239
	HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
1240
	HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
1241
	{
1242
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1243
		.name = "Capture Source",
1244
		.count = 1,
1245
		.info = stac92xx_mux_enum_info,
1246
		.get = stac92xx_mux_enum_get,
1247
		.put = stac92xx_mux_enum_put,
1248
	},
1249
	{}
1250
};
1251
1252
static struct hda_codec_ops stac7661_patch_ops = {
1253
	.build_controls = stac92xx_build_controls,
1254
	.build_pcms = stac92xx_build_pcms,
1255
	.init = stac92xx_init,
1256
	.free = stac92xx_free,
1257
#ifdef CONFIG_PM
1258
	.resume = stac92xx_resume,
1259
#endif
1260
};
1261
1262
enum { STAC7661_VAIO };
1263
1264
static struct hda_board_config stac7661_cfg_tbl[] = {
1265
	{ .modelname = "vaio", .config = STAC7661_VAIO },
1266
	{ .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
1267
	  .config = STAC7661_VAIO },
1268
	{}
1269
};
1270
1271
static int patch_stac7661(struct hda_codec *codec)
1272
{
1273
	struct sigmatel_spec *spec;
1274
	int board_config;
1275
1276
	board_config = snd_hda_check_board_config(codec, stac7661_cfg_tbl);
1277
	if (board_config < 0)
1278
		/* unknown config, let generic-parser do its job... */
1279
		return snd_hda_parse_generic_codec(codec);
1280
	
1281
	spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
1282
	if (spec == NULL)
1283
		return -ENOMEM;
1284
1285
	codec->spec = spec;
1286
	switch (board_config) {
1287
	case STAC7661_VAIO:
1288
		spec->mixer = vaio_mixer;
1289
		spec->init = vaio_init;
1290
		spec->multiout.max_channels = 2;
1291
		spec->multiout.num_dacs = 4;
1292
		spec->multiout.dac_nids = vaio_dacs;
1293
		spec->num_adcs = 2;
1294
		spec->adc_nids = vaio_adcs;
1295
		spec->input_mux = &vaio_mux;
1296
		spec->mux_nids = vaio_mux_nids;
1297
		break;
1298
	}
1299
1300
	codec->patch_ops = stac7661_patch_ops;
1301
	return 0;
1302
}
1303
1304
1305
/*
1151
 * patch entries
1306
 * patch entries
1152
 */
1307
 */
1153
struct hda_codec_preset snd_hda_preset_sigmatel[] = {
1308
struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Lines 1168-1172 Link Here
1168
 	{ .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1323
 	{ .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1169
 	{ .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1324
 	{ .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1170
 	{ .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
1325
 	{ .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
1326
 	{ .id = 0x83847661, .name = "STAC7661", .patch = patch_stac7661 },
1171
	{} /* terminator */
1327
	{} /* terminator */
1172
};
1328
};

Return to bug 156494