2009-09-15 08:33:54 -06:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX25821 PCIe bridge
|
|
|
|
*
|
2009-09-13 08:25:45 -06:00
|
|
|
* Copyright (C) 2009 Conexant Systems Inc.
|
2009-09-15 08:33:54 -06:00
|
|
|
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
*
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-09-15 08:33:54 -06:00
|
|
|
#include "cx25821.h"
|
|
|
|
#include "cx25821-medusa-video.h"
|
|
|
|
#include "cx25821-biffuncs.h"
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/*
|
|
|
|
* medusa_enable_bluefield_output()
|
|
|
|
*
|
|
|
|
* Enable the generation of blue filed output if no video
|
|
|
|
*
|
|
|
|
*/
|
2009-09-13 08:30:11 -06:00
|
|
|
static void medusa_enable_bluefield_output(struct cx25821_dev *dev, int channel,
|
|
|
|
int enable)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 1;
|
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
int out_ctrl = OUT_CTRL1;
|
|
|
|
int out_ctrl_ns = OUT_CTRL_NS;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
switch (channel) {
|
2009-09-13 08:25:45 -06:00
|
|
|
default:
|
|
|
|
case VDEC_A:
|
2009-09-13 08:30:11 -06:00
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_B:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_B_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_B_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_C:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_C_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_C_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_D:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_D_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_D_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_E:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_E_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_E_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_F:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_F_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_F_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_G:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_G_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_G_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_H:
|
2009-09-13 08:30:11 -06:00
|
|
|
out_ctrl = VDEC_H_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_H_OUT_CTRL_NS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp);
|
2010-03-21 12:46:26 -06:00
|
|
|
value &= 0xFFFFFF7F; /* clear BLUE_FIELD_EN */
|
2009-09-13 08:30:11 -06:00
|
|
|
if (enable)
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x00000080; /* set BLUE_FIELD_EN */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value);
|
|
|
|
|
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp);
|
|
|
|
value &= 0xFFFFFF7F;
|
|
|
|
if (enable)
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x00000080; /* set BLUE_FIELD_EN */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int medusa_initialize_ntsc(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_DECODERS; i++) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set video format NTSC-M */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value &= 0xFFFFFFF0;
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable the fast locking mode bit[16] */
|
|
|
|
value |= 0x10001;
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* resolution NTSC 720x480 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), &tmp);
|
|
|
|
value &= 0x00C00C00;
|
|
|
|
value |= 0x612D0074;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), &tmp);
|
|
|
|
value &= 0x00C00C00;
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x1C1E001A; /* vblank_cnt + 2 to get camera ID */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* chroma subcarrier step size */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
SC_STEP_SIZE + (0x200 * i), 0x43E00000);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable VIP optional active */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), &tmp);
|
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable VIP optional active (VIP_OPT_AL) for direct output. */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1 + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1 + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/*
|
|
|
|
* clear VPRES_VERT_EN bit, fixes the chroma run away problem
|
|
|
|
* when the input switching rate < 16 fields
|
|
|
|
*/
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), &tmp);
|
2010-03-21 12:46:26 -06:00
|
|
|
/* disable special play detection */
|
|
|
|
value = setBitAtPos(value, 14);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = clearBitAtPos(value, 15);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set vbi_gate_en to 0 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1 + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value = clearBitAtPos(value, 29);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1 + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Enable the generation of blue field output if no video */
|
2009-09-13 08:30:11 -06:00
|
|
|
medusa_enable_bluefield_output(dev, i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_ENCODERS; i++) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* NTSC hclock */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xF000FC00;
|
|
|
|
value |= 0x06B402D0;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* burst begin and burst end */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFF000000;
|
|
|
|
value |= 0x007E9054;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), value);
|
|
|
|
|
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFC00FE00;
|
|
|
|
value |= 0x00EC00F0;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set NTSC vblank, no phase alternation, 7.5 IRE pedestal */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), &tmp);
|
|
|
|
value &= 0x00FCFFFF;
|
|
|
|
value |= 0x13020000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), value);
|
|
|
|
|
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFFFF0000;
|
|
|
|
value |= 0x0000E575;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), value);
|
|
|
|
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_6 + (0x100 * i), 0x009A89C1);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Subcarrier Increment */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_7 + (0x100 * i), 0x21F07C1F);
|
|
|
|
}
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set picture resolutions */
|
|
|
|
/* 0 - 720 */
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL, 0x0);
|
|
|
|
/* 0 - 480 */
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL, 0x0);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set Bypass input format to NTSC 525 lines */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
|
|
|
|
value |= 0x00080200;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
|
|
|
static int medusa_PALCombInit(struct cx25821_dev *dev, int dec)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = -1;
|
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Setup for 2D threshold */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFS_CFG + (0x200 * dec),
|
|
|
|
0x20002861);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFD_CFG + (0x200 * dec),
|
|
|
|
0x20002861);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_LF_CFG + (0x200 * dec),
|
|
|
|
0x200A1023);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Setup flat chroma and luma thresholds */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
COMB_FLAT_THRESH_CTRL + (0x200 * dec), &tmp);
|
|
|
|
value &= 0x06230000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
COMB_FLAT_THRESH_CTRL + (0x200 * dec), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set comb 2D blend */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_BLEND + (0x200 * dec),
|
|
|
|
0x210F0F0F);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* COMB MISC CONTROL */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], COMB_MISC_CTRL + (0x200 * dec),
|
|
|
|
0x41120A7F);
|
|
|
|
|
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int medusa_initialize_pal(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_DECODERS; i++) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set video format PAL-BDGHI */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value &= 0xFFFFFFF0;
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable the fast locking mode bit[16] */
|
|
|
|
value |= 0x10004;
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* resolution PAL 720x576 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), &tmp);
|
|
|
|
value &= 0x00C00C00;
|
|
|
|
value |= 0x632D007D;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), &tmp);
|
|
|
|
value &= 0x00C00C00;
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x28240026; /* vblank_cnt + 2 to get camera ID */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* chroma subcarrier step size */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
SC_STEP_SIZE + (0x200 * i), 0x5411E2D0);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable VIP optional active */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), &tmp);
|
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable VIP optional active (VIP_OPT_AL) for direct output. */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1 + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1 + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/*
|
|
|
|
* clear VPRES_VERT_EN bit, fixes the chroma run away problem
|
|
|
|
* when the input switching rate < 16 fields
|
|
|
|
*/
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), &tmp);
|
2010-03-21 12:46:26 -06:00
|
|
|
/* disable special play detection */
|
|
|
|
value = setBitAtPos(value, 14);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = clearBitAtPos(value, 15);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set vbi_gate_en to 0 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1 + (0x200 * i),
|
|
|
|
&tmp);
|
|
|
|
value = clearBitAtPos(value, 29);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1 + (0x200 * i),
|
|
|
|
value);
|
|
|
|
|
|
|
|
medusa_PALCombInit(dev, i);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Enable the generation of blue field output if no video */
|
2009-09-13 08:30:11 -06:00
|
|
|
medusa_enable_bluefield_output(dev, i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_ENCODERS; i++) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* PAL hclock */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xF000FC00;
|
|
|
|
value |= 0x06C002D0;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* burst begin and burst end */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFF000000;
|
|
|
|
value |= 0x007E9754;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* hblank and vactive */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFC00FE00;
|
|
|
|
value |= 0x00FC0120;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set PAL vblank, phase alternation, 0 IRE pedestal */
|
2009-09-13 08:30:11 -06:00
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), &tmp);
|
|
|
|
value &= 0x00FCFFFF;
|
|
|
|
value |= 0x14010000;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), value);
|
|
|
|
|
|
|
|
value =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), &tmp);
|
|
|
|
value &= 0xFFFF0000;
|
|
|
|
value |= 0x0000F078;
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), value);
|
|
|
|
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_6 + (0x100 * i), 0x00A493CF);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Subcarrier Increment */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_7 + (0x100 * i), 0x2A098ACB);
|
|
|
|
}
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set picture resolutions */
|
|
|
|
/* 0 - 720 */
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL, 0x0);
|
|
|
|
/* 0 - 576 */
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL, 0x0);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* set Bypass input format to PAL 625 lines */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
|
|
|
|
value &= 0xFFF7FDFF;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
return ret_val;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
|
|
|
int medusa_set_videostandard(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int status = STATUS_SUCCESS;
|
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
|
2009-09-13 08:30:11 -06:00
|
|
|
status = medusa_initialize_pal(dev);
|
2010-03-21 12:46:26 -06:00
|
|
|
else
|
2009-09-13 08:30:11 -06:00
|
|
|
status = medusa_initialize_ntsc(dev);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Enable DENC_A output */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4, &tmp);
|
|
|
|
value = setBitAtPos(value, 4);
|
|
|
|
status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4, value);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Enable DENC_B output */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_B_REG_4, &tmp);
|
|
|
|
value = setBitAtPos(value, 4);
|
|
|
|
status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_B_REG_4, value);
|
|
|
|
|
|
|
|
return status;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
void medusa_set_resolution(struct cx25821_dev *dev, int width,
|
|
|
|
int decoder_select)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int decoder = 0;
|
|
|
|
int decoder_count = 0;
|
|
|
|
int ret_val = 0;
|
|
|
|
u32 hscale = 0x0;
|
|
|
|
u32 vscale = 0x0;
|
|
|
|
const int MAX_WIDTH = 720;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
2011-10-21 22:43:38 -06:00
|
|
|
/* validate the width */
|
2009-09-13 08:30:11 -06:00
|
|
|
if (width > MAX_WIDTH) {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("%s(): width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH\n",
|
|
|
|
__func__, width, MAX_WIDTH);
|
2009-09-13 08:30:11 -06:00
|
|
|
width = MAX_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decoder_select <= 7 && decoder_select >= 0) {
|
|
|
|
decoder = decoder_select;
|
|
|
|
decoder_count = decoder_select + 1;
|
|
|
|
} else {
|
|
|
|
decoder = 0;
|
|
|
|
decoder_count = _num_decoders;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (width) {
|
2009-09-13 08:25:45 -06:00
|
|
|
case 320:
|
2009-09-13 08:30:11 -06:00
|
|
|
hscale = 0x13E34B;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
case 352:
|
2009-09-13 08:30:11 -06:00
|
|
|
hscale = 0x10A273;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
case 176:
|
2009-09-13 08:30:11 -06:00
|
|
|
hscale = 0x3115B2;
|
|
|
|
vscale = 0x1E00;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
case 160:
|
2009-09-13 08:30:11 -06:00
|
|
|
hscale = 0x378D84;
|
|
|
|
vscale = 0x1E00;
|
|
|
|
break;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
default: /* 720 */
|
2009-09-13 08:30:11 -06:00
|
|
|
hscale = 0x0;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; decoder < decoder_count; decoder++) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* write scaling values for each decoder */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
HSCALE_CTRL + (0x200 * decoder), hscale);
|
|
|
|
ret_val =
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VSCALE_CTRL + (0x200 * decoder), vscale);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
|
|
|
|
int duration)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
u32 fld_cnt = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
u32 disp_cnt_reg = DISP_AB_CNT;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_lock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* no support */
|
2009-09-13 08:30:11 -06:00
|
|
|
if (decoder < VDEC_A && decoder > VDEC_H) {
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
switch (decoder) {
|
2009-09-13 08:25:45 -06:00
|
|
|
default:
|
2009-09-13 08:30:11 -06:00
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_C:
|
|
|
|
case VDEC_D:
|
2009-09-13 08:30:11 -06:00
|
|
|
disp_cnt_reg = DISP_CD_CNT;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_E:
|
|
|
|
case VDEC_F:
|
2009-09-13 08:30:11 -06:00
|
|
|
disp_cnt_reg = DISP_EF_CNT;
|
|
|
|
break;
|
2009-09-13 08:25:45 -06:00
|
|
|
case VDEC_G:
|
|
|
|
case VDEC_H:
|
2009-09-13 08:30:11 -06:00
|
|
|
disp_cnt_reg = DISP_GH_CNT;
|
|
|
|
break;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
_display_field_cnt[decoder] = duration;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* update hardware */
|
2009-09-13 08:30:11 -06:00
|
|
|
fld_cnt = cx25821_i2c_read(&dev->i2c_bus[0], disp_cnt_reg, &tmp);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
if (!(decoder % 2)) { /* EVEN decoder */
|
2009-09-13 08:30:11 -06:00
|
|
|
fld_cnt &= 0xFFFF0000;
|
|
|
|
fld_cnt |= duration;
|
|
|
|
} else {
|
|
|
|
fld_cnt &= 0x0000FFFF;
|
|
|
|
fld_cnt |= ((u32) duration) << 16;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Map to Medusa register setting */
|
2009-09-13 08:30:11 -06:00
|
|
|
static int mapM(int srcMin,
|
|
|
|
int srcMax, int srcVal, int dstMin, int dstMax, int *dstVal)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int numerator;
|
|
|
|
int denominator;
|
|
|
|
int quotient;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
if ((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax))
|
2009-09-13 08:30:11 -06:00
|
|
|
return -1;
|
2010-03-21 12:46:26 -06:00
|
|
|
/*
|
|
|
|
* This is the overall expression used:
|
|
|
|
* *dstVal =
|
|
|
|
* (srcVal - srcMin)*(dstMax - dstMin) / (srcMax - srcMin) + dstMin;
|
|
|
|
* but we need to account for rounding so below we use the modulus
|
|
|
|
* operator to find the remainder and increment if necessary.
|
|
|
|
*/
|
2009-09-13 08:30:11 -06:00
|
|
|
numerator = (srcVal - srcMin) * (dstMax - dstMin);
|
|
|
|
denominator = srcMax - srcMin;
|
|
|
|
quotient = numerator / denominator;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
if (2 * (numerator % denominator) >= denominator)
|
2009-09-13 08:30:11 -06:00
|
|
|
quotient++;
|
|
|
|
|
|
|
|
*dstVal = quotient + dstMin;
|
|
|
|
|
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long convert_to_twos(long numeric, unsigned long bits_len)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned char temp;
|
|
|
|
|
|
|
|
if (numeric >= 0)
|
|
|
|
return numeric;
|
|
|
|
else {
|
|
|
|
temp = ~(abs(numeric) & 0xFF);
|
|
|
|
temp += 1;
|
|
|
|
return temp;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2009-09-15 08:33:54 -06:00
|
|
|
int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
if ((brightness > VIDEO_PROCAMP_MAX)
|
|
|
|
|| (brightness < VIDEO_PROCAMP_MIN)) {
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ret_val =
|
|
|
|
mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness,
|
|
|
|
SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
|
|
|
|
value = convert_to_twos(value, 8);
|
|
|
|
val =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_BRITE_CTRL + (0x200 * decoder), &tmp);
|
|
|
|
val &= 0xFFFFFF00;
|
|
|
|
ret_val |=
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_BRITE_CTRL + (0x200 * decoder),
|
|
|
|
val | value);
|
2009-09-13 08:25:45 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-13 08:30:11 -06:00
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
if ((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) {
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_val =
|
|
|
|
mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast,
|
|
|
|
UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
|
|
|
|
val =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_CNTRST_CTRL + (0x200 * decoder), &tmp);
|
|
|
|
val &= 0xFFFFFF00;
|
|
|
|
ret_val |=
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_CNTRST_CTRL + (0x200 * decoder),
|
|
|
|
val | value);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-13 08:30:11 -06:00
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_lock(&dev->lock);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if ((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) {
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return -1;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val =
|
|
|
|
mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN,
|
|
|
|
SIGNED_BYTE_MAX, &value);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
value = convert_to_twos(value, 8);
|
|
|
|
val =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_HUE_CTRL + (0x200 * decoder), &tmp);
|
|
|
|
val &= 0xFFFFFF00;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val |=
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_HUE_CTRL + (0x200 * decoder), val | value);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
|
|
if ((saturation > VIDEO_PROCAMP_MAX)
|
|
|
|
|| (saturation < VIDEO_PROCAMP_MIN)) {
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_val =
|
|
|
|
mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation,
|
|
|
|
UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
|
|
|
|
|
|
|
|
val =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_USAT_CTRL + (0x200 * decoder), &tmp);
|
|
|
|
val &= 0xFFFFFF00;
|
|
|
|
ret_val |=
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_USAT_CTRL + (0x200 * decoder),
|
|
|
|
val | value);
|
|
|
|
|
|
|
|
val =
|
|
|
|
cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_VSAT_CTRL + (0x200 * decoder), &tmp);
|
|
|
|
val &= 0xFFFFFF00;
|
|
|
|
ret_val |=
|
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_VSAT_CTRL + (0x200 * decoder),
|
|
|
|
val | value);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-13 08:30:11 -06:00
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Program the display sequence and monitor output. */
|
|
|
|
|
2009-09-15 08:33:54 -06:00
|
|
|
int medusa_video_init(struct cx25821_dev *dev)
|
|
|
|
{
|
2010-09-27 07:01:36 -06:00
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mutex_lock(&dev->lock);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
_num_decoders = dev->_max_num_decoders;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* disable Auto source selection on all video decoders */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
|
|
|
|
value &= 0xFFFFF0FF;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Turn off Master source switch enable */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
|
|
|
|
value &= 0xFFFFFFDF;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2009-12-28 09:59:46 -07:00
|
|
|
if (ret_val < 0)
|
2010-05-05 09:30:01 -06:00
|
|
|
goto error;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:25:45 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
for (i = 0; i < _num_decoders; i++)
|
2009-09-13 08:30:11 -06:00
|
|
|
medusa_set_decoderduration(dev, i, _display_field_cnt[i]);
|
|
|
|
|
|
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Select monitor as DENC A input, power up the DAC */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp);
|
|
|
|
value &= 0xFF70FF70;
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x00090008; /* set en_active */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* enable input is VIP/656 */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
|
2010-03-21 12:46:26 -06:00
|
|
|
value |= 0x00040100; /* enable VIP */
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* select AFE clock to output mode */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
|
|
|
|
value &= 0x83FFFFFF;
|
2010-09-27 07:01:36 -06:00
|
|
|
ret_val =
|
2010-07-04 12:37:05 -06:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL,
|
|
|
|
value | 0x10000000);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2010-03-21 12:46:26 -06:00
|
|
|
/* Turn on all of the data out and control output pins. */
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], PIN_OE_CTRL, &tmp);
|
|
|
|
value &= 0xFEF0FE00;
|
|
|
|
if (_num_decoders == MAX_DECODERS) {
|
2010-03-21 12:46:26 -06:00
|
|
|
/*
|
|
|
|
* Note: The octal board does not support control pins(bit16-19)
|
|
|
|
* These bits are ignored in the octal board.
|
|
|
|
*
|
|
|
|
* disable VDEC A-C port, default to Mobilygen Interface
|
|
|
|
*/
|
|
|
|
value |= 0x010001F8;
|
2009-09-13 08:30:11 -06:00
|
|
|
} else {
|
2010-03-21 12:46:26 -06:00
|
|
|
/* disable VDEC A-C port, default to Mobilygen Interface */
|
|
|
|
value |= 0x010F0108;
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
value |= 7;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2009-09-13 08:25:45 -06:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
ret_val = medusa_set_videostandard(dev);
|
2010-07-04 11:15:38 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
return ret_val;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-05-05 09:30:01 -06:00
|
|
|
error:
|
|
|
|
mutex_unlock(&dev->lock);
|
|
|
|
return ret_val;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|