/* cx25840 - Conexant CX25840 audio/video decoder driver
*
* Copyright (C) 2004 Ulf Eklund
*
* Based on the saa7115 driver and on the first verison of Chris Kennedy's
* cx25840 driver.
*
* Changes by Tyler Trafford <tatrafford@comcast.net>
* - cleanup/rewrite for V4L2 API (2005)
*
* VBI support by Hans Verkuil <hverkuil@xs4all.nl>.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <media/audiochip.h>
#include <media/v4l2-common.h>
#include "cx25840.h"
MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
MODULE_LICENSE("GPL");
static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
int debug = 0;
module_param(debug, bool, 0644);
MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");
I2C_CLIENT_INSMOD;
/* ----------------------------------------------------------------------- */
int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
{
u8 buffer[3];
buffer[0] = addr >> 8;
buffer[1] = addr & 0xff;
buffer[2] = value;
return i2c_master_send(client, buffer, 3);
}
int cx25840_write4(struct i2c_client *client, u16 addr, u32 value)
{
u8 buffer[6];
buffer[0] = addr >> 8;
buffer[1] = addr & 0xff;
buffer[2] = value >> 24;
buffer[3] = (value >> 16) & 0xff;
buffer[4] = (value >> 8) & 0xff;
buffer[5] = value & 0xff;
return i2c_master_send(client, buffer, 6);
}
u8 cx25840_read(struct i2c_client * client, u16 addr)
{
u8 buffer[2];
buffer[0] = addr >> 8;
buffer[1] = addr & 0xff;
if (i2c_master_send(client, buffer, 2) < 2)
return 0;
if (i2c_master_recv(client, buffer, 1) < 1)
return 0;
return buffer[0];
}
u32 cx25840_read4(struct i2c_client * client, u16 addr)
{
u8 buffer[4];
buffer[0] = addr >> 8;
buffer[1] = addr & 0xff;
if (i2c_master_send(client, buffer, 2) < 2)
return 0;
if (i2c_master_recv(client, buffer, 4) < 4)
return 0;
return (buffer[0] << 24) | (buffer[1] << 16) |
(buffer[2] << 8) | buffer[3];
}
int cx25840_and_or(struct i2c_client *client, u16 addr, u8 and_mask,
u8 or