2 * Driver for the Conexant CX25821 PCIe bridge
4 * Copyright (C) 2009 Conexant Systems Inc.
5 * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "cx25821-medusa-video.h"
25 #include "cx25821-biffuncs.h"
27 /////////////////////////////////////////////////////////////////////////////////////////
28 //medusa_enable_bluefield_output()
30 // Enable the generation of blue filed output if no video
32 static void medusa_enable_bluefield_output(struct cx25821_dev
*dev
, int channel
,
38 int out_ctrl
= OUT_CTRL1
;
39 int out_ctrl_ns
= OUT_CTRL_NS
;
46 out_ctrl
= VDEC_B_OUT_CTRL1
;
47 out_ctrl_ns
= VDEC_B_OUT_CTRL_NS
;
50 out_ctrl
= VDEC_C_OUT_CTRL1
;
51 out_ctrl_ns
= VDEC_C_OUT_CTRL_NS
;
54 out_ctrl
= VDEC_D_OUT_CTRL1
;
55 out_ctrl_ns
= VDEC_D_OUT_CTRL_NS
;
58 out_ctrl
= VDEC_E_OUT_CTRL1
;
59 out_ctrl_ns
= VDEC_E_OUT_CTRL_NS
;
62 out_ctrl
= VDEC_F_OUT_CTRL1
;
63 out_ctrl_ns
= VDEC_F_OUT_CTRL_NS
;
66 out_ctrl
= VDEC_G_OUT_CTRL1
;
67 out_ctrl_ns
= VDEC_G_OUT_CTRL_NS
;
70 out_ctrl
= VDEC_H_OUT_CTRL1
;
71 out_ctrl_ns
= VDEC_H_OUT_CTRL_NS
;
75 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], out_ctrl
, &tmp
);
76 value
&= 0xFFFFFF7F; // clear BLUE_FIELD_EN
78 value
|= 0x00000080; // set BLUE_FIELD_EN
79 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], out_ctrl
, value
);
81 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], out_ctrl_ns
, &tmp
);
84 value
|= 0x00000080; // set BLUE_FIELD_EN
85 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], out_ctrl_ns
, value
);
88 static int medusa_initialize_ntsc(struct cx25821_dev
*dev
)
95 mutex_lock(&dev
->lock
);
97 for (i
= 0; i
< MAX_DECODERS
; i
++) {
98 // set video format NTSC-M
100 cx25821_i2c_read(&dev
->i2c_bus
[0], MODE_CTRL
+ (0x200 * i
),
103 value
|= 0x10001; // enable the fast locking mode bit[16]
105 cx25821_i2c_write(&dev
->i2c_bus
[0], MODE_CTRL
+ (0x200 * i
),
108 // resolution NTSC 720x480
110 cx25821_i2c_read(&dev
->i2c_bus
[0],
111 HORIZ_TIM_CTRL
+ (0x200 * i
), &tmp
);
115 cx25821_i2c_write(&dev
->i2c_bus
[0],
116 HORIZ_TIM_CTRL
+ (0x200 * i
), value
);
119 cx25821_i2c_read(&dev
->i2c_bus
[0],
120 VERT_TIM_CTRL
+ (0x200 * i
), &tmp
);
122 value
|= 0x1C1E001A; // vblank_cnt + 2 to get camera ID
124 cx25821_i2c_write(&dev
->i2c_bus
[0],
125 VERT_TIM_CTRL
+ (0x200 * i
), value
);
127 // chroma subcarrier step size
129 cx25821_i2c_write(&dev
->i2c_bus
[0],
130 SC_STEP_SIZE
+ (0x200 * i
), 0x43E00000);
132 // enable VIP optional active
134 cx25821_i2c_read(&dev
->i2c_bus
[0],
135 OUT_CTRL_NS
+ (0x200 * i
), &tmp
);
139 cx25821_i2c_write(&dev
->i2c_bus
[0],
140 OUT_CTRL_NS
+ (0x200 * i
), value
);
142 // enable VIP optional active (VIP_OPT_AL) for direct output.
144 cx25821_i2c_read(&dev
->i2c_bus
[0], OUT_CTRL1
+ (0x200 * i
),
149 cx25821_i2c_write(&dev
->i2c_bus
[0], OUT_CTRL1
+ (0x200 * i
),
152 // clear VPRES_VERT_EN bit, fixes the chroma run away problem
153 // when the input switching rate < 16 fields
156 cx25821_i2c_read(&dev
->i2c_bus
[0],
157 MISC_TIM_CTRL
+ (0x200 * i
), &tmp
);
158 value
= setBitAtPos(value
, 14); // disable special play detection
159 value
= clearBitAtPos(value
, 15);
161 cx25821_i2c_write(&dev
->i2c_bus
[0],
162 MISC_TIM_CTRL
+ (0x200 * i
), value
);
164 // set vbi_gate_en to 0
166 cx25821_i2c_read(&dev
->i2c_bus
[0], DFE_CTRL1
+ (0x200 * i
),
168 value
= clearBitAtPos(value
, 29);
170 cx25821_i2c_write(&dev
->i2c_bus
[0], DFE_CTRL1
+ (0x200 * i
),
173 // Enable the generation of blue field output if no video
174 medusa_enable_bluefield_output(dev
, i
, 1);
177 for (i
= 0; i
< MAX_ENCODERS
; i
++) {
180 cx25821_i2c_read(&dev
->i2c_bus
[0],
181 DENC_A_REG_1
+ (0x100 * i
), &tmp
);
185 cx25821_i2c_write(&dev
->i2c_bus
[0],
186 DENC_A_REG_1
+ (0x100 * i
), value
);
188 // burst begin and burst end
190 cx25821_i2c_read(&dev
->i2c_bus
[0],
191 DENC_A_REG_2
+ (0x100 * i
), &tmp
);
195 cx25821_i2c_write(&dev
->i2c_bus
[0],
196 DENC_A_REG_2
+ (0x100 * i
), value
);
199 cx25821_i2c_read(&dev
->i2c_bus
[0],
200 DENC_A_REG_3
+ (0x100 * i
), &tmp
);
204 cx25821_i2c_write(&dev
->i2c_bus
[0],
205 DENC_A_REG_3
+ (0x100 * i
), value
);
207 // set NTSC vblank, no phase alternation, 7.5 IRE pedestal
209 cx25821_i2c_read(&dev
->i2c_bus
[0],
210 DENC_A_REG_4
+ (0x100 * i
), &tmp
);
214 cx25821_i2c_write(&dev
->i2c_bus
[0],
215 DENC_A_REG_4
+ (0x100 * i
), value
);
218 cx25821_i2c_read(&dev
->i2c_bus
[0],
219 DENC_A_REG_5
+ (0x100 * i
), &tmp
);
223 cx25821_i2c_write(&dev
->i2c_bus
[0],
224 DENC_A_REG_5
+ (0x100 * i
), value
);
227 cx25821_i2c_write(&dev
->i2c_bus
[0],
228 DENC_A_REG_6
+ (0x100 * i
), 0x009A89C1);
230 // Subcarrier Increment
232 cx25821_i2c_write(&dev
->i2c_bus
[0],
233 DENC_A_REG_7
+ (0x100 * i
), 0x21F07C1F);
236 //set picture resolutions
237 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], HSCALE_CTRL
, 0x0); //0 - 720
238 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], VSCALE_CTRL
, 0x0); //0 - 480
240 // set Bypass input format to NTSC 525 lines
241 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], BYP_AB_CTRL
, &tmp
);
243 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], BYP_AB_CTRL
, value
);
245 mutex_unlock(&dev
->lock
);
250 static int medusa_PALCombInit(struct cx25821_dev
*dev
, int dec
)
253 u32 value
= 0, tmp
= 0;
255 // Setup for 2D threshold
257 cx25821_i2c_write(&dev
->i2c_bus
[0], COMB_2D_HFS_CFG
+ (0x200 * dec
),
260 cx25821_i2c_write(&dev
->i2c_bus
[0], COMB_2D_HFD_CFG
+ (0x200 * dec
),
263 cx25821_i2c_write(&dev
->i2c_bus
[0], COMB_2D_LF_CFG
+ (0x200 * dec
),
266 // Setup flat chroma and luma thresholds
268 cx25821_i2c_read(&dev
->i2c_bus
[0],
269 COMB_FLAT_THRESH_CTRL
+ (0x200 * dec
), &tmp
);
272 cx25821_i2c_write(&dev
->i2c_bus
[0],
273 COMB_FLAT_THRESH_CTRL
+ (0x200 * dec
), value
);
277 cx25821_i2c_write(&dev
->i2c_bus
[0], COMB_2D_BLEND
+ (0x200 * dec
),
282 cx25821_i2c_write(&dev
->i2c_bus
[0], COMB_MISC_CTRL
+ (0x200 * dec
),
288 static int medusa_initialize_pal(struct cx25821_dev
*dev
)
295 mutex_lock(&dev
->lock
);
297 for (i
= 0; i
< MAX_DECODERS
; i
++) {
298 // set video format PAL-BDGHI
300 cx25821_i2c_read(&dev
->i2c_bus
[0], MODE_CTRL
+ (0x200 * i
),
303 value
|= 0x10004; // enable the fast locking mode bit[16]
305 cx25821_i2c_write(&dev
->i2c_bus
[0], MODE_CTRL
+ (0x200 * i
),
308 // resolution PAL 720x576
310 cx25821_i2c_read(&dev
->i2c_bus
[0],
311 HORIZ_TIM_CTRL
+ (0x200 * i
), &tmp
);
315 cx25821_i2c_write(&dev
->i2c_bus
[0],
316 HORIZ_TIM_CTRL
+ (0x200 * i
), value
);
318 // vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24
320 cx25821_i2c_read(&dev
->i2c_bus
[0],
321 VERT_TIM_CTRL
+ (0x200 * i
), &tmp
);
323 value
|= 0x28240026; // vblank_cnt + 2 to get camera ID
325 cx25821_i2c_write(&dev
->i2c_bus
[0],
326 VERT_TIM_CTRL
+ (0x200 * i
), value
);
328 // chroma subcarrier step size
330 cx25821_i2c_write(&dev
->i2c_bus
[0],
331 SC_STEP_SIZE
+ (0x200 * i
), 0x5411E2D0);
333 // enable VIP optional active
335 cx25821_i2c_read(&dev
->i2c_bus
[0],
336 OUT_CTRL_NS
+ (0x200 * i
), &tmp
);
340 cx25821_i2c_write(&dev
->i2c_bus
[0],
341 OUT_CTRL_NS
+ (0x200 * i
), value
);
343 // enable VIP optional active (VIP_OPT_AL) for direct output.
345 cx25821_i2c_read(&dev
->i2c_bus
[0], OUT_CTRL1
+ (0x200 * i
),
350 cx25821_i2c_write(&dev
->i2c_bus
[0], OUT_CTRL1
+ (0x200 * i
),
353 // clear VPRES_VERT_EN bit, fixes the chroma run away problem
354 // when the input switching rate < 16 fields
356 cx25821_i2c_read(&dev
->i2c_bus
[0],
357 MISC_TIM_CTRL
+ (0x200 * i
), &tmp
);
358 value
= setBitAtPos(value
, 14); // disable special play detection
359 value
= clearBitAtPos(value
, 15);
361 cx25821_i2c_write(&dev
->i2c_bus
[0],
362 MISC_TIM_CTRL
+ (0x200 * i
), value
);
364 // set vbi_gate_en to 0
366 cx25821_i2c_read(&dev
->i2c_bus
[0], DFE_CTRL1
+ (0x200 * i
),
368 value
= clearBitAtPos(value
, 29);
370 cx25821_i2c_write(&dev
->i2c_bus
[0], DFE_CTRL1
+ (0x200 * i
),
373 medusa_PALCombInit(dev
, i
);
375 // Enable the generation of blue field output if no video
376 medusa_enable_bluefield_output(dev
, i
, 1);
379 for (i
= 0; i
< MAX_ENCODERS
; i
++) {
382 cx25821_i2c_read(&dev
->i2c_bus
[0],
383 DENC_A_REG_1
+ (0x100 * i
), &tmp
);
387 cx25821_i2c_write(&dev
->i2c_bus
[0],
388 DENC_A_REG_1
+ (0x100 * i
), value
);
390 // burst begin and burst end
392 cx25821_i2c_read(&dev
->i2c_bus
[0],
393 DENC_A_REG_2
+ (0x100 * i
), &tmp
);
397 cx25821_i2c_write(&dev
->i2c_bus
[0],
398 DENC_A_REG_2
+ (0x100 * i
), value
);
400 // hblank and vactive
402 cx25821_i2c_read(&dev
->i2c_bus
[0],
403 DENC_A_REG_3
+ (0x100 * i
), &tmp
);
407 cx25821_i2c_write(&dev
->i2c_bus
[0],
408 DENC_A_REG_3
+ (0x100 * i
), value
);
410 // set PAL vblank, phase alternation, 0 IRE pedestal
412 cx25821_i2c_read(&dev
->i2c_bus
[0],
413 DENC_A_REG_4
+ (0x100 * i
), &tmp
);
417 cx25821_i2c_write(&dev
->i2c_bus
[0],
418 DENC_A_REG_4
+ (0x100 * i
), value
);
421 cx25821_i2c_read(&dev
->i2c_bus
[0],
422 DENC_A_REG_5
+ (0x100 * i
), &tmp
);
426 cx25821_i2c_write(&dev
->i2c_bus
[0],
427 DENC_A_REG_5
+ (0x100 * i
), value
);
430 cx25821_i2c_write(&dev
->i2c_bus
[0],
431 DENC_A_REG_6
+ (0x100 * i
), 0x00A493CF);
433 // Subcarrier Increment
435 cx25821_i2c_write(&dev
->i2c_bus
[0],
436 DENC_A_REG_7
+ (0x100 * i
), 0x2A098ACB);
439 //set picture resolutions
440 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], HSCALE_CTRL
, 0x0); //0 - 720
441 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], VSCALE_CTRL
, 0x0); //0 - 576
443 // set Bypass input format to PAL 625 lines
444 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], BYP_AB_CTRL
, &tmp
);
446 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], BYP_AB_CTRL
, value
);
448 mutex_unlock(&dev
->lock
);
453 int medusa_set_videostandard(struct cx25821_dev
*dev
)
455 int status
= STATUS_SUCCESS
;
456 u32 value
= 0, tmp
= 0;
458 if (dev
->tvnorm
& V4L2_STD_PAL_BG
|| dev
->tvnorm
& V4L2_STD_PAL_DK
) {
459 status
= medusa_initialize_pal(dev
);
461 status
= medusa_initialize_ntsc(dev
);
464 // Enable DENC_A output
465 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], DENC_A_REG_4
, &tmp
);
466 value
= setBitAtPos(value
, 4);
467 status
= cx25821_i2c_write(&dev
->i2c_bus
[0], DENC_A_REG_4
, value
);
469 // Enable DENC_B output
470 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], DENC_B_REG_4
, &tmp
);
471 value
= setBitAtPos(value
, 4);
472 status
= cx25821_i2c_write(&dev
->i2c_bus
[0], DENC_B_REG_4
, value
);
477 void medusa_set_resolution(struct cx25821_dev
*dev
, int width
,
481 int decoder_count
= 0;
485 const int MAX_WIDTH
= 720;
487 mutex_lock(&dev
->lock
);
489 // validate the width - cannot be negative
490 if (width
> MAX_WIDTH
) {
492 ("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n",
493 __func__
, width
, MAX_WIDTH
);
497 if (decoder_select
<= 7 && decoder_select
>= 0) {
498 decoder
= decoder_select
;
499 decoder_count
= decoder_select
+ 1;
502 decoder_count
= _num_decoders
;
532 for (; decoder
< decoder_count
; decoder
++) {
533 // write scaling values for each decoder
535 cx25821_i2c_write(&dev
->i2c_bus
[0],
536 HSCALE_CTRL
+ (0x200 * decoder
), hscale
);
538 cx25821_i2c_write(&dev
->i2c_bus
[0],
539 VSCALE_CTRL
+ (0x200 * decoder
), vscale
);
542 mutex_unlock(&dev
->lock
);
545 static void medusa_set_decoderduration(struct cx25821_dev
*dev
, int decoder
,
551 u32 disp_cnt_reg
= DISP_AB_CNT
;
553 mutex_lock(&dev
->lock
);
556 if (decoder
< VDEC_A
&& decoder
> VDEC_H
) {
557 mutex_unlock(&dev
->lock
);
566 disp_cnt_reg
= DISP_CD_CNT
;
570 disp_cnt_reg
= DISP_EF_CNT
;
574 disp_cnt_reg
= DISP_GH_CNT
;
578 _display_field_cnt
[decoder
] = duration
;
581 fld_cnt
= cx25821_i2c_read(&dev
->i2c_bus
[0], disp_cnt_reg
, &tmp
);
583 if (!(decoder
% 2)) // EVEN decoder
585 fld_cnt
&= 0xFFFF0000;
588 fld_cnt
&= 0x0000FFFF;
589 fld_cnt
|= ((u32
) duration
) << 16;
592 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], disp_cnt_reg
, fld_cnt
);
594 mutex_unlock(&dev
->lock
);
597 /////////////////////////////////////////////////////////////////////////////////////////
598 // Map to Medusa register setting
599 static int mapM(int srcMin
,
600 int srcMax
, int srcVal
, int dstMin
, int dstMax
, int *dstVal
)
606 if ((srcMin
== srcMax
) || (srcVal
< srcMin
) || (srcVal
> srcMax
)) {
609 // This is the overall expression used:
610 // *dstVal = (srcVal - srcMin)*(dstMax - dstMin) / (srcMax - srcMin) + dstMin;
611 // but we need to account for rounding so below we use the modulus
612 // operator to find the remainder and increment if necessary.
613 numerator
= (srcVal
- srcMin
) * (dstMax
- dstMin
);
614 denominator
= srcMax
- srcMin
;
615 quotient
= numerator
/ denominator
;
617 if (2 * (numerator
% denominator
) >= denominator
) {
621 *dstVal
= quotient
+ dstMin
;
626 static unsigned long convert_to_twos(long numeric
, unsigned long bits_len
)
633 temp
= ~(abs(numeric
) & 0xFF);
639 /////////////////////////////////////////////////////////////////////////////////////////
640 int medusa_set_brightness(struct cx25821_dev
*dev
, int brightness
, int decoder
)
644 u32 val
= 0, tmp
= 0;
646 mutex_lock(&dev
->lock
);
647 if ((brightness
> VIDEO_PROCAMP_MAX
)
648 || (brightness
< VIDEO_PROCAMP_MIN
)) {
649 mutex_unlock(&dev
->lock
);
653 mapM(VIDEO_PROCAMP_MIN
, VIDEO_PROCAMP_MAX
, brightness
,
654 SIGNED_BYTE_MIN
, SIGNED_BYTE_MAX
, &value
);
655 value
= convert_to_twos(value
, 8);
657 cx25821_i2c_read(&dev
->i2c_bus
[0],
658 VDEC_A_BRITE_CTRL
+ (0x200 * decoder
), &tmp
);
661 cx25821_i2c_write(&dev
->i2c_bus
[0],
662 VDEC_A_BRITE_CTRL
+ (0x200 * decoder
),
664 mutex_unlock(&dev
->lock
);
668 /////////////////////////////////////////////////////////////////////////////////////////
669 int medusa_set_contrast(struct cx25821_dev
*dev
, int contrast
, int decoder
)
673 u32 val
= 0, tmp
= 0;
675 mutex_lock(&dev
->lock
);
677 if ((contrast
> VIDEO_PROCAMP_MAX
) || (contrast
< VIDEO_PROCAMP_MIN
)) {
678 mutex_unlock(&dev
->lock
);
683 mapM(VIDEO_PROCAMP_MIN
, VIDEO_PROCAMP_MAX
, contrast
,
684 UNSIGNED_BYTE_MIN
, UNSIGNED_BYTE_MAX
, &value
);
686 cx25821_i2c_read(&dev
->i2c_bus
[0],
687 VDEC_A_CNTRST_CTRL
+ (0x200 * decoder
), &tmp
);
690 cx25821_i2c_write(&dev
->i2c_bus
[0],
691 VDEC_A_CNTRST_CTRL
+ (0x200 * decoder
),
694 mutex_unlock(&dev
->lock
);
698 /////////////////////////////////////////////////////////////////////////////////////////
699 int medusa_set_hue(struct cx25821_dev
*dev
, int hue
, int decoder
)
703 u32 val
= 0, tmp
= 0;
705 mutex_lock(&dev
->lock
);
707 if ((hue
> VIDEO_PROCAMP_MAX
) || (hue
< VIDEO_PROCAMP_MIN
)) {
708 mutex_unlock(&dev
->lock
);
713 mapM(VIDEO_PROCAMP_MIN
, VIDEO_PROCAMP_MAX
, hue
, SIGNED_BYTE_MIN
,
714 SIGNED_BYTE_MAX
, &value
);
716 value
= convert_to_twos(value
, 8);
718 cx25821_i2c_read(&dev
->i2c_bus
[0],
719 VDEC_A_HUE_CTRL
+ (0x200 * decoder
), &tmp
);
723 cx25821_i2c_write(&dev
->i2c_bus
[0],
724 VDEC_A_HUE_CTRL
+ (0x200 * decoder
), val
| value
);
726 mutex_unlock(&dev
->lock
);
730 /////////////////////////////////////////////////////////////////////////////////////////
731 int medusa_set_saturation(struct cx25821_dev
*dev
, int saturation
, int decoder
)
735 u32 val
= 0, tmp
= 0;
737 mutex_lock(&dev
->lock
);
739 if ((saturation
> VIDEO_PROCAMP_MAX
)
740 || (saturation
< VIDEO_PROCAMP_MIN
)) {
741 mutex_unlock(&dev
->lock
);
746 mapM(VIDEO_PROCAMP_MIN
, VIDEO_PROCAMP_MAX
, saturation
,
747 UNSIGNED_BYTE_MIN
, UNSIGNED_BYTE_MAX
, &value
);
750 cx25821_i2c_read(&dev
->i2c_bus
[0],
751 VDEC_A_USAT_CTRL
+ (0x200 * decoder
), &tmp
);
754 cx25821_i2c_write(&dev
->i2c_bus
[0],
755 VDEC_A_USAT_CTRL
+ (0x200 * decoder
),
759 cx25821_i2c_read(&dev
->i2c_bus
[0],
760 VDEC_A_VSAT_CTRL
+ (0x200 * decoder
), &tmp
);
763 cx25821_i2c_write(&dev
->i2c_bus
[0],
764 VDEC_A_VSAT_CTRL
+ (0x200 * decoder
),
767 mutex_unlock(&dev
->lock
);
771 /////////////////////////////////////////////////////////////////////////////////////////
772 // Program the display sequence and monitor output.
774 int medusa_video_init(struct cx25821_dev
*dev
)
776 u32 value
= 0, tmp
= 0;
780 mutex_lock(&dev
->lock
);
782 _num_decoders
= dev
->_max_num_decoders
;
784 // disable Auto source selection on all video decoders
785 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], MON_A_CTRL
, &tmp
);
787 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], MON_A_CTRL
, value
);
790 mutex_unlock(&dev
->lock
);
793 // Turn off Master source switch enable
794 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], MON_A_CTRL
, &tmp
);
796 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], MON_A_CTRL
, value
);
799 mutex_unlock(&dev
->lock
);
803 mutex_unlock(&dev
->lock
);
805 for (i
= 0; i
< _num_decoders
; i
++) {
806 medusa_set_decoderduration(dev
, i
, _display_field_cnt
[i
]);
809 mutex_lock(&dev
->lock
);
811 // Select monitor as DENC A input, power up the DAC
812 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], DENC_AB_CTRL
, &tmp
);
814 value
|= 0x00090008; // set en_active
815 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], DENC_AB_CTRL
, value
);
818 mutex_unlock(&dev
->lock
);
821 // enable input is VIP/656
822 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], BYP_AB_CTRL
, &tmp
);
823 value
|= 0x00040100; // enable VIP
824 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], BYP_AB_CTRL
, value
);
827 mutex_unlock(&dev
->lock
);
830 // select AFE clock to output mode
831 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], AFE_AB_DIAG_CTRL
, &tmp
);
834 cx25821_i2c_write(&dev
->i2c_bus
[0], AFE_AB_DIAG_CTRL
,
838 mutex_unlock(&dev
->lock
);
841 // Turn on all of the data out and control output pins.
842 value
= cx25821_i2c_read(&dev
->i2c_bus
[0], PIN_OE_CTRL
, &tmp
);
844 if (_num_decoders
== MAX_DECODERS
) {
845 // Note: The octal board does not support control pins(bit16-19).
846 // These bits are ignored in the octal board.
847 value
|= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface
849 value
|= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface
853 ret_val
= cx25821_i2c_write(&dev
->i2c_bus
[0], PIN_OE_CTRL
, value
);
855 mutex_unlock(&dev
->lock
);
859 mutex_unlock(&dev
->lock
);
861 ret_val
= medusa_set_videostandard(dev
);
864 mutex_unlock(&dev
->lock
);