/*
* saa7114 - Philips SAA7114H video decoder driver version 0.0.1
*
* Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
*
* Based on saa7111 driver by Dave Perks
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
*
* Slight changes for video timing and attachment output by
* Wolfgang Scherr <scherr@net4you.net>
*
* Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
* - moved over to linux>=2.4.x i2c protocol (1/1/2003)
*
* 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.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/pci.h>
#include <linux/signal.h>
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <linux/sched.h>
#include <asm/segment.h>
#include <linux/types.h>
#include <linux/videodev.h>
#include <asm/uaccess.h>
MODULE_DESCRIPTION("Philips SAA7114H video decoder driver");
MODULE_AUTHOR("Maxim Yevtyushkin");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#define I2C_NAME(x) (x)->name
#include <linux/video_decoder.h>
static int debug = 0;
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug level (0-1)");
#define dprintk(num, format, args...) \
do { \
if (debug >= num) \
printk(format, ##args); \
} while (0)
/* ----------------------------------------------------------------------- */
struct saa7114 {
unsigned char reg[0xf0 * 2];
int norm;
int input;
int enable;
int bright;
int contrast;
int hue;
int sat;
int playback;
};
#define I2C_SAA7114 0x42
#define I2C_SAA7114A 0x40
#define I2C_DELAY 10
//#define SAA_7114_NTSC_HSYNC_START (-3)
//#define SAA_7114_NTSC_HSYNC_STOP (-18)
#define SAA_7114_NTSC_HSYNC_START (-17)
#define SAA_7114_NTSC_HSYNC_STOP (-32)
//#define SAA_7114_NTSC_HOFFSET (5)
#define SAA_7114_NTSC_HOFFSET (6)
#define SAA_7114_NTSC_VOFFSET (10)
#define SAA_7114_NTSC_WIDTH (720)
#define SAA_7114_NTSC_HEIGHT (250)
#define SAA_7114_SECAM_HSYNC_START (-17)
#define SAA_7114_SECAM_HSYNC_STOP (-32)
#define SAA_7114_SECAM_HOFFSET (2)
#define SAA_7114_SECAM_VOFFSET (10)
#define SAA_7114_SECAM_WIDTH (720)
#define SAA_7114_SECAM_HEIGHT (300)
#define SAA_7114_PAL_HSYNC_START (-17)
#define SAA_7114_PAL_HSYNC_STOP (-32)
#define SAA_7114_PAL_HOFFSET (2)
#define SAA_7114_PAL_VOFFSET (10)
#define SAA_7114_PAL_WIDTH (720)
#define SAA_7114_PAL_HEIGHT (300)
#define SAA_7114_VERTICAL_CHROMA_OFFSET 0 //0x50504040
#define SAA_7114_VERTICAL_LUMA_OFFSET 0
#define REG_ADDR(x) (((x) << 1) + 1)
#define LOBYTE(x) ((unsigned char)((x) & 0xff))
#define HIBYTE(x) ((unsigned char)(((x) >> 8) & 0xff))
#define LOWORD(x) ((unsigned short int)((x) & 0xffff))
#define HIWORD(x) ((unsigned short int)(((x) >> 16) & 0xffff))
/* ----------------------------------------------------------------------- */
static inline int
saa7114_write (struct i2c_client *client,
u8 reg,
u8 value)
{
/*struct saa7114 *decoder = i2c_get_clientdata(client);*/
/*decoder->reg[reg] = value;*/
return i2c_smbus_write_byte_data(client, reg, value);
}
static int
saa7114_write_block (struct i2c_client *client,
const u8 *data,
unsigned int len)
{
int ret = -1;
u8 reg;
/* the saa7114 has an autoincrement function, use it if
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
/*struct saa7114 *decoder = i2c_get_clientdata(client);*/
struct i2c_msg msg;
u8 block_data[32];
msg.addr = client->addr;
msg.flags = 0;
while (len >= 2) {
msg.buf = (char *) block_data;