[ALSA] hda-codec - Fix max_channels computation for STAC92xx codecs
[linux-2.6.git] / sound / pci / hda / patch_sigmatel.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for SigmaTel STAC92xx
5  *
6  * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7  * Matt Porter <mporter@embeddedalley.com>
8  *
9  * Based on patch_cmedia.c and patch_realtek.c
10  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11  *
12  *  This driver is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This driver is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
25  */
26
27 #include <sound/driver.h>
28 #include <linux/init.h>
29 #include <linux/delay.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
36
37 #define NUM_CONTROL_ALLOC       32
38 #define STAC_HP_EVENT           0x37
39 #define STAC_UNSOL_ENABLE       (AC_USRSP_EN | STAC_HP_EVENT)
40
41 #define STAC_REF                0
42 #define STAC_D945GTP3           1
43 #define STAC_D945GTP5           2
44
45 struct sigmatel_spec {
46         struct snd_kcontrol_new *mixers[4];
47         unsigned int num_mixers;
48
49         int board_config;
50         unsigned int surr_switch: 1;
51         unsigned int line_switch: 1;
52         unsigned int mic_switch: 1;
53         unsigned int alt_switch: 1;
54
55         /* playback */
56         struct hda_multi_out multiout;
57         hda_nid_t dac_nids[5];
58
59         /* capture */
60         hda_nid_t *adc_nids;
61         unsigned int num_adcs;
62         hda_nid_t *mux_nids;
63         unsigned int num_muxes;
64         hda_nid_t dig_in_nid;
65
66         /* pin widgets */
67         hda_nid_t *pin_nids;
68         unsigned int num_pins;
69         unsigned int *pin_configs;
70
71         /* codec specific stuff */
72         struct hda_verb *init;
73         struct snd_kcontrol_new *mixer;
74
75         /* capture source */
76         struct hda_input_mux *input_mux;
77         unsigned int cur_mux[3];
78
79         /* i/o switches */
80         unsigned int io_switch[2];
81
82         struct hda_pcm pcm_rec[2];      /* PCM information */
83
84         /* dynamic controls and input_mux */
85         struct auto_pin_cfg autocfg;
86         unsigned int num_kctl_alloc, num_kctl_used;
87         struct snd_kcontrol_new *kctl_alloc;
88         struct hda_input_mux private_imux;
89 };
90
91 static hda_nid_t stac9200_adc_nids[1] = {
92         0x03,
93 };
94
95 static hda_nid_t stac9200_mux_nids[1] = {
96         0x0c,
97 };
98
99 static hda_nid_t stac9200_dac_nids[1] = {
100         0x02,
101 };
102
103 static hda_nid_t stac922x_adc_nids[2] = {
104         0x06, 0x07,
105 };
106
107 static hda_nid_t stac922x_mux_nids[2] = {
108         0x12, 0x13,
109 };
110
111 static hda_nid_t stac927x_adc_nids[3] = {
112         0x07, 0x08, 0x09
113 };
114
115 static hda_nid_t stac927x_mux_nids[3] = {
116         0x15, 0x16, 0x17
117 };
118
119 static hda_nid_t stac9200_pin_nids[8] = {
120         0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
121 };
122
123 static hda_nid_t stac922x_pin_nids[10] = {
124         0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
125         0x0f, 0x10, 0x11, 0x15, 0x1b,
126 };
127
128 static hda_nid_t stac927x_pin_nids[14] = {
129         0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
130         0x0f, 0x10, 0x11, 0x12, 0x13,
131         0x14, 0x21, 0x22, 0x23,
132 };
133
134 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
135 {
136         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
137         struct sigmatel_spec *spec = codec->spec;
138         return snd_hda_input_mux_info(spec->input_mux, uinfo);
139 }
140
141 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
142 {
143         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
144         struct sigmatel_spec *spec = codec->spec;
145         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
146
147         ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
148         return 0;
149 }
150
151 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
152 {
153         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
154         struct sigmatel_spec *spec = codec->spec;
155         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
156
157         return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
158                                      spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
159 }
160
161 static struct hda_verb stac9200_core_init[] = {
162         /* set dac0mux for dac converter */
163         { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
164         {}
165 };
166
167 static struct hda_verb stac922x_core_init[] = {
168         /* set master volume and direct control */      
169         { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
170         {}
171 };
172
173 static struct hda_verb stac927x_core_init[] = {
174         /* set master volume and direct control */      
175         { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
176         {}
177 };
178
179 static struct snd_kcontrol_new stac9200_mixer[] = {
180         HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
181         HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
182         {
183                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
184                 .name = "Input Source",
185                 .count = 1,
186                 .info = stac92xx_mux_enum_info,
187                 .get = stac92xx_mux_enum_get,
188                 .put = stac92xx_mux_enum_put,
189         },
190         HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
191         HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
192         HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
193         { } /* end */
194 };
195
196 /* This needs to be generated dynamically based on sequence */
197 static struct snd_kcontrol_new stac922x_mixer[] = {
198         {
199                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
200                 .name = "Input Source",
201                 .count = 1,
202                 .info = stac92xx_mux_enum_info,
203                 .get = stac92xx_mux_enum_get,
204                 .put = stac92xx_mux_enum_put,
205         },
206         HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
207         HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
208         HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
209         { } /* end */
210 };
211
212 static snd_kcontrol_new_t stac927x_mixer[] = {
213         {
214                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
215                 .name = "Input Source",
216                 .count = 1,
217                 .info = stac92xx_mux_enum_info,
218                 .get = stac92xx_mux_enum_get,
219                 .put = stac92xx_mux_enum_put,
220         },
221         HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
222         HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
223         HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
224         { } /* end */
225 };
226
227 static int stac92xx_build_controls(struct hda_codec *codec)
228 {
229         struct sigmatel_spec *spec = codec->spec;
230         int err;
231         int i;
232
233         err = snd_hda_add_new_ctls(codec, spec->mixer);
234         if (err < 0)
235                 return err;
236
237         for (i = 0; i < spec->num_mixers; i++) {
238                 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
239                 if (err < 0)
240                         return err;
241         }
242
243         if (spec->multiout.dig_out_nid) {
244                 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
245                 if (err < 0)
246                         return err;
247         }
248         if (spec->dig_in_nid) {
249                 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
250                 if (err < 0)
251                         return err;
252         }
253         return 0;       
254 }
255
256 static unsigned int ref9200_pin_configs[8] = {
257         0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
258         0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
259 };
260
261 static unsigned int *stac9200_brd_tbl[] = {
262         ref9200_pin_configs,
263 };
264
265 static struct hda_board_config stac9200_cfg_tbl[] = {
266         { .modelname = "ref",
267           .pci_subvendor = PCI_VENDOR_ID_INTEL,
268           .pci_subdevice = 0x2668,      /* DFI LanParty */
269           .config = STAC_REF },
270         {} /* terminator */
271 };
272
273 static unsigned int ref922x_pin_configs[10] = {
274         0x01014010, 0x01016011, 0x01012012, 0x0221401f,
275         0x01813122, 0x01011014, 0x01441030, 0x01c41030,
276         0x40000100, 0x40000100,
277 };
278
279 static unsigned int d945gtp3_pin_configs[10] = {
280         0x0221401f, 0x01a19022, 0x01813021, 0x01114010,
281         0x40000100, 0x40000100, 0x40000100, 0x40000100,
282         0x02a19120, 0x40000100,
283 };
284
285 static unsigned int d945gtp5_pin_configs[10] = {
286         0x0221401f, 0x01111012, 0x01813024, 0x01114010,
287         0x01a19021, 0x01116011, 0x01452130, 0x40000100,
288         0x02a19320, 0x40000100,
289 };
290
291 static unsigned int *stac922x_brd_tbl[] = {
292         ref922x_pin_configs,
293         d945gtp3_pin_configs,
294         d945gtp5_pin_configs,
295 };
296
297 static struct hda_board_config stac922x_cfg_tbl[] = {
298         { .modelname = "ref",
299           .pci_subvendor = PCI_VENDOR_ID_INTEL,
300           .pci_subdevice = 0x2668,      /* DFI LanParty */
301           .config = STAC_REF },         /* SigmaTel reference board */
302         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
303           .pci_subdevice = 0x0101,
304           .config = STAC_D945GTP3 },    /* Intel D945GTP - 3 Stack */
305         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
306           .pci_subdevice = 0x0404,
307           .config = STAC_D945GTP5 },    /* Intel D945GTP - 5 Stack */
308         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
309           .pci_subdevice = 0x0303,
310           .config = STAC_D945GTP5 },    /* Intel D945GNT - 5 Stack */
311         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
312           .pci_subdevice = 0x0013,
313           .config = STAC_D945GTP5 },    /* Intel D955XBK - 5 Stack */
314         { .pci_subvendor = PCI_VENDOR_ID_INTEL,
315           .pci_subdevice = 0x0417,
316           .config = STAC_D945GTP5 },    /* Intel D975XBK - 5 Stack */
317         {} /* terminator */
318 };
319
320 static unsigned int ref927x_pin_configs[14] = {
321         0x01813122, 0x01a19021, 0x01014010, 0x01016011,
322         0x01012012, 0x01011014, 0x40000100, 0x40000100, 
323         0x40000100, 0x40000100, 0x40000100, 0x01441030,
324         0x01c41030, 0x40000100,
325 };
326
327 static unsigned int *stac927x_brd_tbl[] = {
328         ref927x_pin_configs,
329 };
330
331 static struct hda_board_config stac927x_cfg_tbl[] = {
332         { .modelname = "ref",
333           .pci_subvendor = PCI_VENDOR_ID_INTEL,
334           .pci_subdevice = 0x2668,      /* DFI LanParty */
335           .config = STAC_REF },         /* SigmaTel reference board */
336         {} /* terminator */
337 };
338
339 static void stac92xx_set_config_regs(struct hda_codec *codec)
340 {
341         int i;
342         struct sigmatel_spec *spec = codec->spec;
343         unsigned int pin_cfg;
344
345         for (i=0; i < spec->num_pins; i++) {
346                 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
347                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
348                                     spec->pin_configs[i] & 0x000000ff);
349                 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
350                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
351                                     (spec->pin_configs[i] & 0x0000ff00) >> 8);
352                 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
353                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
354                                     (spec->pin_configs[i] & 0x00ff0000) >> 16);
355                 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
356                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
357                                     spec->pin_configs[i] >> 24);
358                 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
359                                              AC_VERB_GET_CONFIG_DEFAULT,
360                                              0x00);     
361                 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
362         }
363 }
364
365 /*
366  * Analog playback callbacks
367  */
368 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
369                                       struct hda_codec *codec,
370                                       struct snd_pcm_substream *substream)
371 {
372         struct sigmatel_spec *spec = codec->spec;
373         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
374 }
375
376 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
377                                          struct hda_codec *codec,
378                                          unsigned int stream_tag,
379                                          unsigned int format,
380                                          struct snd_pcm_substream *substream)
381 {
382         struct sigmatel_spec *spec = codec->spec;
383         return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
384 }
385
386 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
387                                         struct hda_codec *codec,
388                                         struct snd_pcm_substream *substream)
389 {
390         struct sigmatel_spec *spec = codec->spec;
391         return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
392 }
393
394 /*
395  * Digital playback callbacks
396  */
397 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
398                                           struct hda_codec *codec,
399                                           struct snd_pcm_substream *substream)
400 {
401         struct sigmatel_spec *spec = codec->spec;
402         return snd_hda_multi_out_dig_open(codec, &spec->multiout);
403 }
404
405 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
406                                            struct hda_codec *codec,
407                                            struct snd_pcm_substream *substream)
408 {
409         struct sigmatel_spec *spec = codec->spec;
410         return snd_hda_multi_out_dig_close(codec, &spec->multiout);
411 }
412
413
414 /*
415  * Analog capture callbacks
416  */
417 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
418                                         struct hda_codec *codec,
419                                         unsigned int stream_tag,
420                                         unsigned int format,
421                                         struct snd_pcm_substream *substream)
422 {
423         struct sigmatel_spec *spec = codec->spec;
424
425         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
426                                    stream_tag, 0, format);
427         return 0;
428 }
429
430 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
431                                         struct hda_codec *codec,
432                                         struct snd_pcm_substream *substream)
433 {
434         struct sigmatel_spec *spec = codec->spec;
435
436         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
437         return 0;
438 }
439
440 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
441         .substreams = 1,
442         .channels_min = 2,
443         .channels_max = 2,
444         /* NID is set in stac92xx_build_pcms */
445         .ops = {
446                 .open = stac92xx_dig_playback_pcm_open,
447                 .close = stac92xx_dig_playback_pcm_close
448         },
449 };
450
451 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
452         .substreams = 1,
453         .channels_min = 2,
454         .channels_max = 2,
455         /* NID is set in stac92xx_build_pcms */
456 };
457
458 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
459         .substreams = 1,
460         .channels_min = 2,
461         .channels_max = 8,
462         .nid = 0x02, /* NID to query formats and rates */
463         .ops = {
464                 .open = stac92xx_playback_pcm_open,
465                 .prepare = stac92xx_playback_pcm_prepare,
466                 .cleanup = stac92xx_playback_pcm_cleanup
467         },
468 };
469
470 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
471         .substreams = 1,
472         .channels_min = 2,
473         .channels_max = 2,
474         .nid = 0x06, /* NID to query formats and rates */
475         .ops = {
476                 .open = stac92xx_playback_pcm_open,
477                 .prepare = stac92xx_playback_pcm_prepare,
478                 .cleanup = stac92xx_playback_pcm_cleanup
479         },
480 };
481
482 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
483         .substreams = 2,
484         .channels_min = 2,
485         .channels_max = 2,
486         /* NID is set in stac92xx_build_pcms */
487         .ops = {
488                 .prepare = stac92xx_capture_pcm_prepare,
489                 .cleanup = stac92xx_capture_pcm_cleanup
490         },
491 };
492
493 static int stac92xx_build_pcms(struct hda_codec *codec)
494 {
495         struct sigmatel_spec *spec = codec->spec;
496         struct hda_pcm *info = spec->pcm_rec;
497
498         codec->num_pcms = 1;
499         codec->pcm_info = info;
500
501         info->name = "STAC92xx Analog";
502         info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
503         info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
504         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
505
506         if (spec->alt_switch) {
507                 codec->num_pcms++;
508                 info++;
509                 info->name = "STAC92xx Analog Alt";
510                 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
511         }
512
513         if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
514                 codec->num_pcms++;
515                 info++;
516                 info->name = "STAC92xx Digital";
517                 if (spec->multiout.dig_out_nid) {
518                         info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
519                         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
520                 }
521                 if (spec->dig_in_nid) {
522                         info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
523                         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
524                 }
525         }
526
527         return 0;
528 }
529
530 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
531
532 {
533         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
534 }
535
536 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
537 {
538         uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
539         uinfo->count = 1;
540         uinfo->value.integer.min = 0;
541         uinfo->value.integer.max = 1;
542         return 0;
543 }
544
545 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
546 {
547         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548         struct sigmatel_spec *spec = codec->spec;
549         int io_idx = kcontrol-> private_value & 0xff;
550
551         ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
552         return 0;
553 }
554
555 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
556 {
557         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558         struct sigmatel_spec *spec = codec->spec;
559         hda_nid_t nid = kcontrol->private_value >> 8;
560         int io_idx = kcontrol-> private_value & 0xff;
561         unsigned short val = ucontrol->value.integer.value[0];
562
563         spec->io_switch[io_idx] = val;
564
565         if (val)
566                 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
567         else
568                 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
569
570         return 1;
571 }
572
573 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
574         { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
575           .name = xname, \
576           .index = 0, \
577           .info = stac92xx_io_switch_info, \
578           .get = stac92xx_io_switch_get, \
579           .put = stac92xx_io_switch_put, \
580           .private_value = xpval, \
581         }
582
583
584 enum {
585         STAC_CTL_WIDGET_VOL,
586         STAC_CTL_WIDGET_MUTE,
587         STAC_CTL_WIDGET_IO_SWITCH,
588 };
589
590 static struct snd_kcontrol_new stac92xx_control_templates[] = {
591         HDA_CODEC_VOLUME(NULL, 0, 0, 0),
592         HDA_CODEC_MUTE(NULL, 0, 0, 0),
593         STAC_CODEC_IO_SWITCH(NULL, 0),
594 };
595
596 /* add dynamic controls */
597 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
598 {
599         struct snd_kcontrol_new *knew;
600
601         if (spec->num_kctl_used >= spec->num_kctl_alloc) {
602                 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
603
604                 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
605                 if (! knew)
606                         return -ENOMEM;
607                 if (spec->kctl_alloc) {
608                         memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
609                         kfree(spec->kctl_alloc);
610                 }
611                 spec->kctl_alloc = knew;
612                 spec->num_kctl_alloc = num;
613         }
614
615         knew = &spec->kctl_alloc[spec->num_kctl_used];
616         *knew = stac92xx_control_templates[type];
617         knew->name = kstrdup(name, GFP_KERNEL);
618         if (! knew->name)
619                 return -ENOMEM;
620         knew->private_value = val;
621         spec->num_kctl_used++;
622         return 0;
623 }
624
625 /* flag inputs as additional dynamic lineouts */
626 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
627 {
628         struct sigmatel_spec *spec = codec->spec;
629
630         switch (cfg->line_outs) {
631         case 3:
632                 /* add line-in as side */
633                 if (cfg->input_pins[AUTO_PIN_LINE]) {
634                         cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
635                         spec->line_switch = 1;
636                         cfg->line_outs++;
637                 }
638                 break;
639         case 2:
640                 /* add line-in as clfe and mic as side */
641                 if (cfg->input_pins[AUTO_PIN_LINE]) {
642                         cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
643                         spec->line_switch = 1;
644                         cfg->line_outs++;
645                 }
646                 if (cfg->input_pins[AUTO_PIN_MIC]) {
647                         cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
648                         spec->mic_switch = 1;
649                         cfg->line_outs++;
650                 }
651                 break;
652         case 1:
653                 /* add line-in as surr and mic as clfe */
654                 if (cfg->input_pins[AUTO_PIN_LINE]) {
655                         cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
656                         spec->line_switch = 1;
657                         cfg->line_outs++;
658                 }
659                 if (cfg->input_pins[AUTO_PIN_MIC]) {
660                         cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
661                         spec->mic_switch = 1;
662                         cfg->line_outs++;
663                 }
664                 break;
665         }
666
667         return 0;
668 }
669
670 /*
671  * XXX The line_out pin widget connection list may not be set to the
672  * desired DAC nid. This is the case on 927x where ports A and B can
673  * be routed to several DACs.
674  *
675  * This requires an analysis of the line-out/hp pin configuration
676  * to provide a best fit for pin/DAC configurations that are routable.
677  * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
678  * A and B is not supported.
679  */
680 /* fill in the dac_nids table from the parsed pin configuration */
681 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
682 {
683         struct sigmatel_spec *spec = codec->spec;
684         hda_nid_t nid;
685         int i;
686
687         /* check the pins hardwired to audio widget */
688         for (i = 0; i < cfg->line_outs; i++) {
689                 nid = cfg->line_out_pins[i];
690                 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
691                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
692         }
693
694         if (cfg->line_outs)
695                 spec->multiout.num_dacs = cfg->line_outs;
696         else if (cfg->hp_pin) {
697                 spec->multiout.dac_nids[0] = snd_hda_codec_read(codec, cfg->hp_pin, 0,
698                                         AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
699                 spec->multiout.num_dacs = 1;
700         }
701
702         return 0;
703 }
704
705 /* add playback controls from the parsed DAC table */
706 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg)
707 {
708         char name[32];
709         static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
710         hda_nid_t nid;
711         int i, err;
712
713         for (i = 0; i < cfg->line_outs; i++) {
714                 if (!spec->multiout.dac_nids[i])
715                         continue;
716
717                 nid = spec->multiout.dac_nids[i];
718
719                 if (i == 2) {
720                         /* Center/LFE */
721                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
722                                                HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
723                                 return err;
724                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
725                                                HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
726                                 return err;
727                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
728                                                HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
729                                 return err;
730                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
731                                                HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
732                                 return err;
733                 } else {
734                         sprintf(name, "%s Playback Volume", chname[i]);
735                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
736                                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
737                                 return err;
738                         sprintf(name, "%s Playback Switch", chname[i]);
739                         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
740                                                HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
741                                 return err;
742                 }
743         }
744
745         if (spec->line_switch)
746                 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
747                         return err;
748
749         if (spec->mic_switch)
750                 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
751                         return err;
752
753         return 0;
754 }
755
756 /* add playback controls for HP output */
757 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
758 {
759         struct sigmatel_spec *spec = codec->spec;
760         hda_nid_t pin = cfg->hp_pin;
761         hda_nid_t nid;
762         int i, err;
763         unsigned int wid_caps;
764
765         if (! pin)
766                 return 0;
767
768         wid_caps = get_wcaps(codec, pin);
769         if (wid_caps & AC_WCAP_UNSOL_CAP)
770                 /* Enable unsolicited responses on the HP widget */
771                 snd_hda_codec_write(codec, pin, 0,
772                                 AC_VERB_SET_UNSOLICITED_ENABLE,
773                                 STAC_UNSOL_ENABLE);
774
775         nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
776         for (i = 0; i < cfg->line_outs; i++) {
777                 if (! spec->multiout.dac_nids[i])
778                         continue;
779                 if (spec->multiout.dac_nids[i] == nid)
780                         return 0;
781         }
782
783         spec->multiout.hp_nid = nid;
784
785         /* control HP volume/switch on the output mixer amp */
786         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
787                                         HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
788                 return err;
789         if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
790                                         HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
791                 return err;
792
793         return 0;
794 }
795
796 /* create playback/capture controls for input pins */
797 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
798 {
799         struct sigmatel_spec *spec = codec->spec;
800         struct hda_input_mux *imux = &spec->private_imux;
801         hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
802         int i, j, k;
803
804         for (i = 0; i < AUTO_PIN_LAST; i++) {
805                 int index = -1;
806                 if (cfg->input_pins[i]) {
807                         /* Enable active pin widget as an input */
808                         stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);
809
810                         imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
811
812                         for (j=0; j<spec->num_muxes; j++) {
813                                 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
814                                 for (k=0; k<num_cons; k++)
815                                         if (con_lst[k] == cfg->input_pins[i]) {
816                                                 index = k;
817                                                 break;
818                                         }
819                                 if (index >= 0)
820                                         break;
821                         }
822                         imux->items[imux->num_items].index = index;
823                         imux->num_items++;
824                 }
825         }
826
827         return 0;
828 }
829
830 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
831 {
832         struct sigmatel_spec *spec = codec->spec;
833         int i;
834
835         for (i = 0; i < spec->autocfg.line_outs; i++) {
836                 hda_nid_t nid = spec->autocfg.line_out_pins[i];
837                 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
838         }
839 }
840
841 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
842 {
843         struct sigmatel_spec *spec = codec->spec;
844         hda_nid_t pin;
845
846         pin = spec->autocfg.hp_pin;
847         if (pin) /* connect to front */
848                 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
849 }
850
851 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
852 {
853         struct sigmatel_spec *spec = codec->spec;
854         int err;
855
856         if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
857                 return err;
858         if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
859                 return err;
860         if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
861                 return err;
862         if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
863                 return 0; /* can't find valid pin config */
864
865         if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
866             (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
867             (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
868                 return err;
869
870         spec->multiout.max_channels = spec->multiout.num_dacs * 2;
871         if (spec->multiout.max_channels > 2)
872                 spec->surr_switch = 1;
873
874         if (spec->autocfg.dig_out_pin) {
875                 spec->multiout.dig_out_nid = dig_out;
876                 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
877         }
878         if (spec->autocfg.dig_in_pin) {
879                 spec->dig_in_nid = dig_in;
880                 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
881         }
882
883         if (spec->kctl_alloc)
884                 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
885
886         spec->input_mux = &spec->private_imux;
887
888         return 1;
889 }
890
891 static int stac9200_parse_auto_config(struct hda_codec *codec)
892 {
893         struct sigmatel_spec *spec = codec->spec;
894         int err;
895
896         if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
897                 return err;
898
899         if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
900                 return err;
901
902         if (spec->autocfg.dig_out_pin) {
903                 spec->multiout.dig_out_nid = 0x05;
904                 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
905         }
906         if (spec->autocfg.dig_in_pin) {
907                 spec->dig_in_nid = 0x04;
908                 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
909         }
910
911         if (spec->kctl_alloc)
912                 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
913
914         spec->input_mux = &spec->private_imux;
915
916         return 1;
917 }
918
919 static int stac92xx_init(struct hda_codec *codec)
920 {
921         struct sigmatel_spec *spec = codec->spec;
922
923         snd_hda_sequence_write(codec, spec->init);
924
925         stac92xx_auto_init_multi_out(codec);
926         stac92xx_auto_init_hp_out(codec);
927
928         return 0;
929 }
930
931 static void stac92xx_free(struct hda_codec *codec)
932 {
933         struct sigmatel_spec *spec = codec->spec;
934         int i;
935
936         if (! spec)
937                 return;
938
939         if (spec->kctl_alloc) {
940                 for (i = 0; i < spec->num_kctl_used; i++)
941                         kfree(spec->kctl_alloc[i].name);
942                 kfree(spec->kctl_alloc);
943         }
944
945         kfree(spec);
946 }
947
948 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
949                                 unsigned int flag)
950 {
951         unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
952                         0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
953         snd_hda_codec_write(codec, nid, 0,
954                         AC_VERB_SET_PIN_WIDGET_CONTROL,
955                         pin_ctl | flag);
956 }
957
958 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
959                                   unsigned int flag)
960 {
961         unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
962                         0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
963         snd_hda_codec_write(codec, nid, 0,
964                         AC_VERB_SET_PIN_WIDGET_CONTROL,
965                         pin_ctl & ~flag);
966 }
967
968 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
969 {
970         struct sigmatel_spec *spec = codec->spec;
971         struct auto_pin_cfg *cfg = &spec->autocfg;
972         int i, presence;
973
974         if ((res >> 26) != STAC_HP_EVENT)
975                 return;
976
977         presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
978                         AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
979
980         if (presence) {
981                 /* disable lineouts, enable hp */
982                 for (i = 0; i < cfg->line_outs; i++)
983                         stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
984                                                 AC_PINCTL_OUT_EN);
985                 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
986         } else {
987                 /* enable lineouts, disable hp */
988                 for (i = 0; i < cfg->line_outs; i++)
989                         stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
990                                                 AC_PINCTL_OUT_EN);
991                 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
992         }
993
994
995 #ifdef CONFIG_PM
996 static int stac92xx_resume(struct hda_codec *codec)
997 {
998         struct sigmatel_spec *spec = codec->spec;
999         int i;
1000
1001         stac92xx_init(codec);
1002         for (i = 0; i < spec->num_mixers; i++)
1003                 snd_hda_resume_ctls(codec, spec->mixers[i]);
1004         if (spec->multiout.dig_out_nid)
1005                 snd_hda_resume_spdif_out(codec);
1006         if (spec->dig_in_nid)
1007                 snd_hda_resume_spdif_in(codec);
1008
1009         return 0;
1010 }
1011 #endif
1012
1013 static struct hda_codec_ops stac92xx_patch_ops = {
1014         .build_controls = stac92xx_build_controls,
1015         .build_pcms = stac92xx_build_pcms,
1016         .init = stac92xx_init,
1017         .free = stac92xx_free,
1018         .unsol_event = stac92xx_unsol_event,
1019 #ifdef CONFIG_PM
1020         .resume = stac92xx_resume,
1021 #endif
1022 };
1023
1024 static int patch_stac9200(struct hda_codec *codec)
1025 {
1026         struct sigmatel_spec *spec;
1027         int err;
1028
1029         spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
1030         if (spec == NULL)
1031                 return -ENOMEM;
1032
1033         codec->spec = spec;
1034         spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
1035         if (spec->board_config < 0)
1036                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1037         else {
1038                 spec->num_pins = 8;
1039                 spec->pin_nids = stac9200_pin_nids;
1040                 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1041                 stac92xx_set_config_regs(codec);
1042         }
1043
1044         spec->multiout.max_channels = 2;
1045         spec->multiout.num_dacs = 1;
1046         spec->multiout.dac_nids = stac9200_dac_nids;
1047         spec->adc_nids = stac9200_adc_nids;
1048         spec->mux_nids = stac9200_mux_nids;
1049         spec->num_muxes = 1;
1050
1051         spec->init = stac9200_core_init;
1052         spec->mixer = stac9200_mixer;
1053
1054         err = stac9200_parse_auto_config(codec);
1055         if (err < 0) {
1056                 stac92xx_free(codec);
1057                 return err;
1058         }
1059
1060         codec->patch_ops = stac92xx_patch_ops;
1061
1062         return 0;
1063 }
1064
1065 static int patch_stac922x(struct hda_codec *codec)
1066 {
1067         struct sigmatel_spec *spec;
1068         int err;
1069
1070         spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
1071         if (spec == NULL)
1072                 return -ENOMEM;
1073
1074         codec->spec = spec;
1075         spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
1076         if (spec->board_config < 0)
1077                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n");
1078         else {
1079                 spec->num_pins = 10;
1080                 spec->pin_nids = stac922x_pin_nids;
1081                 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
1082                 stac92xx_set_config_regs(codec);
1083         }
1084
1085         spec->adc_nids = stac922x_adc_nids;
1086         spec->mux_nids = stac922x_mux_nids;
1087         spec->num_muxes = 2;
1088
1089         spec->init = stac922x_core_init;
1090         spec->mixer = stac922x_mixer;
1091
1092         spec->multiout.dac_nids = spec->dac_nids;
1093
1094         err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1095         if (err < 0) {
1096                 stac92xx_free(codec);
1097                 return err;
1098         }
1099
1100         codec->patch_ops = stac92xx_patch_ops;
1101
1102         return 0;
1103 }
1104
1105 static int patch_stac927x(struct hda_codec *codec)
1106 {
1107         struct sigmatel_spec *spec;
1108         int err;
1109
1110         spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
1111         if (spec == NULL)
1112                 return -ENOMEM;
1113
1114         codec->spec = spec;
1115         spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
1116         if (spec->board_config < 0)
1117                 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
1118         else {
1119                 spec->num_pins = 14;
1120                 spec->pin_nids = stac927x_pin_nids;
1121                 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
1122                 stac92xx_set_config_regs(codec);
1123         }
1124
1125         spec->adc_nids = stac927x_adc_nids;
1126         spec->mux_nids = stac927x_mux_nids;
1127         spec->num_muxes = 3;
1128
1129         spec->init = stac927x_core_init;
1130         spec->mixer = stac927x_mixer;
1131
1132         spec->multiout.dac_nids = spec->dac_nids;
1133
1134         err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
1135         if (err < 0) {
1136                 stac92xx_free(codec);
1137                 return err;
1138         }
1139
1140         codec->patch_ops = stac92xx_patch_ops;
1141
1142         return 0;
1143 }
1144
1145 /*
1146  * patch entries
1147  */
1148 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
1149         { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
1150         { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
1151         { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
1152         { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
1153         { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
1154         { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
1155         { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
1156         { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
1157         { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
1158         { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
1159         { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
1160         { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
1161         { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
1162         { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
1163         { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1164         { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1165         { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
1166         {} /* terminator */
1167 };