2 * Driver for the NXP SAA7164 PCIe bridge
4 * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/wait.h>
23 #include <linux/slab.h>
27 int saa7164_api_set_encoder(struct saa7164_port
*port
)
29 struct saa7164_dev
*dev
= port
->dev
;
30 tmComResEncVideoBitRate_t vb
;
31 tmComResEncAudioBitRate_t ab
;
34 dprintk(DBGLVL_ENC
, "%s() unitid=0x%x\n", __func__
, port
->hwcfg
.sourceid
);
36 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, SET_CUR
,
37 EU_PROFILE_CONTROL
, sizeof(u8
), &port
->encoder_profile
);
39 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
41 /* Establish video bitrates */
42 vb
.ucVideoBitRateMode
= 0;
43 vb
.dwVideoBitRate
= port
->encoder_params
.bitrate
;
44 vb
.dwVideoBitRatePeak
= vb
.dwVideoBitRate
;
45 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, SET_CUR
,
46 EU_VIDEO_BIT_RATE_CONTROL
, sizeof(tmComResEncVideoBitRate_t
), &vb
);
48 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
50 /* Establish audio bitrates */
51 ab
.ucAudioBitRateMode
= 0;
52 ab
.dwAudioBitRate
= 384000;
53 ab
.dwAudioBitRatePeak
= ab
.dwAudioBitRate
;
54 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, SET_CUR
,
55 EU_AUDIO_BIT_RATE_CONTROL
, sizeof(tmComResEncAudioBitRate_t
), &ab
);
57 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
59 saa7164_api_set_aspect_ratio(port
);
64 int saa7164_api_get_encoder(struct saa7164_port
*port
)
66 struct saa7164_dev
*dev
= port
->dev
;
67 tmComResEncVideoBitRate_t v
;
68 tmComResEncAudioBitRate_t a
;
69 tmComResEncVideoInputAspectRatio_t ar
;
72 dprintk(DBGLVL_ENC
, "%s() unitid=0x%x\n", __func__
, port
->hwcfg
.sourceid
);
74 port
->encoder_profile
= 0;
75 port
->video_format
= 0;
76 port
->video_resolution
= 0;
77 port
->audio_format
= 0;
79 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
80 EU_PROFILE_CONTROL
, sizeof(u8
), &port
->encoder_profile
);
82 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
84 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
85 EU_VIDEO_FORMAT_CONTROL
, sizeof(u8
), &port
->video_format
);
87 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
89 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
90 EU_VIDEO_BIT_RATE_CONTROL
, sizeof(v
), &v
);
92 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
94 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
95 EU_AUDIO_FORMAT_CONTROL
, sizeof(u8
), &port
->audio_format
);
97 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
99 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
100 EU_AUDIO_BIT_RATE_CONTROL
, sizeof(a
), &a
);
102 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
107 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, GET_CUR
,
108 EU_VIDEO_INPUT_ASPECT_CONTROL
,
109 sizeof(tmComResEncVideoInputAspectRatio_t
), &ar
);
111 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
113 dprintk(DBGLVL_ENC
, "encoder_profile = %d\n", port
->encoder_profile
);
114 dprintk(DBGLVL_ENC
, "video_format = %d\n", port
->video_format
);
115 dprintk(DBGLVL_ENC
, "audio_format = %d\n", port
->audio_format
);
116 dprintk(DBGLVL_ENC
, "video_resolution= %d\n", port
->video_resolution
);
117 dprintk(DBGLVL_ENC
, "v.ucVideoBitRateMode = %d\n", v
.ucVideoBitRateMode
);
118 dprintk(DBGLVL_ENC
, "v.dwVideoBitRate = %d\n", v
.dwVideoBitRate
);
119 dprintk(DBGLVL_ENC
, "v.dwVideoBitRatePeak = %d\n", v
.dwVideoBitRatePeak
);
120 dprintk(DBGLVL_ENC
, "a.ucVideoBitRateMode = %d\n", a
.ucAudioBitRateMode
);
121 dprintk(DBGLVL_ENC
, "a.dwVideoBitRate = %d\n", a
.dwAudioBitRate
);
122 dprintk(DBGLVL_ENC
, "a.dwVideoBitRatePeak = %d\n", a
.dwAudioBitRatePeak
);
123 dprintk(DBGLVL_ENC
, "aspect.width / height = %d:%d\n", ar
.width
, ar
.height
);
128 int saa7164_api_set_aspect_ratio(struct saa7164_port
*port
)
130 struct saa7164_dev
*dev
= port
->dev
;
131 tmComResEncVideoInputAspectRatio_t ar
;
134 dprintk(DBGLVL_ENC
, "%s(%d)\n", __func__
,
135 port
->encoder_params
.ctl_aspect
);
137 switch (port
->encoder_params
.ctl_aspect
) {
138 case V4L2_MPEG_VIDEO_ASPECT_1x1
:
142 case V4L2_MPEG_VIDEO_ASPECT_4x3
:
146 case V4L2_MPEG_VIDEO_ASPECT_16x9
:
150 case V4L2_MPEG_VIDEO_ASPECT_221x100
:
158 dprintk(DBGLVL_ENC
, "%s(%d) now %d:%d\n", __func__
,
159 port
->encoder_params
.ctl_aspect
,
160 ar
.width
, ar
.height
);
163 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.sourceid
, SET_CUR
,
164 EU_VIDEO_INPUT_ASPECT_CONTROL
,
165 sizeof(tmComResEncVideoInputAspectRatio_t
), &ar
);
167 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
172 int saa7164_api_set_usercontrol(struct saa7164_port
*port
, u8 ctl
)
174 struct saa7164_dev
*dev
= port
->dev
;
178 if (ctl
== PU_BRIGHTNESS_CONTROL
)
179 val
= port
->ctl_brightness
;
181 if (ctl
== PU_CONTRAST_CONTROL
)
182 val
= port
->ctl_contrast
;
184 if (ctl
== PU_HUE_CONTROL
)
187 if (ctl
== PU_SATURATION_CONTROL
)
188 val
= port
->ctl_saturation
;
190 if (ctl
== PU_SHARPNESS_CONTROL
)
191 val
= port
->ctl_sharpness
;
195 dprintk(DBGLVL_ENC
, "%s() unitid=0x%x ctl=%d, val=%d\n",
196 __func__
, port
->encunit
.vsourceid
, ctl
, val
);
198 ret
= saa7164_cmd_send(port
->dev
, port
->encunit
.vsourceid
, SET_CUR
,
199 ctl
, sizeof(u16
), &val
);
201 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
206 int saa7164_api_get_usercontrol(struct saa7164_port
*port
, u8 ctl
)
208 struct saa7164_dev
*dev
= port
->dev
;
212 ret
= saa7164_cmd_send(port
->dev
, port
->encunit
.vsourceid
, GET_CUR
,
213 ctl
, sizeof(u16
), &val
);
215 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
219 dprintk(DBGLVL_ENC
, "%s() ctl=%d, val=%d\n",
222 if (ctl
== PU_BRIGHTNESS_CONTROL
)
223 port
->ctl_brightness
= val
;
225 if (ctl
== PU_CONTRAST_CONTROL
)
226 port
->ctl_contrast
= val
;
228 if (ctl
== PU_HUE_CONTROL
)
231 if (ctl
== PU_SATURATION_CONTROL
)
232 port
->ctl_saturation
= val
;
234 if (ctl
== PU_SHARPNESS_CONTROL
)
235 port
->ctl_sharpness
= val
;
240 int saa7164_api_set_videomux(struct saa7164_port
*port
)
242 struct saa7164_dev
*dev
= port
->dev
;
243 u8 inputs
[] = { 1, 2, 2, 2, 5, 5, 5 };
246 dprintk(DBGLVL_ENC
, "%s() v_mux=%d a_mux=%d\n",
247 __func__
, port
->mux_input
, inputs
[ port
->mux_input
- 1 ]);
250 ret
= saa7164_api_audio_mute(port
, 1);
252 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
255 ret
= saa7164_cmd_send(port
->dev
, port
->vidproc
.sourceid
, SET_CUR
,
256 SU_INPUT_SELECT_CONTROL
, sizeof(u8
), &port
->mux_input
);
258 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
260 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.sourceid
, SET_CUR
,
261 SU_INPUT_SELECT_CONTROL
, sizeof(u8
), &inputs
[ port
->mux_input
- 1 ]);
263 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
265 ret
= saa7164_api_audio_mute(port
, 0);
267 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
272 int saa7164_api_audio_mute(struct saa7164_port
*port
, int mute
)
274 struct saa7164_dev
*dev
= port
->dev
;
278 dprintk(DBGLVL_API
, "%s(%d)\n", __func__
, mute
);
280 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, SET_CUR
,
281 MUTE_CONTROL
, sizeof(u8
), &v
);
283 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
288 /* 0 = silence, 0xff = full */
289 int saa7164_api_set_audio_volume(struct saa7164_port
*port
, s8 level
)
291 struct saa7164_dev
*dev
= port
->dev
;
295 dprintk(DBGLVL_API
, "%s(%d)\n", __func__
, level
);
297 /* Obtain the min/max ranges */
298 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, GET_MIN
,
299 VOLUME_CONTROL
, sizeof(u16
), &min
);
301 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
303 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, GET_MAX
,
304 VOLUME_CONTROL
, sizeof(u16
), &max
);
306 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
308 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, GET_CUR
,
309 ( 0x01 << 8) | VOLUME_CONTROL
, sizeof(u16
), &v
);
311 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
313 dprintk(DBGLVL_API
, "%s(%d) min=%d max=%d cur=%d\n", __func__
, level
, min
, max
, v
);
322 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, SET_CUR
,
323 ( 0x01 << 8 ) | VOLUME_CONTROL
, sizeof(s16
), &v
);
325 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
328 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, SET_CUR
,
329 ( 0x02 << 8 ) | VOLUME_CONTROL
, sizeof(s16
), &v
);
331 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
333 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, GET_CUR
,
334 ( 0x01 << 8) | VOLUME_CONTROL
, sizeof(u16
), &v
);
336 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
338 dprintk(DBGLVL_API
, "%s(%d) min=%d max=%d cur=%d\n", __func__
, level
, min
, max
, v
);
343 int saa7164_api_set_audio_std(struct saa7164_port
*port
)
345 struct saa7164_dev
*dev
= port
->dev
;
346 tmComResAudioDefaults_t lvl
;
347 tmComResTunerStandard_t tvaudio
;
350 dprintk(DBGLVL_API
, "%s()\n", __func__
);
352 /* Establish default levels */
353 lvl
.ucDecoderLevel
= TMHW_LEV_ADJ_DECLEV_DEFAULT
;
354 lvl
.ucDecoderFM_Level
= TMHW_LEV_ADJ_DECLEV_DEFAULT
;
355 lvl
.ucMonoLevel
= TMHW_LEV_ADJ_MONOLEV_DEFAULT
;
356 lvl
.ucNICAM_Level
= TMHW_LEV_ADJ_NICLEV_DEFAULT
;
357 lvl
.ucSAP_Level
= TMHW_LEV_ADJ_SAPLEV_DEFAULT
;
358 lvl
.ucADC_Level
= TMHW_LEV_ADJ_ADCLEV_DEFAULT
;
359 ret
= saa7164_cmd_send(port
->dev
, port
->audfeat
.unitid
, SET_CUR
,
360 AUDIO_DEFAULT_CONTROL
, sizeof(tmComResAudioDefaults_t
), &lvl
);
362 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
364 /* Manually select the appropriate TV audio standard */
365 if (port
->encodernorm
.id
& V4L2_STD_NTSC
) {
366 tvaudio
.std
= TU_STANDARD_NTSC_M
;
369 tvaudio
.std
= TU_STANDARD_PAL_I
;
370 tvaudio
.country
= 44;
373 ret
= saa7164_cmd_send(port
->dev
, port
->tunerunit
.unitid
, SET_CUR
,
374 TU_STANDARD_CONTROL
, sizeof(tvaudio
), &tvaudio
);
376 printk(KERN_ERR
"%s() TU_STANDARD_CONTROL error, ret = 0x%x\n", __func__
, ret
);
380 int saa7164_api_set_audio_detection(struct saa7164_port
*port
, int autodetect
)
382 struct saa7164_dev
*dev
= port
->dev
;
383 tmComResTunerStandardAuto_t p
;
386 dprintk(DBGLVL_API
, "%s(%d)\n", __func__
, autodetect
);
388 /* Disable TV Audio autodetect if not already set (buggy) */
390 p
.mode
= TU_STANDARD_AUTO
;
392 p
.mode
= TU_STANDARD_MANUAL
;
393 ret
= saa7164_cmd_send(port
->dev
, port
->tunerunit
.unitid
, SET_CUR
,
394 TU_STANDARD_AUTO_CONTROL
, sizeof(p
), &p
);
396 printk(KERN_ERR
"%s() TU_STANDARD_AUTO_CONTROL error, ret = 0x%x\n", __func__
, ret
);
401 int saa7164_api_get_videomux(struct saa7164_port
*port
)
403 struct saa7164_dev
*dev
= port
->dev
;
406 ret
= saa7164_cmd_send(port
->dev
, port
->vidproc
.sourceid
, GET_CUR
,
407 SU_INPUT_SELECT_CONTROL
, sizeof(u8
), &port
->mux_input
);
409 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
411 dprintk(DBGLVL_ENC
, "%s() v_mux=%d\n",
412 __func__
, port
->mux_input
);
417 int saa7164_api_set_dif(struct saa7164_port
*port
, u8 reg
, u8 val
)
419 struct saa7164_dev
*dev
= port
->dev
;
426 dprintk(DBGLVL_API
, "%s()\n", __func__
);
433 memset(buf
, 0, sizeof(buf
));
455 ret
= saa7164_cmd_send(dev
, port
->ifunit
.unitid
, GET_LEN
,
456 EXU_REGISTER_ACCESS_CONTROL
, sizeof(len
), &len
);
458 printk(KERN_ERR
"%s() error, ret(1) = 0x%x\n", __func__
, ret
);
462 ret
= saa7164_cmd_send(dev
, port
->ifunit
.unitid
, SET_CUR
,
463 EXU_REGISTER_ACCESS_CONTROL
, len
, &buf
);
465 printk(KERN_ERR
"%s() error, ret(2) = 0x%x\n", __func__
, ret
);
467 //saa7164_dumphex16(dev, buf, 16);
469 return ret
== SAA_OK
? 0 : -EIO
;
472 /* Disable the IF block AGC controls */
473 int saa7164_api_configure_dif(struct saa7164_port
*port
, u32 std
)
475 struct saa7164_dev
*dev
= port
->dev
;
479 dprintk(DBGLVL_API
, "%s(%p, 0x%x)\n", __func__
, port
, std
);
481 if (std
& V4L2_STD_NTSC
) {
482 dprintk(DBGLVL_API
, " NTSC\n");
483 saa7164_api_set_dif(port
, 0x00, 0x01); /* Video Standard */
485 } else if (std
& V4L2_STD_PAL_I
) {
486 dprintk(DBGLVL_API
, " PAL-I\n");
487 saa7164_api_set_dif(port
, 0x00, 0x08); /* Video Standard */
489 } else if (std
& V4L2_STD_PAL_M
) {
490 dprintk(DBGLVL_API
, " PAL-M\n");
491 saa7164_api_set_dif(port
, 0x00, 0x01); /* Video Standard */
493 } else if (std
& V4L2_STD_PAL_N
) {
494 dprintk(DBGLVL_API
, " PAL-N\n");
495 saa7164_api_set_dif(port
, 0x00, 0x01); /* Video Standard */
497 } else if (std
& V4L2_STD_PAL_Nc
) {
498 dprintk(DBGLVL_API
, " PAL-Nc\n");
499 saa7164_api_set_dif(port
, 0x00, 0x01); /* Video Standard */
501 } else if (std
& V4L2_STD_PAL_B
) {
502 dprintk(DBGLVL_API
, " PAL-B\n");
503 saa7164_api_set_dif(port
, 0x00, 0x02); /* Video Standard */
505 } else if (std
& V4L2_STD_PAL_DK
) {
506 dprintk(DBGLVL_API
, " PAL-DK\n");
507 saa7164_api_set_dif(port
, 0x00, 0x10); /* Video Standard */
509 } else if (std
& V4L2_STD_SECAM_L
) {
510 dprintk(DBGLVL_API
, " SECAM-L\n");
511 saa7164_api_set_dif(port
, 0x00, 0x20); /* Video Standard */
514 /* Unknown standard, assume DTV */
515 dprintk(DBGLVL_API
, " Unknown (assuming DTV)\n");
516 saa7164_api_set_dif(port
, 0x00, 0x80); /* Undefined Video Standard */
520 saa7164_api_set_dif(port
, 0x48, 0xa0); /* AGC Functions 1 */
521 saa7164_api_set_dif(port
, 0xc0, agc_disable
); /* AGC Output Disable */
522 saa7164_api_set_dif(port
, 0x7c, 0x04); /* CVBS EQ */
523 saa7164_api_set_dif(port
, 0x04, 0x01); /* Active */
525 saa7164_api_set_dif(port
, 0x04, 0x00); /* Active (again) */
531 /* Ensure the dif is in the correct state for the operating mode
532 * (analog / dtv). We only configure the diff through the analog encoder
533 * so when we're in digital mode we need to find the appropriate encoder
534 * and use it to configure the DIF.
536 int saa7164_api_initialize_dif(struct saa7164_port
*port
)
538 struct saa7164_dev
*dev
= port
->dev
;
539 struct saa7164_port
*p
= 0;
543 if (port
->type
== SAA7164_MPEG_ENCODER
) {
544 /* Pick any analog standard to init the diff.
545 * we'll come back during encoder_init'
546 * and set the correct standard if requried.
550 if (port
->type
== SAA7164_MPEG_DVB
) {
551 if (port
->nr
== SAA7164_PORT_TS1
)
552 p
= &dev
->ports
[ SAA7164_PORT_ENC1
];
554 p
= &dev
->ports
[ SAA7164_PORT_ENC2
];
559 ret
= saa7164_api_configure_dif(p
, std
);
564 int saa7164_api_transition_port(struct saa7164_port
*port
, u8 mode
)
568 ret
= saa7164_cmd_send(port
->dev
, port
->hwcfg
.unitid
, SET_CUR
,
569 SAA_STATE_CONTROL
, sizeof(mode
), &mode
);
571 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
576 int saa7164_api_get_fw_version(struct saa7164_dev
*dev
, u32
*version
)
580 ret
= saa7164_cmd_send(dev
, 0, GET_CUR
,
581 GET_FW_VERSION_CONTROL
, sizeof(u32
), version
);
583 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
588 int saa7164_api_read_eeprom(struct saa7164_dev
*dev
, u8
*buf
, int buflen
)
590 u8 reg
[] = { 0x0f, 0x00 };
595 /* Assumption: Hauppauge eeprom is at 0xa0 on on bus 0 */
596 /* TODO: Pull the details from the boards struct */
597 return saa7164_api_i2c_read(&dev
->i2c_bus
[0], 0xa0 >> 1, sizeof(reg
),
602 int saa7164_api_configure_port_mpeg2ts(struct saa7164_dev
*dev
,
603 struct saa7164_port
*port
,
604 tmComResTSFormatDescrHeader_t
*tsfmt
)
606 dprintk(DBGLVL_API
, " bFormatIndex = 0x%x\n", tsfmt
->bFormatIndex
);
607 dprintk(DBGLVL_API
, " bDataOffset = 0x%x\n", tsfmt
->bDataOffset
);
608 dprintk(DBGLVL_API
, " bPacketLength= 0x%x\n", tsfmt
->bPacketLength
);
609 dprintk(DBGLVL_API
, " bStrideLength= 0x%x\n", tsfmt
->bStrideLength
);
610 dprintk(DBGLVL_API
, " bguid = (....)\n");
612 /* Cache the hardware configuration in the port */
614 port
->bufcounter
= port
->hwcfg
.BARLocation
;
615 port
->pitch
= port
->hwcfg
.BARLocation
+ (2 * sizeof(u32
));
616 port
->bufsize
= port
->hwcfg
.BARLocation
+ (3 * sizeof(u32
));
617 port
->bufoffset
= port
->hwcfg
.BARLocation
+ (4 * sizeof(u32
));
618 port
->bufptr32l
= port
->hwcfg
.BARLocation
+
620 (sizeof(u32
) * port
->hwcfg
.buffercount
) + sizeof(u32
);
621 port
->bufptr32h
= port
->hwcfg
.BARLocation
+
623 (sizeof(u32
) * port
->hwcfg
.buffercount
);
624 port
->bufptr64
= port
->hwcfg
.BARLocation
+
626 (sizeof(u32
) * port
->hwcfg
.buffercount
);
627 dprintk(DBGLVL_API
, " = port->hwcfg.BARLocation = 0x%x\n",
628 port
->hwcfg
.BARLocation
);
630 dprintk(DBGLVL_API
, " = VS_FORMAT_MPEGTS (becomes dev->ts[%d])\n",
636 int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev
*dev
,
637 struct saa7164_port
*port
,
638 tmComResPSFormatDescrHeader_t
*fmt
)
640 dprintk(DBGLVL_API
, " bFormatIndex = 0x%x\n", fmt
->bFormatIndex
);
641 dprintk(DBGLVL_API
, " wPacketLength= 0x%x\n", fmt
->wPacketLength
);
642 dprintk(DBGLVL_API
, " wPackLength= 0x%x\n", fmt
->wPackLength
);
643 dprintk(DBGLVL_API
, " bPackDataType= 0x%x\n", fmt
->bPackDataType
);
645 /* Cache the hardware configuration in the port */
646 /* TODO: CHECK THIS in the port config */
647 port
->bufcounter
= port
->hwcfg
.BARLocation
;
648 port
->pitch
= port
->hwcfg
.BARLocation
+ (2 * sizeof(u32
));
649 port
->bufsize
= port
->hwcfg
.BARLocation
+ (3 * sizeof(u32
));
650 port
->bufoffset
= port
->hwcfg
.BARLocation
+ (4 * sizeof(u32
));
651 port
->bufptr32l
= port
->hwcfg
.BARLocation
+
653 (sizeof(u32
) * port
->hwcfg
.buffercount
) + sizeof(u32
);
654 port
->bufptr32h
= port
->hwcfg
.BARLocation
+
656 (sizeof(u32
) * port
->hwcfg
.buffercount
);
657 port
->bufptr64
= port
->hwcfg
.BARLocation
+
659 (sizeof(u32
) * port
->hwcfg
.buffercount
);
660 dprintk(DBGLVL_API
, " = port->hwcfg.BARLocation = 0x%x\n",
661 port
->hwcfg
.BARLocation
);
663 dprintk(DBGLVL_API
, " = VS_FORMAT_MPEGPS (becomes dev->enc[%d])\n",
669 int saa7164_api_dump_subdevs(struct saa7164_dev
*dev
, u8
*buf
, int len
)
671 struct saa7164_port
*tsport
= 0;
672 struct saa7164_port
*encport
= 0;
673 u32 idx
, next_offset
;
675 tmComResDescrHeader_t
*hdr
, *t
;
676 tmComResExtDevDescrHeader_t
*exthdr
;
677 tmComResPathDescrHeader_t
*pathhdr
;
678 tmComResAntTermDescrHeader_t
*anttermhdr
;
679 tmComResTunerDescrHeader_t
*tunerunithdr
;
680 tmComResDMATermDescrHeader_t
*vcoutputtermhdr
;
681 tmComResTSFormatDescrHeader_t
*tsfmt
;
682 tmComResPSFormatDescrHeader_t
*psfmt
;
683 tmComResSelDescrHeader_t
*psel
;
684 tmComResProcDescrHeader_t
*pdh
;
685 tmComResAFeatureDescrHeader_t
*afd
;
686 tmComResEncoderDescrHeader_t
*edh
;
690 "%s(?,?,%d) sizeof(tmComResDescrHeader_t) = %d bytes\n",
691 __func__
, len
, (u32
)sizeof(tmComResDescrHeader_t
));
693 for (idx
= 0; idx
< (len
- sizeof(tmComResDescrHeader_t
)); ) {
695 hdr
= (tmComResDescrHeader_t
*)(buf
+ idx
);
697 if (hdr
->type
!= CS_INTERFACE
)
698 return SAA_ERR_NOT_SUPPORTED
;
700 dprintk(DBGLVL_API
, "@ 0x%x = \n", idx
);
701 switch (hdr
->subtype
) {
702 case GENERAL_REQUEST
:
703 dprintk(DBGLVL_API
, " GENERAL_REQUEST\n");
706 dprintk(DBGLVL_API
, " VC_TUNER_PATH\n");
707 pathhdr
= (tmComResPathDescrHeader_t
*)(buf
+ idx
);
708 dprintk(DBGLVL_API
, " pathid = 0x%x\n",
710 currpath
= pathhdr
->pathid
;
712 case VC_INPUT_TERMINAL
:
713 dprintk(DBGLVL_API
, " VC_INPUT_TERMINAL\n");
715 (tmComResAntTermDescrHeader_t
*)(buf
+ idx
);
716 dprintk(DBGLVL_API
, " terminalid = 0x%x\n",
717 anttermhdr
->terminalid
);
718 dprintk(DBGLVL_API
, " terminaltype = 0x%x\n",
719 anttermhdr
->terminaltype
);
720 switch (anttermhdr
->terminaltype
) {
722 dprintk(DBGLVL_API
, " = ITT_ANTENNA\n");
725 dprintk(DBGLVL_API
, " = LINE_CONNECTOR\n");
727 case SPDIF_CONNECTOR
:
728 dprintk(DBGLVL_API
, " = SPDIF_CONNECTOR\n");
730 case COMPOSITE_CONNECTOR
:
732 " = COMPOSITE_CONNECTOR\n");
734 case SVIDEO_CONNECTOR
:
735 dprintk(DBGLVL_API
, " = SVIDEO_CONNECTOR\n");
737 case COMPONENT_CONNECTOR
:
739 " = COMPONENT_CONNECTOR\n");
742 dprintk(DBGLVL_API
, " = STANDARD_DMA\n");
745 dprintk(DBGLVL_API
, " = undefined (0x%x)\n",
746 anttermhdr
->terminaltype
);
748 dprintk(DBGLVL_API
, " assocterminal= 0x%x\n",
749 anttermhdr
->assocterminal
);
750 dprintk(DBGLVL_API
, " iterminal = 0x%x\n",
751 anttermhdr
->iterminal
);
752 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
753 anttermhdr
->controlsize
);
755 case VC_OUTPUT_TERMINAL
:
756 dprintk(DBGLVL_API
, " VC_OUTPUT_TERMINAL\n");
758 (tmComResDMATermDescrHeader_t
*)(buf
+ idx
);
759 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
760 vcoutputtermhdr
->unitid
);
761 dprintk(DBGLVL_API
, " terminaltype = 0x%x\n",
762 vcoutputtermhdr
->terminaltype
);
763 switch (vcoutputtermhdr
->terminaltype
) {
765 dprintk(DBGLVL_API
, " = ITT_ANTENNA\n");
768 dprintk(DBGLVL_API
, " = LINE_CONNECTOR\n");
770 case SPDIF_CONNECTOR
:
771 dprintk(DBGLVL_API
, " = SPDIF_CONNECTOR\n");
773 case COMPOSITE_CONNECTOR
:
775 " = COMPOSITE_CONNECTOR\n");
777 case SVIDEO_CONNECTOR
:
778 dprintk(DBGLVL_API
, " = SVIDEO_CONNECTOR\n");
780 case COMPONENT_CONNECTOR
:
782 " = COMPONENT_CONNECTOR\n");
785 dprintk(DBGLVL_API
, " = STANDARD_DMA\n");
788 dprintk(DBGLVL_API
, " = undefined (0x%x)\n",
789 vcoutputtermhdr
->terminaltype
);
791 dprintk(DBGLVL_API
, " assocterminal= 0x%x\n",
792 vcoutputtermhdr
->assocterminal
);
793 dprintk(DBGLVL_API
, " sourceid = 0x%x\n",
794 vcoutputtermhdr
->sourceid
);
795 dprintk(DBGLVL_API
, " iterminal = 0x%x\n",
796 vcoutputtermhdr
->iterminal
);
797 dprintk(DBGLVL_API
, " BARLocation = 0x%x\n",
798 vcoutputtermhdr
->BARLocation
);
799 dprintk(DBGLVL_API
, " flags = 0x%x\n",
800 vcoutputtermhdr
->flags
);
801 dprintk(DBGLVL_API
, " interruptid = 0x%x\n",
802 vcoutputtermhdr
->interruptid
);
803 dprintk(DBGLVL_API
, " buffercount = 0x%x\n",
804 vcoutputtermhdr
->buffercount
);
805 dprintk(DBGLVL_API
, " metadatasize = 0x%x\n",
806 vcoutputtermhdr
->metadatasize
);
807 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
808 vcoutputtermhdr
->controlsize
);
809 dprintk(DBGLVL_API
, " numformats = 0x%x\n",
810 vcoutputtermhdr
->numformats
);
812 t
= (tmComResDescrHeader_t
*)
813 ((tmComResDMATermDescrHeader_t
*)(buf
+ idx
));
814 next_offset
= idx
+ (vcoutputtermhdr
->len
);
815 for (i
= 0; i
< vcoutputtermhdr
->numformats
; i
++) {
816 t
= (tmComResDescrHeader_t
*)
818 switch (t
->subtype
) {
819 case VS_FORMAT_MPEG2TS
:
821 (tmComResTSFormatDescrHeader_t
*)t
;
823 tsport
= &dev
->ports
[ SAA7164_PORT_TS1
];
825 tsport
= &dev
->ports
[ SAA7164_PORT_TS2
];
826 memcpy(&tsport
->hwcfg
, vcoutputtermhdr
,
827 sizeof(*vcoutputtermhdr
));
828 saa7164_api_configure_port_mpeg2ts(dev
,
831 case VS_FORMAT_MPEG2PS
:
833 (tmComResPSFormatDescrHeader_t
*)t
;
835 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
837 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
838 memcpy(&encport
->hwcfg
, vcoutputtermhdr
,
839 sizeof(*vcoutputtermhdr
));
840 saa7164_api_configure_port_mpeg2ps(dev
,
845 " = VS_FORMAT_VBI\n");
849 " = VS_FORMAT_RDS\n");
851 case VS_FORMAT_UNCOMPRESSED
:
853 " = VS_FORMAT_UNCOMPRESSED\n");
857 " = VS_FORMAT_TYPE\n");
861 " = undefined (0x%x)\n",
864 next_offset
+= t
->len
;
869 dprintk(DBGLVL_API
, " TUNER_UNIT\n");
871 (tmComResTunerDescrHeader_t
*)(buf
+ idx
);
872 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
873 tunerunithdr
->unitid
);
874 dprintk(DBGLVL_API
, " sourceid = 0x%x\n",
875 tunerunithdr
->sourceid
);
876 dprintk(DBGLVL_API
, " iunit = 0x%x\n",
877 tunerunithdr
->iunit
);
878 dprintk(DBGLVL_API
, " tuningstandards = 0x%x\n",
879 tunerunithdr
->tuningstandards
);
880 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
881 tunerunithdr
->controlsize
);
882 dprintk(DBGLVL_API
, " controls = 0x%x\n",
883 tunerunithdr
->controls
);
885 if (tunerunithdr
->unitid
== tunerunithdr
->iunit
) {
887 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
889 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
890 memcpy(&encport
->tunerunit
, tunerunithdr
,
891 sizeof(tmComResTunerDescrHeader_t
));
892 dprintk(DBGLVL_API
, " (becomes dev->enc[%d] tuner)\n", encport
->nr
);
895 case VC_SELECTOR_UNIT
:
896 psel
= (tmComResSelDescrHeader_t
*)(buf
+ idx
);
897 dprintk(DBGLVL_API
, " VC_SELECTOR_UNIT\n");
898 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
900 dprintk(DBGLVL_API
, " nrinpins = 0x%x\n",
902 dprintk(DBGLVL_API
, " sourceid = 0x%x\n",
905 case VC_PROCESSING_UNIT
:
906 pdh
= (tmComResProcDescrHeader_t
*)(buf
+ idx
);
907 dprintk(DBGLVL_API
, " VC_PROCESSING_UNIT\n");
908 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
910 dprintk(DBGLVL_API
, " sourceid = 0x%x\n",
912 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
914 if (pdh
->controlsize
== 0x04) {
916 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
918 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
919 memcpy(&encport
->vidproc
, pdh
,
920 sizeof(tmComResProcDescrHeader_t
));
921 dprintk(DBGLVL_API
, " (becomes dev->enc[%d])\n", encport
->nr
);
925 afd
= (tmComResAFeatureDescrHeader_t
*)(buf
+ idx
);
926 dprintk(DBGLVL_API
, " FEATURE_UNIT\n");
927 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
929 dprintk(DBGLVL_API
, " sourceid = 0x%x\n",
931 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
934 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
936 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
937 memcpy(&encport
->audfeat
, afd
,
938 sizeof(tmComResAFeatureDescrHeader_t
));
939 dprintk(DBGLVL_API
, " (becomes dev->enc[%d])\n", encport
->nr
);
942 edh
= (tmComResEncoderDescrHeader_t
*)(buf
+ idx
);
943 dprintk(DBGLVL_API
, " ENCODER_UNIT\n");
944 dprintk(DBGLVL_API
, " subtype = 0x%x\n", edh
->subtype
);
945 dprintk(DBGLVL_API
, " unitid = 0x%x\n", edh
->unitid
);
946 dprintk(DBGLVL_API
, " vsourceid = 0x%x\n", edh
->vsourceid
);
947 dprintk(DBGLVL_API
, " asourceid = 0x%x\n", edh
->asourceid
);
948 dprintk(DBGLVL_API
, " iunit = 0x%x\n", edh
->iunit
);
949 if (edh
->iunit
== edh
->unitid
) {
951 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
953 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
954 memcpy(&encport
->encunit
, edh
,
955 sizeof(tmComResEncoderDescrHeader_t
));
956 dprintk(DBGLVL_API
, " (becomes dev->enc[%d])\n", encport
->nr
);
960 dprintk(DBGLVL_API
, " EXTENSION_UNIT\n");
961 exthdr
= (tmComResExtDevDescrHeader_t
*)(buf
+ idx
);
962 dprintk(DBGLVL_API
, " unitid = 0x%x\n",
964 dprintk(DBGLVL_API
, " deviceid = 0x%x\n",
966 dprintk(DBGLVL_API
, " devicetype = 0x%x\n",
968 if (exthdr
->devicetype
& 0x1)
969 dprintk(DBGLVL_API
, " = Decoder Device\n");
970 if (exthdr
->devicetype
& 0x2)
971 dprintk(DBGLVL_API
, " = GPIO Source\n");
972 if (exthdr
->devicetype
& 0x4)
973 dprintk(DBGLVL_API
, " = Video Decoder\n");
974 if (exthdr
->devicetype
& 0x8)
975 dprintk(DBGLVL_API
, " = Audio Decoder\n");
976 if (exthdr
->devicetype
& 0x20)
977 dprintk(DBGLVL_API
, " = Crossbar\n");
978 if (exthdr
->devicetype
& 0x40)
979 dprintk(DBGLVL_API
, " = Tuner\n");
980 if (exthdr
->devicetype
& 0x80)
981 dprintk(DBGLVL_API
, " = IF PLL\n");
982 if (exthdr
->devicetype
& 0x100)
983 dprintk(DBGLVL_API
, " = Demodulator\n");
984 if (exthdr
->devicetype
& 0x200)
985 dprintk(DBGLVL_API
, " = RDS Decoder\n");
986 if (exthdr
->devicetype
& 0x400)
987 dprintk(DBGLVL_API
, " = Encoder\n");
988 if (exthdr
->devicetype
& 0x800)
989 dprintk(DBGLVL_API
, " = IR Decoder\n");
990 if (exthdr
->devicetype
& 0x1000)
991 dprintk(DBGLVL_API
, " = EEPROM\n");
992 if (exthdr
->devicetype
& 0x2000)
995 if (exthdr
->devicetype
& 0x10000)
997 " = Streaming Device\n");
998 if (exthdr
->devicetype
& 0x20000)
1001 if (exthdr
->devicetype
& 0x40000000)
1003 " = Generic Device\n");
1004 if (exthdr
->devicetype
& 0x80000000)
1006 " = Config Space Device\n");
1007 dprintk(DBGLVL_API
, " numgpiopins = 0x%x\n",
1008 exthdr
->numgpiopins
);
1009 dprintk(DBGLVL_API
, " numgpiogroups = 0x%x\n",
1010 exthdr
->numgpiogroups
);
1011 dprintk(DBGLVL_API
, " controlsize = 0x%x\n",
1012 exthdr
->controlsize
);
1013 if (exthdr
->devicetype
& 0x80) {
1015 encport
= &dev
->ports
[ SAA7164_PORT_ENC1
];
1017 encport
= &dev
->ports
[ SAA7164_PORT_ENC2
];
1018 memcpy(&encport
->ifunit
, exthdr
,
1019 sizeof(tmComResExtDevDescrHeader_t
));
1020 dprintk(DBGLVL_API
, " (becomes dev->enc[%d])\n", encport
->nr
);
1023 case PVC_INFRARED_UNIT
:
1024 dprintk(DBGLVL_API
, " PVC_INFRARED_UNIT\n");
1027 dprintk(DBGLVL_API
, " DRM_UNIT\n");
1030 dprintk(DBGLVL_API
, "default %d\n", hdr
->subtype
);
1033 dprintk(DBGLVL_API
, " 1.%x\n", hdr
->len
);
1034 dprintk(DBGLVL_API
, " 2.%x\n", hdr
->type
);
1035 dprintk(DBGLVL_API
, " 3.%x\n", hdr
->subtype
);
1036 dprintk(DBGLVL_API
, " 4.%x\n", hdr
->unitid
);
1044 int saa7164_api_enum_subdevs(struct saa7164_dev
*dev
)
1050 dprintk(DBGLVL_API
, "%s()\n", __func__
);
1052 /* Get the total descriptor length */
1053 ret
= saa7164_cmd_send(dev
, 0, GET_LEN
,
1054 GET_DESCRIPTORS_CONTROL
, sizeof(buflen
), &buflen
);
1056 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
1058 dprintk(DBGLVL_API
, "%s() total descriptor size = %d bytes.\n",
1061 /* Allocate enough storage for all of the descs */
1062 buf
= kzalloc(buflen
, GFP_KERNEL
);
1064 return SAA_ERR_NO_RESOURCES
;
1067 ret
= saa7164_cmd_send(dev
, 0, GET_CUR
,
1068 GET_DESCRIPTORS_CONTROL
, buflen
, buf
);
1069 if (ret
!= SAA_OK
) {
1070 printk(KERN_ERR
"%s() error, ret = 0x%x\n", __func__
, ret
);
1074 if (saa_debug
& DBGLVL_API
)
1075 saa7164_dumphex16(dev
, buf
, (buflen
/16)*16);
1077 saa7164_api_dump_subdevs(dev
, buf
, buflen
);
1084 int saa7164_api_i2c_read(struct saa7164_i2c
*bus
, u8 addr
, u32 reglen
, u8
*reg
,
1085 u32 datalen
, u8
*data
)
1087 struct saa7164_dev
*dev
= bus
->dev
;
1094 dprintk(DBGLVL_API
, "%s()\n", __func__
);
1103 regval
= ((*(reg
) << 8) || *(reg
+1));
1106 regval
= ((*(reg
) << 16) | (*(reg
+1) << 8) | *(reg
+2));
1109 regval
= ((*(reg
) << 24) | (*(reg
+1) << 16) |
1110 (*(reg
+2) << 8) | *(reg
+3));
1112 /* Prepare the send buffer */
1113 /* Bytes 00-03 source register length
1114 * 04-07 source bytes to read
1115 * 08... register address
1117 memset(buf
, 0, sizeof(buf
));
1118 memcpy((buf
+ 2 * sizeof(u32
) + 0), reg
, reglen
);
1119 *((u32
*)(buf
+ 0 * sizeof(u32
))) = reglen
;
1120 *((u32
*)(buf
+ 1 * sizeof(u32
))) = datalen
;
1122 unitid
= saa7164_i2caddr_to_unitid(bus
, addr
);
1125 "%s() error, cannot translate regaddr 0x%x to unitid\n",
1130 ret
= saa7164_cmd_send(bus
->dev
, unitid
, GET_LEN
,
1131 EXU_REGISTER_ACCESS_CONTROL
, sizeof(len
), &len
);
1132 if (ret
!= SAA_OK
) {
1133 printk(KERN_ERR
"%s() error, ret(1) = 0x%x\n", __func__
, ret
);
1137 dprintk(DBGLVL_API
, "%s() len = %d bytes\n", __func__
, len
);
1139 if (saa_debug
& DBGLVL_I2C
)
1140 saa7164_dumphex16(dev
, buf
, 2 * 16);
1142 ret
= saa7164_cmd_send(bus
->dev
, unitid
, GET_CUR
,
1143 EXU_REGISTER_ACCESS_CONTROL
, len
, &buf
);
1145 printk(KERN_ERR
"%s() error, ret(2) = 0x%x\n", __func__
, ret
);
1147 if (saa_debug
& DBGLVL_I2C
)
1148 saa7164_dumphex16(dev
, buf
, sizeof(buf
));
1149 memcpy(data
, (buf
+ 2 * sizeof(u32
) + reglen
), datalen
);
1152 return ret
== SAA_OK
? 0 : -EIO
;
1155 /* For a given 8 bit i2c address device, write the buffer */
1156 int saa7164_api_i2c_write(struct saa7164_i2c
*bus
, u8 addr
, u32 datalen
,
1159 struct saa7164_dev
*dev
= bus
->dev
;
1166 dprintk(DBGLVL_API
, "%s()\n", __func__
);
1168 if ((datalen
== 0) || (datalen
> 232))
1171 memset(buf
, 0, sizeof(buf
));
1173 unitid
= saa7164_i2caddr_to_unitid(bus
, addr
);
1176 "%s() error, cannot translate regaddr 0x%x to unitid\n",
1181 reglen
= saa7164_i2caddr_to_reglen(bus
, addr
);
1184 "%s() error, cannot translate regaddr to reglen\n",
1189 ret
= saa7164_cmd_send(bus
->dev
, unitid
, GET_LEN
,
1190 EXU_REGISTER_ACCESS_CONTROL
, sizeof(len
), &len
);
1191 if (ret
!= SAA_OK
) {
1192 printk(KERN_ERR
"%s() error, ret(1) = 0x%x\n", __func__
, ret
);
1196 dprintk(DBGLVL_API
, "%s() len = %d bytes\n", __func__
, len
);
1198 /* Prepare the send buffer */
1199 /* Bytes 00-03 dest register length
1200 * 04-07 dest bytes to write
1201 * 08... register address
1203 *((u32
*)(buf
+ 0 * sizeof(u32
))) = reglen
;
1204 *((u32
*)(buf
+ 1 * sizeof(u32
))) = datalen
- reglen
;
1205 memcpy((buf
+ 2 * sizeof(u32
)), data
, datalen
);
1207 if (saa_debug
& DBGLVL_I2C
)
1208 saa7164_dumphex16(dev
, buf
, sizeof(buf
));
1210 ret
= saa7164_cmd_send(bus
->dev
, unitid
, SET_CUR
,
1211 EXU_REGISTER_ACCESS_CONTROL
, len
, &buf
);
1213 printk(KERN_ERR
"%s() error, ret(2) = 0x%x\n", __func__
, ret
);
1215 return ret
== SAA_OK
? 0 : -EIO
;
1219 int saa7164_api_modify_gpio(struct saa7164_dev
*dev
, u8 unitid
,
1225 dprintk(DBGLVL_API
, "%s(0x%x, %d, %d)\n",
1226 __func__
, unitid
, pin
, state
);
1228 if ((pin
> 7) || (state
> 2))
1229 return SAA_ERR_BAD_PARAMETER
;
1234 ret
= saa7164_cmd_send(dev
, unitid
, SET_CUR
,
1235 EXU_GPIO_CONTROL
, sizeof(t
), &t
);
1237 printk(KERN_ERR
"%s() error, ret = 0x%x\n",
1243 int saa7164_api_set_gpiobit(struct saa7164_dev
*dev
, u8 unitid
,
1246 return saa7164_api_modify_gpio(dev
, unitid
, pin
, 1);
1249 int saa7164_api_clear_gpiobit(struct saa7164_dev
*dev
, u8 unitid
,
1252 return saa7164_api_modify_gpio(dev
, unitid
, pin
, 0);