mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
Staging: add the go7007 video driver
Todo: - checkpatch.pl cleanups - sparse cleanups - lots of little modules, should be merged together and added to the build. - testing? - handle churn in v4l layer. Many thanks to Ross Cohen <rcohen@snurgle.org> for cleanup patches on this driver. Cc: Ross Cohen <rcohen@snurgle.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
c0f005888c
commit
866b8695d6
22 changed files with 9269 additions and 0 deletions
|
@ -31,4 +31,6 @@ source "drivers/staging/sxg/Kconfig"
|
|||
|
||||
source "drivers/staging/me4000/Kconfig"
|
||||
|
||||
source "drivers/staging/go7007/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
|
|
@ -4,3 +4,4 @@ obj-$(CONFIG_ET131X) += et131x/
|
|||
obj-$(CONFIG_SLICOSS) += slicoss/
|
||||
obj-$(CONFIG_SXG) += sxg/
|
||||
obj-$(CONFIG_ME4000) += me4000/
|
||||
obj-$(CONFIG_VIDEO_GO7007) += go7007/
|
||||
|
|
25
drivers/staging/go7007/Kconfig
Normal file
25
drivers/staging/go7007/Kconfig
Normal file
|
@ -0,0 +1,25 @@
|
|||
config VIDEO_GO7007
|
||||
tristate "Go 7007 support"
|
||||
depends on VIDEO_DEV && PCI && I2C && INPUT
|
||||
select VIDEOBUF_DMA_SG
|
||||
select VIDEO_IR
|
||||
select VIDEO_TUNER
|
||||
select VIDEO_TVEEPROM
|
||||
select CRC32
|
||||
default N
|
||||
---help---
|
||||
This is a video4linux driver for some wierd device...
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called go7007
|
||||
|
||||
config VIDEO_GO7007_USB
|
||||
tristate "Go 7007 USB support"
|
||||
depends on VIDEO_GO7007 && USB
|
||||
default N
|
||||
---help---
|
||||
This is a video4linux driver for some wierd device...
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called go7007-usb
|
||||
|
18
drivers/staging/go7007/Makefile
Normal file
18
drivers/staging/go7007/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
#obj-m += go7007.o go7007-usb.o snd-go7007.o wis-saa7115.o wis-tw9903.o \
|
||||
wis-uda1342.o wis-sony-tuner.o wis-saa7113.o wis-ov7640.o \
|
||||
wis-tw2804.o
|
||||
|
||||
|
||||
obj-$(CONFIG_VIDEO_GO7007) += go7007.o
|
||||
obj-$(CONFIG_VIDEO_GO7007_USB) += go7007-usb.o
|
||||
|
||||
go7007-objs += go7007-v4l2.o go7007-driver.o go7007-i2c.o go7007-fw.o snd-go7007.o
|
||||
|
||||
|
||||
#ifneq ($(SAA7134_BUILD),)
|
||||
#obj-m += saa7134-go7007.o
|
||||
#endif
|
||||
|
||||
EXTRA_CFLAGS += -Idrivers/staging/saa7134
|
||||
EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
|
||||
EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
|
11
drivers/staging/go7007/README
Normal file
11
drivers/staging/go7007/README
Normal file
|
@ -0,0 +1,11 @@
|
|||
Todo:
|
||||
- checkpatch.pl cleanups
|
||||
- sparse cleanups
|
||||
- lots of little modules, should be merged together
|
||||
and added to the build.
|
||||
- testing?
|
||||
- handle churn in v4l layer.
|
||||
|
||||
Please send patchs to Greg Kroah-Hartman <greg@kroah.com> and Cc: Ross
|
||||
Cohen <rcohen@snurgle.org> as well.
|
||||
|
688
drivers/staging/go7007/go7007-driver.c
Normal file
688
drivers/staging/go7007/go7007-driver.c
Normal file
|
@ -0,0 +1,688 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <asm/system.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <media/tuner.h>
|
||||
#include <media/v4l2-common.h>
|
||||
|
||||
#include "go7007-priv.h"
|
||||
#include "wis-i2c.h"
|
||||
|
||||
/*
|
||||
* Wait for an interrupt to be delivered from the GO7007SB and return
|
||||
* the associated value and data.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_read_interrupt(struct go7007 *go, u16 *value, u16 *data)
|
||||
{
|
||||
go->interrupt_available = 0;
|
||||
go->hpi_ops->read_interrupt(go);
|
||||
if (wait_event_timeout(go->interrupt_waitq,
|
||||
go->interrupt_available, 5*HZ) < 0) {
|
||||
printk(KERN_ERR "go7007: timeout waiting for read interrupt\n");
|
||||
return -1;
|
||||
}
|
||||
if (!go->interrupt_available)
|
||||
return -1;
|
||||
go->interrupt_available = 0;
|
||||
*value = go->interrupt_value & 0xfffe;
|
||||
*data = go->interrupt_data;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_read_interrupt);
|
||||
|
||||
/*
|
||||
* Read a register/address on the GO7007SB.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_read_addr(struct go7007 *go, u16 addr, u16 *data)
|
||||
{
|
||||
int count = 100;
|
||||
u16 value;
|
||||
|
||||
if (go7007_write_interrupt(go, 0x0010, addr) < 0)
|
||||
return -EIO;
|
||||
while (count-- > 0) {
|
||||
if (go7007_read_interrupt(go, &value, data) == 0 &&
|
||||
value == 0xa000)
|
||||
return 0;
|
||||
}
|
||||
return -EIO;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_read_addr);
|
||||
|
||||
/*
|
||||
* Send the boot firmware to the encoder, which just wakes it up and lets
|
||||
* us talk to the GPIO pins and on-board I2C adapter.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
static int go7007_load_encoder(struct go7007 *go)
|
||||
{
|
||||
const struct firmware *fw_entry;
|
||||
char fw_name[] = "go7007fw.bin";
|
||||
void *bounce;
|
||||
int fw_len, rv = 0;
|
||||
u16 intr_val, intr_data;
|
||||
|
||||
if (request_firmware(&fw_entry, fw_name, go->dev)) {
|
||||
printk(KERN_ERR
|
||||
"go7007: unable to load firmware from file \"%s\"\n",
|
||||
fw_name);
|
||||
return -1;
|
||||
}
|
||||
if (fw_entry->size < 16 || memcmp(fw_entry->data, "WISGO7007FW", 11)) {
|
||||
printk(KERN_ERR "go7007: file \"%s\" does not appear to be "
|
||||
"go7007 firmware\n", fw_name);
|
||||
release_firmware(fw_entry);
|
||||
return -1;
|
||||
}
|
||||
fw_len = fw_entry->size - 16;
|
||||
bounce = kmalloc(fw_len, GFP_KERNEL);
|
||||
if (bounce == NULL) {
|
||||
printk(KERN_ERR "go7007: unable to allocate %d bytes for "
|
||||
"firmware transfer\n", fw_len);
|
||||
release_firmware(fw_entry);
|
||||
return -1;
|
||||
}
|
||||
memcpy(bounce, fw_entry->data + 16, fw_len);
|
||||
release_firmware(fw_entry);
|
||||
if (go7007_interface_reset(go) < 0 ||
|
||||
go7007_send_firmware(go, bounce, fw_len) < 0 ||
|
||||
go7007_read_interrupt(go, &intr_val, &intr_data) < 0 ||
|
||||
(intr_val & ~0x1) != 0x5a5a) {
|
||||
printk(KERN_ERR "go7007: error transferring firmware\n");
|
||||
rv = -1;
|
||||
}
|
||||
kfree(bounce);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Boot the encoder and register the I2C adapter if requested. Do the
|
||||
* minimum initialization necessary, since the board-specific code may
|
||||
* still need to probe the board ID.
|
||||
*
|
||||
* Must NOT be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_boot_encoder(struct go7007 *go, int init_i2c)
|
||||
{
|
||||
int ret;
|
||||
|
||||
down(&go->hw_lock);
|
||||
ret = go7007_load_encoder(go);
|
||||
up(&go->hw_lock);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
if (!init_i2c)
|
||||
return 0;
|
||||
if (go7007_i2c_init(go) < 0)
|
||||
return -1;
|
||||
go->i2c_adapter_online = 1;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_boot_encoder);
|
||||
|
||||
/*
|
||||
* Configure any hardware-related registers in the GO7007, such as GPIO
|
||||
* pins and bus parameters, which are board-specific. This assumes
|
||||
* the boot firmware has already been downloaded.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
static int go7007_init_encoder(struct go7007 *go)
|
||||
{
|
||||
if (go->board_info->audio_flags & GO7007_AUDIO_I2S_MASTER) {
|
||||
go7007_write_addr(go, 0x1000, 0x0811);
|
||||
go7007_write_addr(go, 0x1000, 0x0c11);
|
||||
}
|
||||
if (go->board_id == GO7007_BOARDID_MATRIX_REV) {
|
||||
/* Set GPIO pin 0 to be an output (audio clock control) */
|
||||
go7007_write_addr(go, 0x3c82, 0x0001);
|
||||
go7007_write_addr(go, 0x3c80, 0x00fe);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the boot firmware to the GO7007 and configure the registers. This
|
||||
* is the only way to stop the encoder once it has started streaming video.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_reset_encoder(struct go7007 *go)
|
||||
{
|
||||
if (go7007_load_encoder(go) < 0)
|
||||
return -1;
|
||||
return go7007_init_encoder(go);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to instantiate an I2C client by ID, probably loading a module.
|
||||
*/
|
||||
static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)
|
||||
{
|
||||
char *modname;
|
||||
|
||||
switch (id) {
|
||||
case I2C_DRIVERID_WIS_SAA7115:
|
||||
modname = "wis-saa7115";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_SAA7113:
|
||||
modname = "wis-saa7113";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_UDA1342:
|
||||
modname = "wis-uda1342";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_SONY_TUNER:
|
||||
modname = "wis-sony-tuner";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_TW9903:
|
||||
modname = "wis-tw9903";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_TW2804:
|
||||
modname = "wis-tw2804";
|
||||
break;
|
||||
case I2C_DRIVERID_WIS_OV7640:
|
||||
modname = "wis-ov7640";
|
||||
break;
|
||||
default:
|
||||
modname = NULL;
|
||||
break;
|
||||
}
|
||||
if (modname != NULL)
|
||||
request_module(modname);
|
||||
if (wis_i2c_probe_device(adapter, id, addr) == 1)
|
||||
return 0;
|
||||
if (modname != NULL)
|
||||
printk(KERN_INFO
|
||||
"go7007: probing for module %s failed", modname);
|
||||
else
|
||||
printk(KERN_INFO
|
||||
"go7007: sensor %u seems to be unsupported!\n", id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalize the GO7007 hardware setup, register the on-board I2C adapter
|
||||
* (if used on this board), load the I2C client driver for the sensor
|
||||
* (SAA7115 or whatever) and other devices, and register the ALSA and V4L2
|
||||
* interfaces.
|
||||
*
|
||||
* Must NOT be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_register_encoder(struct go7007 *go)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
printk(KERN_INFO "go7007: registering new %s\n", go->name);
|
||||
|
||||
down(&go->hw_lock);
|
||||
ret = go7007_init_encoder(go);
|
||||
up(&go->hw_lock);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
if (!go->i2c_adapter_online &&
|
||||
go->board_info->flags & GO7007_BOARD_USE_ONBOARD_I2C) {
|
||||
if (go7007_i2c_init(go) < 0)
|
||||
return -1;
|
||||
go->i2c_adapter_online = 1;
|
||||
}
|
||||
if (go->i2c_adapter_online) {
|
||||
for (i = 0; i < go->board_info->num_i2c_devs; ++i)
|
||||
init_i2c_module(&go->i2c_adapter,
|
||||
go->board_info->i2c_devs[i].id,
|
||||
go->board_info->i2c_devs[i].addr);
|
||||
#ifdef TUNER_SET_TYPE_ADDR
|
||||
if (go->tuner_type >= 0) {
|
||||
struct tuner_setup tun_setup = {
|
||||
.mode_mask = T_ANALOG_TV,
|
||||
.addr = ADDR_UNSET,
|
||||
.type = go->tuner_type
|
||||
};
|
||||
i2c_clients_command(&go->i2c_adapter,
|
||||
TUNER_SET_TYPE_ADDR, &tun_setup);
|
||||
}
|
||||
#else
|
||||
if (go->tuner_type >= 0)
|
||||
i2c_clients_command(&go->i2c_adapter,
|
||||
TUNER_SET_TYPE, &go->tuner_type);
|
||||
#endif
|
||||
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
|
||||
i2c_clients_command(&go->i2c_adapter,
|
||||
DECODER_SET_CHANNEL, &go->channel_number);
|
||||
}
|
||||
if (go->board_info->flags & GO7007_BOARD_HAS_AUDIO) {
|
||||
go->audio_enabled = 1;
|
||||
go7007_snd_init(go);
|
||||
}
|
||||
return go7007_v4l2_init(go);
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_register_encoder);
|
||||
|
||||
/*
|
||||
* Send the encode firmware to the encoder, which will cause it
|
||||
* to immediately start delivering the video and audio streams.
|
||||
*
|
||||
* Must be called with the hw_lock held.
|
||||
*/
|
||||
int go7007_start_encoder(struct go7007 *go)
|
||||
{
|
||||
u8 *fw;
|
||||
int fw_len, rv = 0, i;
|
||||
u16 intr_val, intr_data;
|
||||
|
||||
go->modet_enable = 0;
|
||||
if (!go->dvd_mode)
|
||||
for (i = 0; i < 4; ++i) {
|
||||
if (go->modet[i].enable) {
|
||||
go->modet_enable = 1;
|
||||
continue;
|
||||
}
|
||||
go->modet[i].pixel_threshold = 32767;
|
||||
go->modet[i].motion_threshold = 32767;
|
||||
go->modet[i].mb_threshold = 32767;
|
||||
}
|
||||
|
||||
if (go7007_construct_fw_image(go, &fw, &fw_len) < 0)
|
||||
return -1;
|
||||
|
||||
if (go7007_send_firmware(go, fw, fw_len) < 0 ||
|
||||
go7007_read_interrupt(go, &intr_val, &intr_data) < 0) {
|
||||
printk(KERN_ERR "go7007: error transferring firmware\n");
|
||||
rv = -1;
|
||||
goto start_error;
|
||||
}
|
||||
|
||||
go->state = STATE_DATA;
|
||||
go->parse_length = 0;
|
||||
go->seen_frame = 0;
|
||||
if (go7007_stream_start(go) < 0) {
|
||||
printk(KERN_ERR "go7007: error starting stream transfer\n");
|
||||
rv = -1;
|
||||
goto start_error;
|
||||
}
|
||||
|
||||
start_error:
|
||||
kfree(fw);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store a byte in the current video buffer, if there is one.
|
||||
*/
|
||||
static inline void store_byte(struct go7007_buffer *gobuf, u8 byte)
|
||||
{
|
||||
if (gobuf != NULL && gobuf->bytesused < GO7007_BUF_SIZE) {
|
||||
unsigned int pgidx = gobuf->offset >> PAGE_SHIFT;
|
||||
unsigned int pgoff = gobuf->offset & ~PAGE_MASK;
|
||||
|
||||
*((u8 *)page_address(gobuf->pages[pgidx]) + pgoff) = byte;
|
||||
++gobuf->offset;
|
||||
++gobuf->bytesused;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Deliver the last video buffer and get a new one to start writing to.
|
||||
*/
|
||||
static void frame_boundary(struct go7007 *go)
|
||||
{
|
||||
struct go7007_buffer *gobuf;
|
||||
int i;
|
||||
|
||||
if (go->active_buf) {
|
||||
if (go->active_buf->modet_active) {
|
||||
if (go->active_buf->bytesused + 216 < GO7007_BUF_SIZE) {
|
||||
for (i = 0; i < 216; ++i)
|
||||
store_byte(go->active_buf,
|
||||
go->active_map[i]);
|
||||
go->active_buf->bytesused -= 216;
|
||||
} else
|
||||
go->active_buf->modet_active = 0;
|
||||
}
|
||||
go->active_buf->state = BUF_STATE_DONE;
|
||||
wake_up_interruptible(&go->frame_waitq);
|
||||
go->active_buf = NULL;
|
||||
}
|
||||
list_for_each_entry(gobuf, &go->stream, stream)
|
||||
if (gobuf->state == BUF_STATE_QUEUED) {
|
||||
gobuf->seq = go->next_seq;
|
||||
do_gettimeofday(&gobuf->timestamp);
|
||||
go->active_buf = gobuf;
|
||||
break;
|
||||
}
|
||||
++go->next_seq;
|
||||
}
|
||||
|
||||
static void write_bitmap_word(struct go7007 *go)
|
||||
{
|
||||
int x, y, i, stride = ((go->width >> 4) + 7) >> 3;
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
y = (((go->parse_length - 1) << 3) + i) / (go->width >> 4);
|
||||
x = (((go->parse_length - 1) << 3) + i) % (go->width >> 4);
|
||||
go->active_map[stride * y + (x >> 3)] |=
|
||||
(go->modet_word & 1) << (x & 0x7);
|
||||
go->modet_word >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a chunk of the video stream into frames. The frames are not
|
||||
* delimited by the hardware, so we have to parse the frame boundaries
|
||||
* based on the type of video stream we're receiving.
|
||||
*/
|
||||
void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length)
|
||||
{
|
||||
int i, seq_start_code = -1, frame_start_code = -1;
|
||||
|
||||
spin_lock(&go->spinlock);
|
||||
|
||||
switch (go->format) {
|
||||
case GO7007_FORMAT_MPEG4:
|
||||
seq_start_code = 0xB0;
|
||||
frame_start_code = 0xB6;
|
||||
break;
|
||||
case GO7007_FORMAT_MPEG1:
|
||||
case GO7007_FORMAT_MPEG2:
|
||||
seq_start_code = 0xB3;
|
||||
frame_start_code = 0x00;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
if (go->active_buf != NULL &&
|
||||
go->active_buf->bytesused >= GO7007_BUF_SIZE - 3) {
|
||||
printk(KERN_DEBUG "go7007: dropping oversized frame\n");
|
||||
go->active_buf->offset -= go->active_buf->bytesused;
|
||||
go->active_buf->bytesused = 0;
|
||||
go->active_buf->modet_active = 0;
|
||||
go->active_buf = NULL;
|
||||
}
|
||||
|
||||
switch (go->state) {
|
||||
case STATE_DATA:
|
||||
switch (buf[i]) {
|
||||
case 0x00:
|
||||
go->state = STATE_00;
|
||||
break;
|
||||
case 0xFF:
|
||||
go->state = STATE_FF;
|
||||
break;
|
||||
default:
|
||||
store_byte(go->active_buf, buf[i]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case STATE_00:
|
||||
switch (buf[i]) {
|
||||
case 0x00:
|
||||
go->state = STATE_00_00;
|
||||
break;
|
||||
case 0xFF:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
go->state = STATE_FF;
|
||||
break;
|
||||
default:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, buf[i]);
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case STATE_00_00:
|
||||
switch (buf[i]) {
|
||||
case 0x00:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
/* go->state remains STATE_00_00 */
|
||||
break;
|
||||
case 0x01:
|
||||
go->state = STATE_00_00_01;
|
||||
break;
|
||||
case 0xFF:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x00);
|
||||
go->state = STATE_FF;
|
||||
break;
|
||||
default:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, buf[i]);
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case STATE_00_00_01:
|
||||
/* If this is the start of a new MPEG frame,
|
||||
* get a new buffer */
|
||||
if ((go->format == GO7007_FORMAT_MPEG1 ||
|
||||
go->format == GO7007_FORMAT_MPEG2 ||
|
||||
go->format == GO7007_FORMAT_MPEG4) &&
|
||||
(buf[i] == seq_start_code ||
|
||||
buf[i] == 0xB8 || /* GOP code */
|
||||
buf[i] == frame_start_code)) {
|
||||
if (go->active_buf == NULL || go->seen_frame)
|
||||
frame_boundary(go);
|
||||
if (buf[i] == frame_start_code) {
|
||||
if (go->active_buf != NULL)
|
||||
go->active_buf->frame_offset =
|
||||
go->active_buf->offset;
|
||||
go->seen_frame = 1;
|
||||
} else {
|
||||
go->seen_frame = 0;
|
||||
}
|
||||
}
|
||||
/* Handle any special chunk types, or just write the
|
||||
* start code to the (potentially new) buffer */
|
||||
switch (buf[i]) {
|
||||
case 0xF5: /* timestamp */
|
||||
go->parse_length = 12;
|
||||
go->state = STATE_UNPARSED;
|
||||
break;
|
||||
case 0xF6: /* vbi */
|
||||
go->state = STATE_VBI_LEN_A;
|
||||
break;
|
||||
case 0xF8: /* MD map */
|
||||
go->parse_length = 0;
|
||||
memset(go->active_map, 0,
|
||||
sizeof(go->active_map));
|
||||
go->state = STATE_MODET_MAP;
|
||||
break;
|
||||
case 0xFF: /* Potential JPEG start code */
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x01);
|
||||
go->state = STATE_FF;
|
||||
break;
|
||||
default:
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x00);
|
||||
store_byte(go->active_buf, 0x01);
|
||||
store_byte(go->active_buf, buf[i]);
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case STATE_FF:
|
||||
switch (buf[i]) {
|
||||
case 0x00:
|
||||
store_byte(go->active_buf, 0xFF);
|
||||
go->state = STATE_00;
|
||||
break;
|
||||
case 0xFF:
|
||||
store_byte(go->active_buf, 0xFF);
|
||||
/* go->state remains STATE_FF */
|
||||
break;
|
||||
case 0xD8:
|
||||
if (go->format == GO7007_FORMAT_MJPEG)
|
||||
frame_boundary(go);
|
||||
/* fall through */
|
||||
default:
|
||||
store_byte(go->active_buf, 0xFF);
|
||||
store_byte(go->active_buf, buf[i]);
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case STATE_VBI_LEN_A:
|
||||
go->parse_length = buf[i] << 8;
|
||||
go->state = STATE_VBI_LEN_B;
|
||||
break;
|
||||
case STATE_VBI_LEN_B:
|
||||
go->parse_length |= buf[i];
|
||||
if (go->parse_length > 0)
|
||||
go->state = STATE_UNPARSED;
|
||||
else
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
case STATE_MODET_MAP:
|
||||
if (go->parse_length < 204) {
|
||||
if (go->parse_length & 1) {
|
||||
go->modet_word |= buf[i];
|
||||
write_bitmap_word(go);
|
||||
} else
|
||||
go->modet_word = buf[i] << 8;
|
||||
} else if (go->parse_length == 207 && go->active_buf) {
|
||||
go->active_buf->modet_active = buf[i];
|
||||
}
|
||||
if (++go->parse_length == 208)
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
case STATE_UNPARSED:
|
||||
if (--go->parse_length == 0)
|
||||
go->state = STATE_DATA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock(&go->spinlock);
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_parse_video_stream);
|
||||
|
||||
/*
|
||||
* Allocate a new go7007 struct. Used by the hardware-specific probe.
|
||||
*/
|
||||
struct go7007 *go7007_alloc(struct go7007_board_info *board, struct device *dev)
|
||||
{
|
||||
struct go7007 *go;
|
||||
int i;
|
||||
|
||||
go = kmalloc(sizeof(struct go7007), GFP_KERNEL);
|
||||
if (go == NULL)
|
||||
return NULL;
|
||||
go->dev = dev;
|
||||
go->board_info = board;
|
||||
go->board_id = 0;
|
||||
go->tuner_type = -1;
|
||||
go->channel_number = 0;
|
||||
go->name[0] = 0;
|
||||
init_MUTEX(&go->hw_lock);
|
||||
init_waitqueue_head(&go->frame_waitq);
|
||||
spin_lock_init(&go->spinlock);
|
||||
go->video_dev = NULL;
|
||||
go->ref_count = 0;
|
||||
go->status = STATUS_INIT;
|
||||
memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter));
|
||||
go->i2c_adapter_online = 0;
|
||||
go->interrupt_available = 0;
|
||||
init_waitqueue_head(&go->interrupt_waitq);
|
||||
go->in_use = 0;
|
||||
go->input = 0;
|
||||
if (board->sensor_flags & GO7007_SENSOR_TV) {
|
||||
go->standard = GO7007_STD_NTSC;
|
||||
go->width = 720;
|
||||
go->height = 480;
|
||||
go->sensor_framerate = 30000;
|
||||
} else {
|
||||
go->standard = GO7007_STD_OTHER;
|
||||
go->width = board->sensor_width;
|
||||
go->height = board->sensor_height;
|
||||
go->sensor_framerate = board->sensor_framerate;
|
||||
}
|
||||
go->encoder_v_offset = board->sensor_v_offset;
|
||||
go->encoder_h_offset = board->sensor_h_offset;
|
||||
go->encoder_h_halve = 0;
|
||||
go->encoder_v_halve = 0;
|
||||
go->encoder_subsample = 0;
|
||||
go->streaming = 0;
|
||||
go->format = GO7007_FORMAT_MJPEG;
|
||||
go->bitrate = 1500000;
|
||||
go->fps_scale = 1;
|
||||
go->pali = 0;
|
||||
go->aspect_ratio = GO7007_RATIO_1_1;
|
||||
go->gop_size = 0;
|
||||
go->ipb = 0;
|
||||
go->closed_gop = 0;
|
||||
go->repeat_seqhead = 0;
|
||||
go->seq_header_enable = 0;
|
||||
go->gop_header_enable = 0;
|
||||
go->dvd_mode = 0;
|
||||
go->interlace_coding = 0;
|
||||
for (i = 0; i < 4; ++i)
|
||||
go->modet[i].enable = 0;;
|
||||
for (i = 0; i < 1624; ++i)
|
||||
go->modet_map[i] = 0;
|
||||
go->audio_deliver = NULL;
|
||||
go->audio_enabled = 0;
|
||||
INIT_LIST_HEAD(&go->stream);
|
||||
|
||||
return go;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_alloc);
|
||||
|
||||
/*
|
||||
* Detach and unregister the encoder. The go7007 struct won't be freed
|
||||
* until v4l2 finishes releasing its resources and all associated fds are
|
||||
* closed by applications.
|
||||
*/
|
||||
void go7007_remove(struct go7007 *go)
|
||||
{
|
||||
if (go->i2c_adapter_online) {
|
||||
if (i2c_del_adapter(&go->i2c_adapter) == 0)
|
||||
go->i2c_adapter_online = 0;
|
||||
else
|
||||
printk(KERN_ERR
|
||||
"go7007: error removing I2C adapter!\n");
|
||||
}
|
||||
|
||||
if (go->audio_enabled)
|
||||
go7007_snd_remove(go);
|
||||
go7007_v4l2_remove(go);
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_remove);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
1639
drivers/staging/go7007/go7007-fw.c
Normal file
1639
drivers/staging/go7007/go7007-fw.c
Normal file
File diff suppressed because it is too large
Load diff
309
drivers/staging/go7007/go7007-i2c.c
Normal file
309
drivers/staging/go7007/go7007-i2c.c
Normal file
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <asm/system.h>
|
||||
|
||||
#include "go7007-priv.h"
|
||||
#include "wis-i2c.h"
|
||||
|
||||
/************** Registration interface for I2C client drivers **************/
|
||||
|
||||
/* Since there's no way to auto-probe the I2C devices connected to the I2C
|
||||
* bus on the go7007, we have this silly little registration system that
|
||||
* client drivers can use to register their I2C driver ID and their
|
||||
* detect_client function (the one that's normally passed to i2c_probe).
|
||||
*
|
||||
* When a new go7007 device is connected, we can look up in a board info
|
||||
* table by the USB or PCI vendor/product/revision ID to determine
|
||||
* which I2C client module to load. The client driver module will register
|
||||
* itself here, and then we can call the registered detect_client function
|
||||
* to force-load a new client at the address listed in the board info table.
|
||||
*
|
||||
* Really the I2C subsystem should have a way to force-load I2C client
|
||||
* drivers when we have a priori knowledge of what's on the bus, especially
|
||||
* since the existing I2C auto-probe mechanism is so hokey, but we'll use
|
||||
* our own mechanism for the time being. */
|
||||
|
||||
struct wis_i2c_client_driver {
|
||||
unsigned int id;
|
||||
found_proc found_proc;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
static LIST_HEAD(i2c_client_drivers);
|
||||
static DECLARE_MUTEX(i2c_client_driver_list_lock);
|
||||
|
||||
/* Client drivers register here by their I2C driver ID */
|
||||
int wis_i2c_add_driver(unsigned int id, found_proc found_proc)
|
||||
{
|
||||
struct wis_i2c_client_driver *driver;
|
||||
|
||||
driver = kmalloc(sizeof(struct wis_i2c_client_driver), GFP_KERNEL);
|
||||
if (driver == NULL)
|
||||
return -ENOMEM;
|
||||
driver->id = id;
|
||||
driver->found_proc = found_proc;
|
||||
|
||||
down(&i2c_client_driver_list_lock);
|
||||
list_add_tail(&driver->list, &i2c_client_drivers);
|
||||
up(&i2c_client_driver_list_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(wis_i2c_add_driver);
|
||||
|
||||
void wis_i2c_del_driver(found_proc found_proc)
|
||||
{
|
||||
struct wis_i2c_client_driver *driver, *next;
|
||||
|
||||
down(&i2c_client_driver_list_lock);
|
||||
list_for_each_entry_safe(driver, next, &i2c_client_drivers, list)
|
||||
if (driver->found_proc == found_proc) {
|
||||
list_del(&driver->list);
|
||||
kfree(driver);
|
||||
}
|
||||
up(&i2c_client_driver_list_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(wis_i2c_del_driver);
|
||||
|
||||
/* The main go7007 driver calls this to instantiate a client by driver
|
||||
* ID and bus address, which are both stored in the board info table */
|
||||
int wis_i2c_probe_device(struct i2c_adapter *adapter,
|
||||
unsigned int id, int addr)
|
||||
{
|
||||
struct wis_i2c_client_driver *driver;
|
||||
int found = 0;
|
||||
|
||||
if (addr < 0 || addr > 0x7f)
|
||||
return -1;
|
||||
down(&i2c_client_driver_list_lock);
|
||||
list_for_each_entry(driver, &i2c_client_drivers, list)
|
||||
if (driver->id == id) {
|
||||
if (driver->found_proc(adapter, addr, 0) == 0)
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
up(&i2c_client_driver_list_lock);
|
||||
return found;
|
||||
}
|
||||
|
||||
/********************* Driver for on-board I2C adapter *********************/
|
||||
|
||||
/* #define GO7007_I2C_DEBUG */
|
||||
|
||||
#define SPI_I2C_ADDR_BASE 0x1400
|
||||
#define STATUS_REG_ADDR (SPI_I2C_ADDR_BASE + 0x2)
|
||||
#define I2C_CTRL_REG_ADDR (SPI_I2C_ADDR_BASE + 0x6)
|
||||
#define I2C_DEV_UP_ADDR_REG_ADDR (SPI_I2C_ADDR_BASE + 0x7)
|
||||
#define I2C_LO_ADDR_REG_ADDR (SPI_I2C_ADDR_BASE + 0x8)
|
||||
#define I2C_DATA_REG_ADDR (SPI_I2C_ADDR_BASE + 0x9)
|
||||
#define I2C_CLKFREQ_REG_ADDR (SPI_I2C_ADDR_BASE + 0xa)
|
||||
|
||||
#define I2C_STATE_MASK 0x0007
|
||||
#define I2C_READ_READY_MASK 0x0008
|
||||
|
||||
/* There is only one I2C port on the TW2804 that feeds all four GO7007 VIPs
|
||||
* on the Adlink PCI-MPG24, so access is shared between all of them. */
|
||||
static DECLARE_MUTEX(adlink_mpg24_i2c_lock);
|
||||
|
||||
static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
|
||||
u16 command, int flags, u8 *data)
|
||||
{
|
||||
int i, ret = -1;
|
||||
u16 val;
|
||||
|
||||
if (go->status == STATUS_SHUTDOWN)
|
||||
return -1;
|
||||
|
||||
#ifdef GO7007_I2C_DEBUG
|
||||
if (read)
|
||||
printk(KERN_DEBUG "go7007-i2c: reading 0x%02x on 0x%02x\n",
|
||||
command, addr);
|
||||
else
|
||||
printk(KERN_DEBUG
|
||||
"go7007-i2c: writing 0x%02x to 0x%02x on 0x%02x\n",
|
||||
*data, command, addr);
|
||||
#endif
|
||||
|
||||
down(&go->hw_lock);
|
||||
|
||||
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
|
||||
/* Bridge the I2C port on this GO7007 to the shared bus */
|
||||
down(&adlink_mpg24_i2c_lock);
|
||||
go7007_write_addr(go, 0x3c82, 0x0020);
|
||||
}
|
||||
|
||||
/* Wait for I2C adapter to be ready */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
if (go7007_read_addr(go, STATUS_REG_ADDR, &val) < 0)
|
||||
goto i2c_done;
|
||||
if (!(val & I2C_STATE_MASK))
|
||||
break;
|
||||
msleep(100);
|
||||
}
|
||||
if (i == 10) {
|
||||
printk(KERN_ERR "go7007-i2c: I2C adapter is hung\n");
|
||||
goto i2c_done;
|
||||
}
|
||||
|
||||
/* Set target register (command) */
|
||||
go7007_write_addr(go, I2C_CTRL_REG_ADDR, flags);
|
||||
go7007_write_addr(go, I2C_LO_ADDR_REG_ADDR, command);
|
||||
|
||||
/* If we're writing, send the data and target address and we're done */
|
||||
if (!read) {
|
||||
go7007_write_addr(go, I2C_DATA_REG_ADDR, *data);
|
||||
go7007_write_addr(go, I2C_DEV_UP_ADDR_REG_ADDR,
|
||||
(addr << 9) | (command >> 8));
|
||||
ret = 0;
|
||||
goto i2c_done;
|
||||
}
|
||||
|
||||
/* Otherwise, we're reading. First clear i2c_rx_data_rdy. */
|
||||
if (go7007_read_addr(go, I2C_DATA_REG_ADDR, &val) < 0)
|
||||
goto i2c_done;
|
||||
|
||||
/* Send the target address plus read flag */
|
||||
go7007_write_addr(go, I2C_DEV_UP_ADDR_REG_ADDR,
|
||||
(addr << 9) | 0x0100 | (command >> 8));
|
||||
|
||||
/* Wait for i2c_rx_data_rdy */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
if (go7007_read_addr(go, STATUS_REG_ADDR, &val) < 0)
|
||||
goto i2c_done;
|
||||
if (val & I2C_READ_READY_MASK)
|
||||
break;
|
||||
msleep(100);
|
||||
}
|
||||
if (i == 10) {
|
||||
printk(KERN_ERR "go7007-i2c: I2C adapter is hung\n");
|
||||
goto i2c_done;
|
||||
}
|
||||
|
||||
/* Retrieve the read byte */
|
||||
if (go7007_read_addr(go, I2C_DATA_REG_ADDR, &val) < 0)
|
||||
goto i2c_done;
|
||||
*data = val;
|
||||
ret = 0;
|
||||
|
||||
i2c_done:
|
||||
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
|
||||
/* Isolate the I2C port on this GO7007 from the shared bus */
|
||||
go7007_write_addr(go, 0x3c82, 0x0000);
|
||||
up(&adlink_mpg24_i2c_lock);
|
||||
}
|
||||
up(&go->hw_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int go7007_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data *data)
|
||||
{
|
||||
struct go7007 *go = i2c_get_adapdata(adapter);
|
||||
|
||||
if (size != I2C_SMBUS_BYTE_DATA)
|
||||
return -1;
|
||||
return go7007_i2c_xfer(go, addr, read_write == I2C_SMBUS_READ, command,
|
||||
flags & I2C_CLIENT_SCCB ? 0x10 : 0x00, &data->byte);
|
||||
}
|
||||
|
||||
/* VERY LIMITED I2C master xfer function -- only needed because the
|
||||
* SMBus functions only support 8-bit commands and the SAA7135 uses
|
||||
* 16-bit commands. The I2C interface on the GO7007, as limited as
|
||||
* it is, does support this mode. */
|
||||
|
||||
static int go7007_i2c_master_xfer(struct i2c_adapter *adapter,
|
||||
struct i2c_msg msgs[], int num)
|
||||
{
|
||||
struct go7007 *go = i2c_get_adapdata(adapter);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
/* We can only do two things here -- write three bytes, or
|
||||
* write two bytes and read one byte. */
|
||||
if (msgs[i].len == 2) {
|
||||
if (i + 1 == num || msgs[i].addr != msgs[i + 1].addr ||
|
||||
(msgs[i].flags & I2C_M_RD) ||
|
||||
!(msgs[i + 1].flags & I2C_M_RD) ||
|
||||
msgs[i + 1].len != 1)
|
||||
return -1;
|
||||
if (go7007_i2c_xfer(go, msgs[i].addr, 1,
|
||||
(msgs[i].buf[0] << 8) | msgs[i].buf[1],
|
||||
0x01, &msgs[i + 1].buf[0]) < 0)
|
||||
return -1;
|
||||
++i;
|
||||
} else if (msgs[i].len == 3) {
|
||||
if (msgs[i].flags & I2C_M_RD)
|
||||
return -1;
|
||||
if (msgs[i].len != 3)
|
||||
return -1;
|
||||
if (go7007_i2c_xfer(go, msgs[i].addr, 0,
|
||||
(msgs[i].buf[0] << 8) | msgs[i].buf[1],
|
||||
0x01, &msgs[i].buf[2]) < 0)
|
||||
return -1;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 go7007_functionality(struct i2c_adapter *adapter)
|
||||
{
|
||||
return I2C_FUNC_SMBUS_BYTE_DATA;
|
||||
}
|
||||
|
||||
static struct i2c_algorithm go7007_algo = {
|
||||
.smbus_xfer = go7007_smbus_xfer,
|
||||
.master_xfer = go7007_i2c_master_xfer,
|
||||
.functionality = go7007_functionality,
|
||||
};
|
||||
|
||||
static struct i2c_adapter go7007_adap_templ = {
|
||||
.owner = THIS_MODULE,
|
||||
.class = I2C_CLASS_TV_ANALOG,
|
||||
.name = "WIS GO7007SB",
|
||||
.id = I2C_ALGO_GO7007,
|
||||
.algo = &go7007_algo,
|
||||
};
|
||||
|
||||
int go7007_i2c_init(struct go7007 *go)
|
||||
{
|
||||
memcpy(&go->i2c_adapter, &go7007_adap_templ,
|
||||
sizeof(go7007_adap_templ));
|
||||
go->i2c_adapter.dev.parent = go->dev;
|
||||
i2c_set_adapdata(&go->i2c_adapter, go);
|
||||
if (i2c_add_adapter(&go->i2c_adapter) < 0) {
|
||||
printk(KERN_ERR
|
||||
"go7007-i2c: error: i2c_add_adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
279
drivers/staging/go7007/go7007-priv.h
Normal file
279
drivers/staging/go7007/go7007-priv.h
Normal file
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the private include file for the go7007 driver. It should not
|
||||
* be included by anybody but the driver itself, and especially not by
|
||||
* user-space applications.
|
||||
*/
|
||||
|
||||
struct go7007;
|
||||
|
||||
/* IDs to activate board-specific support code */
|
||||
#define GO7007_BOARDID_MATRIX_II 0
|
||||
#define GO7007_BOARDID_MATRIX_RELOAD 1
|
||||
#define GO7007_BOARDID_STAR_TREK 2
|
||||
#define GO7007_BOARDID_PCI_VOYAGER 3
|
||||
#define GO7007_BOARDID_XMEN 4
|
||||
#define GO7007_BOARDID_XMEN_II 5
|
||||
#define GO7007_BOARDID_XMEN_III 6
|
||||
#define GO7007_BOARDID_MATRIX_REV 7
|
||||
#define GO7007_BOARDID_PX_M402U 16
|
||||
#define GO7007_BOARDID_PX_TV402U_ANY 17 /* need to check tuner model */
|
||||
#define GO7007_BOARDID_PX_TV402U_NA 18 /* detected NTSC tuner */
|
||||
#define GO7007_BOARDID_PX_TV402U_EU 19 /* detected PAL tuner */
|
||||
#define GO7007_BOARDID_PX_TV402U_JP 20 /* detected NTSC-J tuner */
|
||||
#define GO7007_BOARDID_LIFEVIEW_LR192 21 /* TV Walker Ultra */
|
||||
#define GO7007_BOARDID_ENDURA 22
|
||||
#define GO7007_BOARDID_ADLINK_MPG24 23
|
||||
|
||||
/* Various characteristics of each board */
|
||||
#define GO7007_BOARD_HAS_AUDIO (1<<0)
|
||||
#define GO7007_BOARD_USE_ONBOARD_I2C (1<<1)
|
||||
#define GO7007_BOARD_HAS_TUNER (1<<2)
|
||||
|
||||
/* Characteristics of sensor devices */
|
||||
#define GO7007_SENSOR_VALID_POLAR (1<<0)
|
||||
#define GO7007_SENSOR_HREF_POLAR (1<<1)
|
||||
#define GO7007_SENSOR_VREF_POLAR (1<<2)
|
||||
#define GO7007_SENSOR_FIELD_ID_POLAR (1<<3)
|
||||
#define GO7007_SENSOR_BIT_WIDTH (1<<4)
|
||||
#define GO7007_SENSOR_VALID_ENABLE (1<<5)
|
||||
#define GO7007_SENSOR_656 (1<<6)
|
||||
#define GO7007_SENSOR_CONFIG_MASK 0x7f
|
||||
#define GO7007_SENSOR_TV (1<<7)
|
||||
#define GO7007_SENSOR_VBI (1<<8)
|
||||
#define GO7007_SENSOR_SCALING (1<<9)
|
||||
|
||||
/* Characteristics of audio sensor devices */
|
||||
#define GO7007_AUDIO_I2S_MODE_1 (1)
|
||||
#define GO7007_AUDIO_I2S_MODE_2 (2)
|
||||
#define GO7007_AUDIO_I2S_MODE_3 (3)
|
||||
#define GO7007_AUDIO_BCLK_POLAR (1<<2)
|
||||
#define GO7007_AUDIO_WORD_14 (14<<4)
|
||||
#define GO7007_AUDIO_WORD_16 (16<<4)
|
||||
#define GO7007_AUDIO_ONE_CHANNEL (1<<11)
|
||||
#define GO7007_AUDIO_I2S_MASTER (1<<16)
|
||||
#define GO7007_AUDIO_OKI_MODE (1<<17)
|
||||
|
||||
struct go7007_board_info {
|
||||
char *firmware;
|
||||
unsigned int flags;
|
||||
int hpi_buffer_cap;
|
||||
unsigned int sensor_flags;
|
||||
int sensor_width;
|
||||
int sensor_height;
|
||||
int sensor_framerate;
|
||||
int sensor_h_offset;
|
||||
int sensor_v_offset;
|
||||
unsigned int audio_flags;
|
||||
int audio_rate;
|
||||
int audio_bclk_div;
|
||||
int audio_main_div;
|
||||
int num_i2c_devs;
|
||||
struct {
|
||||
int id;
|
||||
int addr;
|
||||
} i2c_devs[4];
|
||||
int num_inputs;
|
||||
struct {
|
||||
int video_input;
|
||||
int audio_input;
|
||||
char *name;
|
||||
} inputs[4];
|
||||
};
|
||||
|
||||
struct go7007_hpi_ops {
|
||||
int (*interface_reset)(struct go7007 *go);
|
||||
int (*write_interrupt)(struct go7007 *go, int addr, int data);
|
||||
int (*read_interrupt)(struct go7007 *go);
|
||||
int (*stream_start)(struct go7007 *go);
|
||||
int (*stream_stop)(struct go7007 *go);
|
||||
int (*send_firmware)(struct go7007 *go, u8 *data, int len);
|
||||
};
|
||||
|
||||
/* The video buffer size must be a multiple of PAGE_SIZE */
|
||||
#define GO7007_BUF_PAGES (128 * 1024 / PAGE_SIZE)
|
||||
#define GO7007_BUF_SIZE (GO7007_BUF_PAGES << PAGE_SHIFT)
|
||||
|
||||
struct go7007_buffer {
|
||||
struct go7007 *go; /* Reverse reference for VMA ops */
|
||||
int index; /* Reverse reference for DQBUF */
|
||||
enum { BUF_STATE_IDLE, BUF_STATE_QUEUED, BUF_STATE_DONE } state;
|
||||
u32 seq;
|
||||
struct timeval timestamp;
|
||||
struct list_head stream;
|
||||
struct page *pages[GO7007_BUF_PAGES + 1]; /* extra for straddling */
|
||||
unsigned long user_addr;
|
||||
unsigned int page_count;
|
||||
unsigned int offset;
|
||||
unsigned int bytesused;
|
||||
unsigned int frame_offset;
|
||||
u32 modet_active;
|
||||
int mapped;
|
||||
};
|
||||
|
||||
struct go7007_file {
|
||||
struct go7007 *go;
|
||||
struct semaphore lock;
|
||||
int buf_count;
|
||||
struct go7007_buffer *bufs;
|
||||
};
|
||||
|
||||
#define GO7007_FORMAT_MJPEG 0
|
||||
#define GO7007_FORMAT_MPEG4 1
|
||||
#define GO7007_FORMAT_MPEG1 2
|
||||
#define GO7007_FORMAT_MPEG2 3
|
||||
#define GO7007_FORMAT_H263 4
|
||||
|
||||
#define GO7007_RATIO_1_1 0
|
||||
#define GO7007_RATIO_4_3 1
|
||||
#define GO7007_RATIO_16_9 2
|
||||
|
||||
enum go7007_parser_state {
|
||||
STATE_DATA,
|
||||
STATE_00,
|
||||
STATE_00_00,
|
||||
STATE_00_00_01,
|
||||
STATE_FF,
|
||||
STATE_VBI_LEN_A,
|
||||
STATE_VBI_LEN_B,
|
||||
STATE_MODET_MAP,
|
||||
STATE_UNPARSED,
|
||||
};
|
||||
|
||||
struct go7007 {
|
||||
struct device *dev;
|
||||
struct go7007_board_info *board_info;
|
||||
unsigned int board_id;
|
||||
int tuner_type;
|
||||
int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
|
||||
char name[64];
|
||||
struct video_device *video_dev;
|
||||
int ref_count;
|
||||
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
|
||||
spinlock_t spinlock;
|
||||
struct semaphore hw_lock;
|
||||
int streaming;
|
||||
int in_use;
|
||||
int audio_enabled;
|
||||
|
||||
/* Video input */
|
||||
int input;
|
||||
enum { GO7007_STD_NTSC, GO7007_STD_PAL, GO7007_STD_OTHER } standard;
|
||||
int sensor_framerate;
|
||||
int width;
|
||||
int height;
|
||||
int encoder_h_offset;
|
||||
int encoder_v_offset;
|
||||
unsigned int encoder_h_halve:1;
|
||||
unsigned int encoder_v_halve:1;
|
||||
unsigned int encoder_subsample:1;
|
||||
|
||||
/* Encoder config */
|
||||
int format;
|
||||
int bitrate;
|
||||
int fps_scale;
|
||||
int pali;
|
||||
int aspect_ratio;
|
||||
int gop_size;
|
||||
unsigned int ipb:1;
|
||||
unsigned int closed_gop:1;
|
||||
unsigned int repeat_seqhead:1;
|
||||
unsigned int seq_header_enable:1;
|
||||
unsigned int gop_header_enable:1;
|
||||
unsigned int dvd_mode:1;
|
||||
unsigned int interlace_coding:1;
|
||||
|
||||
/* Motion detection */
|
||||
unsigned int modet_enable:1;
|
||||
struct {
|
||||
unsigned int enable:1;
|
||||
int pixel_threshold;
|
||||
int motion_threshold;
|
||||
int mb_threshold;
|
||||
} modet[4];
|
||||
unsigned char modet_map[1624];
|
||||
unsigned char active_map[216];
|
||||
|
||||
/* Video streaming */
|
||||
struct go7007_buffer *active_buf;
|
||||
enum go7007_parser_state state;
|
||||
int parse_length;
|
||||
u16 modet_word;
|
||||
int seen_frame;
|
||||
u32 next_seq;
|
||||
struct list_head stream;
|
||||
wait_queue_head_t frame_waitq;
|
||||
|
||||
/* Audio streaming */
|
||||
void (*audio_deliver)(struct go7007 *go, u8 *buf, int length);
|
||||
void *snd_context;
|
||||
|
||||
/* I2C */
|
||||
int i2c_adapter_online;
|
||||
struct i2c_adapter i2c_adapter;
|
||||
|
||||
/* HPI driver */
|
||||
struct go7007_hpi_ops *hpi_ops;
|
||||
void *hpi_context;
|
||||
int interrupt_available;
|
||||
wait_queue_head_t interrupt_waitq;
|
||||
unsigned short interrupt_value;
|
||||
unsigned short interrupt_data;
|
||||
};
|
||||
|
||||
/* All of these must be called with the hpi_lock semaphore held! */
|
||||
#define go7007_interface_reset(go) \
|
||||
((go)->hpi_ops->interface_reset(go))
|
||||
#define go7007_write_interrupt(go, x, y) \
|
||||
((go)->hpi_ops->write_interrupt)((go), (x), (y))
|
||||
#define go7007_stream_start(go) \
|
||||
((go)->hpi_ops->stream_start(go))
|
||||
#define go7007_stream_stop(go) \
|
||||
((go)->hpi_ops->stream_stop(go))
|
||||
#define go7007_send_firmware(go, x, y) \
|
||||
((go)->hpi_ops->send_firmware)((go), (x), (y))
|
||||
#define go7007_write_addr(go, x, y) \
|
||||
((go)->hpi_ops->write_interrupt)((go), (x)|0x8000, (y))
|
||||
|
||||
/* go7007-driver.c */
|
||||
int go7007_read_addr(struct go7007 *go, u16 addr, u16 *data);
|
||||
int go7007_read_interrupt(struct go7007 *go, u16 *value, u16 *data);
|
||||
int go7007_boot_encoder(struct go7007 *go, int init_i2c);
|
||||
int go7007_reset_encoder(struct go7007 *go);
|
||||
int go7007_register_encoder(struct go7007 *go);
|
||||
int go7007_start_encoder(struct go7007 *go);
|
||||
void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length);
|
||||
struct go7007 *go7007_alloc(struct go7007_board_info *board,
|
||||
struct device *dev);
|
||||
void go7007_remove(struct go7007 *go);
|
||||
|
||||
/* go7007-fw.c */
|
||||
int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen);
|
||||
|
||||
/* go7007-i2c.c */
|
||||
int go7007_i2c_init(struct go7007 *go);
|
||||
int go7007_i2c_remove(struct go7007 *go);
|
||||
|
||||
/* go7007-v4l2.c */
|
||||
int go7007_v4l2_init(struct go7007 *go);
|
||||
void go7007_v4l2_remove(struct go7007 *go);
|
||||
|
||||
/* snd-go7007.c */
|
||||
int go7007_snd_init(struct go7007 *go);
|
||||
int go7007_snd_remove(struct go7007 *go);
|
1229
drivers/staging/go7007/go7007-usb.c
Normal file
1229
drivers/staging/go7007/go7007-usb.c
Normal file
File diff suppressed because it is too large
Load diff
1503
drivers/staging/go7007/go7007-v4l2.c
Normal file
1503
drivers/staging/go7007/go7007-v4l2.c
Normal file
File diff suppressed because it is too large
Load diff
114
drivers/staging/go7007/go7007.h
Normal file
114
drivers/staging/go7007/go7007.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2005-2006 Micronas USA Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and the associated README documentation file (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* DEPRECATED -- use V4L2_PIX_FMT_MPEG and then call GO7007IOC_S_MPEG_PARAMS
|
||||
* to select between MPEG1, MPEG2, and MPEG4 */
|
||||
#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG4 */
|
||||
|
||||
/* These will be replaced with a better interface
|
||||
* soon, so don't get too attached to them */
|
||||
#define GO7007IOC_S_BITRATE _IOW('V', BASE_VIDIOC_PRIVATE + 0, int)
|
||||
#define GO7007IOC_G_BITRATE _IOR('V', BASE_VIDIOC_PRIVATE + 1, int)
|
||||
|
||||
enum go7007_aspect_ratio {
|
||||
GO7007_ASPECT_RATIO_1_1 = 0,
|
||||
GO7007_ASPECT_RATIO_4_3_NTSC = 1,
|
||||
GO7007_ASPECT_RATIO_4_3_PAL = 2,
|
||||
GO7007_ASPECT_RATIO_16_9_NTSC = 3,
|
||||
GO7007_ASPECT_RATIO_16_9_PAL = 4,
|
||||
};
|
||||
|
||||
/* Used to set generic compression parameters */
|
||||
struct go7007_comp_params {
|
||||
__u32 gop_size;
|
||||
__u32 max_b_frames;
|
||||
enum go7007_aspect_ratio aspect_ratio;
|
||||
__u32 flags;
|
||||
__u32 reserved[8];
|
||||
};
|
||||
|
||||
#define GO7007_COMP_CLOSED_GOP 0x00000001
|
||||
#define GO7007_COMP_OMIT_SEQ_HEADER 0x00000002
|
||||
|
||||
enum go7007_mpeg_video_standard {
|
||||
GO7007_MPEG_VIDEO_MPEG1 = 0,
|
||||
GO7007_MPEG_VIDEO_MPEG2 = 1,
|
||||
GO7007_MPEG_VIDEO_MPEG4 = 2,
|
||||
};
|
||||
|
||||
/* Used to set parameters for V4L2_PIX_FMT_MPEG format */
|
||||
struct go7007_mpeg_params {
|
||||
enum go7007_mpeg_video_standard mpeg_video_standard;
|
||||
__u32 flags;
|
||||
__u32 pali;
|
||||
__u32 reserved[8];
|
||||
};
|
||||
|
||||
#define GO7007_MPEG_FORCE_DVD_MODE 0x00000001
|
||||
#define GO7007_MPEG_OMIT_GOP_HEADER 0x00000002
|
||||
#define GO7007_MPEG_REPEAT_SEQHEADER 0x00000004
|
||||
|
||||
#define GO7007_MPEG_PROFILE(format, pali) (((format)<<24)|(pali))
|
||||
|
||||
#define GO7007_MPEG2_PROFILE_MAIN_MAIN GO7007_MPEG_PROFILE(2, 0x48)
|
||||
|
||||
#define GO7007_MPEG4_PROFILE_S_L0 GO7007_MPEG_PROFILE(4, 0x08)
|
||||
#define GO7007_MPEG4_PROFILE_S_L1 GO7007_MPEG_PROFILE(4, 0x01)
|
||||
#define GO7007_MPEG4_PROFILE_S_L2 GO7007_MPEG_PROFILE(4, 0x02)
|
||||
#define GO7007_MPEG4_PROFILE_S_L3 GO7007_MPEG_PROFILE(4, 0x03)
|
||||
#define GO7007_MPEG4_PROFILE_ARTS_L1 GO7007_MPEG_PROFILE(4, 0x91)
|
||||
#define GO7007_MPEG4_PROFILE_ARTS_L2 GO7007_MPEG_PROFILE(4, 0x92)
|
||||
#define GO7007_MPEG4_PROFILE_ARTS_L3 GO7007_MPEG_PROFILE(4, 0x93)
|
||||
#define GO7007_MPEG4_PROFILE_ARTS_L4 GO7007_MPEG_PROFILE(4, 0x94)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L0 GO7007_MPEG_PROFILE(4, 0xf0)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L1 GO7007_MPEG_PROFILE(4, 0xf1)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L2 GO7007_MPEG_PROFILE(4, 0xf2)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L3 GO7007_MPEG_PROFILE(4, 0xf3)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L4 GO7007_MPEG_PROFILE(4, 0xf4)
|
||||
#define GO7007_MPEG4_PROFILE_AS_L5 GO7007_MPEG_PROFILE(4, 0xf5)
|
||||
|
||||
struct go7007_md_params {
|
||||
__u16 region;
|
||||
__u16 trigger;
|
||||
__u16 pixel_threshold;
|
||||
__u16 motion_threshold;
|
||||
__u32 reserved[8];
|
||||
};
|
||||
|
||||
struct go7007_md_region {
|
||||
__u16 region;
|
||||
__u16 flags;
|
||||
struct v4l2_clip *clips;
|
||||
__u32 reserved[8];
|
||||
};
|
||||
|
||||
#define GO7007IOC_S_MPEG_PARAMS _IOWR('V', BASE_VIDIOC_PRIVATE + 2, \
|
||||
struct go7007_mpeg_params)
|
||||
#define GO7007IOC_G_MPEG_PARAMS _IOR('V', BASE_VIDIOC_PRIVATE + 3, \
|
||||
struct go7007_mpeg_params)
|
||||
#define GO7007IOC_S_COMP_PARAMS _IOWR('V', BASE_VIDIOC_PRIVATE + 4, \
|
||||
struct go7007_comp_params)
|
||||
#define GO7007IOC_G_COMP_PARAMS _IOR('V', BASE_VIDIOC_PRIVATE + 5, \
|
||||
struct go7007_comp_params)
|
||||
#define GO7007IOC_S_MD_PARAMS _IOWR('V', BASE_VIDIOC_PRIVATE + 6, \
|
||||
struct go7007_md_params)
|
||||
#define GO7007IOC_G_MD_PARAMS _IOR('V', BASE_VIDIOC_PRIVATE + 7, \
|
||||
struct go7007_md_params)
|
||||
#define GO7007IOC_S_MD_REGION _IOW('V', BASE_VIDIOC_PRIVATE + 8, \
|
||||
struct go7007_md_region)
|
484
drivers/staging/go7007/saa7134-go7007.c
Normal file
484
drivers/staging/go7007/saa7134-go7007.c
Normal file
|
@ -0,0 +1,484 @@
|
|||
/*
|
||||
* 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/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <media/audiochip.h>
|
||||
|
||||
#include "saa7134-reg.h"
|
||||
#include "saa7134.h"
|
||||
#include "go7007-priv.h"
|
||||
|
||||
#define GO7007_HPI_DEBUG
|
||||
|
||||
enum hpi_address {
|
||||
HPI_ADDR_VIDEO_BUFFER = 0xe4,
|
||||
HPI_ADDR_INIT_BUFFER = 0xea,
|
||||
HPI_ADDR_INTR_RET_VALUE = 0xee,
|
||||
HPI_ADDR_INTR_RET_DATA = 0xec,
|
||||
HPI_ADDR_INTR_STATUS = 0xf4,
|
||||
HPI_ADDR_INTR_WR_PARAM = 0xf6,
|
||||
HPI_ADDR_INTR_WR_INDEX = 0xf8,
|
||||
};
|
||||
|
||||
enum gpio_command {
|
||||
GPIO_COMMAND_RESET = 0x00, /* 000b */
|
||||
GPIO_COMMAND_REQ1 = 0x04, /* 001b */
|
||||
GPIO_COMMAND_WRITE = 0x20, /* 010b */
|
||||
GPIO_COMMAND_REQ2 = 0x24, /* 011b */
|
||||
GPIO_COMMAND_READ = 0x80, /* 100b */
|
||||
GPIO_COMMAND_VIDEO = 0x84, /* 101b */
|
||||
GPIO_COMMAND_IDLE = 0xA0, /* 110b */
|
||||
GPIO_COMMAND_ADDR = 0xA4, /* 111b */
|
||||
};
|
||||
|
||||
struct saa7134_go7007 {
|
||||
struct saa7134_dev *dev;
|
||||
u8 *top;
|
||||
u8 *bottom;
|
||||
dma_addr_t top_dma;
|
||||
dma_addr_t bottom_dma;
|
||||
};
|
||||
|
||||
static struct go7007_board_info board_voyager = {
|
||||
.firmware = "go7007tv.bin",
|
||||
.flags = 0,
|
||||
.sensor_flags = GO7007_SENSOR_656 |
|
||||
GO7007_SENSOR_VALID_ENABLE |
|
||||
GO7007_SENSOR_TV |
|
||||
GO7007_SENSOR_VBI,
|
||||
.audio_flags = GO7007_AUDIO_I2S_MODE_1 |
|
||||
GO7007_AUDIO_WORD_16,
|
||||
.audio_rate = 48000,
|
||||
.audio_bclk_div = 8,
|
||||
.audio_main_div = 2,
|
||||
.hpi_buffer_cap = 7,
|
||||
.num_inputs = 1,
|
||||
.inputs = {
|
||||
{
|
||||
.name = "SAA7134",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/********************* Driver for GPIO HPI interface *********************/
|
||||
|
||||
static int gpio_write(struct saa7134_dev *dev, u8 addr, u16 data)
|
||||
{
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0xff);
|
||||
|
||||
/* Write HPI address */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, addr);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_ADDR);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
/* Write low byte */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, data & 0xff);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_WRITE);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
/* Write high byte */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, data >> 8);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_WRITE);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_read(struct saa7134_dev *dev, u8 addr, u16 *data)
|
||||
{
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0xff);
|
||||
|
||||
/* Write HPI address */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, addr);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_ADDR);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0x00);
|
||||
|
||||
/* Read low byte */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_READ);
|
||||
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
*data = saa_readb(SAA7134_GPIO_GPSTATUS0);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
/* Read high byte */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_READ);
|
||||
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
*data |= saa_readb(SAA7134_GPIO_GPSTATUS0) << 8;
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_interface_reset(struct go7007 *go)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
u32 status;
|
||||
u16 intr_val, intr_data;
|
||||
int count = 20;
|
||||
|
||||
saa_clearb(SAA7134_TS_PARALLEL, 0x80); /* Disable TS interface */
|
||||
saa_writeb(SAA7134_GPIO_GPMODE2, 0xa4);
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0xff);
|
||||
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_REQ1);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_RESET);
|
||||
msleep(1);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_REQ1);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_REQ2);
|
||||
msleep(10);
|
||||
|
||||
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
|
||||
status = saa_readb(SAA7134_GPIO_GPSTATUS2);
|
||||
/*printk(KERN_DEBUG "status is %s\n", status & 0x40 ? "OK" : "not OK"); */
|
||||
|
||||
/* enter command mode...(?) */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_REQ1);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_REQ2);
|
||||
|
||||
do {
|
||||
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
||||
status = saa_readb(SAA7134_GPIO_GPSTATUS2);
|
||||
/*printk(KERN_INFO "gpio is %08x\n", saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2)); */
|
||||
} while (--count > 0);
|
||||
|
||||
/* Wait for an interrupt to indicate successful hardware reset */
|
||||
if (go7007_read_interrupt(go, &intr_val, &intr_data) < 0 ||
|
||||
(intr_val & ~0x1) != 0x55aa) {
|
||||
printk(KERN_ERR
|
||||
"saa7134-go7007: unable to reset the GO7007\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_write_interrupt(struct go7007 *go, int addr, int data)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
int i;
|
||||
u16 status_reg;
|
||||
|
||||
#ifdef GO7007_HPI_DEBUG
|
||||
printk(KERN_DEBUG
|
||||
"saa7134-go7007: WriteInterrupt: %04x %04x\n", addr, data);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 100; ++i) {
|
||||
gpio_read(dev, HPI_ADDR_INTR_STATUS, &status_reg);
|
||||
if (!(status_reg & 0x0010))
|
||||
break;
|
||||
msleep(10);
|
||||
}
|
||||
if (i == 100) {
|
||||
printk(KERN_ERR
|
||||
"saa7134-go7007: device is hung, status reg = 0x%04x\n",
|
||||
status_reg);
|
||||
return -1;
|
||||
}
|
||||
gpio_write(dev, HPI_ADDR_INTR_WR_PARAM, data);
|
||||
gpio_write(dev, HPI_ADDR_INTR_WR_INDEX, addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_read_interrupt(struct go7007 *go)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
|
||||
/* XXX we need to wait if there is no interrupt available */
|
||||
go->interrupt_available = 1;
|
||||
gpio_read(dev, HPI_ADDR_INTR_RET_VALUE, &go->interrupt_value);
|
||||
gpio_read(dev, HPI_ADDR_INTR_RET_DATA, &go->interrupt_data);
|
||||
#ifdef GO7007_HPI_DEBUG
|
||||
printk(KERN_DEBUG "saa7134-go7007: ReadInterrupt: %04x %04x\n",
|
||||
go->interrupt_value, go->interrupt_data);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void saa7134_go7007_irq_ts_done(struct saa7134_dev *dev,
|
||||
unsigned long status)
|
||||
{
|
||||
struct go7007 *go = video_get_drvdata(dev->empress_dev);
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
|
||||
if (!go->streaming)
|
||||
return;
|
||||
if (0 != (status & 0x000f0000))
|
||||
printk(KERN_DEBUG "saa7134-go7007: irq: lost %ld\n",
|
||||
(status >> 16) & 0x0f);
|
||||
if (status & 0x100000) {
|
||||
dma_sync_single(&dev->pci->dev,
|
||||
saa->bottom_dma, PAGE_SIZE, DMA_FROM_DEVICE);
|
||||
go7007_parse_video_stream(go, saa->bottom, PAGE_SIZE);
|
||||
saa_writel(SAA7134_RS_BA2(5), cpu_to_le32(saa->bottom_dma));
|
||||
} else {
|
||||
dma_sync_single(&dev->pci->dev,
|
||||
saa->top_dma, PAGE_SIZE, DMA_FROM_DEVICE);
|
||||
go7007_parse_video_stream(go, saa->top, PAGE_SIZE);
|
||||
saa_writel(SAA7134_RS_BA1(5), cpu_to_le32(saa->top_dma));
|
||||
}
|
||||
}
|
||||
|
||||
static int saa7134_go7007_stream_start(struct go7007 *go)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
|
||||
saa->top_dma = dma_map_page(&dev->pci->dev, virt_to_page(saa->top),
|
||||
0, PAGE_SIZE, DMA_FROM_DEVICE);
|
||||
if (!saa->top_dma)
|
||||
return -ENOMEM;
|
||||
saa->bottom_dma = dma_map_page(&dev->pci->dev,
|
||||
virt_to_page(saa->bottom),
|
||||
0, PAGE_SIZE, DMA_FROM_DEVICE);
|
||||
if (!saa->bottom_dma) {
|
||||
dma_unmap_page(&dev->pci->dev, saa->top_dma, PAGE_SIZE,
|
||||
DMA_FROM_DEVICE);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
saa_writel(SAA7134_VIDEO_PORT_CTRL0 >> 2, 0xA300B000);
|
||||
saa_writel(SAA7134_VIDEO_PORT_CTRL4 >> 2, 0x40000200);
|
||||
|
||||
/* Set HPI interface for video */
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0xff);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, HPI_ADDR_VIDEO_BUFFER);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_ADDR);
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0x00);
|
||||
|
||||
/* Enable TS interface */
|
||||
saa_writeb(SAA7134_TS_PARALLEL, 0xe6);
|
||||
|
||||
/* Reset TS interface */
|
||||
saa_setb(SAA7134_TS_SERIAL1, 0x01);
|
||||
saa_clearb(SAA7134_TS_SERIAL1, 0x01);
|
||||
|
||||
/* Set up transfer block size */
|
||||
saa_writeb(SAA7134_TS_PARALLEL_SERIAL, 128 - 1);
|
||||
saa_writeb(SAA7134_TS_DMA0, (PAGE_SIZE >> 7) - 1);
|
||||
saa_writeb(SAA7134_TS_DMA1, 0);
|
||||
saa_writeb(SAA7134_TS_DMA2, 0);
|
||||
|
||||
/* Enable video streaming mode */
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_VIDEO);
|
||||
|
||||
saa_writel(SAA7134_RS_BA1(5), cpu_to_le32(saa->top_dma));
|
||||
saa_writel(SAA7134_RS_BA2(5), cpu_to_le32(saa->bottom_dma));
|
||||
saa_writel(SAA7134_RS_PITCH(5), 128);
|
||||
saa_writel(SAA7134_RS_CONTROL(5), SAA7134_RS_CONTROL_BURST_MAX);
|
||||
|
||||
/* Enable TS FIFO */
|
||||
saa_setl(SAA7134_MAIN_CTRL, SAA7134_MAIN_CTRL_TE5);
|
||||
|
||||
/* Enable DMA IRQ */
|
||||
saa_setl(SAA7134_IRQ1,
|
||||
SAA7134_IRQ1_INTE_RA2_1 | SAA7134_IRQ1_INTE_RA2_0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_stream_stop(struct go7007 *go)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
|
||||
/* Shut down TS FIFO */
|
||||
saa_clearl(SAA7134_MAIN_CTRL, SAA7134_MAIN_CTRL_TE5);
|
||||
|
||||
/* Disable DMA IRQ */
|
||||
saa_clearl(SAA7134_IRQ1,
|
||||
SAA7134_IRQ1_INTE_RA2_1 | SAA7134_IRQ1_INTE_RA2_0);
|
||||
|
||||
/* Disable TS interface */
|
||||
saa_clearb(SAA7134_TS_PARALLEL, 0x80);
|
||||
|
||||
dma_unmap_page(&dev->pci->dev, saa->top_dma, PAGE_SIZE,
|
||||
DMA_FROM_DEVICE);
|
||||
dma_unmap_page(&dev->pci->dev, saa->bottom_dma, PAGE_SIZE,
|
||||
DMA_FROM_DEVICE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len)
|
||||
{
|
||||
struct saa7134_go7007 *saa = go->hpi_context;
|
||||
struct saa7134_dev *dev = saa->dev;
|
||||
u16 status_reg;
|
||||
int i;
|
||||
|
||||
#ifdef GO7007_HPI_DEBUG
|
||||
printk(KERN_DEBUG "saa7134-go7007: DownloadBuffer "
|
||||
"sending %d bytes\n", len);
|
||||
#endif
|
||||
|
||||
while (len > 0) {
|
||||
i = len > 64 ? 64 : len;
|
||||
saa_writeb(SAA7134_GPIO_GPMODE0, 0xff);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, HPI_ADDR_INIT_BUFFER);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_ADDR);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
while (i-- > 0) {
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS0, *data);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_WRITE);
|
||||
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_IDLE);
|
||||
++data;
|
||||
--len;
|
||||
}
|
||||
for (i = 0; i < 100; ++i) {
|
||||
gpio_read(dev, HPI_ADDR_INTR_STATUS, &status_reg);
|
||||
if (!(status_reg & 0x0002))
|
||||
break;
|
||||
}
|
||||
if (i == 100) {
|
||||
printk(KERN_ERR "saa7134-go7007: device is hung, "
|
||||
"status reg = 0x%04x\n", status_reg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
|
||||
.interface_reset = saa7134_go7007_interface_reset,
|
||||
.write_interrupt = saa7134_go7007_write_interrupt,
|
||||
.read_interrupt = saa7134_go7007_read_interrupt,
|
||||
.stream_start = saa7134_go7007_stream_start,
|
||||
.stream_stop = saa7134_go7007_stream_stop,
|
||||
.send_firmware = saa7134_go7007_send_firmware,
|
||||
};
|
||||
|
||||
/********************* Add/remove functions *********************/
|
||||
|
||||
static int saa7134_go7007_init(struct saa7134_dev *dev)
|
||||
{
|
||||
struct go7007 *go;
|
||||
struct saa7134_go7007 *saa;
|
||||
|
||||
printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n");
|
||||
|
||||
saa = kmalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
|
||||
if (saa == NULL)
|
||||
return -ENOMEM;
|
||||
memset(saa, 0, sizeof(struct saa7134_go7007));
|
||||
|
||||
/* Allocate a couple pages for receiving the compressed stream */
|
||||
saa->top = (u8 *)get_zeroed_page(GFP_KERNEL);
|
||||
if (!saa->top)
|
||||
goto allocfail;
|
||||
saa->bottom = (u8 *)get_zeroed_page(GFP_KERNEL);
|
||||
if (!saa->bottom)
|
||||
goto allocfail;
|
||||
|
||||
go = go7007_alloc(&board_voyager, &dev->pci->dev);
|
||||
if (go == NULL)
|
||||
goto allocfail;
|
||||
go->board_id = GO7007_BOARDID_PCI_VOYAGER;
|
||||
strncpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
|
||||
go->hpi_ops = &saa7134_go7007_hpi_ops;
|
||||
go->hpi_context = saa;
|
||||
saa->dev = dev;
|
||||
|
||||
/* Boot the GO7007 */
|
||||
if (go7007_boot_encoder(go, go->board_info->flags &
|
||||
GO7007_BOARD_USE_ONBOARD_I2C) < 0)
|
||||
goto initfail;
|
||||
|
||||
/* Do any final GO7007 initialization, then register the
|
||||
* V4L2 and ALSA interfaces */
|
||||
if (go7007_register_encoder(go) < 0)
|
||||
goto initfail;
|
||||
dev->empress_dev = go->video_dev;
|
||||
video_set_drvdata(dev->empress_dev, go);
|
||||
|
||||
go->status = STATUS_ONLINE;
|
||||
return 0;
|
||||
|
||||
initfail:
|
||||
go->status = STATUS_SHUTDOWN;
|
||||
return 0;
|
||||
|
||||
allocfail:
|
||||
if (saa->top)
|
||||
free_page((unsigned long)saa->top);
|
||||
if (saa->bottom)
|
||||
free_page((unsigned long)saa->bottom);
|
||||
kfree(saa);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static int saa7134_go7007_fini(struct saa7134_dev *dev)
|
||||
{
|
||||
struct go7007 *go;
|
||||
struct saa7134_go7007 *saa;
|
||||
|
||||
if (NULL == dev->empress_dev)
|
||||
return 0;
|
||||
|
||||
go = video_get_drvdata(dev->empress_dev);
|
||||
saa = go->hpi_context;
|
||||
go->status = STATUS_SHUTDOWN;
|
||||
free_page((unsigned long)saa->top);
|
||||
free_page((unsigned long)saa->bottom);
|
||||
kfree(saa);
|
||||
go7007_remove(go);
|
||||
dev->empress_dev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct saa7134_mpeg_ops saa7134_go7007_ops = {
|
||||
.type = SAA7134_MPEG_GO7007,
|
||||
.init = saa7134_go7007_init,
|
||||
.fini = saa7134_go7007_fini,
|
||||
.irq_ts_done = saa7134_go7007_irq_ts_done,
|
||||
};
|
||||
|
||||
static int __init saa7134_go7007_mod_init(void)
|
||||
{
|
||||
return saa7134_ts_register(&saa7134_go7007_ops);
|
||||
}
|
||||
|
||||
static void __exit saa7134_go7007_mod_cleanup(void)
|
||||
{
|
||||
saa7134_ts_unregister(&saa7134_go7007_ops);
|
||||
}
|
||||
|
||||
module_init(saa7134_go7007_mod_init);
|
||||
module_exit(saa7134_go7007_mod_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
305
drivers/staging/go7007/snd-go7007.c
Normal file
305
drivers/staging/go7007/snd-go7007.c
Normal file
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* 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/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <asm/system.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/initval.h>
|
||||
|
||||
#include "go7007-priv.h"
|
||||
|
||||
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
|
||||
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
|
||||
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
|
||||
|
||||
module_param_array(index, int, NULL, 0444);
|
||||
module_param_array(id, charp, NULL, 0444);
|
||||
module_param_array(enable, bool, NULL, 0444);
|
||||
MODULE_PARM_DESC(index, "Index value for the go7007 audio driver");
|
||||
MODULE_PARM_DESC(index, "ID string for the go7007 audio driver");
|
||||
MODULE_PARM_DESC(index, "Enable for the go7007 audio driver");
|
||||
|
||||
struct go7007_snd {
|
||||
struct snd_card *card;
|
||||
struct snd_pcm *pcm;
|
||||
struct snd_pcm_substream *substream;
|
||||
spinlock_t lock;
|
||||
int w_idx;
|
||||
int hw_ptr;
|
||||
int avail;
|
||||
int capturing;
|
||||
};
|
||||
|
||||
static struct snd_pcm_hardware go7007_snd_capture_hw = {
|
||||
.info = (SNDRV_PCM_INFO_MMAP |
|
||||
SNDRV_PCM_INFO_INTERLEAVED |
|
||||
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
||||
SNDRV_PCM_INFO_MMAP_VALID),
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
.rates = SNDRV_PCM_RATE_48000,
|
||||
.rate_min = 48000,
|
||||
.rate_max = 48000,
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.buffer_bytes_max = (128*1024),
|
||||
.period_bytes_min = 4096,
|
||||
.period_bytes_max = (128*1024),
|
||||
.periods_min = 1,
|
||||
.periods_max = 32,
|
||||
};
|
||||
|
||||
static void parse_audio_stream_data(struct go7007 *go, u8 *buf, int length)
|
||||
{
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
struct snd_pcm_runtime *runtime = gosnd->substream->runtime;
|
||||
int frames = bytes_to_frames(runtime, length);
|
||||
|
||||
spin_lock(&gosnd->lock);
|
||||
gosnd->hw_ptr += frames;
|
||||
if (gosnd->hw_ptr >= runtime->buffer_size)
|
||||
gosnd->hw_ptr -= runtime->buffer_size;
|
||||
gosnd->avail += frames;
|
||||
spin_unlock(&gosnd->lock);
|
||||
if (gosnd->w_idx + length > runtime->dma_bytes) {
|
||||
int cpy = runtime->dma_bytes - gosnd->w_idx;
|
||||
|
||||
memcpy(runtime->dma_area + gosnd->w_idx, buf, cpy);
|
||||
length -= cpy;
|
||||
buf += cpy;
|
||||
gosnd->w_idx = 0;
|
||||
}
|
||||
memcpy(runtime->dma_area + gosnd->w_idx, buf, length);
|
||||
gosnd->w_idx += length;
|
||||
spin_lock(&gosnd->lock);
|
||||
if (gosnd->avail < runtime->period_size) {
|
||||
spin_unlock(&gosnd->lock);
|
||||
return;
|
||||
}
|
||||
gosnd->avail -= runtime->period_size;
|
||||
spin_unlock(&gosnd->lock);
|
||||
if (gosnd->capturing)
|
||||
snd_pcm_period_elapsed(gosnd->substream);
|
||||
}
|
||||
|
||||
static int go7007_snd_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *hw_params)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
unsigned int bytes;
|
||||
|
||||
bytes = params_buffer_bytes(hw_params);
|
||||
if (substream->runtime->dma_bytes > 0)
|
||||
vfree(substream->runtime->dma_area);
|
||||
substream->runtime->dma_bytes = 0;
|
||||
substream->runtime->dma_area = vmalloc(bytes);
|
||||
if (substream->runtime->dma_area == NULL)
|
||||
return -ENOMEM;
|
||||
substream->runtime->dma_bytes = bytes;
|
||||
go->audio_deliver = parse_audio_stream_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int go7007_snd_hw_free(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
|
||||
go->audio_deliver = NULL;
|
||||
if (substream->runtime->dma_bytes > 0)
|
||||
vfree(substream->runtime->dma_area);
|
||||
substream->runtime->dma_bytes = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int go7007_snd_capture_open(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
unsigned long flags;
|
||||
int r;
|
||||
|
||||
spin_lock_irqsave(&gosnd->lock, flags);
|
||||
if (gosnd->substream == NULL) {
|
||||
gosnd->substream = substream;
|
||||
substream->runtime->hw = go7007_snd_capture_hw;
|
||||
r = 0;
|
||||
} else
|
||||
r = -EBUSY;
|
||||
spin_unlock_irqrestore(&gosnd->lock, flags);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int go7007_snd_capture_close(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
|
||||
gosnd->substream = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int go7007_snd_pcm_prepare(struct snd_pcm_substream *substream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int go7007_snd_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
/* Just set a flag to indicate we should signal ALSA when
|
||||
* sound comes in */
|
||||
gosnd->capturing = 1;
|
||||
return 0;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0;
|
||||
gosnd->capturing = 0;
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static snd_pcm_uframes_t go7007_snd_pcm_pointer(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct go7007 *go = snd_pcm_substream_chip(substream);
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
|
||||
return gosnd->hw_ptr;
|
||||
}
|
||||
|
||||
static struct page *go7007_snd_pcm_page(struct snd_pcm_substream *substream,
|
||||
unsigned long offset)
|
||||
{
|
||||
return vmalloc_to_page(substream->runtime->dma_area + offset);
|
||||
}
|
||||
|
||||
static struct snd_pcm_ops go7007_snd_capture_ops = {
|
||||
.open = go7007_snd_capture_open,
|
||||
.close = go7007_snd_capture_close,
|
||||
.ioctl = snd_pcm_lib_ioctl,
|
||||
.hw_params = go7007_snd_hw_params,
|
||||
.hw_free = go7007_snd_hw_free,
|
||||
.prepare = go7007_snd_pcm_prepare,
|
||||
.trigger = go7007_snd_pcm_trigger,
|
||||
.pointer = go7007_snd_pcm_pointer,
|
||||
.page = go7007_snd_pcm_page,
|
||||
};
|
||||
|
||||
static int go7007_snd_free(struct snd_device *device)
|
||||
{
|
||||
struct go7007 *go = device->device_data;
|
||||
|
||||
kfree(go->snd_context);
|
||||
go->snd_context = NULL;
|
||||
if (--go->ref_count == 0)
|
||||
kfree(go);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_device_ops go7007_snd_device_ops = {
|
||||
.dev_free = go7007_snd_free,
|
||||
};
|
||||
|
||||
int go7007_snd_init(struct go7007 *go)
|
||||
{
|
||||
static int dev;
|
||||
struct go7007_snd *gosnd;
|
||||
int ret = 0;
|
||||
|
||||
if (dev >= SNDRV_CARDS)
|
||||
return -ENODEV;
|
||||
if (!enable[dev]) {
|
||||
dev++;
|
||||
return -ENOENT;
|
||||
}
|
||||
gosnd = kmalloc(sizeof(struct go7007_snd), GFP_KERNEL);
|
||||
if (gosnd == NULL)
|
||||
return -ENOMEM;
|
||||
spin_lock_init(&gosnd->lock);
|
||||
gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0;
|
||||
gosnd->capturing = 0;
|
||||
gosnd->card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (gosnd->card == NULL) {
|
||||
kfree(gosnd);
|
||||
return -ENOMEM;
|
||||
}
|
||||
ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
|
||||
&go7007_snd_device_ops);
|
||||
if (ret < 0) {
|
||||
kfree(gosnd);
|
||||
return ret;
|
||||
}
|
||||
snd_card_set_dev(gosnd->card, go->dev);
|
||||
ret = snd_pcm_new(gosnd->card, "go7007", 0, 0, 1, &gosnd->pcm);
|
||||
if (ret < 0) {
|
||||
snd_card_free(gosnd->card);
|
||||
kfree(gosnd);
|
||||
return ret;
|
||||
}
|
||||
strncpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver));
|
||||
strncpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver));
|
||||
strncpy(gosnd->card->longname, gosnd->card->shortname,
|
||||
sizeof(gosnd->card->longname));
|
||||
|
||||
gosnd->pcm->private_data = go;
|
||||
snd_pcm_set_ops(gosnd->pcm, SNDRV_PCM_STREAM_CAPTURE,
|
||||
&go7007_snd_capture_ops);
|
||||
|
||||
ret = snd_card_register(gosnd->card);
|
||||
if (ret < 0) {
|
||||
snd_card_free(gosnd->card);
|
||||
kfree(gosnd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gosnd->substream = NULL;
|
||||
go->snd_context = gosnd;
|
||||
++dev;
|
||||
++go->ref_count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_snd_init);
|
||||
|
||||
int go7007_snd_remove(struct go7007 *go)
|
||||
{
|
||||
struct go7007_snd *gosnd = go->snd_context;
|
||||
|
||||
snd_card_disconnect(gosnd->card);
|
||||
snd_card_free_when_closed(gosnd->card);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(go7007_snd_remove);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
55
drivers/staging/go7007/wis-i2c.h
Normal file
55
drivers/staging/go7007/wis-i2c.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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_ALGO_GO7007 0xf00000
|
||||
#define I2C_ALGO_GO7007_USB 0xf10000
|
||||
|
||||
/* Flag to indicate that the client needs to be accessed with SCCB semantics */
|
||||
/* We re-use the I2C_M_TEN value so the flag passes through the masks in the
|
||||
* core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */
|
||||
#define I2C_CLIENT_SCCB 0x10
|
||||
|
||||
typedef int (*found_proc) (struct i2c_adapter *, int, int);
|
||||
int wis_i2c_add_driver(unsigned int id, found_proc found_proc);
|
||||
void wis_i2c_del_driver(found_proc found_proc);
|
||||
|
||||
int wis_i2c_probe_device(struct i2c_adapter *adapter,
|
||||
unsigned int id, int addr);
|
||||
|
||||
/* 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)
|
||||
|
||||
/* Sony tuner types */
|
||||
|
||||
#define TUNER_SONY_BTF_PG472Z 200
|
||||
#define TUNER_SONY_BTF_PK467Z 201
|
||||
#define TUNER_SONY_BTF_PB463Z 202
|
131
drivers/staging/go7007/wis-ov7640.c
Normal file
131
drivers/staging/go7007/wis-ov7640.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <linux/video_decoder.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 struct i2c_driver wis_ov7640_driver;
|
||||
|
||||
static struct i2c_client wis_ov7640_client_templ = {
|
||||
.name = "OV7640 (WIS)",
|
||||
.driver = &wis_ov7640_driver,
|
||||
};
|
||||
|
||||
static int wis_ov7640_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_ov7640_client_templ,
|
||||
sizeof(wis_ov7640_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
client->flags = I2C_CLIENT_SCCB;
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-ov7640: initializing OV7640 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
if (write_regs(client, initial_registers) < 0) {
|
||||
printk(KERN_ERR "wis-ov7640: error initializing OV7640\n");
|
||||
kfree(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_ov7640_detach(struct i2c_client *client)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_ov7640_driver = {
|
||||
.driver = {
|
||||
.name = "WIS OV7640 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_OV7640,
|
||||
.detach_client = wis_ov7640_detach,
|
||||
};
|
||||
|
||||
static int __init wis_ov7640_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_ov7640_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_ov7640_driver.id, wis_ov7640_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_ov7640_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_ov7640_detect);
|
||||
i2c_del_driver(&wis_ov7640_driver);
|
||||
}
|
||||
|
||||
module_init(wis_ov7640_init);
|
||||
module_exit(wis_ov7640_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
363
drivers/staging/go7007/wis-saa7113.c
Normal file
363
drivers/staging/go7007/wis-saa7113.c
Normal file
|
@ -0,0 +1,363 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <linux/video_decoder.h>
|
||||
#include <linux/ioctl.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 DECODER_SET_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 DECODER_SET_NORM:
|
||||
{
|
||||
int *input = arg;
|
||||
dec->norm = *input;
|
||||
switch (dec->norm) {
|
||||
case VIDEO_MODE_PAL:
|
||||
write_reg(client, 0x0e, 0x01);
|
||||
write_reg(client, 0x10, 0x48);
|
||||
break;
|
||||
case VIDEO_MODE_NTSC:
|
||||
write_reg(client, 0x0e, 0x01);
|
||||
write_reg(client, 0x10, 0x40);
|
||||
break;
|
||||
case VIDEO_MODE_SECAM:
|
||||
write_reg(client, 0x0e, 0x50);
|
||||
write_reg(client, 0x10, 0x48);
|
||||
break;
|
||||
}
|
||||
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 struct i2c_driver wis_saa7113_driver;
|
||||
|
||||
static struct i2c_client wis_saa7113_client_templ = {
|
||||
.name = "SAA7113 (WIS)",
|
||||
.driver = &wis_saa7113_driver,
|
||||
};
|
||||
|
||||
static int wis_saa7113_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct wis_saa7113 *dec;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_saa7113_client_templ,
|
||||
sizeof(wis_saa7113_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
dec = kmalloc(sizeof(struct wis_saa7113), GFP_KERNEL);
|
||||
if (dec == NULL) {
|
||||
kfree(client);
|
||||
return -ENOMEM;
|
||||
}
|
||||
dec->norm = VIDEO_MODE_NTSC;
|
||||
dec->brightness = 128;
|
||||
dec->contrast = 71;
|
||||
dec->saturation = 64;
|
||||
dec->hue = 0;
|
||||
i2c_set_clientdata(client, dec);
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-saa7113: initializing SAA7113 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
if (write_regs(client, initial_registers) < 0) {
|
||||
printk(KERN_ERR
|
||||
"wis-saa7113: error initializing SAA7113\n");
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_saa7113_detach(struct i2c_client *client)
|
||||
{
|
||||
struct wis_saa7113 *dec = i2c_get_clientdata(client);
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_saa7113_driver = {
|
||||
.driver = {
|
||||
.name = "WIS SAA7113 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_SAA7113,
|
||||
.detach_client = wis_saa7113_detach,
|
||||
.command = wis_saa7113_command,
|
||||
};
|
||||
|
||||
static int __init wis_saa7113_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_saa7113_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_saa7113_driver.id, wis_saa7113_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_saa7113_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_saa7113_detect);
|
||||
i2c_del_driver(&wis_saa7113_driver);
|
||||
}
|
||||
|
||||
module_init(wis_saa7113_init);
|
||||
module_exit(wis_saa7113_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
492
drivers/staging/go7007/wis-saa7115.c
Normal file
492
drivers/staging/go7007/wis-saa7115.c
Normal file
|
@ -0,0 +1,492 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <linux/video_decoder.h>
|
||||
#include <linux/ioctl.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 DECODER_SET_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 == VIDEO_MODE_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 DECODER_SET_NORM:
|
||||
{
|
||||
int *input = arg;
|
||||
u8 regs[] = {
|
||||
0x88, 0xc0,
|
||||
0x98, *input == VIDEO_MODE_NTSC ? 0x12 : 0x16,
|
||||
0x9a, *input == VIDEO_MODE_NTSC ? 0xf2 : 0x20,
|
||||
0x9b, *input == VIDEO_MODE_NTSC ? 0x00 : 0x01,
|
||||
0xc8, *input == VIDEO_MODE_NTSC ? 0x12 : 0x16,
|
||||
0xca, *input == VIDEO_MODE_NTSC ? 0xf2 : 0x20,
|
||||
0xcb, *input == VIDEO_MODE_NTSC ? 0x00 : 0x01,
|
||||
0x88, 0xf0,
|
||||
0x30, *input == VIDEO_MODE_NTSC ? 0x66 : 0x00,
|
||||
0x31, *input == VIDEO_MODE_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 struct i2c_driver wis_saa7115_driver;
|
||||
|
||||
static struct i2c_client wis_saa7115_client_templ = {
|
||||
.name = "SAA7115 (WIS)",
|
||||
.driver = &wis_saa7115_driver,
|
||||
};
|
||||
|
||||
static int wis_saa7115_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct wis_saa7115 *dec;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_saa7115_client_templ,
|
||||
sizeof(wis_saa7115_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL);
|
||||
if (dec == NULL) {
|
||||
kfree(client);
|
||||
return -ENOMEM;
|
||||
}
|
||||
dec->norm = VIDEO_MODE_NTSC;
|
||||
dec->brightness = 128;
|
||||
dec->contrast = 64;
|
||||
dec->saturation = 64;
|
||||
dec->hue = 0;
|
||||
i2c_set_clientdata(client, dec);
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-saa7115: initializing SAA7115 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
if (write_regs(client, initial_registers) < 0) {
|
||||
printk(KERN_ERR
|
||||
"wis-saa7115: error initializing SAA7115\n");
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_saa7115_detach(struct i2c_client *client)
|
||||
{
|
||||
struct wis_saa7115 *dec = i2c_get_clientdata(client);
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_saa7115_driver = {
|
||||
.driver = {
|
||||
.name = "WIS SAA7115 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_SAA7115,
|
||||
.detach_client = wis_saa7115_detach,
|
||||
.command = wis_saa7115_command,
|
||||
};
|
||||
|
||||
static int __init wis_saa7115_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_saa7115_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_saa7115_driver.id, wis_saa7115_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_saa7115_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_saa7115_detect);
|
||||
i2c_del_driver(&wis_saa7115_driver);
|
||||
}
|
||||
|
||||
module_init(wis_saa7115_init);
|
||||
module_exit(wis_saa7115_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
741
drivers/staging/go7007/wis-sony-tuner.c
Normal file
741
drivers/staging/go7007/wis-sony-tuner.c
Normal file
|
@ -0,0 +1,741 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <media/tuner.h>
|
||||
#include <media/v4l2-common.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;
|
||||
}
|
||||
printk(KERN_DEBUG "wis-sony-tuner: 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];
|
||||
|
||||
printk(KERN_DEBUG "wis-sony-tuner: 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);
|
||||
printk(KERN_DEBUG "wis-sony-tuner: MPX system: %02x%02x\n",
|
||||
buf2[0], buf2[1]);
|
||||
buf1[0] = 0x11;
|
||||
buf1[1] = 0x02;
|
||||
buf1[2] = 0x00;
|
||||
i2c_transfer(client->adapter, msgs, 2);
|
||||
printk(KERN_DEBUG "wis-sony-tuner: 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;
|
||||
printk(KERN_DEBUG "wis-sony-tuner: 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) {
|
||||
#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)
|
||||
printk(KERN_ERR "wis-sony-tuner: 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':
|
||||
printk(KERN_INFO "wis-sony-tuner: forcing "
|
||||
"tuner to PAL-B/G bands\n");
|
||||
force_band = V4L2_STD_PAL_BG;
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
printk(KERN_INFO "wis-sony-tuner: forcing "
|
||||
"tuner to PAL-I band\n");
|
||||
force_band = V4L2_STD_PAL_I;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
case 'k':
|
||||
case 'K':
|
||||
printk(KERN_INFO "wis-sony-tuner: forcing "
|
||||
"tuner to PAL-D/K bands\n");
|
||||
force_band = V4L2_STD_PAL_I;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
printk(KERN_INFO "wis-sony-tuner: 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:
|
||||
printk(KERN_ERR "wis-sony-tuner: tuner type %d is not "
|
||||
"supported by this module\n", *type);
|
||||
break;
|
||||
}
|
||||
if (type >= 0)
|
||||
printk(KERN_INFO
|
||||
"wis-sony-tuner: type set to %d (%s)\n",
|
||||
t->type, sony_tuners[t->type - 200].name);
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
printk(KERN_DEBUG "wis-sony-tuner: 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 {
|
||||
printk(KERN_ERR "wis-sony-tuner: 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)) {
|
||||
printk(KERN_ERR "wis-sony-tuner: TV standard "
|
||||
"not supported\n");
|
||||
*std = 0; /* hack to indicate EINVAL */
|
||||
}
|
||||
break;
|
||||
case TUNER_SONY_BTF_PB463Z:
|
||||
if (!(*std & V4L2_STD_NTSC_M)) {
|
||||
printk(KERN_ERR "wis-sony-tuner: 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(t, 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 struct i2c_driver wis_sony_tuner_driver;
|
||||
|
||||
static struct i2c_client wis_sony_tuner_client_templ = {
|
||||
.name = "Sony TV Tuner (WIS)",
|
||||
.driver = &wis_sony_tuner_driver,
|
||||
};
|
||||
|
||||
static int wis_sony_tuner_detect(struct i2c_adapter *adapter,
|
||||
int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct wis_sony_tuner *t;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_sony_tuner_client_templ,
|
||||
sizeof(wis_sony_tuner_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
t = kmalloc(sizeof(struct wis_sony_tuner), GFP_KERNEL);
|
||||
if (t == NULL) {
|
||||
kfree(client);
|
||||
return -ENOMEM;
|
||||
}
|
||||
t->type = -1;
|
||||
t->freq = 0;
|
||||
t->mpxmode = 0;
|
||||
t->audmode = V4L2_TUNER_MODE_STEREO;
|
||||
i2c_set_clientdata(client, t);
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-sony-tuner: initializing tuner at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
i2c_attach_client(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_sony_tuner_detach(struct i2c_client *client)
|
||||
{
|
||||
struct wis_sony_tuner *t = i2c_get_clientdata(client);
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(t);
|
||||
kfree(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_sony_tuner_driver = {
|
||||
.driver = {
|
||||
.name = "WIS Sony TV Tuner I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_SONY_TUNER,
|
||||
.detach_client = wis_sony_tuner_detach,
|
||||
.command = tuner_command,
|
||||
};
|
||||
|
||||
static int __init wis_sony_tuner_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_sony_tuner_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_sony_tuner_driver.id,
|
||||
wis_sony_tuner_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_sony_tuner_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_sony_tuner_detect);
|
||||
i2c_del_driver(&wis_sony_tuner_driver);
|
||||
}
|
||||
|
||||
module_init(wis_sony_tuner_init);
|
||||
module_exit(wis_sony_tuner_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
381
drivers/staging/go7007/wis-tw2804.c
Normal file
381
drivers/staging/go7007/wis-tw2804.c
Normal file
|
@ -0,0 +1,381 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <linux/video_decoder.h>
|
||||
#include <linux/ioctl.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) {
|
||||
printk(KERN_ERR "wis-tw2804: channel %d is not "
|
||||
"between 0 and 3!\n", *input);
|
||||
return 0;
|
||||
}
|
||||
dec->channel = *input;
|
||||
printk(KERN_DEBUG "wis-tw2804: initializing TW2804 "
|
||||
"channel %d\n", dec->channel);
|
||||
if (dec->channel == 0 &&
|
||||
write_regs(client, global_registers, 0) < 0) {
|
||||
printk(KERN_ERR "wis-tw2804: error initializing "
|
||||
"TW2804 global registers\n");
|
||||
return 0;
|
||||
}
|
||||
if (write_regs(client, channel_registers, dec->channel) < 0) {
|
||||
printk(KERN_ERR "wis-tw2804: error initializing "
|
||||
"TW2804 channel %d\n", dec->channel);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dec->channel < 0) {
|
||||
printk(KERN_DEBUG "wis-tw2804: ignoring command %08x until "
|
||||
"channel number is set\n", cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case DECODER_SET_NORM:
|
||||
{
|
||||
int *input = arg;
|
||||
u8 regs[] = {
|
||||
0x01, *input == VIDEO_MODE_NTSC ? 0xc4 : 0x84,
|
||||
0x09, *input == VIDEO_MODE_NTSC ? 0x07 : 0x04,
|
||||
0x0a, *input == VIDEO_MODE_NTSC ? 0xf0 : 0x20,
|
||||
0x0b, *input == VIDEO_MODE_NTSC ? 0x07 : 0x04,
|
||||
0x0c, *input == VIDEO_MODE_NTSC ? 0xf0 : 0x20,
|
||||
0x0d, *input == VIDEO_MODE_NTSC ? 0x40 : 0x4a,
|
||||
0x16, *input == VIDEO_MODE_NTSC ? 0x00 : 0x40,
|
||||
0x17, *input == VIDEO_MODE_NTSC ? 0x00 : 0x40,
|
||||
0x20, *input == VIDEO_MODE_NTSC ? 0x07 : 0x0f,
|
||||
0x21, *input == VIDEO_MODE_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 struct i2c_driver wis_tw2804_driver;
|
||||
|
||||
static struct i2c_client wis_tw2804_client_templ = {
|
||||
.name = "TW2804 (WIS)",
|
||||
.driver = &wis_tw2804_driver,
|
||||
};
|
||||
|
||||
static int wis_tw2804_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct wis_tw2804 *dec;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_tw2804_client_templ,
|
||||
sizeof(wis_tw2804_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
|
||||
if (dec == NULL) {
|
||||
kfree(client);
|
||||
return -ENOMEM;
|
||||
}
|
||||
dec->channel = -1;
|
||||
dec->norm = VIDEO_MODE_NTSC;
|
||||
dec->brightness = 128;
|
||||
dec->contrast = 128;
|
||||
dec->saturation = 128;
|
||||
dec->hue = 128;
|
||||
i2c_set_clientdata(client, dec);
|
||||
|
||||
printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_tw2804_detach(struct i2c_client *client)
|
||||
{
|
||||
struct wis_tw2804 *dec = i2c_get_clientdata(client);
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_tw2804_driver = {
|
||||
.driver = {
|
||||
.name = "WIS TW2804 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_TW2804,
|
||||
.detach_client = wis_tw2804_detach,
|
||||
.command = wis_tw2804_command,
|
||||
};
|
||||
|
||||
static int __init wis_tw2804_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_tw2804_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_tw2804_driver.id, wis_tw2804_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_tw2804_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_tw2804_detect);
|
||||
i2c_del_driver(&wis_tw2804_driver);
|
||||
}
|
||||
|
||||
module_init(wis_tw2804_init);
|
||||
module_exit(wis_tw2804_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
363
drivers/staging/go7007/wis-tw9903.c
Normal file
363
drivers/staging/go7007/wis-tw9903.c
Normal file
|
@ -0,0 +1,363 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.h>
|
||||
#include <linux/video_decoder.h>
|
||||
#include <linux/ioctl.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 DECODER_SET_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 == VIDEO_MODE_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,
|
||||
};
|
||||
printk(KERN_DEBUG "vscale is %04x, hscale is %04x\n",
|
||||
vscale, hscale);
|
||||
/*write_regs(client, regs);*/
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case DECODER_SET_NORM:
|
||||
{
|
||||
int *input = arg;
|
||||
u8 regs[] = {
|
||||
0x05, *input == VIDEO_MODE_NTSC ? 0x80 : 0x00,
|
||||
0x07, *input == VIDEO_MODE_NTSC ? 0x02 : 0x12,
|
||||
0x08, *input == VIDEO_MODE_NTSC ? 0x14 : 0x18,
|
||||
0x09, *input == VIDEO_MODE_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 struct i2c_driver wis_tw9903_driver;
|
||||
|
||||
static struct i2c_client wis_tw9903_client_templ = {
|
||||
.name = "TW9903 (WIS)",
|
||||
.driver = &wis_tw9903_driver,
|
||||
};
|
||||
|
||||
static int wis_tw9903_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct wis_tw9903 *dec;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_tw9903_client_templ,
|
||||
sizeof(wis_tw9903_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
dec = kmalloc(sizeof(struct wis_tw9903), GFP_KERNEL);
|
||||
if (dec == NULL) {
|
||||
kfree(client);
|
||||
return -ENOMEM;
|
||||
}
|
||||
dec->norm = VIDEO_MODE_NTSC;
|
||||
dec->brightness = 0;
|
||||
dec->contrast = 0x60;
|
||||
dec->hue = 0;
|
||||
i2c_set_clientdata(client, dec);
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-tw9903: initializing TW9903 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
if (write_regs(client, initial_registers) < 0) {
|
||||
printk(KERN_ERR "wis-tw9903: error initializing TW9903\n");
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_tw9903_detach(struct i2c_client *client)
|
||||
{
|
||||
struct wis_tw9903 *dec = i2c_get_clientdata(client);
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
kfree(dec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_tw9903_driver = {
|
||||
.driver = {
|
||||
.name = "WIS TW9903 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_TW9903,
|
||||
.detach_client = wis_tw9903_detach,
|
||||
.command = wis_tw9903_command,
|
||||
};
|
||||
|
||||
static int __init wis_tw9903_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_tw9903_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_tw9903_driver.id, wis_tw9903_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_tw9903_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_tw9903_detect);
|
||||
i2c_del_driver(&wis_tw9903_driver);
|
||||
}
|
||||
|
||||
module_init(wis_tw9903_init);
|
||||
module_exit(wis_tw9903_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
136
drivers/staging/go7007/wis-uda1342.c
Normal file
136
drivers/staging/go7007/wis-uda1342.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* 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/version.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/videodev.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:
|
||||
printk(KERN_ERR "wis-uda1342: input %d not supported\n",
|
||||
*inp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_uda1342_driver;
|
||||
|
||||
static struct i2c_client wis_uda1342_client_templ = {
|
||||
.name = "UDA1342 (WIS)",
|
||||
.driver = &wis_uda1342_driver,
|
||||
};
|
||||
|
||||
static int wis_uda1342_detect(struct i2c_adapter *adapter, int addr, int kind)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return 0;
|
||||
|
||||
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
memcpy(client, &wis_uda1342_client_templ,
|
||||
sizeof(wis_uda1342_client_templ));
|
||||
client->adapter = adapter;
|
||||
client->addr = addr;
|
||||
|
||||
printk(KERN_DEBUG
|
||||
"wis-uda1342: initializing UDA1342 at address %d on %s\n",
|
||||
addr, adapter->name);
|
||||
|
||||
write_reg(client, 0x00, 0x8000); /* reset registers */
|
||||
write_reg(client, 0x00, 0x1241); /* select input 1 */
|
||||
|
||||
i2c_attach_client(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wis_uda1342_detach(struct i2c_client *client)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_detach_client(client);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
kfree(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver wis_uda1342_driver = {
|
||||
.driver = {
|
||||
.name = "WIS UDA1342 I2C driver",
|
||||
},
|
||||
.id = I2C_DRIVERID_WIS_UDA1342,
|
||||
.detach_client = wis_uda1342_detach,
|
||||
.command = wis_uda1342_command,
|
||||
};
|
||||
|
||||
static int __init wis_uda1342_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = i2c_add_driver(&wis_uda1342_driver);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return wis_i2c_add_driver(wis_uda1342_driver.id, wis_uda1342_detect);
|
||||
}
|
||||
|
||||
static void __exit wis_uda1342_cleanup(void)
|
||||
{
|
||||
wis_i2c_del_driver(wis_uda1342_detect);
|
||||
i2c_del_driver(&wis_uda1342_driver);
|
||||
}
|
||||
|
||||
module_init(wis_uda1342_init);
|
||||
module_exit(wis_uda1342_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
Loading…
Reference in a new issue