Commit 94c0c676 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] go7007: remove all wis* drivers

These are now no longer used and so they can be removed.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3acd16ab
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
/* Temporary I2C IDs -- these need to be replaced with real registered IDs */
#define I2C_DRIVERID_WIS_SAA7115 0xf0f0
#define I2C_DRIVERID_WIS_UDA1342 0xf0f1
#define I2C_DRIVERID_WIS_SONY_TUNER 0xf0f2
#define I2C_DRIVERID_WIS_TW9903 0xf0f3
#define I2C_DRIVERID_WIS_SAA7113 0xf0f4
#define I2C_DRIVERID_WIS_OV7640 0xf0f5
#define I2C_DRIVERID_WIS_TW2804 0xf0f6
#define I2C_DRIVERID_S2250 0xf0f7
/* Definitions for new video decoder commands */
struct video_decoder_resolution {
unsigned int width;
unsigned int height;
};
#define DECODER_SET_RESOLUTION _IOW('d', 200, struct video_decoder_resolution)
#define DECODER_SET_CHANNEL _IOW('d', 201, int)
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include "wis-i2c.h"
struct wis_ov7640 {
int brightness;
int contrast;
int saturation;
int hue;
};
static u8 initial_registers[] = {
0x12, 0x80,
0x12, 0x54,
0x14, 0x24,
0x15, 0x01,
0x28, 0x20,
0x75, 0x82,
0xFF, 0xFF, /* Terminator (reg 0xFF is unused) */
};
static int write_regs(struct i2c_client *client, u8 *regs)
{
int i;
for (i = 0; regs[i] != 0xFF; i += 2)
if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1]) < 0)
return -1;
return 0;
}
static int wis_ov7640_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
client->flags = I2C_CLIENT_SCCB;
dev_dbg(&client->dev,
"wis-ov7640: initializing OV7640 at address %d on %s\n",
client->addr, adapter->name);
if (write_regs(client, initial_registers) < 0) {
dev_err(&client->dev, "wis-ov7640: error initializing OV7640\n");
return -ENODEV;
}
return 0;
}
static int wis_ov7640_remove(struct i2c_client *client)
{
return 0;
}
static const struct i2c_device_id wis_ov7640_id[] = {
{ "wis_ov7640", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_ov7640_id);
static struct i2c_driver wis_ov7640_driver = {
.driver = {
.name = "WIS OV7640 I2C driver",
},
.probe = wis_ov7640_probe,
.remove = wis_ov7640_remove,
.id_table = wis_ov7640_id,
};
module_i2c_driver(wis_ov7640_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include "wis-i2c.h"
struct wis_saa7113 {
int norm;
int brightness;
int contrast;
int saturation;
int hue;
};
static u8 initial_registers[] = {
0x01, 0x08,
0x02, 0xc0,
0x03, 0x33,
0x04, 0x00,
0x05, 0x00,
0x06, 0xe9,
0x07, 0x0d,
0x08, 0xd8,
0x09, 0x40,
0x0a, 0x80,
0x0b, 0x47,
0x0c, 0x40,
0x0d, 0x00,
0x0e, 0x01,
0x0f, 0x2a,
0x10, 0x40,
0x11, 0x0c,
0x12, 0xfe,
0x13, 0x00,
0x14, 0x00,
0x15, 0x04,
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1b, 0x00,
0x1c, 0x00,
0x1d, 0x00,
0x1e, 0x00,
0x1f, 0xc8,
0x40, 0x00,
0x41, 0xff,
0x42, 0xff,
0x43, 0xff,
0x44, 0xff,
0x45, 0xff,
0x46, 0xff,
0x47, 0xff,
0x48, 0xff,
0x49, 0xff,
0x4a, 0xff,
0x4b, 0xff,
0x4c, 0xff,
0x4d, 0xff,
0x4e, 0xff,
0x4f, 0xff,
0x50, 0xff,
0x51, 0xff,
0x52, 0xff,
0x53, 0xff,
0x54, 0xff,
0x55, 0xff,
0x56, 0xff,
0x57, 0xff,
0x58, 0x00,
0x59, 0x54,
0x5a, 0x07,
0x5b, 0x83,
0x5c, 0x00,
0x5d, 0x00,
0x5e, 0x00,
0x5f, 0x00,
0x60, 0x00,
0x61, 0x00,
0x00, 0x00, /* Terminator (reg 0x00 is read-only) */
};
static int write_reg(struct i2c_client *client, u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
static int write_regs(struct i2c_client *client, u8 *regs)
{
int i;
for (i = 0; regs[i] != 0x00; i += 2)
if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1]) < 0)
return -1;
return 0;
}
static int wis_saa7113_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
struct wis_saa7113 *dec = i2c_get_clientdata(client);
switch (cmd) {
case VIDIOC_S_INPUT:
{
int *input = arg;
i2c_smbus_write_byte_data(client, 0x02, 0xC0 | *input);
i2c_smbus_write_byte_data(client, 0x09,
*input < 6 ? 0x40 : 0x80);
break;
}
case VIDIOC_S_STD:
{
v4l2_std_id *input = arg;
dec->norm = *input;
if (dec->norm & V4L2_STD_NTSC) {
write_reg(client, 0x0e, 0x01);
write_reg(client, 0x10, 0x40);
} else if (dec->norm & V4L2_STD_PAL) {
write_reg(client, 0x0e, 0x01);
write_reg(client, 0x10, 0x48);
} else if (dec->norm & V4L2_STD_SECAM) {
write_reg(client, 0x0e, 0x50);
write_reg(client, 0x10, 0x48);
}
break;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
case V4L2_CID_CONTRAST:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 71;
ctrl->flags = 0;
break;
case V4L2_CID_SATURATION:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 64;
ctrl->flags = 0;
break;
case V4L2_CID_HUE:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
ctrl->minimum = -128;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 0;
ctrl->flags = 0;
break;
}
break;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
if (ctrl->value > 255)
dec->brightness = 255;
else if (ctrl->value < 0)
dec->brightness = 0;
else
dec->brightness = ctrl->value;
write_reg(client, 0x0a, dec->brightness);
break;
case V4L2_CID_CONTRAST:
if (ctrl->value > 127)
dec->contrast = 127;
else if (ctrl->value < 0)
dec->contrast = 0;
else
dec->contrast = ctrl->value;
write_reg(client, 0x0b, dec->contrast);
break;
case V4L2_CID_SATURATION:
if (ctrl->value > 127)
dec->saturation = 127;
else if (ctrl->value < 0)
dec->saturation = 0;
else
dec->saturation = ctrl->value;
write_reg(client, 0x0c, dec->saturation);
break;
case V4L2_CID_HUE:
if (ctrl->value > 127)
dec->hue = 127;
else if (ctrl->value < -128)
dec->hue = -128;
else
dec->hue = ctrl->value;
write_reg(client, 0x0d, dec->hue);
break;
}
break;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->value = dec->brightness;
break;
case V4L2_CID_CONTRAST:
ctrl->value = dec->contrast;
break;
case V4L2_CID_SATURATION:
ctrl->value = dec->saturation;
break;
case V4L2_CID_HUE:
ctrl->value = dec->hue;
break;
}
break;
}
default:
break;
}
return 0;
}
static int wis_saa7113_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
struct wis_saa7113 *dec;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
dec = kmalloc(sizeof(struct wis_saa7113), GFP_KERNEL);
if (dec == NULL)
return -ENOMEM;
dec->norm = V4L2_STD_NTSC;
dec->brightness = 128;
dec->contrast = 71;
dec->saturation = 64;
dec->hue = 0;
i2c_set_clientdata(client, dec);
dev_dbg(&client->dev,
"wis-saa7113: initializing SAA7113 at address %d on %s\n",
client->addr, adapter->name);
if (write_regs(client, initial_registers) < 0) {
dev_err(&client->dev,
"wis-saa7113: error initializing SAA7113\n");
kfree(dec);
return -ENODEV;
}
return 0;
}
static int wis_saa7113_remove(struct i2c_client *client)
{
struct wis_saa7113 *dec = i2c_get_clientdata(client);
kfree(dec);
return 0;
}
static const struct i2c_device_id wis_saa7113_id[] = {
{ "wis_saa7113", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_saa7113_id);
static struct i2c_driver wis_saa7113_driver = {
.driver = {
.name = "WIS SAA7113 I2C driver",
},
.probe = wis_saa7113_probe,
.remove = wis_saa7113_remove,
.command = wis_saa7113_command,
.id_table = wis_saa7113_id,
};
module_i2c_driver(wis_saa7113_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include "wis-i2c.h"
struct wis_saa7115 {
int norm;
int brightness;
int contrast;
int saturation;
int hue;
};
static u8 initial_registers[] = {
0x01, 0x08,
0x02, 0xc0,
0x03, 0x20,
0x04, 0x80,
0x05, 0x80,
0x06, 0xeb,
0x07, 0xe0,
0x08, 0xf0, /* always toggle FID */
0x09, 0x40,
0x0a, 0x80,
0x0b, 0x40,
0x0c, 0x40,
0x0d, 0x00,
0x0e, 0x03,
0x0f, 0x2a,
0x10, 0x0e,
0x11, 0x00,
0x12, 0x8d,
0x13, 0x00,
0x14, 0x00,
0x15, 0x11,
0x16, 0x01,
0x17, 0xda,
0x18, 0x40,
0x19, 0x80,
0x1a, 0x00,
0x1b, 0x42,
0x1c, 0xa9,
0x30, 0x66,
0x31, 0x90,
0x32, 0x01,
0x34, 0x00,
0x35, 0x00,
0x36, 0x20,
0x38, 0x03,
0x39, 0x20,
0x3a, 0x88,
0x40, 0x00,
0x41, 0xff,
0x42, 0xff,
0x43, 0xff,
0x44, 0xff,
0x45, 0xff,
0x46, 0xff,
0x47, 0xff,
0x48, 0xff,
0x49, 0xff,
0x4a, 0xff,
0x4b, 0xff,
0x4c, 0xff,
0x4d, 0xff,
0x4e, 0xff,
0x4f, 0xff,
0x50, 0xff,
0x51, 0xff,
0x52, 0xff,
0x53, 0xff,
0x54, 0xf4 /*0xff*/,
0x55, 0xff,
0x56, 0xff,
0x57, 0xff,
0x58, 0x40,
0x59, 0x47,
0x5a, 0x06 /*0x03*/,
0x5b, 0x83,
0x5d, 0x06,
0x5e, 0x00,
0x80, 0x30, /* window defined scaler operation, task A and B enabled */
0x81, 0x03, /* use scaler datapath generated V */
0x83, 0x00,
0x84, 0x00,
0x85, 0x00,
0x86, 0x45,
0x87, 0x31,
0x88, 0xc0,
0x90, 0x02, /* task A process top field */
0x91, 0x08,
0x92, 0x09,
0x93, 0x80,
0x94, 0x06,
0x95, 0x00,
0x96, 0xc0,
0x97, 0x02,
0x98, 0x12,
0x99, 0x00,
0x9a, 0xf2,
0x9b, 0x00,
0x9c, 0xd0,
0x9d, 0x02,
0x9e, 0xf2,
0x9f, 0x00,
0xa0, 0x01,
0xa1, 0x01,
0xa2, 0x01,
0xa4, 0x80,
0xa5, 0x40,
0xa6, 0x40,
0xa8, 0x00,
0xa9, 0x04,
0xaa, 0x00,
0xac, 0x00,
0xad, 0x02,
0xae, 0x00,
0xb0, 0x00,
0xb1, 0x04,
0xb2, 0x00,
0xb3, 0x04,
0xb4, 0x00,
0xb8, 0x00,
0xbc, 0x00,
0xc0, 0x03, /* task B process bottom field */
0xc1, 0x08,
0xc2, 0x09,
0xc3, 0x80,
0xc4, 0x06,
0xc5, 0x00,
0xc6, 0xc0,
0xc7, 0x02,
0xc8, 0x12,
0xc9, 0x00,
0xca, 0xf2,
0xcb, 0x00,
0xcc, 0xd0,
0xcd, 0x02,
0xce, 0xf2,
0xcf, 0x00,
0xd0, 0x01,
0xd1, 0x01,
0xd2, 0x01,
0xd4, 0x80,
0xd5, 0x40,
0xd6, 0x40,
0xd8, 0x00,
0xd9, 0x04,
0xda, 0x00,
0xdc, 0x00,
0xdd, 0x02,
0xde, 0x00,
0xe0, 0x00,
0xe1, 0x04,
0xe2, 0x00,
0xe3, 0x04,
0xe4, 0x00,
0xe8, 0x00,
0x88, 0xf0, /* End of original static list */
0x00, 0x00, /* Terminator (reg 0x00 is read-only) */
};
static int write_reg(struct i2c_client *client, u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
static int write_regs(struct i2c_client *client, u8 *regs)
{
int i;
for (i = 0; regs[i] != 0x00; i += 2)
if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1]) < 0)
return -1;
return 0;
}
static int wis_saa7115_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
struct wis_saa7115 *dec = i2c_get_clientdata(client);
switch (cmd) {
case VIDIOC_S_INPUT:
{
int *input = arg;
i2c_smbus_write_byte_data(client, 0x02, 0xC0 | *input);
i2c_smbus_write_byte_data(client, 0x09,
*input < 6 ? 0x40 : 0xC0);
break;
}
case DECODER_SET_RESOLUTION:
{
struct video_decoder_resolution *res = arg;
/* Course-grained scaler */
int h_integer_scaler = res->width < 704 ? 704 / res->width : 1;
/* Fine-grained scaler to take care of remainder */
int h_scaling_increment = (704 / h_integer_scaler) *
1024 / res->width;
/* Fine-grained scaler only */
int v_scaling_increment = (dec->norm & V4L2_STD_NTSC ?
240 : 288) * 1024 / res->height;
u8 regs[] = {
0x88, 0xc0,
0x9c, res->width & 0xff,
0x9d, res->width >> 8,
0x9e, res->height & 0xff,
0x9f, res->height >> 8,
0xa0, h_integer_scaler,
0xa1, 1,
0xa2, 1,
0xa8, h_scaling_increment & 0xff,
0xa9, h_scaling_increment >> 8,
0xac, (h_scaling_increment / 2) & 0xff,
0xad, (h_scaling_increment / 2) >> 8,
0xb0, v_scaling_increment & 0xff,
0xb1, v_scaling_increment >> 8,
0xb2, v_scaling_increment & 0xff,
0xb3, v_scaling_increment >> 8,
0xcc, res->width & 0xff,
0xcd, res->width >> 8,
0xce, res->height & 0xff,
0xcf, res->height >> 8,
0xd0, h_integer_scaler,
0xd1, 1,
0xd2, 1,
0xd8, h_scaling_increment & 0xff,
0xd9, h_scaling_increment >> 8,
0xdc, (h_scaling_increment / 2) & 0xff,
0xdd, (h_scaling_increment / 2) >> 8,
0xe0, v_scaling_increment & 0xff,
0xe1, v_scaling_increment >> 8,
0xe2, v_scaling_increment & 0xff,
0xe3, v_scaling_increment >> 8,
0x88, 0xf0,
0, 0,
};
write_regs(client, regs);
break;
}
case VIDIOC_S_STD:
{
v4l2_std_id *input = arg;
u8 regs[] = {
0x88, 0xc0,
0x98, *input & V4L2_STD_NTSC ? 0x12 : 0x16,
0x9a, *input & V4L2_STD_NTSC ? 0xf2 : 0x20,
0x9b, *input & V4L2_STD_NTSC ? 0x00 : 0x01,
0xc8, *input & V4L2_STD_NTSC ? 0x12 : 0x16,
0xca, *input & V4L2_STD_NTSC ? 0xf2 : 0x20,
0xcb, *input & V4L2_STD_NTSC ? 0x00 : 0x01,
0x88, 0xf0,
0x30, *input & V4L2_STD_NTSC ? 0x66 : 0x00,
0x31, *input & V4L2_STD_NTSC ? 0x90 : 0xe0,
0, 0,
};
write_regs(client, regs);
dec->norm = *input;
break;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
case V4L2_CID_CONTRAST:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 64;
ctrl->flags = 0;
break;
case V4L2_CID_SATURATION:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 64;
ctrl->flags = 0;
break;
case V4L2_CID_HUE:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
ctrl->minimum = -128;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 0;
ctrl->flags = 0;
break;
}
break;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
if (ctrl->value > 255)
dec->brightness = 255;
else if (ctrl->value < 0)
dec->brightness = 0;
else
dec->brightness = ctrl->value;
write_reg(client, 0x0a, dec->brightness);
break;
case V4L2_CID_CONTRAST:
if (ctrl->value > 127)
dec->contrast = 127;
else if (ctrl->value < 0)
dec->contrast = 0;
else
dec->contrast = ctrl->value;
write_reg(client, 0x0b, dec->contrast);
break;
case V4L2_CID_SATURATION:
if (ctrl->value > 127)
dec->saturation = 127;
else if (ctrl->value < 0)
dec->saturation = 0;
else
dec->saturation = ctrl->value;
write_reg(client, 0x0c, dec->saturation);
break;
case V4L2_CID_HUE:
if (ctrl->value > 127)
dec->hue = 127;
else if (ctrl->value < -128)
dec->hue = -128;
else
dec->hue = ctrl->value;
write_reg(client, 0x0d, dec->hue);
break;
}
break;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->value = dec->brightness;
break;
case V4L2_CID_CONTRAST:
ctrl->value = dec->contrast;
break;
case V4L2_CID_SATURATION:
ctrl->value = dec->saturation;
break;
case V4L2_CID_HUE:
ctrl->value = dec->hue;
break;
}
break;
}
default:
break;
}
return 0;
}
static int wis_saa7115_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
struct wis_saa7115 *dec;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL);
if (dec == NULL)
return -ENOMEM;
dec->norm = V4L2_STD_NTSC;
dec->brightness = 128;
dec->contrast = 64;
dec->saturation = 64;
dec->hue = 0;
i2c_set_clientdata(client, dec);
dev_dbg(&client->dev,
"wis-saa7115: initializing SAA7115 at address %d on %s\n",
client->addr, adapter->name);
if (write_regs(client, initial_registers) < 0) {
dev_err(&client->dev,
"wis-saa7115: error initializing SAA7115\n");
kfree(dec);
return -ENODEV;
}
return 0;
}
static int wis_saa7115_remove(struct i2c_client *client)
{
struct wis_saa7115 *dec = i2c_get_clientdata(client);
kfree(dec);
return 0;
}
static const struct i2c_device_id wis_saa7115_id[] = {
{ "wis_saa7115", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_saa7115_id);
static struct i2c_driver wis_saa7115_driver = {
.driver = {
.name = "WIS SAA7115 I2C driver",
},
.probe = wis_saa7115_probe,
.remove = wis_saa7115_remove,
.command = wis_saa7115_command,
.id_table = wis_saa7115_id,
};
module_i2c_driver(wis_saa7115_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
#include <media/tuner.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include "wis-i2c.h"
/* #define MPX_DEBUG */
/* AS(IF/MPX) pin: LOW HIGH/OPEN
* IF/MPX address: 0x42/0x40 0x43/0x44
*/
#define IF_I2C_ADDR 0x43
#define MPX_I2C_ADDR 0x44
static v4l2_std_id force_band;
static char force_band_str[] = "-";
module_param_string(force_band, force_band_str, sizeof(force_band_str), 0644);
static int force_mpx_mode = -1;
module_param(force_mpx_mode, int, 0644);
/* Store tuner info in the same format as tuner.c, so maybe we can put the
* Sony tuner support in there. */
struct sony_tunertype {
char *name;
unsigned char Vendor; /* unused here */
unsigned char Type; /* unused here */
unsigned short thresh1; /* band switch VHF_LO <=> VHF_HI */
unsigned short thresh2; /* band switch VHF_HI <=> UHF */
unsigned char VHF_L;
unsigned char VHF_H;
unsigned char UHF;
unsigned char config;
unsigned short IFPCoff;
};
/* This array is indexed by (tuner_type - 200) */
static struct sony_tunertype sony_tuners[] = {
{ "Sony PAL+SECAM (BTF-PG472Z)", 0, 0,
16*144.25, 16*427.25, 0x01, 0x02, 0x04, 0xc6, 623},
{ "Sony NTSC_JP (BTF-PK467Z)", 0, 0,
16*220.25, 16*467.25, 0x01, 0x02, 0x04, 0xc6, 940},
{ "Sony NTSC (BTF-PB463Z)", 0, 0,
16*130.25, 16*364.25, 0x01, 0x02, 0x04, 0xc6, 732},
};
struct wis_sony_tuner {
int type;
v4l2_std_id std;
unsigned int freq;
int mpxmode;
u32 audmode;
};
/* Basically the same as default_set_tv_freq() in tuner.c */
static int set_freq(struct i2c_client *client, int freq)
{
struct wis_sony_tuner *t = i2c_get_clientdata(client);
char *band_name;
int n;
int band_select;
struct sony_tunertype *tun;
u8 buffer[4];
tun = &sony_tuners[t->type - 200];
if (freq < tun->thresh1) {
band_name = "VHF_L";
band_select = tun->VHF_L;
} else if (freq < tun->thresh2) {
band_name = "VHF_H";
band_select = tun->VHF_H;
} else {
band_name = "UHF";
band_select = tun->UHF;
}
dev_dbg(&client->dev, "tuning to frequency %d.%04d (%s)\n",
freq / 16, (freq % 16) * 625, band_name);
n = freq + tun->IFPCoff;
buffer[0] = n >> 8;
buffer[1] = n & 0xff;
buffer[2] = tun->config;
buffer[3] = band_select;
i2c_master_send(client, buffer, 4);
return 0;
}
static int mpx_write(struct i2c_client *client, int dev, int addr, int val)
{
u8 buffer[5];
struct i2c_msg msg;
buffer[0] = dev;
buffer[1] = addr >> 8;
buffer[2] = addr & 0xff;
buffer[3] = val >> 8;
buffer[4] = val & 0xff;
msg.addr = MPX_I2C_ADDR;
msg.flags = 0;
msg.len = 5;
msg.buf = buffer;
i2c_transfer(client->adapter, &msg, 1);
return 0;
}
/*
* MPX register values for the BTF-PG472Z:
*
* FM_ NICAM_ SCART_
* MODUS SOURCE ACB PRESCAL PRESCAL PRESCAL SYSTEM VOLUME
* 10/0030 12/0008 12/0013 12/000E 12/0010 12/0000 10/0020 12/0000
* ---------------------------------------------------------------
* Auto 1003 0020 0100 2603 5000 XXXX 0001 7500
*
* B/G
* Mono 1003 0020 0100 2603 5000 XXXX 0003 7500
* A2 1003 0020 0100 2601 5000 XXXX 0003 7500
* NICAM 1003 0120 0100 2603 5000 XXXX 0008 7500
*
* I
* Mono 1003 0020 0100 2603 7900 XXXX 000A 7500
* NICAM 1003 0120 0100 2603 7900 XXXX 000A 7500
*
* D/K
* Mono 1003 0020 0100 2603 5000 XXXX 0004 7500
* A2-1 1003 0020 0100 2601 5000 XXXX 0004 7500
* A2-2 1003 0020 0100 2601 5000 XXXX 0005 7500
* A2-3 1003 0020 0100 2601 5000 XXXX 0007 7500
* NICAM 1003 0120 0100 2603 5000 XXXX 000B 7500
*
* L/L'
* Mono 0003 0200 0100 7C03 5000 2200 0009 7500
* NICAM 0003 0120 0100 7C03 5000 XXXX 0009 7500
*
* M
* Mono 1003 0200 0100 2B03 5000 2B00 0002 7500
*
* For Asia, replace the 0x26XX in FM_PRESCALE with 0x14XX.
*
* Bilingual selection in A2/NICAM:
*
* High byte of SOURCE Left chan Right chan
* 0x01 MAIN SUB
* 0x03 MAIN MAIN
* 0x04 SUB SUB
*
* Force mono in NICAM by setting the high byte of SOURCE to 0x02 (L/L') or
* 0x00 (all other bands). Force mono in A2 with FMONO_A2:
*
* FMONO_A2
* 10/0022
* --------
* Forced mono ON 07F0
* Forced mono OFF 0190
*/
static struct {
enum { AUD_MONO, AUD_A2, AUD_NICAM, AUD_NICAM_L } audio_mode;
u16 modus;
u16 source;
u16 acb;
u16 fm_prescale;
u16 nicam_prescale;
u16 scart_prescale;
u16 system;
u16 volume;
} mpx_audio_modes[] = {
/* Auto */ { AUD_MONO, 0x1003, 0x0020, 0x0100, 0x2603,
0x5000, 0x0000, 0x0001, 0x7500 },
/* B/G Mono */ { AUD_MONO, 0x1003, 0x0020, 0x0100, 0x2603,
0x5000, 0x0000, 0x0003, 0x7500 },
/* B/G A2 */ { AUD_A2, 0x1003, 0x0020, 0x0100, 0x2601,
0x5000, 0x0000, 0x0003, 0x7500 },
/* B/G NICAM */ { AUD_NICAM, 0x1003, 0x0120, 0x0100, 0x2603,
0x5000, 0x0000, 0x0008, 0x7500 },
/* I Mono */ { AUD_MONO, 0x1003, 0x0020, 0x0100, 0x2603,
0x7900, 0x0000, 0x000A, 0x7500 },
/* I NICAM */ { AUD_NICAM, 0x1003, 0x0120, 0x0100, 0x2603,
0x7900, 0x0000, 0x000A, 0x7500 },
/* D/K Mono */ { AUD_MONO, 0x1003, 0x0020, 0x0100, 0x2603,
0x5000, 0x0000, 0x0004, 0x7500 },
/* D/K A2-1 */ { AUD_A2, 0x1003, 0x0020, 0x0100, 0x2601,
0x5000, 0x0000, 0x0004, 0x7500 },
/* D/K A2-2 */ { AUD_A2, 0x1003, 0x0020, 0x0100, 0x2601,
0x5000, 0x0000, 0x0005, 0x7500 },
/* D/K A2-3 */ { AUD_A2, 0x1003, 0x0020, 0x0100, 0x2601,
0x5000, 0x0000, 0x0007, 0x7500 },
/* D/K NICAM */ { AUD_NICAM, 0x1003, 0x0120, 0x0100, 0x2603,
0x5000, 0x0000, 0x000B, 0x7500 },
/* L/L' Mono */ { AUD_MONO, 0x0003, 0x0200, 0x0100, 0x7C03,
0x5000, 0x2200, 0x0009, 0x7500 },
/* L/L' NICAM */{ AUD_NICAM_L, 0x0003, 0x0120, 0x0100, 0x7C03,
0x5000, 0x0000, 0x0009, 0x7500 },
};
#define MPX_NUM_MODES ARRAY_SIZE(mpx_audio_modes)
static int mpx_setup(struct i2c_client *client)
{
struct wis_sony_tuner *t = i2c_get_clientdata(client);
u16 source = 0;
u8 buffer[3];
struct i2c_msg msg;
/* reset MPX */
buffer[0] = 0x00;
buffer[1] = 0x80;
buffer[2] = 0x00;
msg.addr = MPX_I2C_ADDR;
msg.flags = 0;
msg.len = 3;
msg.buf = buffer;
i2c_transfer(client->adapter, &msg, 1);
buffer[1] = 0x00;
i2c_transfer(client->adapter, &msg, 1);
if (mpx_audio_modes[t->mpxmode].audio_mode != AUD_MONO) {
switch (t->audmode) {
case V4L2_TUNER_MODE_MONO:
switch (mpx_audio_modes[t->mpxmode].audio_mode) {
case AUD_A2:
source = mpx_audio_modes[t->mpxmode].source;
break;
case AUD_NICAM:
source = 0x0000;
break;
case AUD_NICAM_L:
source = 0x0200;
break;
default:
break;
}
break;
case V4L2_TUNER_MODE_STEREO:
source = mpx_audio_modes[t->mpxmode].source;
break;
case V4L2_TUNER_MODE_LANG1:
source = 0x0300;
break;
case V4L2_TUNER_MODE_LANG2:
source = 0x0400;
break;
}
source |= mpx_audio_modes[t->mpxmode].source & 0x00ff;
} else
source = mpx_audio_modes[t->mpxmode].source;
mpx_write(client, 0x10, 0x0030, mpx_audio_modes[t->mpxmode].modus);
mpx_write(client, 0x12, 0x0008, source);
mpx_write(client, 0x12, 0x0013, mpx_audio_modes[t->mpxmode].acb);
mpx_write(client, 0x12, 0x000e,
mpx_audio_modes[t->mpxmode].fm_prescale);
mpx_write(client, 0x12, 0x0010,
mpx_audio_modes[t->mpxmode].nicam_prescale);
mpx_write(client, 0x12, 0x000d,
mpx_audio_modes[t->mpxmode].scart_prescale);
mpx_write(client, 0x10, 0x0020, mpx_audio_modes[t->mpxmode].system);
mpx_write(client, 0x12, 0x0000, mpx_audio_modes[t->mpxmode].volume);
if (mpx_audio_modes[t->mpxmode].audio_mode == AUD_A2)
mpx_write(client, 0x10, 0x0022,
t->audmode == V4L2_TUNER_MODE_MONO ? 0x07f0 : 0x0190);
#ifdef MPX_DEBUG
{
u8 buf1[3], buf2[2];
struct i2c_msg msgs[2];
dev_dbg(&client->dev,
"MPX registers: %04x %04x %04x %04x %04x %04x %04x %04x\n",
mpx_audio_modes[t->mpxmode].modus,
source,
mpx_audio_modes[t->mpxmode].acb,
mpx_audio_modes[t->mpxmode].fm_prescale,
mpx_audio_modes[t->mpxmode].nicam_prescale,
mpx_audio_modes[t->mpxmode].scart_prescale,
mpx_audio_modes[t->mpxmode].system,
mpx_audio_modes[t->mpxmode].volume);
buf1[0] = 0x11;
buf1[1] = 0x00;
buf1[2] = 0x7e;
msgs[0].addr = MPX_I2C_ADDR;
msgs[0].flags = 0;
msgs[0].len = 3;
msgs[0].buf = buf1;
msgs[1].addr = MPX_I2C_ADDR;
msgs[1].flags = I2C_M_RD;
msgs[1].len = 2;
msgs[1].buf = buf2;
i2c_transfer(client->adapter, msgs, 2);
dev_dbg(&client->dev, "MPX system: %02x%02x\n",
buf2[0], buf2[1]);
buf1[0] = 0x11;
buf1[1] = 0x02;
buf1[2] = 0x00;
i2c_transfer(client->adapter, msgs, 2);
dev_dbg(&client->dev, "MPX status: %02x%02x\n",
buf2[0], buf2[1]);
}
#endif
return 0;
}
/*
* IF configuration values for the BTF-PG472Z:
*
* B/G: 0x94 0x70 0x49
* I: 0x14 0x70 0x4a
* D/K: 0x14 0x70 0x4b
* L: 0x04 0x70 0x4b
* L': 0x44 0x70 0x53
* M: 0x50 0x30 0x4c
*/
static int set_if(struct i2c_client *client)
{
struct wis_sony_tuner *t = i2c_get_clientdata(client);
u8 buffer[4];
struct i2c_msg msg;
int default_mpx_mode = 0;
/* configure IF */
buffer[0] = 0;
if (t->std & V4L2_STD_PAL_BG) {
buffer[1] = 0x94;
buffer[2] = 0x70;
buffer[3] = 0x49;
default_mpx_mode = 1;
} else if (t->std & V4L2_STD_PAL_I) {
buffer[1] = 0x14;
buffer[2] = 0x70;
buffer[3] = 0x4a;
default_mpx_mode = 4;
} else if (t->std & V4L2_STD_PAL_DK) {
buffer[1] = 0x14;
buffer[2] = 0x70;
buffer[3] = 0x4b;
default_mpx_mode = 6;
} else if (t->std & V4L2_STD_SECAM_L) {
buffer[1] = 0x04;
buffer[2] = 0x70;
buffer[3] = 0x4b;
default_mpx_mode = 11;
}
msg.addr = IF_I2C_ADDR;
msg.flags = 0;
msg.len = 4;
msg.buf = buffer;
i2c_transfer(client->adapter, &msg, 1);
/* Select MPX mode if not forced by the user */
if (force_mpx_mode >= 0 && force_mpx_mode < MPX_NUM_MODES)
t->mpxmode = force_mpx_mode;
else
t->mpxmode = default_mpx_mode;
dev_dbg(&client->dev, "setting MPX to mode %d\n", t->mpxmode);
mpx_setup(client);
return 0;
}
static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
struct wis_sony_tuner *t = i2c_get_clientdata(client);
switch (cmd) {
#if 0
#ifdef TUNER_SET_TYPE_ADDR
case TUNER_SET_TYPE_ADDR:
{
struct tuner_setup *tun_setup = arg;
int *type = &tun_setup->type;
#else
case TUNER_SET_TYPE:
{
int *type = arg;
#endif
if (t->type >= 0) {
if (t->type != *type)
dev_err(&client->dev,
"type already set to %d, ignoring request for %d\n",
t->type, *type);
break;
}
t->type = *type;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
switch (force_band_str[0]) {
case 'b':
case 'B':
case 'g':
case 'G':
dev_info(&client->dev,
"forcing tuner to PAL-B/G bands\n");
force_band = V4L2_STD_PAL_BG;
break;
case 'i':
case 'I':
dev_info(&client->dev,
"forcing tuner to PAL-I band\n");
force_band = V4L2_STD_PAL_I;
break;
case 'd':
case 'D':
case 'k':
case 'K':
dev_info(&client->dev,
"forcing tuner to PAL-D/K bands\n");
force_band = V4L2_STD_PAL_I;
break;
case 'l':
case 'L':
dev_info(&client->dev,
"forcing tuner to SECAM-L band\n");
force_band = V4L2_STD_SECAM_L;
break;
default:
force_band = 0;
break;
}
if (force_band)
t->std = force_band;
else
t->std = V4L2_STD_PAL_BG;
set_if(client);
break;
case TUNER_SONY_BTF_PK467Z:
t->std = V4L2_STD_NTSC_M_JP;
break;
case TUNER_SONY_BTF_PB463Z:
t->std = V4L2_STD_NTSC_M;
break;
default:
dev_err(&client->dev,
"tuner type %d is not supported by this module\n",
*type);
break;
}
if (type >= 0)
dev_info(&clinet->dev,
"type set to %d (%s)\n",
t->type, sony_tuners[t->type - 200].name);
break;
}
#endif
case VIDIOC_G_FREQUENCY:
{
struct v4l2_frequency *f = arg;
f->frequency = t->freq;
break;
}
case VIDIOC_S_FREQUENCY:
{
struct v4l2_frequency *f = arg;
t->freq = f->frequency;
set_freq(client, t->freq);
break;
}
case VIDIOC_ENUMSTD:
{
struct v4l2_standard *std = arg;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
switch (std->index) {
case 0:
v4l2_video_std_construct(std,
V4L2_STD_PAL_BG, "PAL-B/G");
break;
case 1:
v4l2_video_std_construct(std,
V4L2_STD_PAL_I, "PAL-I");
break;
case 2:
v4l2_video_std_construct(std,
V4L2_STD_PAL_DK, "PAL-D/K");
break;
case 3:
v4l2_video_std_construct(std,
V4L2_STD_SECAM_L, "SECAM-L");
break;
default:
std->id = 0; /* hack to indicate EINVAL */
break;
}
break;
case TUNER_SONY_BTF_PK467Z:
if (std->index != 0) {
std->id = 0; /* hack to indicate EINVAL */
break;
}
v4l2_video_std_construct(std,
V4L2_STD_NTSC_M_JP, "NTSC-J");
break;
case TUNER_SONY_BTF_PB463Z:
if (std->index != 0) {
std->id = 0; /* hack to indicate EINVAL */
break;
}
v4l2_video_std_construct(std, V4L2_STD_NTSC_M, "NTSC");
break;
}
break;
}
case VIDIOC_G_STD:
{
v4l2_std_id *std = arg;
*std = t->std;
break;
}
case VIDIOC_S_STD:
{
v4l2_std_id *std = arg;
v4l2_std_id old = t->std;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
if (force_band && (*std & force_band) != *std &&
*std != V4L2_STD_PAL &&
*std != V4L2_STD_SECAM) {
dev_dbg(&client->dev,
"ignoring requested TV standard in favor of force_band value\n");
t->std = force_band;
} else if (*std & V4L2_STD_PAL_BG) { /* default */
t->std = V4L2_STD_PAL_BG;
} else if (*std & V4L2_STD_PAL_I) {
t->std = V4L2_STD_PAL_I;
} else if (*std & V4L2_STD_PAL_DK) {
t->std = V4L2_STD_PAL_DK;
} else if (*std & V4L2_STD_SECAM_L) {
t->std = V4L2_STD_SECAM_L;
} else {
dev_err(&client->dev,
"TV standard not supported\n");
*std = 0; /* hack to indicate EINVAL */
break;
}
if (old != t->std)
set_if(client);
break;
case TUNER_SONY_BTF_PK467Z:
if (!(*std & V4L2_STD_NTSC_M_JP)) {
dev_err(&client->dev,
"TV standard not supported\n");
*std = 0; /* hack to indicate EINVAL */
}
break;
case TUNER_SONY_BTF_PB463Z:
if (!(*std & V4L2_STD_NTSC_M)) {
dev_err(&client->dev,
"TV standard not supported\n");
*std = 0; /* hack to indicate EINVAL */
}
break;
}
break;
}
case VIDIOC_QUERYSTD:
{
v4l2_std_id *std = arg;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
if (force_band)
*std = force_band;
else
*std = V4L2_STD_PAL_BG | V4L2_STD_PAL_I |
V4L2_STD_PAL_DK | V4L2_STD_SECAM_L;
break;
case TUNER_SONY_BTF_PK467Z:
*std = V4L2_STD_NTSC_M_JP;
break;
case TUNER_SONY_BTF_PB463Z:
*std = V4L2_STD_NTSC_M;
break;
}
break;
}
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *tun = arg;
memset(tun, 0, sizeof(*tun));
strcpy(tun->name, "Television");
tun->type = V4L2_TUNER_ANALOG_TV;
tun->rangelow = 0UL; /* does anything use these? */
tun->rangehigh = 0xffffffffUL;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
tun->capability = V4L2_TUNER_CAP_NORM |
V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
V4L2_TUNER_CAP_LANG2;
tun->rxsubchans = V4L2_TUNER_SUB_MONO |
V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_LANG1 |
V4L2_TUNER_SUB_LANG2;
break;
case TUNER_SONY_BTF_PK467Z:
case TUNER_SONY_BTF_PB463Z:
tun->capability = V4L2_TUNER_CAP_STEREO;
tun->rxsubchans = V4L2_TUNER_SUB_MONO |
V4L2_TUNER_SUB_STEREO;
break;
}
tun->audmode = t->audmode;
return 0;
}
case VIDIOC_S_TUNER:
{
struct v4l2_tuner *tun = arg;
switch (t->type) {
case TUNER_SONY_BTF_PG472Z:
if (tun->audmode != t->audmode) {
t->audmode = tun->audmode;
mpx_setup(client);
}
break;
case TUNER_SONY_BTF_PK467Z:
case TUNER_SONY_BTF_PB463Z:
break;
}
return 0;
}
default:
break;
}
return 0;
}
static int wis_sony_tuner_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
struct wis_sony_tuner *t;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
return -ENODEV;
t = kmalloc(sizeof(struct wis_sony_tuner), GFP_KERNEL);
if (t == NULL)
return -ENOMEM;
t->type = -1;
t->freq = 0;
t->mpxmode = 0;
t->audmode = V4L2_TUNER_MODE_STEREO;
i2c_set_clientdata(client, t);
dev_dbg(&client->dev, "initializing tuner at address %d on %s\n",
client->addr, adapter->name);
return 0;
}
static int wis_sony_tuner_remove(struct i2c_client *client)
{
struct wis_sony_tuner *t = i2c_get_clientdata(client);
kfree(t);
return 0;
}
static const struct i2c_device_id wis_sony_tuner_id[] = {
{ "wis_sony_tuner", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_sony_tuner_id);
static struct i2c_driver wis_sony_tuner_driver = {
.driver = {
.name = "WIS Sony TV Tuner I2C driver",
},
.probe = wis_sony_tuner_probe,
.remove = wis_sony_tuner_remove,
.command = tuner_command,
.id_table = wis_sony_tuner_id,
};
module_i2c_driver(wis_sony_tuner_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include "wis-i2c.h"
struct wis_tw2804 {
int channel;
int norm;
int brightness;
int contrast;
int saturation;
int hue;
};
static u8 global_registers[] = {
0x39, 0x00,
0x3a, 0xff,
0x3b, 0x84,
0x3c, 0x80,
0x3d, 0x80,
0x3e, 0x82,
0x3f, 0x82,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
};
static u8 channel_registers[] = {
0x01, 0xc4,
0x02, 0xa5,
0x03, 0x20,
0x04, 0xd0,
0x05, 0x20,
0x06, 0xd0,
0x07, 0x88,
0x08, 0x20,
0x09, 0x07,
0x0a, 0xf0,
0x0b, 0x07,
0x0c, 0xf0,
0x0d, 0x40,
0x0e, 0xd2,
0x0f, 0x80,
0x10, 0x80,
0x11, 0x80,
0x12, 0x80,
0x13, 0x1f,
0x14, 0x00,
0x15, 0x00,
0x16, 0x00,
0x17, 0x00,
0x18, 0xff,
0x19, 0xff,
0x1a, 0xff,
0x1b, 0xff,
0x1c, 0xff,
0x1d, 0xff,
0x1e, 0xff,
0x1f, 0xff,
0x20, 0x07,
0x21, 0x07,
0x22, 0x00,
0x23, 0x91,
0x24, 0x51,
0x25, 0x03,
0x26, 0x00,
0x27, 0x00,
0x28, 0x00,
0x29, 0x00,
0x2a, 0x00,
0x2b, 0x00,
0x2c, 0x00,
0x2d, 0x00,
0x2e, 0x00,
0x2f, 0x00,
0x30, 0x00,
0x31, 0x00,
0x32, 0x00,
0x33, 0x00,
0x34, 0x00,
0x35, 0x00,
0x36, 0x00,
0x37, 0x00,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
};
static int write_reg(struct i2c_client *client, u8 reg, u8 value, int channel)
{
return i2c_smbus_write_byte_data(client, reg | (channel << 6), value);
}
static int write_regs(struct i2c_client *client, u8 *regs, int channel)
{
int i;
for (i = 0; regs[i] != 0xff; i += 2)
if (i2c_smbus_write_byte_data(client,
regs[i] | (channel << 6), regs[i + 1]) < 0)
return -1;
return 0;
}
static int wis_tw2804_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
struct wis_tw2804 *dec = i2c_get_clientdata(client);
if (cmd == DECODER_SET_CHANNEL) {
int *input = arg;
if (*input < 0 || *input > 3) {
dev_err(&client->dev,
"channel %d is not between 0 and 3!\n", *input);
return 0;
}
dec->channel = *input;
dev_dbg(&client->dev, "initializing TW2804 channel %d\n",
dec->channel);
if (dec->channel == 0 &&
write_regs(client, global_registers, 0) < 0) {
dev_err(&client->dev,
"error initializing TW2804 global registers\n");
return 0;
}
if (write_regs(client, channel_registers, dec->channel) < 0) {
dev_err(&client->dev,
"error initializing TW2804 channel %d\n",
dec->channel);
return 0;
}
return 0;
}
if (dec->channel < 0) {
dev_dbg(&client->dev,
"ignoring command %08x until channel number is set\n",
cmd);
return 0;
}
switch (cmd) {
case VIDIOC_S_STD:
{
v4l2_std_id *input = arg;
u8 regs[] = {
0x01, *input & V4L2_STD_NTSC ? 0xc4 : 0x84,
0x09, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
0x0a, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
0x0b, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
0x0c, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
0x0d, *input & V4L2_STD_NTSC ? 0x40 : 0x4a,
0x16, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
0x17, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
0x20, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
0x21, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
0xff, 0xff,
};
write_regs(client, regs, dec->channel);
dec->norm = *input;
break;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
case V4L2_CID_CONTRAST:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
case V4L2_CID_SATURATION:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
case V4L2_CID_HUE:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 128;
ctrl->flags = 0;
break;
}
break;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
if (ctrl->value > 255)
dec->brightness = 255;
else if (ctrl->value < 0)
dec->brightness = 0;
else
dec->brightness = ctrl->value;
write_reg(client, 0x12, dec->brightness, dec->channel);
break;
case V4L2_CID_CONTRAST:
if (ctrl->value > 255)
dec->contrast = 255;
else if (ctrl->value < 0)
dec->contrast = 0;
else
dec->contrast = ctrl->value;
write_reg(client, 0x11, dec->contrast, dec->channel);
break;
case V4L2_CID_SATURATION:
if (ctrl->value > 255)
dec->saturation = 255;
else if (ctrl->value < 0)
dec->saturation = 0;
else
dec->saturation = ctrl->value;
write_reg(client, 0x10, dec->saturation, dec->channel);
break;
case V4L2_CID_HUE:
if (ctrl->value > 255)
dec->hue = 255;
else if (ctrl->value < 0)
dec->hue = 0;
else
dec->hue = ctrl->value;
write_reg(client, 0x0f, dec->hue, dec->channel);
break;
}
break;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->value = dec->brightness;
break;
case V4L2_CID_CONTRAST:
ctrl->value = dec->contrast;
break;
case V4L2_CID_SATURATION:
ctrl->value = dec->saturation;
break;
case V4L2_CID_HUE:
ctrl->value = dec->hue;
break;
}
break;
}
default:
break;
}
return 0;
}
static int wis_tw2804_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
struct wis_tw2804 *dec;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
if (dec == NULL)
return -ENOMEM;
dec->channel = -1;
dec->norm = V4L2_STD_NTSC;
dec->brightness = 128;
dec->contrast = 128;
dec->saturation = 128;
dec->hue = 128;
i2c_set_clientdata(client, dec);
dev_dbg(&client->dev, "creating TW2804 at address %d on %s\n",
client->addr, adapter->name);
return 0;
}
static int wis_tw2804_remove(struct i2c_client *client)
{
struct wis_tw2804 *dec = i2c_get_clientdata(client);
kfree(dec);
return 0;
}
static const struct i2c_device_id wis_tw2804_id[] = {
{ "wis_tw2804", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_tw2804_id);
static struct i2c_driver wis_tw2804_driver = {
.driver = {
.name = "WIS TW2804 I2C driver",
},
.probe = wis_tw2804_probe,
.remove = wis_tw2804_remove,
.command = wis_tw2804_command,
.id_table = wis_tw2804_id,
};
module_i2c_driver(wis_tw2804_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include "wis-i2c.h"
struct wis_tw9903 {
int norm;
int brightness;
int contrast;
int hue;
};
static u8 initial_registers[] = {
0x02, 0x44, /* input 1, composite */
0x03, 0x92, /* correct digital format */
0x04, 0x00,
0x05, 0x80, /* or 0x00 for PAL */
0x06, 0x40, /* second internal current reference */
0x07, 0x02, /* window */
0x08, 0x14, /* window */
0x09, 0xf0, /* window */
0x0a, 0x81, /* window */
0x0b, 0xd0, /* window */
0x0c, 0x8c,
0x0d, 0x00, /* scaling */
0x0e, 0x11, /* scaling */
0x0f, 0x00, /* scaling */
0x10, 0x00, /* brightness */
0x11, 0x60, /* contrast */
0x12, 0x01, /* sharpness */
0x13, 0x7f, /* U gain */
0x14, 0x5a, /* V gain */
0x15, 0x00, /* hue */
0x16, 0xc3, /* sharpness */
0x18, 0x00,
0x19, 0x58, /* vbi */
0x1a, 0x80,
0x1c, 0x0f, /* video norm */
0x1d, 0x7f, /* video norm */
0x20, 0xa0, /* clamping gain (working 0x50) */
0x21, 0x22,
0x22, 0xf0,
0x23, 0xfe,
0x24, 0x3c,
0x25, 0x38,
0x26, 0x44,
0x27, 0x20,
0x28, 0x00,
0x29, 0x15,
0x2a, 0xa0,
0x2b, 0x44,
0x2c, 0x37,
0x2d, 0x00,
0x2e, 0xa5, /* burst PLL control (working: a9) */
0x2f, 0xe0, /* 0xea is blue test frame -- 0xe0 for normal */
0x31, 0x00,
0x33, 0x22,
0x34, 0x11,
0x35, 0x35,
0x3b, 0x05,
0x06, 0xc0, /* reset device */
0x00, 0x00, /* Terminator (reg 0x00 is read-only) */
};
static int write_reg(struct i2c_client *client, u8 reg, u8 value)
{
return i2c_smbus_write_byte_data(client, reg, value);
}
static int write_regs(struct i2c_client *client, u8 *regs)
{
int i;
for (i = 0; regs[i] != 0x00; i += 2)
if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1]) < 0)
return -1;
return 0;
}
static int wis_tw9903_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
struct wis_tw9903 *dec = i2c_get_clientdata(client);
switch (cmd) {
case VIDIOC_S_INPUT:
{
int *input = arg;
i2c_smbus_write_byte_data(client, 0x02, 0x40 | (*input << 1));
break;
}
#if 0
/* The scaler on this thing seems to be horribly broken */
case DECODER_SET_RESOLUTION:
{
struct video_decoder_resolution *res = arg;
/*int hscale = 256 * 720 / res->width;*/
int hscale = 256 * 720 / (res->width - (res->width > 704 ? 0 : 8));
int vscale = 256 * (dec->norm & V4L2_STD_NTSC ? 240 : 288)
/ res->height;
u8 regs[] = {
0x0d, vscale & 0xff,
0x0f, hscale & 0xff,
0x0e, ((vscale & 0xf00) >> 4) | ((hscale & 0xf00) >> 8),
0x06, 0xc0, /* reset device */
0, 0,
};
dev_dbg(&client->dev, "vscale is %04x, hscale is %04x\n",
vscale, hscale);
/*write_regs(client, regs);*/
break;
}
#endif
case VIDIOC_S_STD:
{
v4l2_std_id *input = arg;
u8 regs[] = {
0x05, *input & V4L2_STD_NTSC ? 0x80 : 0x00,
0x07, *input & V4L2_STD_NTSC ? 0x02 : 0x12,
0x08, *input & V4L2_STD_NTSC ? 0x14 : 0x18,
0x09, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
0, 0,
};
write_regs(client, regs);
dec->norm = *input;
break;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
ctrl->minimum = -128;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 0x00;
ctrl->flags = 0;
break;
case V4L2_CID_CONTRAST:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 255;
ctrl->step = 1;
ctrl->default_value = 0x60;
ctrl->flags = 0;
break;
#if 0
/* I don't understand how the Chroma Gain registers work... */
case V4L2_CID_SATURATION:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
ctrl->minimum = 0;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 64;
ctrl->flags = 0;
break;
#endif
case V4L2_CID_HUE:
ctrl->type = V4L2_CTRL_TYPE_INTEGER;
strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
ctrl->minimum = -128;
ctrl->maximum = 127;
ctrl->step = 1;
ctrl->default_value = 0;
ctrl->flags = 0;
break;
}
break;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
if (ctrl->value > 127)
dec->brightness = 127;
else if (ctrl->value < -128)
dec->brightness = -128;
else
dec->brightness = ctrl->value;
write_reg(client, 0x10, dec->brightness);
break;
case V4L2_CID_CONTRAST:
if (ctrl->value > 255)
dec->contrast = 255;
else if (ctrl->value < 0)
dec->contrast = 0;
else
dec->contrast = ctrl->value;
write_reg(client, 0x11, dec->contrast);
break;
#if 0
case V4L2_CID_SATURATION:
if (ctrl->value > 127)
dec->saturation = 127;
else if (ctrl->value < 0)
dec->saturation = 0;
else
dec->saturation = ctrl->value;
/*write_reg(client, 0x0c, dec->saturation);*/
break;
#endif
case V4L2_CID_HUE:
if (ctrl->value > 127)
dec->hue = 127;
else if (ctrl->value < -128)
dec->hue = -128;
else
dec->hue = ctrl->value;
write_reg(client, 0x15, dec->hue);
break;
}
break;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->value = dec->brightness;
break;
case V4L2_CID_CONTRAST:
ctrl->value = dec->contrast;
break;
#if 0
case V4L2_CID_SATURATION:
ctrl->value = dec->saturation;
break;
#endif
case V4L2_CID_HUE:
ctrl->value = dec->hue;
break;
}
break;
}
default:
break;
}
return 0;
}
static int wis_tw9903_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
struct wis_tw9903 *dec;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
dec = kmalloc(sizeof(struct wis_tw9903), GFP_KERNEL);
if (dec == NULL)
return -ENOMEM;
dec->norm = V4L2_STD_NTSC;
dec->brightness = 0;
dec->contrast = 0x60;
dec->hue = 0;
i2c_set_clientdata(client, dec);
dev_dbg(&client->dev, "initializing TW9903 at address %d on %s\n",
client->addr, adapter->name);
if (write_regs(client, initial_registers) < 0) {
dev_err(&client->dev, "error initializing TW9903\n");
kfree(dec);
return -ENODEV;
}
return 0;
}
static int wis_tw9903_remove(struct i2c_client *client)
{
struct wis_tw9903 *dec = i2c_get_clientdata(client);
kfree(dec);
return 0;
}
static const struct i2c_device_id wis_tw9903_id[] = {
{ "wis_tw9903", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_tw9903_id);
static struct i2c_driver wis_tw9903_driver = {
.driver = {
.name = "WIS TW9903 I2C driver",
},
.probe = wis_tw9903_probe,
.remove = wis_tw9903_remove,
.command = wis_tw9903_command,
.id_table = wis_tw9903_id,
};
module_i2c_driver(wis_tw9903_driver);
MODULE_LICENSE("GPL v2");
/*
* Copyright (C) 2005-2006 Micronas USA Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <media/tvaudio.h>
#include <media/v4l2-common.h>
#include "wis-i2c.h"
static int write_reg(struct i2c_client *client, int reg, int value)
{
/* UDA1342 wants MSB first, but SMBus sends LSB first */
i2c_smbus_write_word_data(client, reg, swab16(value));
return 0;
}
static int wis_uda1342_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
switch (cmd) {
case VIDIOC_S_AUDIO:
{
int *inp = arg;
switch (*inp) {
case TVAUDIO_INPUT_TUNER:
write_reg(client, 0x00, 0x1441); /* select input 2 */
break;
case TVAUDIO_INPUT_EXTERN:
write_reg(client, 0x00, 0x1241); /* select input 1 */
break;
default:
dev_err(&client->dev, "input %d not supported\n",
*inp);
break;
}
break;
}
default:
break;
}
return 0;
}
static int wis_uda1342_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV;
dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n",
client->addr, adapter->name);
write_reg(client, 0x00, 0x8000); /* reset registers */
write_reg(client, 0x00, 0x1241); /* select input 1 */
return 0;
}
static int wis_uda1342_remove(struct i2c_client *client)
{
return 0;
}
static const struct i2c_device_id wis_uda1342_id[] = {
{ "wis_uda1342", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, wis_uda1342_id);
static struct i2c_driver wis_uda1342_driver = {
.driver = {
.name = "WIS UDA1342 I2C driver",
},
.probe = wis_uda1342_probe,
.remove = wis_uda1342_remove,
.command = wis_uda1342_command,
.id_table = wis_uda1342_id,
};
module_i2c_driver(wis_uda1342_driver);
MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment