Commit ac247433 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (5929): Add vp27smpx driver



This device is internal to the Panasonic VP27S tuner and is used to set 
the mono/stereo/bilingual setting of the tuner.

It is used by two Japanese cx23416-based cards.
Signed-off-by: default avatarTakahiro Adachi <tadachi@tadachi-net.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b4c85248
......@@ -148,6 +148,15 @@ config VIDEO_WM8739
To compile this driver as a module, choose M here: the
module will be called wm8739.
config VIDEO_VP27SMPX
tristate "Panasonic VP27s internal MPX"
depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
---help---
Support for the internal MPX of the Panasonic VP27s tuner.
To compile this driver as a module, choose M here: the
module will be called vp27smpx.
comment "Video decoders"
config VIDEO_BT819
......
......@@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o
obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
obj-$(CONFIG_VIDEO_MXB) += mxb.o
......
......@@ -14,6 +14,7 @@ config VIDEO_IVTV
select VIDEO_CS53L32A
select VIDEO_WM8775
select VIDEO_WM8739
select VIDEO_VP27SMPX
select VIDEO_UPD64031A
select VIDEO_UPD64083
---help---
......
......@@ -616,7 +616,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx = {
.hw_video = IVTV_HW_SAA7115 | IVTV_HW_UPD64031A | IVTV_HW_UPD6408X,
.hw_audio = IVTV_HW_GPIO,
.hw_audio_ctrl = IVTV_HW_WM8739,
.hw_all = IVTV_HW_GPIO | IVTV_HW_SAA7115 | IVTV_HW_TVAUDIO |
.hw_all = IVTV_HW_GPIO | IVTV_HW_SAA7115 | IVTV_HW_VP27SMPX |
IVTV_HW_TUNER | IVTV_HW_WM8739 |
IVTV_HW_UPD64031A | IVTV_HW_UPD6408X,
.video_inputs = {
......@@ -654,7 +654,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx2e = {
.hw_audio = IVTV_HW_GPIO,
.hw_audio_ctrl = IVTV_HW_WM8739,
.hw_all = IVTV_HW_GPIO | IVTV_HW_SAA7115 | IVTV_HW_TUNER |
IVTV_HW_TVAUDIO | IVTV_HW_WM8739,
IVTV_HW_VP27SMPX | IVTV_HW_WM8739,
.video_inputs = {
{ IVTV_CARD_INPUT_VID_TUNER, 0, IVTV_SAA71XX_COMPOSITE4 },
{ IVTV_CARD_INPUT_SVIDEO1, 1, IVTV_SAA71XX_SVIDEO0 },
......
......@@ -33,7 +33,8 @@
#define IVTV_HW_UPD6408X (1 << 11)
#define IVTV_HW_SAA717X (1 << 12)
#define IVTV_HW_WM8739 (1 << 13)
#define IVTV_HW_GPIO (1 << 14)
#define IVTV_HW_VP27SMPX (1 << 14)
#define IVTV_HW_GPIO (1 << 15)
#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
......
......@@ -853,6 +853,10 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
#ifndef CONFIG_VIDEO_MSP3400
if (hw & IVTV_HW_MSP34XX)
ivtv_request_module(itv, "msp3400");
#endif
#ifndef CONFIG_VIDEO_VP27SMPX
if (hw & IVTV_HW_VP27SMPX)
ivtv_request_module(itv, "vp27smpx");
#endif
if (hw & IVTV_HW_TVAUDIO)
ivtv_request_module(itv, "tvaudio");
......
......@@ -109,6 +109,7 @@ static const u8 hw_driverids[] = {
I2C_DRIVERID_UPD64083,
I2C_DRIVERID_SAA717X,
I2C_DRIVERID_WM8739,
I2C_DRIVERID_VP27SMPX,
0 /* IVTV_HW_GPIO dummy driver ID */
};
......@@ -128,6 +129,7 @@ static const char * const hw_drivernames[] = {
"upd64083",
"saa717x",
"wm8739",
"vp27smpx",
"gpio",
};
......
/*
* vp27smpx - driver version 0.0.1
*
* Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
*
* Special thanks to Kazz for the i2c data.
*
* 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/types.h>
#include <linux/ioctl.h>
#include <asm/uaccess.h>
#include <linux/i2c.h>
#include <linux/i2c-id.h>
#include <linux/videodev.h>
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
MODULE_DESCRIPTION("vp27smpx driver");
MODULE_AUTHOR("Hans Verkuil");
MODULE_LICENSE("GPL");
static unsigned short normal_i2c[] = { 0xb6 >> 1, I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
/* ----------------------------------------------------------------------- */
struct vp27smpx_state {
int radio;
u32 audmode;
};
static void vp27smpx_set_audmode(struct i2c_client *client, u32 audmode)
{
struct vp27smpx_state *state = i2c_get_clientdata(client);
u8 data[3] = { 0x00, 0x00, 0x04 };
switch (audmode) {
case V4L2_TUNER_MODE_MONO:
case V4L2_TUNER_MODE_LANG1:
break;
case V4L2_TUNER_MODE_STEREO:
case V4L2_TUNER_MODE_LANG1_LANG2:
data[1] = 0x01;
break;
case V4L2_TUNER_MODE_LANG2:
data[1] = 0x02;
break;
}
if (i2c_master_send(client, data, sizeof(data)) != sizeof(data)) {
v4l_err(client, "%s: I/O error setting audmode\n", client->name);
}
else {
state->audmode = audmode;
}
}
static int vp27smpx_command(struct i2c_client *client, unsigned int cmd,
void *arg)
{
struct vp27smpx_state *state = i2c_get_clientdata(client);
struct v4l2_tuner *vt = arg;
switch (cmd) {
case AUDC_SET_RADIO:
state->radio = 1;
break;
case VIDIOC_S_STD:
state->radio = 0;
break;
case VIDIOC_S_TUNER:
if (!state->radio)
vp27smpx_set_audmode(client, vt->audmode);
break;
case VIDIOC_G_TUNER:
if (state->radio)
break;
vt->audmode = state->audmode;
vt->capability = V4L2_TUNER_CAP_STEREO |
V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
vt->rxsubchans = V4L2_TUNER_SUB_MONO;
break;
case VIDIOC_G_CHIP_IDENT:
return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_VP27SMPX, 0);
case VIDIOC_LOG_STATUS:
v4l_info(client, "Audio Mode: %u%s\n", state->audmode,
state->radio ? " (Radio)" : "");
break;
default:
return -EINVAL;
}
return 0;
}
/* ----------------------------------------------------------------------- */
/* i2c implementation */
/*
* Generic i2c probe
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
*/
static struct i2c_driver i2c_driver;
static int vp27smpx_attach(struct i2c_adapter *adapter, int address, int kind)
{
struct i2c_client *client;
struct vp27smpx_state *state;
/* Check if the adapter supports the needed features */
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return 0;
client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (client == 0)
return -ENOMEM;
client->addr = address;
client->adapter = adapter;
client->driver = &i2c_driver;
snprintf(client->name, sizeof(client->name) - 1, "vp27smpx");
v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
state = kzalloc(sizeof(struct vp27smpx_state), GFP_KERNEL);
if (state == NULL) {
kfree(client);
return -ENOMEM;
}
state->audmode = V4L2_TUNER_MODE_STEREO;
i2c_set_clientdata(client, state);
/* initialize vp27smpx */
vp27smpx_set_audmode(client, state->audmode);
i2c_attach_client(client);
return 0;
}
static int vp27smpx_probe(struct i2c_adapter *adapter)
{
if (adapter->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adapter, &addr_data, vp27smpx_attach);
return 0;
}
static int vp27smpx_detach(struct i2c_client *client)
{
struct vp27smpx_state *state = i2c_get_clientdata(client);
int err;
err = i2c_detach_client(client);
if (err) {
return err;
}
kfree(state);
kfree(client);
return 0;
}
/* ----------------------------------------------------------------------- */
/* i2c implementation */
static struct i2c_driver i2c_driver = {
.driver = {
.name = "vp27smpx",
},
.id = I2C_DRIVERID_VP27SMPX,
.attach_adapter = vp27smpx_probe,
.detach_client = vp27smpx_detach,
.command = vp27smpx_command,
};
static int __init vp27smpx_init_module(void)
{
return i2c_add_driver(&i2c_driver);
}
static void __exit vp27smpx_cleanup_module(void)
{
i2c_del_driver(&i2c_driver);
}
module_init(vp27smpx_init_module);
module_exit(vp27smpx_cleanup_module);
......@@ -119,6 +119,7 @@
#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */
#define I2C_DRIVERID_WM8753 91 /* Wolfson WM8753 audio codec */
#define I2C_DRIVERID_LM4857 92 /* LM4857 Audio Amplifier */
#define I2C_DRIVERID_VP27SMPX 93 /* Panasonic VP27s tuner internal MPX */
#define I2C_DRIVERID_I2CDEV 900
#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
......
......@@ -65,6 +65,9 @@ enum {
V4L2_IDENT_CX23415 = 415,
V4L2_IDENT_CX23416 = 416,
/* module vp27smpx: just ident 2700 */
V4L2_IDENT_VP27SMPX = 2700,
/* module wm8739: just ident 8739 */
V4L2_IDENT_WM8739 = 8739,
......
Supports Markdown
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