2009-09-15 14:33:54 +00:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX25821 PCIe bridge
|
|
|
|
*
|
2009-09-13 14:25:45 +00:00
|
|
|
* Copyright (C) 2009 Conexant Systems Inc.
|
2009-09-15 14:33:54 +00: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.
|
|
|
|
*/
|
|
|
|
|
2010-11-07 20:48:21 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
#include "cx25821.h"
|
|
|
|
#include "cx25821-medusa-video.h"
|
|
|
|
#include "cx25821-biffuncs.h"
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/*
|
|
|
|
* medusa_enable_bluefield_output()
|
|
|
|
*
|
|
|
|
* Enable the generation of blue filed output if no video
|
|
|
|
*
|
|
|
|
*/
|
2009-09-13 14:30:11 +00:00
|
|
|
static void medusa_enable_bluefield_output(struct cx25821_dev *dev, int channel,
|
|
|
|
int enable)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
int out_ctrl = OUT_CTRL1;
|
|
|
|
int out_ctrl_ns = OUT_CTRL_NS;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
switch (channel) {
|
2009-09-13 14:25:45 +00:00
|
|
|
default:
|
|
|
|
case VDEC_A:
|
2009-09-13 14:30:11 +00:00
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_B:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_B_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_B_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_C:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_C_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_C_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_D:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_D_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_D_OUT_CTRL_NS;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_E:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_E_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_E_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_F:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_F_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_F_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_G:
|
2009-09-13 14:30:11 +00:00
|
|
|
out_ctrl = VDEC_G_OUT_CTRL1;
|
|
|
|
out_ctrl_ns = VDEC_G_OUT_CTRL_NS;
|
|
|
|
return;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_H:
|
2009-09-13 14:30:11 +00: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 18:46:26 +00:00
|
|
|
value &= 0xFFFFFF7F; /* clear BLUE_FIELD_EN */
|
2009-09-13 14:30:11 +00:00
|
|
|
if (enable)
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x00000080; /* set BLUE_FIELD_EN */
|
2012-04-20 09:26:19 +00:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp);
|
|
|
|
value &= 0xFFFFFF7F;
|
|
|
|
if (enable)
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x00000080; /* set BLUE_FIELD_EN */
|
2012-04-20 09:26:19 +00:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value);
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int medusa_initialize_ntsc(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_DECODERS; i++) {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set video format NTSC-M */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MODE_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFFFFF0;
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable the fast locking mode bit[16] */
|
|
|
|
value |= 0x10001;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MODE_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* resolution NTSC 720x480 */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00C00C00;
|
|
|
|
value |= 0x612D0074;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00C00C00;
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x1C1E001A; /* vblank_cnt + 2 to get camera ID */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* chroma subcarrier step size */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
SC_STEP_SIZE + (0x200 * i), 0x43E00000);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable VIP optional active */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable VIP optional active (VIP_OPT_AL) for direct output. */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL1 + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL1 + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/*
|
|
|
|
* clear VPRES_VERT_EN bit, fixes the chroma run away problem
|
|
|
|
* when the input switching rate < 16 fields
|
|
|
|
*/
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), &tmp);
|
2010-03-21 18:46:26 +00:00
|
|
|
/* disable special play detection */
|
|
|
|
value = setBitAtPos(value, 14);
|
2009-09-13 14:30:11 +00:00
|
|
|
value = clearBitAtPos(value, 15);
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set vbi_gate_en to 0 */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DFE_CTRL1 + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value = clearBitAtPos(value, 29);
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DFE_CTRL1 + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Enable the generation of blue field output if no video */
|
2009-09-13 14:30:11 +00:00
|
|
|
medusa_enable_bluefield_output(dev, i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_ENCODERS; i++) {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* NTSC hclock */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xF000FC00;
|
|
|
|
value |= 0x06B402D0;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* burst begin and burst end */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFF000000;
|
|
|
|
value |= 0x007E9054;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFC00FE00;
|
|
|
|
value |= 0x00EC00F0;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set NTSC vblank, no phase alternation, 7.5 IRE pedestal */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00FCFFFF;
|
|
|
|
value |= 0x13020000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFF0000;
|
|
|
|
value |= 0x0000E575;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_6 + (0x100 * i), 0x009A89C1);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Subcarrier Increment */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_7 + (0x100 * i), 0x21F07C1F);
|
2009-09-13 14:30:11 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 18:46:26 +00: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 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set Bypass input format to NTSC 525 lines */
|
2009-09-13 14:30:11 +00: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 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
return ret_val;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
static int medusa_PALCombInit(struct cx25821_dev *dev, int dec)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = -1;
|
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Setup for 2D threshold */
|
2011-10-22 04:43:40 +00: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);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Setup flat chroma and luma thresholds */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
COMB_FLAT_THRESH_CTRL + (0x200 * dec), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x06230000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
COMB_FLAT_THRESH_CTRL + (0x200 * dec), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set comb 2D blend */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
COMB_2D_BLEND + (0x200 * dec), 0x210F0F0F);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* COMB MISC CONTROL */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
COMB_MISC_CTRL + (0x200 * dec), 0x41120A7F);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int medusa_initialize_pal(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
|
|
|
u32 value = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_DECODERS; i++) {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set video format PAL-BDGHI */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MODE_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFFFFF0;
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable the fast locking mode bit[16] */
|
|
|
|
value |= 0x10004;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MODE_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* resolution PAL 720x576 */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00C00C00;
|
|
|
|
value |= 0x632D007D;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
HORIZ_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24 */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00C00C00;
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x28240026; /* vblank_cnt + 2 to get camera ID */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VERT_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* chroma subcarrier step size */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
SC_STEP_SIZE + (0x200 * i), 0x5411E2D0);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable VIP optional active */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL_NS + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable VIP optional active (VIP_OPT_AL) for direct output. */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL1 + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFBFFFF;
|
|
|
|
value |= 0x00040000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
OUT_CTRL1 + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/*
|
|
|
|
* clear VPRES_VERT_EN bit, fixes the chroma run away problem
|
|
|
|
* when the input switching rate < 16 fields
|
|
|
|
*/
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), &tmp);
|
2010-03-21 18:46:26 +00:00
|
|
|
/* disable special play detection */
|
|
|
|
value = setBitAtPos(value, 14);
|
2009-09-13 14:30:11 +00:00
|
|
|
value = clearBitAtPos(value, 15);
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
MISC_TIM_CTRL + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set vbi_gate_en to 0 */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DFE_CTRL1 + (0x200 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value = clearBitAtPos(value, 29);
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DFE_CTRL1 + (0x200 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
|
|
|
medusa_PALCombInit(dev, i);
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Enable the generation of blue field output if no video */
|
2009-09-13 14:30:11 +00:00
|
|
|
medusa_enable_bluefield_output(dev, i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_ENCODERS; i++) {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* PAL hclock */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xF000FC00;
|
|
|
|
value |= 0x06C002D0;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_1 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* burst begin and burst end */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFF000000;
|
|
|
|
value |= 0x007E9754;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_2 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* hblank and vactive */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFC00FE00;
|
|
|
|
value |= 0x00FC0120;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_3 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set PAL vblank, phase alternation, 0 IRE pedestal */
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0x00FCFFFF;
|
|
|
|
value |= 0x14010000;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_4 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
value &= 0xFFFF0000;
|
|
|
|
value |= 0x0000F078;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_5 + (0x100 * i), value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_6 + (0x100 * i), 0x00A493CF);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Subcarrier Increment */
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
DENC_A_REG_7 + (0x100 * i), 0x2A098ACB);
|
2009-09-13 14:30:11 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 18:46:26 +00: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 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* set Bypass input format to PAL 625 lines */
|
2009-09-13 14:30:11 +00: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);
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
|
|
|
int medusa_set_videostandard(struct cx25821_dev *dev)
|
|
|
|
{
|
2013-04-14 14:13:43 +00:00
|
|
|
int status = 0;
|
2009-09-13 14:30:11 +00:00
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
|
2009-09-13 14:30:11 +00:00
|
|
|
status = medusa_initialize_pal(dev);
|
2010-03-21 18:46:26 +00:00
|
|
|
else
|
2009-09-13 14:30:11 +00:00
|
|
|
status = medusa_initialize_ntsc(dev);
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Enable DENC_A output */
|
2009-09-13 14:30:11 +00: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 18:46:26 +00:00
|
|
|
/* Enable DENC_B output */
|
2009-09-13 14:30:11 +00: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 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
void medusa_set_resolution(struct cx25821_dev *dev, int width,
|
|
|
|
int decoder_select)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int decoder = 0;
|
|
|
|
int decoder_count = 0;
|
|
|
|
u32 hscale = 0x0;
|
|
|
|
u32 vscale = 0x0;
|
|
|
|
const int MAX_WIDTH = 720;
|
|
|
|
|
2011-10-22 04:43:38 +00:00
|
|
|
/* validate the width */
|
2009-09-13 14:30:11 +00:00
|
|
|
if (width > MAX_WIDTH) {
|
2010-11-07 20:48:21 +00:00
|
|
|
pr_info("%s(): width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH\n",
|
|
|
|
__func__, width, MAX_WIDTH);
|
2009-09-13 14:30:11 +00:00
|
|
|
width = MAX_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decoder_select <= 7 && decoder_select >= 0) {
|
|
|
|
decoder = decoder_select;
|
|
|
|
decoder_count = decoder_select + 1;
|
|
|
|
} else {
|
|
|
|
decoder = 0;
|
2013-10-04 14:01:51 +00:00
|
|
|
decoder_count = dev->_max_num_decoders;
|
2009-09-13 14:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (width) {
|
2009-09-13 14:25:45 +00:00
|
|
|
case 320:
|
2009-09-13 14:30:11 +00:00
|
|
|
hscale = 0x13E34B;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
|
|
|
case 352:
|
2009-09-13 14:30:11 +00:00
|
|
|
hscale = 0x10A273;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
|
|
|
case 176:
|
2009-09-13 14:30:11 +00:00
|
|
|
hscale = 0x3115B2;
|
|
|
|
vscale = 0x1E00;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
|
|
|
case 160:
|
2009-09-13 14:30:11 +00:00
|
|
|
hscale = 0x378D84;
|
|
|
|
vscale = 0x1E00;
|
|
|
|
break;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
default: /* 720 */
|
2009-09-13 14:30:11 +00:00
|
|
|
hscale = 0x0;
|
|
|
|
vscale = 0x0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; decoder < decoder_count; decoder++) {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* write scaling values for each decoder */
|
2012-04-20 09:26:19 +00:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
2011-10-22 04:43:40 +00:00
|
|
|
HSCALE_CTRL + (0x200 * decoder), hscale);
|
2012-04-20 09:26:19 +00:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0],
|
2011-10-22 04:43:40 +00:00
|
|
|
VSCALE_CTRL + (0x200 * decoder), vscale);
|
2009-09-13 14:30:11 +00:00
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
|
|
|
|
int duration)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
u32 fld_cnt = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
u32 disp_cnt_reg = DISP_AB_CNT;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* no support */
|
2012-07-24 15:00:24 +00:00
|
|
|
if (decoder < VDEC_A || decoder > VDEC_H) {
|
2009-09-13 14:30:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
switch (decoder) {
|
2009-09-13 14:25:45 +00:00
|
|
|
default:
|
2009-09-13 14:30:11 +00:00
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_C:
|
|
|
|
case VDEC_D:
|
2009-09-13 14:30:11 +00:00
|
|
|
disp_cnt_reg = DISP_CD_CNT;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_E:
|
|
|
|
case VDEC_F:
|
2009-09-13 14:30:11 +00:00
|
|
|
disp_cnt_reg = DISP_EF_CNT;
|
|
|
|
break;
|
2009-09-13 14:25:45 +00:00
|
|
|
case VDEC_G:
|
|
|
|
case VDEC_H:
|
2009-09-13 14:30:11 +00:00
|
|
|
disp_cnt_reg = DISP_GH_CNT;
|
|
|
|
break;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* update hardware */
|
2009-09-13 14:30:11 +00:00
|
|
|
fld_cnt = cx25821_i2c_read(&dev->i2c_bus[0], disp_cnt_reg, &tmp);
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
if (!(decoder % 2)) { /* EVEN decoder */
|
2009-09-13 14:30:11 +00:00
|
|
|
fld_cnt &= 0xFFFF0000;
|
|
|
|
fld_cnt |= duration;
|
|
|
|
} else {
|
|
|
|
fld_cnt &= 0x0000FFFF;
|
|
|
|
fld_cnt |= ((u32) duration) << 16;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2012-04-20 09:26:19 +00:00
|
|
|
cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Map to Medusa register setting */
|
2011-10-22 04:43:40 +00:00
|
|
|
static int mapM(int srcMin, int srcMax, int srcVal, int dstMin, int dstMax,
|
|
|
|
int *dstVal)
|
2009-09-15 14:33:54 +00:00
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int numerator;
|
|
|
|
int denominator;
|
|
|
|
int quotient;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
if ((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax))
|
2009-09-13 14:30:11 +00:00
|
|
|
return -1;
|
2010-03-21 18:46:26 +00: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 14:30:11 +00:00
|
|
|
numerator = (srcVal - srcMin) * (dstMax - dstMin);
|
|
|
|
denominator = srcMax - srcMin;
|
|
|
|
quotient = numerator / denominator;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
if (2 * (numerator % denominator) >= denominator)
|
2009-09-13 14:30:11 +00:00
|
|
|
quotient++;
|
|
|
|
|
|
|
|
*dstVal = quotient + dstMin;
|
|
|
|
|
|
|
|
return 0;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long convert_to_twos(long numeric, unsigned long bits_len)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
unsigned char temp;
|
|
|
|
|
|
|
|
if (numeric >= 0)
|
|
|
|
return numeric;
|
|
|
|
else {
|
|
|
|
temp = ~(abs(numeric) & 0xFF);
|
|
|
|
temp += 1;
|
|
|
|
return temp;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
2011-10-22 04:43:39 +00:00
|
|
|
if ((brightness > VIDEO_PROCAMP_MAX) ||
|
|
|
|
(brightness < VIDEO_PROCAMP_MIN)) {
|
2009-09-13 14:30:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness,
|
|
|
|
SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
|
2009-09-13 14:30:11 +00:00
|
|
|
value = convert_to_twos(value, 8);
|
2011-10-22 04:43:40 +00:00
|
|
|
val = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_BRITE_CTRL + (0x200 * decoder), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
val &= 0xFFFFFF00;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_BRITE_CTRL + (0x200 * decoder), val | value);
|
2009-09-13 14:30:11 +00:00
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
|
|
|
if ((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
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);
|
2009-09-13 14:30:11 +00:00
|
|
|
val &= 0xFFFFFF00;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_CNTRST_CTRL + (0x200 * decoder), val | value);
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
if ((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue,
|
|
|
|
SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
value = convert_to_twos(value, 8);
|
2011-10-22 04:43:40 +00:00
|
|
|
val = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_HUE_CTRL + (0x200 * decoder), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
val &= 0xFFFFFF00;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_HUE_CTRL + (0x200 * decoder), val | value);
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
|
|
|
|
{
|
2009-09-13 14:30:11 +00:00
|
|
|
int ret_val = 0;
|
|
|
|
int value = 0;
|
|
|
|
u32 val = 0, tmp = 0;
|
|
|
|
|
2011-10-22 04:43:39 +00:00
|
|
|
if ((saturation > VIDEO_PROCAMP_MAX) ||
|
|
|
|
(saturation < VIDEO_PROCAMP_MIN)) {
|
2009-09-13 14:30:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation,
|
|
|
|
UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2011-10-22 04:43:40 +00:00
|
|
|
val = cx25821_i2c_read(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_USAT_CTRL + (0x200 * decoder), &tmp);
|
2009-09-13 14:30:11 +00:00
|
|
|
val &= 0xFFFFFF00;
|
2011-10-22 04:43:40 +00:00
|
|
|
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);
|
2009-09-13 14:30:11 +00:00
|
|
|
val &= 0xFFFFFF00;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
|
|
|
VDEC_A_VSAT_CTRL + (0x200 * decoder), val | value);
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Program the display sequence and monitor output. */
|
|
|
|
|
2009-09-15 14:33:54 +00:00
|
|
|
int medusa_video_init(struct cx25821_dev *dev)
|
|
|
|
{
|
2010-09-27 13:01:36 +00:00
|
|
|
u32 value = 0, tmp = 0;
|
|
|
|
int ret_val = 0;
|
|
|
|
int i = 0;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* disable Auto source selection on all video decoders */
|
2009-09-13 14:30:11 +00: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 17:15:38 +00:00
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Turn off Master source switch enable */
|
2009-09-13 14:30:11 +00: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 17:15:38 +00:00
|
|
|
|
2009-12-28 16:59:46 +00:00
|
|
|
if (ret_val < 0)
|
2010-05-05 15:30:01 +00:00
|
|
|
goto error;
|
2009-09-15 14:33:54 +00:00
|
|
|
|
2013-10-04 14:01:51 +00:00
|
|
|
/*
|
|
|
|
* FIXME: due to a coding bug the duration was always 0. It's
|
|
|
|
* likely that it really should be something else, but due to the
|
|
|
|
* lack of documentation I have no idea what it should be. For
|
|
|
|
* now just fill in 0 as the duration.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < dev->_max_num_decoders; i++)
|
|
|
|
medusa_set_decoderduration(dev, i, 0);
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Select monitor as DENC A input, power up the DAC */
|
2009-09-13 14:30:11 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp);
|
|
|
|
value &= 0xFF70FF70;
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x00090008; /* set en_active */
|
2009-09-13 14:30:11 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value);
|
2010-07-04 17:15:38 +00:00
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* enable input is VIP/656 */
|
2009-09-13 14:30:11 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
|
2010-03-21 18:46:26 +00:00
|
|
|
value |= 0x00040100; /* enable VIP */
|
2009-09-13 14:30:11 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* select AFE clock to output mode */
|
2009-09-13 14:30:11 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
|
|
|
|
value &= 0x83FFFFFF;
|
2011-10-22 04:43:40 +00:00
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL,
|
|
|
|
value | 0x10000000);
|
2010-07-04 17:15:38 +00:00
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 14:30:11 +00:00
|
|
|
|
2010-03-21 18:46:26 +00:00
|
|
|
/* Turn on all of the data out and control output pins. */
|
2009-09-13 14:30:11 +00:00
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], PIN_OE_CTRL, &tmp);
|
|
|
|
value &= 0xFEF0FE00;
|
2013-10-04 14:01:51 +00:00
|
|
|
if (dev->_max_num_decoders == MAX_DECODERS) {
|
2010-03-21 18:46:26 +00: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 14:30:11 +00:00
|
|
|
} else {
|
2010-03-21 18:46:26 +00:00
|
|
|
/* disable VDEC A-C port, default to Mobilygen Interface */
|
|
|
|
value |= 0x010F0108;
|
2009-09-13 14:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
value |= 7;
|
|
|
|
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
|
2010-07-04 17:15:38 +00:00
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
if (ret_val < 0)
|
|
|
|
goto error;
|
2009-09-13 14:25:45 +00:00
|
|
|
|
2009-09-13 14:30:11 +00:00
|
|
|
ret_val = medusa_set_videostandard(dev);
|
2010-07-04 17:15:38 +00:00
|
|
|
|
2010-05-05 15:30:01 +00:00
|
|
|
error:
|
|
|
|
return ret_val;
|
2009-09-15 14:33:54 +00:00
|
|
|
}
|