Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

This commit is contained in:
Jaroslav Kysela 2006-03-22 11:02:08 +01:00
commit 5501972e0b
993 changed files with 55615 additions and 31625 deletions

View file

@ -1,5 +1,6 @@
saa7146-objs := saa7146_i2c.o saa7146_core.o
saa7146_vv-objs := saa7146_vv_ksyms.o saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o
ir-common-objs := ir-functions.o ir-keymaps.o
obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o

View file

@ -1,519 +0,0 @@
/*
*
* some common structs and functions to handle infrared remotes via
* input layer ...
*
* (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <media/ir-common.h>
/* -------------------------------------------------------------------------- */
MODULE_AUTHOR("Gerd Knorr <[email protected]> [SuSE Labs]");
MODULE_LICENSE("GPL");
static int repeat = 1;
module_param(repeat, int, 0444);
MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
static int debug = 0; /* debug level (0,1,2) */
module_param(debug, int, 0644);
#define dprintk(level, fmt, arg...) if (debug >= level) \
printk(KERN_DEBUG fmt , ## arg)
/* -------------------------------------------------------------------------- */
/* generic RC5 keytable */
/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
/* used by old (black) Hauppauge remotes */
IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
/* Keys 0 to 9 */
[ 0x00 ] = KEY_KP0,
[ 0x01 ] = KEY_KP1,
[ 0x02 ] = KEY_KP2,
[ 0x03 ] = KEY_KP3,
[ 0x04 ] = KEY_KP4,
[ 0x05 ] = KEY_KP5,
[ 0x06 ] = KEY_KP6,
[ 0x07 ] = KEY_KP7,
[ 0x08 ] = KEY_KP8,
[ 0x09 ] = KEY_KP9,
[ 0x0b ] = KEY_CHANNEL, /* channel / program (japan: 11) */
[ 0x0c ] = KEY_POWER, /* standby */
[ 0x0d ] = KEY_MUTE, /* mute / demute */
[ 0x0f ] = KEY_TV, /* display */
[ 0x10 ] = KEY_VOLUMEUP,
[ 0x11 ] = KEY_VOLUMEDOWN,
[ 0x12 ] = KEY_BRIGHTNESSUP,
[ 0x13 ] = KEY_BRIGHTNESSDOWN,
[ 0x1e ] = KEY_SEARCH, /* search + */
[ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
[ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
[ 0x22 ] = KEY_CHANNEL, /* alt / channel */
[ 0x23 ] = KEY_LANGUAGE, /* 1st / 2nd language */
[ 0x26 ] = KEY_SLEEP, /* sleeptimer */
[ 0x2e ] = KEY_MENU, /* 2nd controls (USA: menu) */
[ 0x30 ] = KEY_PAUSE,
[ 0x32 ] = KEY_REWIND,
[ 0x33 ] = KEY_GOTO,
[ 0x35 ] = KEY_PLAY,
[ 0x36 ] = KEY_STOP,
[ 0x37 ] = KEY_RECORD, /* recording */
[ 0x3c ] = KEY_TEXT, /* teletext submode (Japan: 12) */
[ 0x3d ] = KEY_SUSPEND, /* system standby */
};
EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
/* Keys 0 to 9 */
[ 18 ] = KEY_KP0,
[ 5 ] = KEY_KP1,
[ 6 ] = KEY_KP2,
[ 7 ] = KEY_KP3,
[ 9 ] = KEY_KP4,
[ 10 ] = KEY_KP5,
[ 11 ] = KEY_KP6,
[ 13 ] = KEY_KP7,
[ 14 ] = KEY_KP8,
[ 15 ] = KEY_KP9,
[ 0 ] = KEY_POWER,
[ 2 ] = KEY_TUNER, /* TV/FM */
[ 30 ] = KEY_VIDEO,
[ 4 ] = KEY_VOLUMEUP,
[ 8 ] = KEY_VOLUMEDOWN,
[ 12 ] = KEY_CHANNELUP,
[ 16 ] = KEY_CHANNELDOWN,
[ 3 ] = KEY_ZOOM, /* fullscreen */
[ 31 ] = KEY_SUBTITLE, /* closed caption/teletext */
[ 32 ] = KEY_SLEEP,
[ 20 ] = KEY_MUTE,
[ 43 ] = KEY_RED,
[ 44 ] = KEY_GREEN,
[ 45 ] = KEY_YELLOW,
[ 46 ] = KEY_BLUE,
[ 24 ] = KEY_KPPLUS, /* fine tune + */
[ 25 ] = KEY_KPMINUS, /* fine tune - */
[ 33 ] = KEY_KPDOT,
[ 19 ] = KEY_KPENTER,
[ 34 ] = KEY_BACK,
[ 35 ] = KEY_PLAYPAUSE,
[ 36 ] = KEY_NEXT,
[ 38 ] = KEY_STOP,
[ 39 ] = KEY_RECORD
};
EXPORT_SYMBOL_GPL(ir_codes_winfast);
IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
[ 0x59 ] = KEY_MUTE,
[ 0x4a ] = KEY_POWER,
[ 0x18 ] = KEY_TEXT,
[ 0x26 ] = KEY_TV,
[ 0x3d ] = KEY_PRINT,
[ 0x48 ] = KEY_RED,
[ 0x04 ] = KEY_GREEN,
[ 0x11 ] = KEY_YELLOW,
[ 0x00 ] = KEY_BLUE,
[ 0x2d ] = KEY_VOLUMEUP,
[ 0x1e ] = KEY_VOLUMEDOWN,
[ 0x49 ] = KEY_MENU,
[ 0x16 ] = KEY_CHANNELUP,
[ 0x17 ] = KEY_CHANNELDOWN,
[ 0x20 ] = KEY_UP,
[ 0x21 ] = KEY_DOWN,
[ 0x22 ] = KEY_LEFT,
[ 0x23 ] = KEY_RIGHT,
[ 0x0d ] = KEY_SELECT,
[ 0x08 ] = KEY_BACK,
[ 0x07 ] = KEY_REFRESH,
[ 0x2f ] = KEY_ZOOM,
[ 0x29 ] = KEY_RECORD,
[ 0x4b ] = KEY_PAUSE,
[ 0x4d ] = KEY_REWIND,
[ 0x2e ] = KEY_PLAY,
[ 0x4e ] = KEY_FORWARD,
[ 0x53 ] = KEY_PREVIOUS,
[ 0x4c ] = KEY_STOP,
[ 0x54 ] = KEY_NEXT,
[ 0x69 ] = KEY_KP0,
[ 0x6a ] = KEY_KP1,
[ 0x6b ] = KEY_KP2,
[ 0x6c ] = KEY_KP3,
[ 0x6d ] = KEY_KP4,
[ 0x6e ] = KEY_KP5,
[ 0x6f ] = KEY_KP6,
[ 0x70 ] = KEY_KP7,
[ 0x71 ] = KEY_KP8,
[ 0x72 ] = KEY_KP9,
[ 0x74 ] = KEY_CHANNEL,
[ 0x0a ] = KEY_BACKSPACE,
};
EXPORT_SYMBOL_GPL(ir_codes_pinnacle);
/* empty keytable, can be used as placeholder for not-yet created keytables */
IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
[ 42 ] = KEY_COFFEE,
};
EXPORT_SYMBOL_GPL(ir_codes_empty);
/* Hauppauge: the newer, gray remotes (seems there are multiple
* slightly different versions), shipped with cx88+ivtv cards.
* almost rc5 coding, but some non-standard keys */
IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = {
/* Keys 0 to 9 */
[ 0x00 ] = KEY_KP0,
[ 0x01 ] = KEY_KP1,
[ 0x02 ] = KEY_KP2,
[ 0x03 ] = KEY_KP3,
[ 0x04 ] = KEY_KP4,
[ 0x05 ] = KEY_KP5,
[ 0x06 ] = KEY_KP6,
[ 0x07 ] = KEY_KP7,
[ 0x08 ] = KEY_KP8,
[ 0x09 ] = KEY_KP9,
[ 0x0a ] = KEY_TEXT, /* keypad asterisk as well */
[ 0x0b ] = KEY_RED, /* red button */
[ 0x0c ] = KEY_RADIO,
[ 0x0d ] = KEY_MENU,
[ 0x0e ] = KEY_SUBTITLE, /* also the # key */
[ 0x0f ] = KEY_MUTE,
[ 0x10 ] = KEY_VOLUMEUP,
[ 0x11 ] = KEY_VOLUMEDOWN,
[ 0x12 ] = KEY_PREVIOUS, /* previous channel */
[ 0x14 ] = KEY_UP,
[ 0x15 ] = KEY_DOWN,
[ 0x16 ] = KEY_LEFT,
[ 0x17 ] = KEY_RIGHT,
[ 0x18 ] = KEY_VIDEO, /* Videos */
[ 0x19 ] = KEY_AUDIO, /* Music */
/* 0x1a: Pictures - presume this means
"Multimedia Home Platform" -
no "PICTURES" key in input.h
*/
[ 0x1a ] = KEY_MHP,
[ 0x1b ] = KEY_EPG, /* Guide */
[ 0x1c ] = KEY_TV,
[ 0x1e ] = KEY_NEXTSONG, /* skip >| */
[ 0x1f ] = KEY_EXIT, /* back/exit */
[ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
[ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
[ 0x22 ] = KEY_CHANNEL, /* source (old black remote) */
[ 0x24 ] = KEY_PREVIOUSSONG, /* replay |< */
[ 0x25 ] = KEY_ENTER, /* OK */
[ 0x26 ] = KEY_SLEEP, /* minimize (old black remote) */
[ 0x29 ] = KEY_BLUE, /* blue key */
[ 0x2e ] = KEY_GREEN, /* green button */
[ 0x30 ] = KEY_PAUSE, /* pause */
[ 0x32 ] = KEY_REWIND, /* backward << */
[ 0x34 ] = KEY_FASTFORWARD, /* forward >> */
[ 0x35 ] = KEY_PLAY,
[ 0x36 ] = KEY_STOP,
[ 0x37 ] = KEY_RECORD, /* recording */
[ 0x38 ] = KEY_YELLOW, /* yellow key */
[ 0x3b ] = KEY_SELECT, /* top right button */
[ 0x3c ] = KEY_ZOOM, /* full */
[ 0x3d ] = KEY_POWER, /* system power (green button) */
};
EXPORT_SYMBOL(ir_codes_hauppauge_new);
IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
[ 2 ] = KEY_KP0,
[ 1 ] = KEY_KP1,
[ 11 ] = KEY_KP2,
[ 27 ] = KEY_KP3,
[ 5 ] = KEY_KP4,
[ 9 ] = KEY_KP5,
[ 21 ] = KEY_KP6,
[ 6 ] = KEY_KP7,
[ 10 ] = KEY_KP8,
[ 18 ] = KEY_KP9,
[ 3 ] = KEY_TUNER, /* TV/FM */
[ 7 ] = KEY_SEARCH, /* scan */
[ 28 ] = KEY_ZOOM, /* full screen */
[ 30 ] = KEY_POWER,
[ 23 ] = KEY_VOLUMEDOWN,
[ 31 ] = KEY_VOLUMEUP,
[ 20 ] = KEY_CHANNELDOWN,
[ 22 ] = KEY_CHANNELUP,
[ 24 ] = KEY_MUTE,
[ 0 ] = KEY_LIST, /* source */
[ 19 ] = KEY_INFO, /* loop */
[ 16 ] = KEY_LAST, /* +100 */
[ 13 ] = KEY_CLEAR, /* reset */
[ 12 ] = BTN_RIGHT, /* fun++ */
[ 4 ] = BTN_LEFT, /* fun-- */
[ 14 ] = KEY_GOTO, /* function */
[ 15 ] = KEY_STOP, /* freeze */
};
EXPORT_SYMBOL(ir_codes_pixelview);
/* -------------------------------------------------------------------------- */
static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
{
if (KEY_RESERVED == ir->keycode) {
printk(KERN_INFO "%s: unknown key: key=0x%02x raw=0x%02x down=%d\n",
dev->name,ir->ir_key,ir->ir_raw,ir->keypressed);
return;
}
dprintk(1,"%s: key event code=%d down=%d\n",
dev->name,ir->keycode,ir->keypressed);
input_report_key(dev,ir->keycode,ir->keypressed);
input_sync(dev);
}
/* -------------------------------------------------------------------------- */
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_type, IR_KEYTAB_TYPE *ir_codes)
{
int i;
ir->ir_type = ir_type;
if (ir_codes)
memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
dev->keycode = ir->ir_codes;
dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
dev->keycodemax = IR_KEYTAB_SIZE;
for (i = 0; i < IR_KEYTAB_SIZE; i++)
set_bit(ir->ir_codes[i], dev->keybit);
clear_bit(0, dev->keybit);
set_bit(EV_KEY, dev->evbit);
if (repeat)
set_bit(EV_REP, dev->evbit);
}
void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
{
if (ir->keypressed) {
ir->keypressed = 0;
ir_input_key_event(dev,ir);
}
}
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
u32 ir_key, u32 ir_raw)
{
u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);
if (ir->keypressed && ir->keycode != keycode) {
ir->keypressed = 0;
ir_input_key_event(dev,ir);
}
if (!ir->keypressed) {
ir->ir_key = ir_key;
ir->ir_raw = ir_raw;
ir->keycode = keycode;
ir->keypressed = 1;
ir_input_key_event(dev,ir);
}
}
/* -------------------------------------------------------------------------- */
u32 ir_extract_bits(u32 data, u32 mask)
{
int mbit, vbit;
u32 value;
value = 0;
vbit = 0;
for (mbit = 0; mbit < 32; mbit++) {
if (!(mask & ((u32)1 << mbit)))
continue;
if (data & ((u32)1 << mbit))
value |= (1 << vbit);
vbit++;
}
return value;
}
static int inline getbit(u32 *samples, int bit)
{
return (samples[bit/32] & (1 << (31-(bit%32)))) ? 1 : 0;
}
/* sump raw samples for visual debugging ;) */
int ir_dump_samples(u32 *samples, int count)
{
int i, bit, start;
printk(KERN_DEBUG "ir samples: ");
start = 0;
for (i = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit)
start = 1;
if (0 == start)
continue;
printk("%s", bit ? "#" : "_");
}
printk("\n");
return 0;
}
/* decode raw samples, pulse distance coding used by NEC remotes */
int ir_decode_pulsedistance(u32 *samples, int count, int low, int high)
{
int i,last,bit,len;
u32 curBit;
u32 value;
/* find start burst */
for (i = len = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit) {
len++;
} else {
if (len >= 29)
break;
len = 0;
}
}
/* start burst to short */
if (len < 29)
return 0xffffffff;
/* find start silence */
for (len = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit) {
break;
} else {
len++;
}
}
/* silence to short */
if (len < 7)
return 0xffffffff;
/* go decoding */
len = 0;
last = 1;
value = 0; curBit = 1;
for (; i < count * 32; i++) {
bit = getbit(samples,i);
if (last) {
if(bit) {
continue;
} else {
len = 1;
}
} else {
if (bit) {
if (len > (low + high) /2)
value |= curBit;
curBit <<= 1;
if (curBit == 1)
break;
} else {
len++;
}
}
last = bit;
}
return value;
}
/* decode raw samples, biphase coding, used by rc5 for example */
int ir_decode_biphase(u32 *samples, int count, int low, int high)
{
int i,last,bit,len,flips;
u32 value;
/* find start bit (1) */
for (i = 0; i < 32; i++) {
bit = getbit(samples,i);
if (bit)
break;
}
/* go decoding */
len = 0;
flips = 0;
value = 1;
for (; i < count * 32; i++) {
if (len > high)
break;
if (flips > 1)
break;
last = bit;
bit = getbit(samples,i);
if (last == bit) {
len++;
continue;
}
if (len < low) {
len++;
flips++;
continue;
}
value <<= 1;
value |= bit;
flips = 0;
len = 1;
}
return value;
}
EXPORT_SYMBOL_GPL(ir_input_init);
EXPORT_SYMBOL_GPL(ir_input_nokey);
EXPORT_SYMBOL_GPL(ir_input_keydown);
EXPORT_SYMBOL_GPL(ir_extract_bits);
EXPORT_SYMBOL_GPL(ir_dump_samples);
EXPORT_SYMBOL_GPL(ir_decode_biphase);
EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
/*
* Local variables:
* c-basic-offset: 8
* End:
*/

View file

@ -0,0 +1,272 @@
/*
*
* some common structs and functions to handle infrared remotes via
* input layer ...
*
* (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <media/ir-common.h>
/* -------------------------------------------------------------------------- */
MODULE_AUTHOR("Gerd Knorr <[email protected]> [SuSE Labs]");
MODULE_LICENSE("GPL");
static int repeat = 1;
module_param(repeat, int, 0444);
MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
static int debug = 0; /* debug level (0,1,2) */
module_param(debug, int, 0644);
#define dprintk(level, fmt, arg...) if (debug >= level) \
printk(KERN_DEBUG fmt , ## arg)
/* -------------------------------------------------------------------------- */
static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
{
if (KEY_RESERVED == ir->keycode) {
printk(KERN_INFO "%s: unknown key: key=0x%02x raw=0x%02x down=%d\n",
dev->name,ir->ir_key,ir->ir_raw,ir->keypressed);
return;
}
dprintk(1,"%s: key event code=%d down=%d\n",
dev->name,ir->keycode,ir->keypressed);
input_report_key(dev,ir->keycode,ir->keypressed);
input_sync(dev);
}
/* -------------------------------------------------------------------------- */
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_type, IR_KEYTAB_TYPE *ir_codes)
{
int i;
ir->ir_type = ir_type;
if (ir_codes)
memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
dev->keycode = ir->ir_codes;
dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
dev->keycodemax = IR_KEYTAB_SIZE;
for (i = 0; i < IR_KEYTAB_SIZE; i++)
set_bit(ir->ir_codes[i], dev->keybit);
clear_bit(0, dev->keybit);
set_bit(EV_KEY, dev->evbit);
if (repeat)
set_bit(EV_REP, dev->evbit);
}
void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
{
if (ir->keypressed) {
ir->keypressed = 0;
ir_input_key_event(dev,ir);
}
}
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
u32 ir_key, u32 ir_raw)
{
u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);
if (ir->keypressed && ir->keycode != keycode) {
ir->keypressed = 0;
ir_input_key_event(dev,ir);
}
if (!ir->keypressed) {
ir->ir_key = ir_key;
ir->ir_raw = ir_raw;
ir->keycode = keycode;
ir->keypressed = 1;
ir_input_key_event(dev,ir);
}
}
/* -------------------------------------------------------------------------- */
u32 ir_extract_bits(u32 data, u32 mask)
{
int mbit, vbit;
u32 value;
value = 0;
vbit = 0;
for (mbit = 0; mbit < 32; mbit++) {
if (!(mask & ((u32)1 << mbit)))
continue;
if (data & ((u32)1 << mbit))
value |= (1 << vbit);
vbit++;
}
return value;
}
static int inline getbit(u32 *samples, int bit)
{
return (samples[bit/32] & (1 << (31-(bit%32)))) ? 1 : 0;
}
/* sump raw samples for visual debugging ;) */
int ir_dump_samples(u32 *samples, int count)
{
int i, bit, start;
printk(KERN_DEBUG "ir samples: ");
start = 0;
for (i = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit)
start = 1;
if (0 == start)
continue;
printk("%s", bit ? "#" : "_");
}
printk("\n");
return 0;
}
/* decode raw samples, pulse distance coding used by NEC remotes */
int ir_decode_pulsedistance(u32 *samples, int count, int low, int high)
{
int i,last,bit,len;
u32 curBit;
u32 value;
/* find start burst */
for (i = len = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit) {
len++;
} else {
if (len >= 29)
break;
len = 0;
}
}
/* start burst to short */
if (len < 29)
return 0xffffffff;
/* find start silence */
for (len = 0; i < count * 32; i++) {
bit = getbit(samples,i);
if (bit) {
break;
} else {
len++;
}
}
/* silence to short */
if (len < 7)
return 0xffffffff;
/* go decoding */
len = 0;
last = 1;
value = 0; curBit = 1;
for (; i < count * 32; i++) {
bit = getbit(samples,i);
if (last) {
if(bit) {
continue;
} else {
len = 1;
}
} else {
if (bit) {
if (len > (low + high) /2)
value |= curBit;
curBit <<= 1;
if (curBit == 1)
break;
} else {
len++;
}
}
last = bit;
}
return value;
}
/* decode raw samples, biphase coding, used by rc5 for example */
int ir_decode_biphase(u32 *samples, int count, int low, int high)
{
int i,last,bit,len,flips;
u32 value;
/* find start bit (1) */
for (i = 0; i < 32; i++) {
bit = getbit(samples,i);
if (bit)
break;
}
/* go decoding */
len = 0;
flips = 0;
value = 1;
for (; i < count * 32; i++) {
if (len > high)
break;
if (flips > 1)
break;
last = bit;
bit = getbit(samples,i);
if (last == bit) {
len++;
continue;
}
if (len < low) {
len++;
flips++;
continue;
}
value <<= 1;
value |= bit;
flips = 0;
len = 1;
}
return value;
}
EXPORT_SYMBOL_GPL(ir_input_init);
EXPORT_SYMBOL_GPL(ir_input_nokey);
EXPORT_SYMBOL_GPL(ir_input_keydown);
EXPORT_SYMBOL_GPL(ir_extract_bits);
EXPORT_SYMBOL_GPL(ir_dump_samples);
EXPORT_SYMBOL_GPL(ir_decode_biphase);
EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
/*
* Local variables:
* c-basic-offset: 8
* End:
*/

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,7 @@
#include <media/saa7146.h>
LIST_HEAD(saa7146_devices);
DECLARE_MUTEX(saa7146_devices_lock);
DEFINE_MUTEX(saa7146_devices_lock);
static int saa7146_num;
@ -116,8 +116,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
pg = vmalloc_to_page(virt);
if (NULL == pg)
goto err;
if (PageHighMem(pg))
BUG();
BUG_ON(PageHighMem(pg));
sglist[i].page = pg;
sglist[i].length = PAGE_SIZE;
}
@ -402,11 +401,11 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
pci_set_drvdata(pci, dev);
init_MUTEX(&dev->lock);
mutex_init(&dev->lock);
spin_lock_init(&dev->int_slock);
spin_lock_init(&dev->slock);
init_MUTEX(&dev->i2c_lock);
mutex_init(&dev->i2c_lock);
dev->module = THIS_MODULE;
init_waitqueue_head(&dev->i2c_wq);

View file

@ -17,18 +17,18 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
}
/* is it free? */
down(&dev->lock);
mutex_lock(&dev->lock);
if (vv->resources & bit) {
DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
/* no, someone else uses it */
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
/* it's free, grab it */
fh->resources |= bit;
vv->resources |= bit;
DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
up(&dev->lock);
mutex_unlock(&dev->lock);
return 1;
}
@ -37,14 +37,13 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
struct saa7146_dev *dev = fh->dev;
struct saa7146_vv *vv = dev->vv_data;
if ((fh->resources & bits) != bits)
BUG();
BUG_ON((fh->resources & bits) != bits);
down(&dev->lock);
mutex_lock(&dev->lock);
fh->resources &= ~bits;
vv->resources &= ~bits;
DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
up(&dev->lock);
mutex_unlock(&dev->lock);
}
@ -55,8 +54,7 @@ void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf)
{
DEB_EE(("dev:%p, buf:%p\n",dev,buf));
if (in_interrupt())
BUG();
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma);
@ -204,7 +202,7 @@ static int fops_open(struct inode *inode, struct file *file)
DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor));
if (down_interruptible(&saa7146_devices_lock))
if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;
list_for_each(list,&saa7146_devices) {
@ -276,7 +274,7 @@ out:
kfree(fh);
file->private_data = NULL;
}
up(&saa7146_devices_lock);
mutex_unlock(&saa7146_devices_lock);
return result;
}
@ -287,7 +285,7 @@ static int fops_release(struct inode *inode, struct file *file)
DEB_EE(("inode:%p, file:%p\n",inode,file));
if (down_interruptible(&saa7146_devices_lock))
if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;
if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
@ -303,7 +301,7 @@ static int fops_release(struct inode *inode, struct file *file)
file->private_data = NULL;
kfree(fh);
up(&saa7146_devices_lock);
mutex_unlock(&saa7146_devices_lock);
return 0;
}

View file

@ -279,7 +279,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
int address_err = 0;
int short_delay = 0;
if (down_interruptible (&dev->i2c_lock))
if (mutex_lock_interruptible(&dev->i2c_lock))
return -ERESTARTSYS;
for(i=0;i<num;i++) {
@ -366,7 +366,7 @@ out:
}
}
up(&dev->i2c_lock);
mutex_unlock(&dev->i2c_lock);
return err;
}

View file

@ -410,7 +410,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
sizeof(struct saa7146_buf),
file);
init_MUTEX(&fh->vbi_q.lock);
mutex_init(&fh->vbi_q.lock);
init_timer(&fh->vbi_read_timeout);
fh->vbi_read_timeout.function = vbi_read_timeout;

View file

@ -378,20 +378,20 @@ static int s_fmt(struct saa7146_fh *fh, struct v4l2_format *f)
err = try_win(dev,&f->fmt.win);
if (0 != err)
return err;
down(&dev->lock);
mutex_lock(&dev->lock);
fh->ov.win = f->fmt.win;
fh->ov.nclips = f->fmt.win.clipcount;
if (fh->ov.nclips > 16)
fh->ov.nclips = 16;
if (copy_from_user(fh->ov.clips,f->fmt.win.clips,sizeof(struct v4l2_clip)*fh->ov.nclips)) {
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EFAULT;
}
/* fh->ov.fh is used to indicate that we have valid overlay informations, too */
fh->ov.fh = fh;
up(&dev->lock);
mutex_unlock(&dev->lock);
/* check if our current overlay is active */
if (IS_OVERLAY_ACTIVE(fh) != 0) {
@ -516,7 +516,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
return -EINVAL;
}
down(&dev->lock);
mutex_lock(&dev->lock);
switch (ctrl->type) {
case V4L2_CTRL_TYPE_BOOLEAN:
@ -560,7 +560,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
/* fixme: we can support changing VFLIP and HFLIP here... */
if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_HFLIP while active capture.\n"));
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EINVAL;
}
vv->hflip = c->value;
@ -568,7 +568,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
case V4L2_CID_VFLIP:
if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_VFLIP while active capture.\n"));
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EINVAL;
}
vv->vflip = c->value;
@ -577,7 +577,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
return -EINVAL;
}
}
up(&dev->lock);
mutex_unlock(&dev->lock);
if (IS_OVERLAY_ACTIVE(fh) != 0) {
saa7146_stop_preview(fh);
@ -939,7 +939,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
}
}
down(&dev->lock);
mutex_lock(&dev->lock);
/* ok, accept it */
vv->ov_fb = *fb;
@ -948,7 +948,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
vv->ov_fb.fmt.bytesperline =
vv->ov_fb.fmt.width*fmt->depth/8;
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
@ -1086,7 +1086,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
}
}
down(&dev->lock);
mutex_lock(&dev->lock);
for(i = 0; i < dev->ext_vv_data->num_stds; i++)
if (*id & dev->ext_vv_data->stds[i].id)
@ -1098,7 +1098,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
found = 1;
}
up(&dev->lock);
mutex_unlock(&dev->lock);
if (vv->ov_suspend != NULL) {
saa7146_start_preview(vv->ov_suspend);
@ -1201,11 +1201,11 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
DEB_D(("VIDIOCGMBUF \n"));
q = &fh->video_q;
down(&q->lock);
mutex_lock(&q->lock);
err = videobuf_mmap_setup(q,gbuffers,gbufsize,
V4L2_MEMORY_MMAP);
if (err < 0) {
up(&q->lock);
mutex_unlock(&q->lock);
return err;
}
memset(mbuf,0,sizeof(*mbuf));
@ -1213,7 +1213,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
mbuf->size = gbuffers * gbufsize;
for (i = 0; i < gbuffers; i++)
mbuf->offsets[i] = i * gbufsize;
up(&q->lock);
mutex_unlock(&q->lock);
return 0;
}
default:
@ -1414,7 +1414,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
sizeof(struct saa7146_buf),
file);
init_MUTEX(&fh->video_q.lock);
mutex_init(&fh->video_q.lock);
return 0;
}

View file

@ -10,6 +10,7 @@
#include <linux/config.h>
#include <linux/pci.h>
#include <linux/mutex.h>
#include "flexcop-reg.h"
@ -73,8 +74,7 @@ struct flexcop_device {
int (*fe_sleep) (struct dvb_frontend *);
struct i2c_adapter i2c_adap;
struct semaphore i2c_sem;
struct mutex i2c_mutex;
struct module *owner;
/* options and status */

View file

@ -135,7 +135,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
int i, ret = 0;
if (down_interruptible(&fc->i2c_sem))
if (mutex_lock_interruptible(&fc->i2c_mutex))
return -ERESTARTSYS;
/* reading */
@ -161,7 +161,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
else
ret = num;
up(&fc->i2c_sem);
mutex_unlock(&fc->i2c_mutex);
return ret;
}
@ -180,7 +180,7 @@ int flexcop_i2c_init(struct flexcop_device *fc)
{
int ret;
sema_init(&fc->i2c_sem,1);
mutex_init(&fc->i2c_mutex);
memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE);

View file

@ -344,7 +344,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
int retval;
retval = 0;
if (down_interruptible (&bt->gpio_lock))
if (mutex_lock_interruptible(&bt->gpio_lock))
return -ERESTARTSYS;
/* special gpio signal */
switch (cmd) {
@ -375,7 +375,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
retval = -EINVAL;
break;
}
up(&bt->gpio_lock);
mutex_unlock(&bt->gpio_lock);
return retval;
}

View file

@ -25,6 +25,8 @@
#include <linux/pci.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include "bt848.h"
#include "bttv.h"
@ -108,7 +110,7 @@ struct cards {
extern int bt878_num;
struct bt878 {
struct semaphore gpio_lock;
struct mutex gpio_lock;
unsigned int nr;
unsigned int bttv_nr;
struct i2c_adapter *adapter;

View file

@ -910,7 +910,7 @@ static int dst_get_device_id(struct dst_state *state)
static int dst_probe(struct dst_state *state)
{
sema_init(&state->dst_mutex, 1);
mutex_init(&state->dst_mutex);
if ((rdc_8820_reset(state)) < 0) {
dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
return -1;
@ -962,7 +962,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
{
u8 reply;
down(&state->dst_mutex);
mutex_lock(&state->dst_mutex);
if ((dst_comm_init(state)) < 0) {
dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
goto error;
@ -1013,11 +1013,11 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
dprintk(verbose, DST_INFO, 1, "checksum failure");
goto error;
}
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return 0;
error:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return -EIO;
}
@ -1128,7 +1128,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
dst_set_voltage(fe, SEC_VOLTAGE_13);
}
state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
down(&state->dst_mutex);
mutex_lock(&state->dst_mutex);
if ((dst_comm_init(state)) < 0) {
dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
goto error;
@ -1160,11 +1160,11 @@ static int dst_write_tuna(struct dvb_frontend *fe)
state->diseq_flags |= ATTEMPT_TUNE;
retval = dst_get_tuna(state);
werr:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return retval;
error:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return -EIO;
}

View file

@ -81,7 +81,7 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
{
u8 reply;
down(&state->dst_mutex);
mutex_lock(&state->dst_mutex);
dst_comm_init(state);
msleep(65);
@ -110,11 +110,11 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
goto error;
}
}
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return 0;
error:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return -EIO;
}

View file

@ -25,6 +25,7 @@
#include <linux/smp_lock.h>
#include <linux/dvb/frontend.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include "bt878.h"
#include "dst_ca.h"
@ -121,7 +122,7 @@ struct dst_state {
u8 vendor[8];
u8 board_info[8];
struct semaphore dst_mutex;
struct mutex dst_mutex;
};
struct dst_types {

View file

@ -76,13 +76,13 @@ static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
if (!dvbdmx->dmx.frontend)
return -EINVAL;
down(&card->lock);
mutex_lock(&card->lock);
card->nfeeds++;
rc = card->nfeeds;
if (card->nfeeds == 1)
bt878_start(card->bt, card->gpio_mode,
card->op_sync_orin, card->irq_err_ignore);
up(&card->lock);
mutex_unlock(&card->lock);
return rc;
}
@ -96,11 +96,11 @@ static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
if (!dvbdmx->dmx.frontend)
return -EINVAL;
down(&card->lock);
mutex_lock(&card->lock);
card->nfeeds--;
if (card->nfeeds == 0)
bt878_stop(card->bt);
up(&card->lock);
mutex_unlock(&card->lock);
return 0;
}
@ -239,6 +239,20 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete
static int pinnsat_pll_init(struct dvb_frontend* fe)
{
struct dvb_bt8xx_card *card = fe->dvb->priv;
bttv_gpio_enable(card->bttv_nr, 1, 1); /* output */
bttv_write_gpio(card->bttv_nr, 1, 1); /* relay on */
return 0;
}
static int pinnsat_pll_sleep(struct dvb_frontend* fe)
{
struct dvb_bt8xx_card *card = fe->dvb->priv;
bttv_write_gpio(card->bttv_nr, 1, 0); /* relay off */
return 0;
}
@ -246,6 +260,7 @@ static struct cx24110_config pctvsat_config = {
.demod_address = 0x55,
.pll_init = pinnsat_pll_init,
.pll_set = cx24108_pll_set,
.pll_sleep = pinnsat_pll_sleep,
};
static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
@ -788,7 +803,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
return -ENOMEM;
init_MUTEX(&card->lock);
mutex_init(&card->lock);
card->bttv_nr = sub->core->nr;
strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
card->i2c_adapter = &sub->core->i2c_adap;
@ -798,14 +813,14 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
card->gpio_mode = 0x0400c060;
/* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
card->op_sync_orin = 0;
card->irq_err_ignore = 0;
card->op_sync_orin = BT878_RISC_SYNC_MASK;
card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
break;
case BTTV_BOARD_DVICO_DVBT_LITE:
card->gpio_mode = 0x0400C060;
card->op_sync_orin = 0;
card->irq_err_ignore = 0;
card->op_sync_orin = BT878_RISC_SYNC_MASK;
card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
/* 26, 15, 14, 6, 5
* A_PWRDN DA_DPM DA_SBR DA_IOM_DA
* DA_APP(parallel) */
@ -820,15 +835,15 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
case BTTV_BOARD_NEBULA_DIGITV:
case BTTV_BOARD_AVDVBT_761:
card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
card->op_sync_orin = 0;
card->irq_err_ignore = 0;
card->op_sync_orin = BT878_RISC_SYNC_MASK;
card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
/* A_PWRDN DA_SBR DA_APP (high speed serial) */
break;
case BTTV_BOARD_AVDVBT_771: //case 0x07711461:
card->gpio_mode = 0x0400402B;
card->op_sync_orin = BT878_RISC_SYNC_MASK;
card->irq_err_ignore = 0;
card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
/* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
break;
@ -852,8 +867,8 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
case BTTV_BOARD_PC_HDTV:
card->gpio_mode = 0x0100EC7B;
card->op_sync_orin = 0;
card->irq_err_ignore = 0;
card->op_sync_orin = BT878_RISC_SYNC_MASK;
card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
break;
default:
@ -881,7 +896,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
return -EFAULT;
}
init_MUTEX(&card->bt->gpio_lock);
mutex_init(&card->bt->gpio_lock);
card->bt->bttv_nr = sub->core->nr;
if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) {

View file

@ -26,6 +26,7 @@
#define DVB_BT8XX_H
#include <linux/i2c.h>
#include <linux/mutex.h>
#include "dvbdev.h"
#include "dvb_net.h"
#include "bttv.h"
@ -38,7 +39,7 @@
#include "lgdt330x.h"
struct dvb_bt8xx_card {
struct semaphore lock;
struct mutex lock;
int nfeeds;
char card_name[32];
struct dvb_adapter dvb_adapter;

View file

@ -30,6 +30,7 @@
#include <linux/pci.h>
#include <linux/input.h>
#include <linux/dvb/frontend.h>
#include <linux/mutex.h>
#include "dmxdev.h"
#include "dvb_demux.h"
@ -116,7 +117,7 @@ static struct dvb_frontend_info cinergyt2_fe_info = {
struct cinergyt2 {
struct dvb_demux demux;
struct usb_device *udev;
struct semaphore sem;
struct mutex sem;
struct dvb_adapter adapter;
struct dvb_device *fedev;
struct dmxdev dmxdev;
@ -345,14 +346,14 @@ static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
struct dvb_demux *demux = dvbdmxfeed->demux;
struct cinergyt2 *cinergyt2 = demux->priv;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if (cinergyt2->streaming == 0)
cinergyt2_start_stream_xfer(cinergyt2);
cinergyt2->streaming++;
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return 0;
}
@ -361,13 +362,13 @@ static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
struct dvb_demux *demux = dvbdmxfeed->demux;
struct cinergyt2 *cinergyt2 = demux->priv;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if (--cinergyt2->streaming == 0)
cinergyt2_stop_stream_xfer(cinergyt2);
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return 0;
}
@ -483,11 +484,11 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
struct cinergyt2 *cinergyt2 = dvbdev->priv;
int err = -ERESTARTSYS;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if ((err = dvb_generic_open(inode, file))) {
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return err;
}
@ -499,12 +500,15 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
atomic_inc(&cinergyt2->inuse);
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return 0;
}
static void cinergyt2_unregister(struct cinergyt2 *cinergyt2)
{
dvb_net_release(&cinergyt2->dvbnet);
dvb_dmxdev_release(&cinergyt2->dmxdev);
dvb_dmx_release(&cinergyt2->demux);
dvb_unregister_device(cinergyt2->fedev);
dvb_unregister_adapter(&cinergyt2->adapter);
@ -517,7 +521,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file)
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
if (down_interruptible(&cinergyt2->sem))
if (mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {
@ -526,7 +530,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file)
cinergyt2_sleep(cinergyt2, 1);
}
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) {
warn("delayed unregister in release");
@ -541,12 +545,12 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct
struct dvb_device *dvbdev = file->private_data;
struct cinergyt2 *cinergyt2 = dvbdev->priv;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
poll_wait(file, &cinergyt2->poll_wq, wait);
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return (POLLIN | POLLRDNORM | POLLPRI);
}
@ -613,7 +617,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
if (copy_from_user(&p, (void __user*) arg, sizeof(p)))
return -EFAULT;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
@ -629,7 +633,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
(char *) param, sizeof(*param),
NULL, 0);
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return (err < 0) ? err : 0;
}
@ -724,7 +728,7 @@ static void cinergyt2_query_rc (void *data)
struct cinergyt2_rc_event rc_events[12];
int n, len, i;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return;
len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
@ -784,7 +788,7 @@ out:
schedule_delayed_work(&cinergyt2->rc_query_work,
msecs_to_jiffies(RC_QUERY_INTERVAL));
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
}
static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
@ -849,7 +853,7 @@ static void cinergyt2_query (void *data)
uint8_t lock_bits;
uint32_t unc;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return;
unc = s->uncorrected_block_count;
@ -868,7 +872,7 @@ static void cinergyt2_query (void *data)
schedule_delayed_work(&cinergyt2->query_work,
msecs_to_jiffies(QUERY_INTERVAL));
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
}
static int cinergyt2_probe (struct usb_interface *intf,
@ -885,7 +889,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
memset (cinergyt2, 0, sizeof (struct cinergyt2));
usb_set_intfdata (intf, (void *) cinergyt2);
init_MUTEX(&cinergyt2->sem);
mutex_init(&cinergyt2->sem);
init_waitqueue_head (&cinergyt2->poll_wq);
INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
@ -937,6 +941,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
return 0;
bailout:
dvb_net_release(&cinergyt2->dvbnet);
dvb_dmxdev_release(&cinergyt2->dmxdev);
dvb_dmx_release(&cinergyt2->demux);
dvb_unregister_adapter(&cinergyt2->adapter);
@ -967,7 +972,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
{
struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if (state.event > PM_EVENT_ON) {
@ -981,7 +986,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
cinergyt2_sleep(cinergyt2, 1);
}
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return 0;
}
@ -990,7 +995,7 @@ static int cinergyt2_resume (struct usb_interface *intf)
struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
struct dvbt_set_parameters_msg *param = &cinergyt2->param;
if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))
if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
return -ERESTARTSYS;
if (!cinergyt2->sleeping) {
@ -1003,7 +1008,7 @@ static int cinergyt2_resume (struct usb_interface *intf)
cinergyt2_resume_rc(cinergyt2);
up(&cinergyt2->sem);
mutex_unlock(&cinergyt2->sem);
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -30,14 +30,15 @@
#include <linux/wait.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <linux/dvb/dmx.h>
#include "dvbdev.h"
#include "demux.h"
#include "dvb_ringbuffer.h"
enum dmxdevype {
enum dmxdev_type {
DMXDEV_TYPE_NONE,
DMXDEV_TYPE_SEC,
DMXDEV_TYPE_PES,
@ -52,18 +53,7 @@ enum dmxdev_state {
DMXDEV_STATE_TIMEDOUT
};
struct dmxdev_buffer {
u8 *data;
int size;
int pread;
int pwrite;
wait_queue_head_t queue;
int error;
};
struct dmxdev_filter {
struct dvb_device *dvbdev;
union {
struct dmx_section_filter *sec;
} filter;
@ -78,26 +68,17 @@ struct dmxdev_filter {
struct dmx_pes_filter_params pes;
} params;
int type;
enum dmxdev_type type;
enum dmxdev_state state;
struct dmxdev *dev;
struct dmxdev_buffer buffer;
struct dvb_ringbuffer buffer;
struct semaphore mutex;
struct mutex mutex;
/* only for sections */
struct timer_list timer;
int todo;
u8 secheader[3];
u16 pid;
};
struct dmxdev_dvr {
int state;
struct dmxdev *dev;
struct dmxdev_buffer buffer;
};
@ -106,7 +87,6 @@ struct dmxdev {
struct dvb_device *dvr_dvbdev;
struct dmxdev_filter *filter;
struct dmxdev_dvr *dvr;
struct dmx_demux *demux;
int filternum;
@ -114,10 +94,10 @@ struct dmxdev {
#define DMXDEV_CAP_DUPLEX 1
struct dmx_frontend *dvr_orig_fe;
struct dmxdev_buffer dvr_buffer;
struct dvb_ringbuffer dvr_buffer;
#define DVR_BUFFER_SIZE (10*188*1024)
struct semaphore mutex;
struct mutex mutex;
spinlock_t lock;
};

View file

@ -589,18 +589,18 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
if (pid > DMX_MAX_PID)
return -EINVAL;
if (down_interruptible(&demux->mutex))
if (mutex_lock_interruptible(&demux->mutex))
return -ERESTARTSYS;
if (ts_type & TS_DECODER) {
if (pes_type >= DMX_TS_PES_OTHER) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EINVAL;
}
if (demux->pesfilter[pes_type] &&
demux->pesfilter[pes_type] != feed) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EINVAL;
}
@ -622,14 +622,14 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
#else
feed->buffer = vmalloc(feed->buffer_size);
if (!feed->buffer) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -ENOMEM;
}
#endif
}
feed->state = DMX_STATE_READY;
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return 0;
}
@ -640,21 +640,21 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
struct dvb_demux *demux = feed->demux;
int ret;
if (down_interruptible(&demux->mutex))
if (mutex_lock_interruptible(&demux->mutex))
return -ERESTARTSYS;
if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EINVAL;
}
if (!demux->start_feed) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -ENODEV;
}
if ((ret = demux->start_feed(feed)) < 0) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return ret;
}
@ -662,7 +662,7 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
ts_feed->is_filtering = 1;
feed->state = DMX_STATE_GO;
spin_unlock_irq(&demux->lock);
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return 0;
}
@ -673,16 +673,16 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
struct dvb_demux *demux = feed->demux;
int ret;
if (down_interruptible(&demux->mutex))
if (mutex_lock_interruptible(&demux->mutex))
return -ERESTARTSYS;
if (feed->state < DMX_STATE_GO) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EINVAL;
}
if (!demux->stop_feed) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -ENODEV;
}
@ -692,7 +692,7 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
ts_feed->is_filtering = 0;
feed->state = DMX_STATE_ALLOCATED;
spin_unlock_irq(&demux->lock);
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return ret;
}
@ -704,11 +704,11 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
struct dvb_demux *demux = (struct dvb_demux *)dmx;
struct dvb_demux_feed *feed;
if (down_interruptible(&demux->mutex))
if (mutex_lock_interruptible(&demux->mutex))
return -ERESTARTSYS;
if (!(feed = dvb_dmx_feed_alloc(demux))) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EBUSY;
}
@ -729,7 +729,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
feed->state = DMX_STATE_FREE;
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EBUSY;
}
@ -737,7 +737,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
feed->filter->feed = feed;
feed->filter->state = DMX_STATE_READY;
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return 0;
}
@ -748,11 +748,11 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
struct dvb_demux *demux = (struct dvb_demux *)dmx;
struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
if (down_interruptible(&demux->mutex))
if (mutex_lock_interruptible(&demux->mutex))
return -ERESTARTSYS;
if (feed->state == DMX_STATE_FREE) {
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return -EINVAL;
}
#ifndef NOBUFS
@ -770,7 +770,7 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER)
demux->pesfilter[feed->pes_type] = NULL;
up(&demux->mutex);
mutex_unlock(&demux->mutex);
return 0;
}
@ -785,12 +785,12 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
struct dvb_demux *dvbdemux = dvbdmxfeed->demux;
struct dvb_demux_filter *dvbdmxfilter;
if (down_interruptible(&dvbdemux->mutex))
if (mutex_lock_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS;
dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux);
if (!dvbdmxfilter) {
up(&dvbdemux->mutex);
mutex_unlock(&dvbdemux->mutex);
return -EBUSY;
}
@ -805,7 +805,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
dvbdmxfeed->filter = dvbdmxfilter;
spin_unlock_irq(&dvbdemux->lock);
up(&dvbdemux->mutex);
mutex_unlock(&dvbdemux->mutex);
return 0;
}
@ -819,7 +819,7 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed,
if (pid > 0x1fff)
return -EINVAL;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
dvb_demux_feed_add(dvbdmxfeed);
@ -833,13 +833,13 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed,
#else
dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
if (!dvbdmxfeed->buffer) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -ENOMEM;
}
#endif
dvbdmxfeed->state = DMX_STATE_READY;
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return 0;
}
@ -871,16 +871,16 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
int ret;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
if (feed->is_filtering) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -EBUSY;
}
if (!dvbdmxfeed->filter) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -EINVAL;
}
@ -890,14 +890,14 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
dvbdmxfeed->feed.sec.seclen = 0;
if (!dvbdmx->start_feed) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -ENODEV;
}
prepare_secfilters(dvbdmxfeed);
if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return ret;
}
@ -906,7 +906,7 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
dvbdmxfeed->state = DMX_STATE_GO;
spin_unlock_irq(&dvbdmx->lock);
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return 0;
}
@ -916,11 +916,11 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
int ret;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
if (!dvbdmx->stop_feed) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -ENODEV;
}
@ -931,7 +931,7 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
feed->is_filtering = 0;
spin_unlock_irq(&dvbdmx->lock);
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return ret;
}
@ -942,11 +942,11 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
if (dvbdmxfilter->feed != dvbdmxfeed) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -EINVAL;
}
@ -966,7 +966,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
dvbdmxfilter->state = DMX_STATE_FREE;
spin_unlock_irq(&dvbdmx->lock);
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return 0;
}
@ -977,11 +977,11 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
struct dvb_demux_feed *dvbdmxfeed;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -EBUSY;
}
@ -1006,7 +1006,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
(*feed)->stop_filtering = dmx_section_feed_stop_filtering;
(*feed)->release_filter = dmx_section_feed_release_filter;
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return 0;
}
@ -1016,11 +1016,11 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
if (down_interruptible(&dvbdmx->mutex))
if (mutex_lock_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS;
if (dvbdmxfeed->state == DMX_STATE_FREE) {
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return -EINVAL;
}
#ifndef NOBUFS
@ -1033,7 +1033,7 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
dvbdmxfeed->pid = 0xffff;
up(&dvbdmx->mutex);
mutex_unlock(&dvbdmx->mutex);
return 0;
}
@ -1071,10 +1071,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
return -EINVAL;
if (down_interruptible(&dvbdemux->mutex))
if (mutex_lock_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS;
dvb_dmx_swfilter(dvbdemux, buf, count);
up(&dvbdemux->mutex);
mutex_unlock(&dvbdemux->mutex);
if (signal_pending(current))
return -EINTR;
@ -1126,11 +1126,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux,
if (demux->frontend)
return -EINVAL;
if (down_interruptible(&dvbdemux->mutex))
if (mutex_lock_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS;
demux->frontend = frontend;
up(&dvbdemux->mutex);
mutex_unlock(&dvbdemux->mutex);
return 0;
}
@ -1138,11 +1138,11 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
{
struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (down_interruptible(&dvbdemux->mutex))
if (mutex_lock_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS;
demux->frontend = NULL;
up(&dvbdemux->mutex);
mutex_unlock(&dvbdemux->mutex);
return 0;
}
@ -1215,7 +1215,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
dmx->disconnect_frontend = dvbdmx_disconnect_frontend;
dmx->get_pes_pids = dvbdmx_get_pes_pids;
sema_init(&dvbdemux->mutex, 1);
mutex_init(&dvbdemux->mutex);
spin_lock_init(&dvbdemux->lock);
return 0;

View file

@ -26,7 +26,7 @@
#include <linux/time.h>
#include <linux/timer.h>
#include <linux/spinlock.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include "demux.h"
@ -125,7 +125,7 @@ struct dvb_demux {
u8 tsbuf[204];
int tsbufp;
struct semaphore mutex;
struct mutex mutex;
spinlock_t lock;
};

View file

@ -37,7 +37,6 @@
#include <linux/suspend.h>
#include <linux/jiffies.h>
#include <asm/processor.h>
#include <asm/semaphore.h>
#include "dvb_frontend.h"
#include "dvbdev.h"
@ -50,13 +49,13 @@ static int dvb_powerdown_on_sleep = 1;
module_param_named(frontend_debug, dvb_frontend_debug, int, 0644);
MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off).");
module_param(dvb_shutdown_timeout, int, 0444);
module_param(dvb_shutdown_timeout, int, 0644);
MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware");
module_param(dvb_force_auto_inversion, int, 0444);
module_param(dvb_force_auto_inversion, int, 0644);
MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AUTO forced always");
module_param(dvb_override_tune_delay, int, 0444);
module_param(dvb_override_tune_delay, int, 0644);
MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt");
module_param(dvb_powerdown_on_sleep, int, 0444);
module_param(dvb_powerdown_on_sleep, int, 0644);
MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB volatage off on sleep (default)");
#define dprintk if (dvb_frontend_debug) printk
@ -88,7 +87,7 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB vola
* FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
*/
static DECLARE_MUTEX(frontend_mutex);
static DEFINE_MUTEX(frontend_mutex);
struct dvb_frontend_private {
@ -1021,12 +1020,12 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
dprintk ("%s\n", __FUNCTION__);
if (down_interruptible (&frontend_mutex))
if (mutex_lock_interruptible(&frontend_mutex))
return -ERESTARTSYS;
fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
if (fe->frontend_priv == NULL) {
up(&frontend_mutex);
mutex_unlock(&frontend_mutex);
return -ENOMEM;
}
fepriv = fe->frontend_priv;
@ -1045,7 +1044,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
fe, DVB_DEVICE_FRONTEND);
up (&frontend_mutex);
mutex_unlock(&frontend_mutex);
return 0;
}
EXPORT_SYMBOL(dvb_register_frontend);
@ -1055,7 +1054,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
struct dvb_frontend_private *fepriv = fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
down (&frontend_mutex);
mutex_lock(&frontend_mutex);
dvb_unregister_device (fepriv->dvbdev);
dvb_frontend_stop (fe);
if (fe->ops->release)
@ -1064,7 +1063,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name);
/* fe is invalid now */
kfree(fepriv);
up (&frontend_mutex);
mutex_unlock(&frontend_mutex);
return 0;
}
EXPORT_SYMBOL(dvb_unregister_frontend);

View file

@ -104,6 +104,7 @@ struct dvb_frontend {
struct dvb_adapter *dvb;
void* demodulator_priv;
void* frontend_priv;
void* misc_priv;
};
extern int dvb_register_frontend(struct dvb_adapter* dvb,

View file

@ -62,6 +62,7 @@
#include <linux/uio.h>
#include <asm/uaccess.h>
#include <linux/crc32.h>
#include <linux/mutex.h>
#include "dvb_demux.h"
#include "dvb_net.h"
@ -151,8 +152,7 @@ struct dvb_net_priv {
unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
unsigned long ts_count; /* Current ts cell counter. */
struct semaphore mutex;
struct mutex mutex;
};
@ -889,7 +889,7 @@ static int dvb_net_feed_start(struct net_device *dev)
unsigned char *mac = (unsigned char *) dev->dev_addr;
dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
down(&priv->mutex);
mutex_lock(&priv->mutex);
if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
@ -974,7 +974,7 @@ static int dvb_net_feed_start(struct net_device *dev)
ret = -EINVAL;
error:
up(&priv->mutex);
mutex_unlock(&priv->mutex);
return ret;
}
@ -984,7 +984,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
int i, ret = 0;
dprintk("%s\n", __FUNCTION__);
down(&priv->mutex);
mutex_lock(&priv->mutex);
if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
if (priv->secfeed) {
if (priv->secfeed->is_filtering) {
@ -1026,7 +1026,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
printk("%s: no ts feed to stop\n", dev->name);
} else
ret = -EINVAL;
up(&priv->mutex);
mutex_unlock(&priv->mutex);
return ret;
}
@ -1208,7 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
init_MUTEX(&priv->mutex);
mutex_init(&priv->mutex);
net->base_addr = pid;

View file

@ -45,6 +45,7 @@ void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len)
rbuf->pread=rbuf->pwrite=0;
rbuf->data=data;
rbuf->size=len;
rbuf->error=0;
init_waitqueue_head(&rbuf->queue);
@ -87,6 +88,7 @@ ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
{
rbuf->pread = rbuf->pwrite;
rbuf->error = 0;
}

View file

@ -35,6 +35,7 @@ struct dvb_ringbuffer {
ssize_t size;
ssize_t pread;
ssize_t pwrite;
int error;
wait_queue_head_t queue;
spinlock_t lock;

View file

@ -77,7 +77,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
if (down_interruptible(&d->i2c_sem) < 0)
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
if (num > 2)
@ -126,7 +126,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
}
}
up(&d->i2c_sem);
mutex_unlock(&d->i2c_mutex);
return i;
}

View file

@ -128,7 +128,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
if (down_interruptible(&d->i2c_sem) < 0)
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
if (num > 2)
@ -146,7 +146,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
break;
}
up(&d->i2c_sem);
mutex_unlock(&d->i2c_mutex);
return i;
}

View file

@ -48,7 +48,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i;
if (down_interruptible(&d->i2c_sem) < 0)
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
if (num > 2)
@ -67,7 +67,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
break;
}
up(&d->i2c_sem);
mutex_unlock(&d->i2c_mutex);
return i;
}

View file

@ -42,8 +42,8 @@ static int dvb_usb_init(struct dvb_usb_device *d)
{
int ret = 0;
sema_init(&d->usb_sem, 1);
sema_init(&d->i2c_sem, 1);
mutex_init(&d->usb_mutex);
mutex_init(&d->i2c_mutex);
d->state = DVB_USB_STATE_INIT;

View file

@ -21,7 +21,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
if (wbuf == NULL || wlen == 0)
return -EINVAL;
if ((ret = down_interruptible(&d->usb_sem)))
if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret;
deb_xfer(">>> ");
@ -53,7 +53,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
}
}
up(&d->usb_sem);
mutex_unlock(&d->usb_mutex);
return ret;
}
EXPORT_SYMBOL(dvb_usb_generic_rw);

View file

@ -12,6 +12,7 @@
#include <linux/input.h>
#include <linux/usb.h>
#include <linux/firmware.h>
#include <linux/mutex.h>
#include "dvb_frontend.h"
#include "dvb_demux.h"
@ -227,8 +228,8 @@ struct dvb_usb_properties {
* @feedcount: number of reqested feeds (used for streaming-activation)
* @pid_filtering: is hardware pid_filtering used or not.
*
* @usb_sem: semaphore of USB control messages (reading needs two messages)
* @i2c_sem: semaphore for i2c-transfers
* @usb_mutex: semaphore of USB control messages (reading needs two messages)
* @i2c_mutex: semaphore for i2c-transfers
*
* @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
* @pll_addr: I2C address of the tuner for programming
@ -283,10 +284,10 @@ struct dvb_usb_device {
int pid_filtering;
/* locking */
struct semaphore usb_sem;
struct mutex usb_mutex;
/* i2c */
struct semaphore i2c_sem;
struct mutex i2c_mutex;
struct i2c_adapter i2c_adap;
/* tuner programming information */

View file

@ -75,7 +75,7 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il
{
int ret;
if ((ret = down_interruptible(&d->usb_sem)))
if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret;
if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0)
@ -84,7 +84,7 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il
ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen);
unlock:
up(&d->usb_sem);
mutex_unlock(&d->usb_mutex);
return ret;
}

View file

@ -38,7 +38,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in,
deb_xfer("out buffer: ");
debug_dump(outbuf,outlen+1,deb_xfer);
if ((ret = down_interruptible(&d->usb_sem)))
if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret;
if (usb_control_msg(d->udev,
@ -68,7 +68,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in,
memcpy(in,&inbuf[1],inlen);
unlock:
up(&d->usb_sem);
mutex_unlock(&d->usb_mutex);
return ret;
}

View file

@ -116,6 +116,12 @@ config DVB_MT352
help
A DVB-T tuner module. Say Y when you want to support this frontend.
config DVB_ZL10353
tristate "Zarlink ZL10353 based"
depends on DVB_CORE
help
A DVB-T tuner module. Say Y when you want to support this frontend.
config DVB_DIB3000MB
tristate "DiBcom 3000M-B"
depends on DVB_CORE
@ -155,7 +161,7 @@ comment "ATSC (North American/Korean Terresterial DTV) frontends"
depends on DVB_CORE
config DVB_NXT200X
tristate "Nextwave NXT2002/NXT2004 based"
tristate "NxtWave Communications NXT2002/NXT2004 based"
depends on DVB_CORE
select FW_LOADER
help
@ -169,14 +175,14 @@ config DVB_NXT200X
or /lib/firmware (depending on configuration of firmware hotplug).
config DVB_OR51211
tristate "or51211 based (pcHDTV HD2000 card)"
tristate "Oren OR51211 based"
depends on DVB_CORE
select FW_LOADER
help
An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
config DVB_OR51132
tristate "OR51132 based (pcHDTV HD3000 card)"
tristate "Oren OR51132 based"
depends on DVB_CORE
select FW_LOADER
help

View file

@ -20,6 +20,7 @@ obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o
obj-$(CONFIG_DVB_SP887X) += sp887x.o
obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
obj-$(CONFIG_DVB_MT352) += mt352.o
obj-$(CONFIG_DVB_ZL10353) += zl10353.o
obj-$(CONFIG_DVB_CX22702) += cx22702.o
obj-$(CONFIG_DVB_TDA10021) += tda10021.o
obj-$(CONFIG_DVB_STV0297) += stv0297.o

View file

@ -39,6 +39,7 @@
#include <linux/jiffies.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include "dvb_frontend.h"
#include "bcm3510.h"
@ -52,7 +53,7 @@ struct bcm3510_state {
struct dvb_frontend frontend;
/* demodulator private data */
struct semaphore hab_sem;
struct mutex hab_mutex;
u8 firmware_loaded:1;
unsigned long next_status_check;
@ -213,7 +214,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob
dbufout(ob,olen+2,deb_hab);
deb_hab("\n");
if (down_interruptible(&st->hab_sem) < 0)
if (mutex_lock_interruptible(&st->hab_mutex) < 0)
return -EAGAIN;
if ((ret = bcm3510_hab_send_request(st, ob, olen+2)) < 0 ||
@ -226,7 +227,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob
memcpy(ibuf,&ib[2],ilen);
error:
up(&st->hab_sem);
mutex_unlock(&st->hab_mutex);
return ret;
}
@ -796,7 +797,7 @@ struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config,
state->frontend.ops = &state->ops;
state->frontend.demodulator_priv = state;
sema_init(&state->hab_sem, 1);
mutex_init(&state->hab_mutex);
if ((ret = bcm3510_readB(state,0xe0,&v)) < 0)
goto error;

View file

@ -0,0 +1,123 @@
/*
* bsbe1.h - ALPS BSBE1 tuner support (moved from av7110.c)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*
*
* the project's page is at http://www.linuxtv.org
*/
#ifndef BSBE1_H
#define BSBE1_H
static u8 alps_bsbe1_inittab[] = {
0x01, 0x15,
0x02, 0x30,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x92,
0xff, 0xff
};
static int alps_bsbe1_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
stv0299_writereg(fe, 0x13, aclk);
stv0299_writereg(fe, 0x14, bclk);
stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
return 0;
}
static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
int ret;
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
ret = i2c_transfer(i2c, &msg, 1);
return (ret != 1) ? -EIO : 0;
}
static struct stv0299_config alps_bsbe1_config = {
.demod_address = 0x68,
.inittab = alps_bsbe1_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsbe1_set_symbol_rate,
.pll_set = alps_bsbe1_pll_set,
};
#endif

View file

@ -0,0 +1,140 @@
/*
* bsru6.h - ALPS BSRU6 tuner support (moved from budget-ci.c)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*
*
* the project's page is at http://www.linuxtv.org
*/
#ifndef BSRU6_H
#define BSRU6_H
static u8 alps_bsru6_inittab[] = {
0x01, 0x15,
0x02, 0x00,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x52,
0xff, 0xff
};
static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) {
aclk = 0xb7;
bclk = 0x47;
} else if (srate < 3000000) {
aclk = 0xb7;
bclk = 0x4b;
} else if (srate < 7000000) {
aclk = 0xb7;
bclk = 0x4f;
} else if (srate < 14000000) {
aclk = 0xb7;
bclk = 0x53;
} else if (srate < 30000000) {
aclk = 0xb6;
bclk = 0x53;
} else if (srate < 45000000) {
aclk = 0xb4;
bclk = 0x51;
}
stv0299_writereg(fe, 0x13, aclk);
stv0299_writereg(fe, 0x14, bclk);
stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg(fe, 0x21, ratio & 0xf0);
return 0;
}
static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params)
{
u8 buf[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
buf[0] = (div >> 8) & 0x7f;
buf[1] = div & 0xff;
buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
buf[3] = 0xC4;
if (params->frequency > 1530000)
buf[3] = 0xc0;
if (i2c_transfer(i2c, &msg, 1) != 1)
return -EIO;
return 0;
}
static struct stv0299_config alps_bsru6_config = {
.demod_address = 0x68,
.inittab = alps_bsru6_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.lock_output = STV0229_LOCKOUTPUT_1,
.volt13_op0_op1 = STV0299_VOLT13_OP1,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsru6_pll_set,
};
#endif

View file

@ -371,6 +371,15 @@ static int cx24110_initfe(struct dvb_frontend* fe)
return 0;
}
static int cx24110_sleep(struct dvb_frontend *fe)
{
struct cx24110_state *state = fe->demodulator_priv;
if (state->config->pll_sleep)
return state->config->pll_sleep(fe);
return 0;
}
static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
{
struct cx24110_state *state = fe->demodulator_priv;
@ -418,6 +427,9 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe,
struct cx24110_state *state = fe->demodulator_priv;
unsigned long timeout;
if (cmd->msg_len < 3 || cmd->msg_len > 6)
return -EINVAL; /* not implemented */
for (i = 0; i < cmd->msg_len; i++)
cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
@ -639,6 +651,7 @@ static struct dvb_frontend_ops cx24110_ops = {
.release = cx24110_release,
.init = cx24110_initfe,
.sleep = cx24110_sleep,
.set_frontend = cx24110_set_frontend,
.get_frontend = cx24110_get_frontend,
.read_status = cx24110_read_status,

View file

@ -35,6 +35,7 @@ struct cx24110_config
/* PLL maintenance */
int (*pll_init)(struct dvb_frontend* fe);
int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
int (*pll_sleep)(struct dvb_frontend* fe);
};
extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,

View file

@ -362,6 +362,63 @@ struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
};
EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
/*
* Philips TD1316 Tuner.
*/
static void td1316_bw(u8 *buf, u32 freq, int bandwidth)
{
u8 band;
/* determine band */
if (freq < 161000000)
band = 1;
else if (freq < 444000000)
band = 2;
else
band = 4;
buf[3] |= band;
/* setup PLL filter */
if (bandwidth == BANDWIDTH_8_MHZ)
buf[3] |= 1 << 3;
}
struct dvb_pll_desc dvb_pll_philips_td1316 = {
.name = "Philips TD1316",
.min = 87000000,
.max = 895000000,
.setbw = td1316_bw,
.count = 9,
.entries = {
{ 93834000, 36166000, 166666, 0xca, 0x60},
{ 123834000, 36166000, 166666, 0xca, 0xa0},
{ 163834000, 36166000, 166666, 0xca, 0xc0},
{ 253834000, 36166000, 166666, 0xca, 0x60},
{ 383834000, 36166000, 166666, 0xca, 0xa0},
{ 443834000, 36166000, 166666, 0xca, 0xc0},
{ 583834000, 36166000, 166666, 0xca, 0x60},
{ 793834000, 36166000, 166666, 0xca, 0xa0},
{ 858834000, 36166000, 166666, 0xca, 0xe0},
},
};
EXPORT_SYMBOL(dvb_pll_philips_td1316);
/* FE6600 used on DViCO Hybrid */
struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
.name = "Thomson FE6600",
.min = 44250000,
.max = 858000000,
.count = 4,
.entries = {
{ 250000000, 36213333, 166667, 0xb4, 0x12 },
{ 455000000, 36213333, 166667, 0xfe, 0x11 },
{ 775500000, 36213333, 166667, 0xbc, 0x18 },
{ 999999999, 36213333, 166667, 0xf4, 0x18 },
}
};
EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
/* ----------------------------------------------------------- */
/* code */
@ -391,8 +448,8 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
buf[0] = div >> 8;
buf[1] = div & 0xff;
buf[2] = desc->entries[i].cb1;
buf[3] = desc->entries[i].cb2;
buf[2] = desc->entries[i].config;
buf[3] = desc->entries[i].cb;
if (desc->setbw)
desc->setbw(buf, freq, bandwidth);

View file

@ -15,8 +15,8 @@ struct dvb_pll_desc {
u32 limit;
u32 offset;
u32 stepsize;
u8 cb1;
u8 cb2;
u8 config;
u8 cb;
} entries[12];
};
@ -40,6 +40,9 @@ extern struct dvb_pll_desc dvb_pll_tuv1236d;
extern struct dvb_pll_desc dvb_pll_tdhu2;
extern struct dvb_pll_desc dvb_pll_samsung_tbmv;
extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261;
extern struct dvb_pll_desc dvb_pll_philips_td1316;
extern struct dvb_pll_desc dvb_pll_thomson_fe6600;
int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
u32 freq, int bandwidth);

View file

@ -0,0 +1,139 @@
/*
* lnbp21.h - driver for lnb supply and control ic lnbp21
*
* Copyright (C) 2006 Oliver Endriss
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*
*
* the project's page is at http://www.linuxtv.org
*/
#ifndef _LNBP21_H
#define _LNBP21_H
/* system register */
#define LNBP21_OLF 0x01
#define LNBP21_OTF 0x02
#define LNBP21_EN 0x04
#define LNBP21_VSEL 0x08
#define LNBP21_LLC 0x10
#define LNBP21_TEN 0x20
#define LNBP21_ISEL 0x40
#define LNBP21_PCL 0x80
struct lnbp21 {
u8 config;
u8 override_or;
u8 override_and;
struct i2c_adapter *i2c;
void (*release_chain)(struct dvb_frontend* fe);
};
static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
{
struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
struct i2c_msg msg = { .addr = 0x08, .flags = 0,
.buf = &lnbp21->config,
.len = sizeof(lnbp21->config) };
lnbp21->config &= ~(LNBP21_VSEL | LNBP21_EN);
switch(voltage) {
case SEC_VOLTAGE_OFF:
break;
case SEC_VOLTAGE_13:
lnbp21->config |= LNBP21_EN;
break;
case SEC_VOLTAGE_18:
lnbp21->config |= (LNBP21_EN | LNBP21_VSEL);
break;
default:
return -EINVAL;
};
lnbp21->config |= lnbp21->override_or;
lnbp21->config &= lnbp21->override_and;
return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
}
static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
{
struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
struct i2c_msg msg = { .addr = 0x08, .flags = 0,
.buf = &lnbp21->config,
.len = sizeof(lnbp21->config) };
if (arg)
lnbp21->config |= LNBP21_LLC;
else
lnbp21->config &= ~LNBP21_LLC;
lnbp21->config |= lnbp21->override_or;
lnbp21->config &= lnbp21->override_and;
return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
}
static void lnbp21_exit(struct dvb_frontend *fe)
{
struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
/* LNBP power off */
lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
/* free data & call next release routine */
fe->ops->release = lnbp21->release_chain;
kfree(fe->misc_priv);
fe->misc_priv = NULL;
if (fe->ops->release)
fe->ops->release(fe);
}
static int lnbp21_init(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
{
struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL);
if (!lnbp21)
return -ENOMEM;
/* default configuration */
lnbp21->config = LNBP21_ISEL;
/* bits which should be forced to '1' */
lnbp21->override_or = override_set;
/* bits which should be forced to '0' */
lnbp21->override_and = ~override_clear;
/* install release callback */
lnbp21->release_chain = fe->ops->release;
fe->ops->release = lnbp21_exit;
/* override frontend ops */
fe->ops->set_voltage = lnbp21_set_voltage;
fe->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
lnbp21->i2c = i2c;
fe->misc_priv = lnbp21;
return lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
}
#endif

View file

@ -229,7 +229,7 @@ static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state)
dprintk("%s\n", __FUNCTION__);
result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2);
msleep(1);
msleep(20);
return result;
}
@ -502,7 +502,12 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
const struct firmware *fw;
/* reset + wake up chip */
tda1004x_write_byteI(state, TDA1004X_CONFC4, 0);
if (state->config->xtal_freq == TDA10046_XTAL_4M) {
tda1004x_write_byteI(state, TDA1004X_CONFC4, 0);
} else {
dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __FUNCTION__);
tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80);
}
tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0);
/* let the clocks recover from sleep */
msleep(5);
@ -651,7 +656,7 @@ static int tda10046_init(struct dvb_frontend* fe)
// tda setup
tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream
tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer
tda1004x_write_byteI(state, TDA1004X_CONFC1, 0x88); // enable pulse killer
switch (state->config->agc_config) {
case TDA10046_AGC_DEFAULT:
@ -672,6 +677,12 @@ static int tda10046_init(struct dvb_frontend* fe)
tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize
tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities
break;
case TDA10046_AGC_TDA827X_GPL:
tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup
tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold
tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize
tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
break;
}
tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38);
tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on
@ -683,6 +694,7 @@ static int tda10046_init(struct dvb_frontend* fe)
tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits
tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config
// tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes
tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
state->initialised = 1;
@ -1027,6 +1039,7 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status
if (status == -1)
return -EIO;
cber |= (status << 8);
// The address 0x20 should be read to cope with a TDA10046 bug
tda1004x_read_byte(state, TDA1004X_CBER_RESET);
if (cber != 65535)
@ -1047,7 +1060,8 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status
status = tda1004x_read_byte(state, TDA1004X_VBER_MSB);
if (status == -1)
return -EIO;
vber |= ((status << 16) & 0x0f);
vber |= (status & 0x0f) << 16;
// The CVBER_LUT should be read to cope with TDA10046 hardware bug
tda1004x_read_byte(state, TDA1004X_CVBER_LUT);
// if RS has passed some valid TS packets, then we must be
@ -1161,6 +1175,7 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber)
if (tmp < 0)
return -EIO;
*ber |= (tmp << 9);
// The address 0x20 should be read to cope with a TDA10046 bug
tda1004x_read_byte(state, TDA1004X_CBER_RESET);
dprintk("%s: ber=0x%x\n", __FUNCTION__, *ber);
@ -1187,6 +1202,8 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
tda1004x_disable_tuner_i2c(state);
}
}
/* set outputs to tristate */
tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff);
tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
break;
}

View file

@ -35,7 +35,8 @@ enum tda10046_agc {
TDA10046_AGC_DEFAULT, /* original configuration */
TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */
TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */
TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */
TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */
TDA10046_AGC_TDA827X_GPL, /* same as above, but GPIOs 0 */
};
enum tda10046_if {

View file

@ -0,0 +1,311 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/slab.h>
#include "dvb_frontend.h"
#include "zl10353_priv.h"
#include "zl10353.h"
struct zl10353_state {
struct i2c_adapter *i2c;
struct dvb_frontend frontend;
struct dvb_frontend_ops ops;
struct zl10353_config config;
};
static int debug_regs = 0;
static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
{
struct zl10353_state *state = fe->demodulator_priv;
u8 buf[2] = { reg, val };
struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
.buf = buf, .len = 2 };
int err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
printk("zl10353: write to reg %x failed (err = %d)!\n", reg, err);
return err;
}
return 0;
}
int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen)
{
int err, i;
for (i = 0; i < ilen - 1; i++)
if ((err = zl10353_single_write(fe, ibuf[0] + i, ibuf[i + 1])))
return err;
return 0;
}
static int zl10353_read_register(struct zl10353_state *state, u8 reg)
{
int ret;
u8 b0[1] = { reg };
u8 b1[1] = { 0 };
struct i2c_msg msg[2] = { { .addr = state->config.demod_address,
.flags = 0,
.buf = b0, .len = 1 },
{ .addr = state->config.demod_address,
.flags = I2C_M_RD,
.buf = b1, .len = 1 } };
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) {
printk("%s: readreg error (reg=%d, ret==%i)\n",
__FUNCTION__, reg, ret);
return ret;
}
return b1[0];
}
static void zl10353_dump_regs(struct dvb_frontend *fe)
{
struct zl10353_state *state = fe->demodulator_priv;
char buf[52], buf2[4];
int ret;
u8 reg;
/* Dump all registers. */
for (reg = 0; ; reg++) {
if (reg % 16 == 0) {
if (reg)
printk(KERN_DEBUG "%s\n", buf);
sprintf(buf, "%02x: ", reg);
}
ret = zl10353_read_register(state, reg);
if (ret >= 0)
sprintf(buf2, "%02x ", (u8)ret);
else
strcpy(buf2, "-- ");
strcat(buf, buf2);
if (reg == 0xff)
break;
}
printk(KERN_DEBUG "%s\n", buf);
}
static int zl10353_sleep(struct dvb_frontend *fe)
{
static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
zl10353_write(fe, zl10353_softdown, sizeof(zl10353_softdown));
return 0;
}
static int zl10353_set_parameters(struct dvb_frontend *fe,
struct dvb_frontend_parameters *param)
{
struct zl10353_state *state = fe->demodulator_priv;
u8 pllbuf[6] = { 0x67 };
/* These settings set "auto-everything" and start the FSM. */
zl10353_single_write(fe, 0x55, 0x80);
udelay(200);
zl10353_single_write(fe, 0xEA, 0x01);
udelay(200);
zl10353_single_write(fe, 0xEA, 0x00);
zl10353_single_write(fe, 0x56, 0x28);
zl10353_single_write(fe, 0x89, 0x20);
zl10353_single_write(fe, 0x5E, 0x00);
zl10353_single_write(fe, 0x65, 0x5A);
zl10353_single_write(fe, 0x66, 0xE9);
zl10353_single_write(fe, 0x62, 0x0A);
state->config.pll_set(fe, param, pllbuf + 1);
zl10353_write(fe, pllbuf, sizeof(pllbuf));
zl10353_single_write(fe, 0x70, 0x01);
udelay(250);
zl10353_single_write(fe, 0xE4, 0x00);
zl10353_single_write(fe, 0xE5, 0x2A);
zl10353_single_write(fe, 0xE9, 0x02);
zl10353_single_write(fe, 0xE7, 0x40);
zl10353_single_write(fe, 0xE8, 0x10);
return 0;
}
static int zl10353_read_status(struct dvb_frontend *fe, fe_status_t *status)
{
struct zl10353_state *state = fe->demodulator_priv;
int s6, s7, s8;
if ((s6 = zl10353_read_register(state, STATUS_6)) < 0)
return -EREMOTEIO;
if ((s7 = zl10353_read_register(state, STATUS_7)) < 0)
return -EREMOTEIO;
if ((s8 = zl10353_read_register(state, STATUS_8)) < 0)
return -EREMOTEIO;
*status = 0;
if (s6 & (1 << 2))
*status |= FE_HAS_CARRIER;
if (s6 & (1 << 1))
*status |= FE_HAS_VITERBI;
if (s6 & (1 << 5))
*status |= FE_HAS_LOCK;
if (s7 & (1 << 4))
*status |= FE_HAS_SYNC;
if (s8 & (1 << 6))
*status |= FE_HAS_SIGNAL;
if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
(FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
*status &= ~FE_HAS_LOCK;
return 0;
}
static int zl10353_read_snr(struct dvb_frontend *fe, u16 *snr)
{
struct zl10353_state *state = fe->demodulator_priv;
u8 _snr;
if (debug_regs)
zl10353_dump_regs(fe);
_snr = zl10353_read_register(state, SNR);
*snr = (_snr << 8) | _snr;
return 0;
}
static int zl10353_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings
*fe_tune_settings)
{
fe_tune_settings->min_delay_ms = 1000;
fe_tune_settings->step_size = 0;
fe_tune_settings->max_drift = 0;
return 0;
}
static int zl10353_init(struct dvb_frontend *fe)
{
struct zl10353_state *state = fe->demodulator_priv;
u8 zl10353_reset_attach[6] = { 0x50, 0x03, 0x64, 0x46, 0x15, 0x0F };
int rc = 0;
if (debug_regs)
zl10353_dump_regs(fe);
/* Do a "hard" reset if not already done */
if (zl10353_read_register(state, 0x50) != 0x03) {
rc = zl10353_write(fe, zl10353_reset_attach,
sizeof(zl10353_reset_attach));
if (debug_regs)
zl10353_dump_regs(fe);
}
return 0;
}
static void zl10353_release(struct dvb_frontend *fe)
{
struct zl10353_state *state = fe->demodulator_priv;
kfree(state);
}
static struct dvb_frontend_ops zl10353_ops;
struct dvb_frontend *zl10353_attach(const struct zl10353_config *config,
struct i2c_adapter *i2c)
{
struct zl10353_state *state = NULL;
/* allocate memory for the internal state */
state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL);
if (state == NULL)
goto error;
/* setup the state */
state->i2c = i2c;
memcpy(&state->config, config, sizeof(struct zl10353_config));
memcpy(&state->ops, &zl10353_ops, sizeof(struct dvb_frontend_ops));
/* check if the demod is there */
if (zl10353_read_register(state, CHIP_ID) != ID_ZL10353)
goto error;
/* create dvb_frontend */
state->frontend.ops = &state->ops;
state->frontend.demodulator_priv = state;
return &state->frontend;
error:
kfree(state);
return NULL;
}
static struct dvb_frontend_ops zl10353_ops = {
.info = {
.name = "Zarlink ZL10353 DVB-T",
.type = FE_OFDM,
.frequency_min = 174000000,
.frequency_max = 862000000,
.frequency_stepsize = 166667,
.frequency_tolerance = 0,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER |
FE_CAN_MUTE_TS
},
.release = zl10353_release,
.init = zl10353_init,
.sleep = zl10353_sleep,
.set_frontend = zl10353_set_parameters,
.get_tune_settings = zl10353_get_tune_settings,
.read_status = zl10353_read_status,
.read_snr = zl10353_read_snr,
};
module_param(debug_regs, int, 0644);
MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off).");
MODULE_DESCRIPTION("Zarlink ZL10353 DVB-T demodulator driver");
MODULE_AUTHOR("Chris Pascoe");
MODULE_LICENSE("GPL");
EXPORT_SYMBOL(zl10353_attach);
EXPORT_SYMBOL(zl10353_write);

View file

@ -0,0 +1,43 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
*/
#ifndef ZL10353_H
#define ZL10353_H
#include <linux/dvb/frontend.h>
struct zl10353_config
{
/* demodulator's I2C address */
u8 demod_address;
/* function which configures the PLL buffer (for secondary I2C
* connected tuner) or tunes the PLL (for direct connected tuner) */
int (*pll_set)(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params, u8 *pllbuf);
};
extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
struct i2c_adapter *i2c);
extern int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen);
#endif /* ZL10353_H */

View file

@ -0,0 +1,42 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
*/
#ifndef _ZL10353_PRIV_
#define _ZL10353_PRIV_
#define ID_ZL10353 0x14
enum zl10353_reg_addr {
INTERRUPT_0 = 0x00,
INTERRUPT_1 = 0x01,
INTERRUPT_2 = 0x02,
INTERRUPT_3 = 0x03,
INTERRUPT_4 = 0x04,
INTERRUPT_5 = 0x05,
STATUS_6 = 0x06,
STATUS_7 = 0x07,
STATUS_8 = 0x08,
STATUS_9 = 0x09,
SNR = 0x10,
CHIP_ID = 0x7F,
};
#endif /* _ZL10353_PRIV_ */

View file

@ -54,7 +54,6 @@
#include <linux/i2c.h>
#include <asm/system.h>
#include <asm/semaphore.h>
#include <linux/dvb/frontend.h>
@ -67,6 +66,10 @@
#include "av7110_ca.h"
#include "av7110_ipack.h"
#include "bsbe1.h"
#include "lnbp21.h"
#include "bsru6.h"
#define TS_WIDTH 376
#define TS_HEIGHT 512
#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
@ -82,6 +85,8 @@ static int hw_sections;
static int rgb_on;
static int volume = 255;
static int budgetpatch;
static int wss_cfg_4_3 = 0x4008;
static int wss_cfg_16_9 = 0x0007;
module_param_named(debug, av7110_debug, int, 0644);
MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
@ -100,6 +105,10 @@ module_param(volume, int, 0444);
MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
module_param(budgetpatch, int, 0444);
MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)");
module_param(wss_cfg_4_3, int, 0444);
MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data");
module_param(wss_cfg_16_9, int, 0444);
MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data");
static void restart_feeds(struct av7110 *av7110);
@ -125,6 +134,13 @@ static void init_av7110_av(struct av7110 *av7110)
if (ret < 0)
printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 2, wss_cfg_4_3);
if (ret < 0)
printk("dvb-ttpci: unable to configure 4:3 wss\n");
ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 3, wss_cfg_16_9);
if (ret < 0)
printk("dvb-ttpci: unable to configure 16:9 wss\n");
ret = av7710_set_video_mode(av7110, vidmode);
if (ret < 0)
printk("dvb-ttpci:cannot set video mode:%d\n",ret);
@ -242,10 +258,10 @@ static int arm_thread(void *data)
if (!av7110->arm_ready)
continue;
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
break;
newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
@ -253,10 +269,10 @@ static int arm_thread(void *data)
recover_arm(av7110);
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
break;
newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
}
av7110->arm_loops = newloops;
av7110->arm_errors = 0;
@ -741,7 +757,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
int ret = 0;
dprintk(4, "%p\n", av7110);
if (down_interruptible(&av7110->pid_mutex))
if (mutex_lock_interruptible(&av7110->pid_mutex))
return -ERESTARTSYS;
if (!(vpid & 0x8000))
@ -760,7 +776,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
}
up(&av7110->pid_mutex);
mutex_unlock(&av7110->pid_mutex);
return ret;
}
@ -1088,11 +1104,9 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
struct av7110 *av7110;
/* pointer casting paranoia... */
if (!demux)
BUG();
BUG_ON(!demux);
dvbdemux = (struct dvb_demux *) demux->priv;
if (!dvbdemux)
BUG();
BUG_ON(!dvbdemux);
av7110 = (struct av7110 *) dvbdemux->priv;
dprintk(4, "%p\n", av7110);
@ -1570,208 +1584,6 @@ static struct ves1x93_config alps_bsrv2_config = {
.pll_set = alps_bsrv2_pll_set,
};
static u8 alps_bsru6_inittab[] = {
0x01, 0x15,
0x02, 0x30,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x52,
0xff, 0xff
};
static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
stv0299_writereg(fe, 0x13, aclk);
stv0299_writereg(fe, 0x14, bclk);
stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
return 0;
}
static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
int ret;
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = 0xC4;
if (params->frequency > 1530000) data[3] = 0xc0;
ret = i2c_transfer(i2c, &msg, 1);
if (ret != 1)
return -EIO;
return 0;
}
static struct stv0299_config alps_bsru6_config = {
.demod_address = 0x68,
.inittab = alps_bsru6_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.lock_output = STV0229_LOCKOUTPUT_1,
.volt13_op0_op1 = STV0299_VOLT13_OP1,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsru6_pll_set,
};
static u8 alps_bsbe1_inittab[] = {
0x01, 0x15,
0x02, 0x30,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x92,
0xff, 0xff
};
static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
int ret;
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
ret = i2c_transfer(i2c, &msg, 1);
return (ret != 1) ? -EIO : 0;
}
static struct stv0299_config alps_bsbe1_config = {
.demod_address = 0x68,
.inittab = alps_bsbe1_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsbe1_pll_set,
};
static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
{
struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
int ret;
u8 data[1];
struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
switch(voltage) {
case SEC_VOLTAGE_OFF:
data[0] = 0x00;
break;
case SEC_VOLTAGE_13:
data[0] = 0x44;
break;
case SEC_VOLTAGE_18:
data[0] = 0x4c;
break;
default:
return -EINVAL;
};
ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
return (ret != 1) ? -EIO : 0;
}
static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct av7110* av7110 = fe->dvb->priv;
@ -2096,7 +1908,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
if (av7110->playing)
return 0;
if (down_interruptible(&av7110->pid_mutex))
if (mutex_lock_interruptible(&av7110->pid_mutex))
return -ERESTARTSYS;
if (synced) {
@ -2118,7 +1930,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
if (!ret)
av7110->fe_synced = synced;
up(&av7110->pid_mutex);
mutex_unlock(&av7110->pid_mutex);
return ret;
}
@ -2374,9 +2186,15 @@ static int frontend_init(struct av7110 *av7110)
/* ALPS BSBE1 */
av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
if (av7110->fe) {
av7110->fe->ops->set_voltage = lnbp21_set_voltage;
av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
av7110->recover = dvb_s_recover;
if (lnbp21_init(av7110->fe, &av7110->i2c_adap, 0, 0)) {
printk("dvb-ttpci: LNBP21 not found!\n");
if (av7110->fe->ops->release)
av7110->fe->ops->release(av7110->fe);
av7110->fe = NULL;
} else {
av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
av7110->recover = dvb_s_recover;
}
}
break;
}
@ -2714,16 +2532,16 @@ static int __devinit av7110_attach(struct saa7146_dev* dev,
tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
sema_init(&av7110->pid_mutex, 1);
mutex_init(&av7110->pid_mutex);
/* locks for data transfers from/to AV7110 */
spin_lock_init(&av7110->debilock);
sema_init(&av7110->dcomlock, 1);
mutex_init(&av7110->dcomlock);
av7110->debitype = -1;
/* default OSD window */
av7110->osdwin = 1;
sema_init(&av7110->osd_sema, 1);
mutex_init(&av7110->osd_mutex);
/* ARM "watchdog" */
init_waitqueue_head(&av7110->arm_wait);

View file

@ -16,6 +16,7 @@
#include <linux/dvb/ca.h>
#include <linux/dvb/osd.h>
#include <linux/dvb/net.h>
#include <linux/mutex.h>
#include "dvbdev.h"
#include "demux.h"
@ -127,7 +128,7 @@ struct av7110 {
/* DEBI and polled command interface */
spinlock_t debilock;
struct semaphore dcomlock;
struct mutex dcomlock;
volatile int debitype;
volatile int debilen;
@ -146,7 +147,7 @@ struct av7110 {
int osdwin; /* currently active window */
u16 osdbpp[8];
struct semaphore osd_sema;
struct mutex osd_mutex;
/* CA */
@ -172,7 +173,7 @@ struct av7110 {
struct tasklet_struct vpe_tasklet;
int fe_synced;
struct semaphore pid_mutex;
struct mutex pid_mutex;
int video_blank;
struct video_status videostate;

View file

@ -327,10 +327,10 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
start = jiffies;
for (;;) {
err = time_after(jiffies, start + ARM_WAIT_FREE);
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
return -ERESTARTSYS;
stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
if ((stat & flags) == 0)
break;
if (err) {
@ -487,11 +487,11 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
dprintk(1, "arm not ready.\n");
return -1;
}
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
return -ERESTARTSYS;
ret = __av7110_send_fw_cmd(av7110, buf, length);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
if (ret && ret!=-ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n",
__FUNCTION__, ret);
@ -563,11 +563,11 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
return -1;
}
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
return -ERESTARTSYS;
if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) {
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err);
return err;
}
@ -579,7 +579,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
break;
if (err) {
printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -ETIMEDOUT;
}
#ifdef _NOHANDSHAKE
@ -595,7 +595,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
break;
if (err) {
printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -ETIMEDOUT;
}
msleep(1);
@ -606,12 +606,12 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
if (stat & GPMQOver) {
printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -1;
}
else if (stat & OSDQOver) {
printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -1;
}
#endif
@ -619,7 +619,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
for (i = 0; i < reply_buf_len; i++)
reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return 0;
}
@ -735,7 +735,7 @@ static int FlushText(struct av7110 *av7110)
unsigned long start;
int err;
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
return -ERESTARTSYS;
start = jiffies;
while (1) {
@ -745,12 +745,12 @@ static int FlushText(struct av7110 *av7110)
if (err) {
printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
__FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -ETIMEDOUT;
}
msleep(1);
}
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return 0;
}
@ -761,7 +761,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
int length = strlen(buf) + 1;
u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y };
if (down_interruptible(&av7110->dcomlock))
if (mutex_lock_interruptible(&av7110->dcomlock))
return -ERESTARTSYS;
start = jiffies;
@ -772,7 +772,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
if (ret) {
printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
__FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -ETIMEDOUT;
}
msleep(1);
@ -786,7 +786,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
if (ret) {
printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
__FUNCTION__);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
return -ETIMEDOUT;
}
msleep(1);
@ -798,7 +798,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
if (length & 1)
wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
up(&av7110->dcomlock);
mutex_unlock(&av7110->dcomlock);
if (ret && ret!=-ERESTARTSYS)
printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret);
return ret;
@ -1062,7 +1062,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
{
int ret;
if (down_interruptible(&av7110->osd_sema))
if (mutex_lock_interruptible(&av7110->osd_mutex))
return -ERESTARTSYS;
switch (dc->cmd) {
@ -1198,7 +1198,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
break;
}
up(&av7110->osd_sema);
mutex_unlock(&av7110->osd_mutex);
if (ret==-ERESTARTSYS)
dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd);
else if (ret)

View file

@ -579,14 +579,11 @@ static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size
return -EFAULT;
if ((d.id != 0 && d.id != V4L2_SLICED_WSS_625) || d.field != 0 || d.line != 23)
return -EINVAL;
if (d.id) {
if (d.id)
av7110->wssData = ((d.data[1] << 8) & 0x3f00) | d.data[0];
rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig,
2, 1, av7110->wssData);
} else {
av7110->wssData = 0;
rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0);
}
else
av7110->wssData = 0x8000;
rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 1, av7110->wssData);
return (rc < 0) ? rc : count;
}

View file

@ -1000,6 +1000,7 @@ static u8 read_pwm(struct budget_av *budget_av)
#define SUBID_DVBS_TV_STAR 0x0014
#define SUBID_DVBS_TV_STAR_CI 0x0016
#define SUBID_DVBS_EASYWATCH 0x001e
#define SUBID_DVBC_KNC1 0x0020
#define SUBID_DVBC_KNC1_PLUS 0x0021
#define SUBID_DVBC_CINERGY1200 0x1156
@ -1038,6 +1039,7 @@ static void frontend_init(struct budget_av *budget_av)
case SUBID_DVBS_TV_STAR:
case SUBID_DVBS_TV_STAR_CI:
case SUBID_DVBS_CYNERGY1200N:
case SUBID_DVBS_EASYWATCH:
fe = stv0299_attach(&philips_sd1878_config,
&budget_av->budget.i2c_adap);
break;
@ -1285,6 +1287,7 @@ MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
@ -1300,6 +1303,7 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),

View file

@ -42,6 +42,9 @@
#include "stv0299.h"
#include "stv0297.h"
#include "tda1004x.h"
#include "lnbp21.h"
#include "bsbe1.h"
#include "bsru6.h"
#define DEBIADDR_IR 0x1234
#define DEBIADDR_CICONTROL 0x0000
@ -474,123 +477,6 @@ static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr)
tasklet_schedule(&budget_ci->ciintf_irq_tasklet);
}
static u8 alps_bsru6_inittab[] = {
0x01, 0x15,
0x02, 0x00,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x52,
0xff, 0xff
};
static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) {
aclk = 0xb7;
bclk = 0x47;
} else if (srate < 3000000) {
aclk = 0xb7;
bclk = 0x4b;
} else if (srate < 7000000) {
aclk = 0xb7;
bclk = 0x4f;
} else if (srate < 14000000) {
aclk = 0xb7;
bclk = 0x53;
} else if (srate < 30000000) {
aclk = 0xb6;
bclk = 0x53;
} else if (srate < 45000000) {
aclk = 0xb4;
bclk = 0x51;
}
stv0299_writereg(fe, 0x13, aclk);
stv0299_writereg(fe, 0x14, bclk);
stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
return 0;
}
static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params)
{
u8 buf[4];
u32 div;
struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
buf[0] = (div >> 8) & 0x7f;
buf[1] = div & 0xff;
buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
buf[3] = 0xC4;
if (params->frequency > 1530000)
buf[3] = 0xc0;
if (i2c_transfer(i2c, &msg, 1) != 1)
return -EIO;
return 0;
}
static struct stv0299_config alps_bsru6_config = {
.demod_address = 0x68,
.inittab = alps_bsru6_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.lock_output = STV0229_LOCKOUTPUT_1,
.volt13_op0_op1 = STV0299_VOLT13_OP1,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsru6_pll_set,
};
static u8 philips_su1278_tt_inittab[] = {
0x01, 0x0f,
0x02, 0x30,
@ -1069,6 +955,20 @@ static void frontend_init(struct budget_ci *budget_ci)
break;
}
break;
case 0x1017: // TT S-1500 PCI
budget_ci->budget.dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget_ci->budget.i2c_adap);
if (budget_ci->budget.dvb_frontend) {
budget_ci->budget.dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;
if (lnbp21_init(budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0)) {
printk("%s: No LNBP21 found!\n", __FUNCTION__);
if (budget_ci->budget.dvb_frontend->ops->release)
budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend);
budget_ci->budget.dvb_frontend = NULL;
}
}
break;
}
if (budget_ci->budget.dvb_frontend == NULL) {
@ -1146,6 +1046,7 @@ static int budget_ci_detach(struct saa7146_dev *dev)
static struct saa7146_extension budget_extension;
MAKE_BUDGET_INFO(ttbs2, "TT-Budget/S-1500 PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
@ -1157,6 +1058,7 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
{
.vendor = 0,
}

View file

@ -37,6 +37,8 @@
#include "ves1x93.h"
#include "tda8083.h"
#include "bsru6.h"
#define budget_patch budget
static struct saa7146_extension budget_extension;
@ -290,103 +292,6 @@ static struct ves1x93_config alps_bsrv2_config = {
.pll_set = alps_bsrv2_pll_set,
};
static u8 alps_bsru6_inittab[] = {
0x01, 0x15,
0x02, 0x00,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x52,
0xff, 0xff
};
static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
stv0299_writereg (fe, 0x13, aclk);
stv0299_writereg (fe, 0x14, bclk);
stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
return 0;
}
static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = 0xC4;
if (params->frequency > 1530000) data[3] = 0xc0;
if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
return 0;
}
static struct stv0299_config alps_bsru6_config = {
.demod_address = 0x68,
.inittab = alps_bsru6_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.lock_output = STV0229_LOCKOUTPUT_1,
.volt13_op0_op1 = STV0299_VOLT13_OP1,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsru6_pll_set,
};
static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;

View file

@ -41,6 +41,8 @@
#include "l64781.h"
#include "tda8083.h"
#include "s5h1420.h"
#include "lnbp21.h"
#include "bsru6.h"
static void Set22K (struct budget *budget, int state)
{
@ -184,64 +186,6 @@ static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t m
return 0;
}
static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
u8 buf;
struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
switch(voltage) {
case SEC_VOLTAGE_13:
buf = (buf & 0xf7) | 0x04;
break;
case SEC_VOLTAGE_18:
buf = (buf & 0xf7) | 0x0c;
break;
case SEC_VOLTAGE_OFF:
buf = buf & 0xf0;
break;
}
msg.flags = 0;
if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
return 0;
}
static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, long arg)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
u8 buf;
struct i2c_msg msg = { .addr = 0x08, .flags = I2C_M_RD, .buf = &buf, .len = sizeof(buf) };
if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
if (arg) {
buf = buf | 0x10;
} else {
buf = buf & 0xef;
}
msg.flags = 0;
if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
return 0;
}
static int lnbp21_init(struct budget* budget)
{
u8 buf = 0x00;
struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = &buf, .len = sizeof(buf) };
if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
return -EIO;
return 0;
}
static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
@ -277,176 +221,6 @@ static struct ves1x93_config alps_bsrv2_config =
.pll_set = alps_bsrv2_pll_set,
};
static u8 alps_bsru6_inittab[] = {
0x01, 0x15,
0x02, 0x00,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x52,
0xff, 0xff
};
static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
{
u8 aclk = 0;
u8 bclk = 0;
if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
stv0299_writereg (fe, 0x13, aclk);
stv0299_writereg (fe, 0x14, bclk);
stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
return 0;
}
static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = 0xC4;
if (params->frequency > 1530000) data[3] = 0xc0;
if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
return 0;
}
static struct stv0299_config alps_bsru6_config = {
.demod_address = 0x68,
.inittab = alps_bsru6_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.lock_output = STV0229_LOCKOUTPUT_1,
.volt13_op0_op1 = STV0299_VOLT13_OP1,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsru6_pll_set,
};
static u8 alps_bsbe1_inittab[] = {
0x01, 0x15,
0x02, 0x30,
0x03, 0x00,
0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
0x06, 0x40, /* DAC not used, set to high impendance mode */
0x07, 0x00, /* DAC LSB */
0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
0x09, 0x00, /* FIFO */
0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
0x10, 0x3f, // AGC2 0x3d
0x11, 0x84,
0x12, 0xb9,
0x15, 0xc9, // lock detector threshold
0x16, 0x00,
0x17, 0x00,
0x18, 0x00,
0x19, 0x00,
0x1a, 0x00,
0x1f, 0x50,
0x20, 0x00,
0x21, 0x00,
0x22, 0x00,
0x23, 0x00,
0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
0x29, 0x1e, // 1/2 threshold
0x2a, 0x14, // 2/3 threshold
0x2b, 0x0f, // 3/4 threshold
0x2c, 0x09, // 5/6 threshold
0x2d, 0x05, // 7/8 threshold
0x2e, 0x01,
0x31, 0x1f, // test all FECs
0x32, 0x19, // viterbi and synchro search
0x33, 0xfc, // rs control
0x34, 0x93, // error control
0x0f, 0x92, // 0x80 = inverse AGC
0xff, 0xff
};
static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
int ret;
u8 data[4];
u32 div;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
if ((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL;
div = (params->frequency + (125 - 1)) / 125; // round correctly
data[0] = (div >> 8) & 0x7f;
data[1] = div & 0xff;
data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
ret = i2c_transfer(i2c, &msg, 1);
return (ret != 1) ? -EIO : 0;
}
static struct stv0299_config alps_bsbe1_config = {
.demod_address = 0x68,
.inittab = alps_bsbe1_inittab,
.mclk = 88000000UL,
.invert = 1,
.skip_reinit = 0,
.min_delay_ms = 100,
.set_symbol_rate = alps_bsru6_set_symbol_rate,
.pll_set = alps_bsbe1_pll_set,
};
static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
struct budget* budget = (struct budget*) fe->dvb->priv;
@ -580,20 +354,6 @@ static u8 read_pwm(struct budget* budget)
static void frontend_init(struct budget *budget)
{
switch(budget->dev->pci->subsystem_device) {
case 0x1017:
// try the ALPS BSBE1 now
budget->dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget->i2c_adap);
if (budget->dvb_frontend) {
budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;
budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;
if (lnbp21_init(budget)) {
printk("%s: No LNBP21 found!\n", __FUNCTION__);
goto error_out;
}
}
break;
case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
case 0x1013:
// try the ALPS BSRV2 first of all
@ -646,9 +406,7 @@ static void frontend_init(struct budget *budget)
case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap);
if (budget->dvb_frontend) {
budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;
budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
if (lnbp21_init(budget)) {
if (lnbp21_init(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) {
printk("%s: No LNBP21 found!\n", __FUNCTION__);
goto error_out;
}
@ -719,7 +477,6 @@ static int budget_detach (struct saa7146_dev* dev)
static struct saa7146_extension budget_extension;
MAKE_BUDGET_INFO(ttbs2, "TT-Budget/WinTV-NOVA-S PCI (rev AL/alps bsbe1 lnbp21 frontend)", BUDGET_TT);
MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
@ -732,7 +489,6 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),

View file

@ -10,6 +10,8 @@
#include "dvb_net.h"
#include <linux/module.h>
#include <linux/mutex.h>
#include <media/saa7146.h>
extern int budget_debug;
@ -51,7 +53,7 @@ struct budget {
struct dmx_frontend mem_frontend;
int fe_synced;
struct semaphore pid_mutex;
struct mutex pid_mutex;
int ci_present;
int video_port;

View file

@ -19,7 +19,7 @@
#include <linux/time.h>
#include <linux/errno.h>
#include <linux/jiffies.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include "dvb_frontend.h"
#include "dmxdev.h"
@ -35,7 +35,6 @@
#include <linux/dvb/dmx.h>
#include <linux/pci.h>
/*
TTUSB_HWSECTIONS:
the DSP supports filtering in hardware, however, since the "muxstream"
@ -83,8 +82,8 @@ struct ttusb {
struct dvb_net dvbnet;
/* and one for USB access. */
struct semaphore semi2c;
struct semaphore semusb;
struct mutex semi2c;
struct mutex semusb;
struct dvb_adapter adapter;
struct usb_device *dev;
@ -150,7 +149,7 @@ static int ttusb_cmd(struct ttusb *ttusb,
printk("\n");
#endif
if (down_interruptible(&ttusb->semusb) < 0)
if (mutex_lock_interruptible(&ttusb->semusb) < 0)
return -EAGAIN;
err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe,
@ -158,13 +157,13 @@ static int ttusb_cmd(struct ttusb *ttusb,
if (err != 0) {
dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n",
__FUNCTION__, err);
up(&ttusb->semusb);
mutex_unlock(&ttusb->semusb);
return err;
}
if (actual_len != len) {
dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__,
actual_len, len);
up(&ttusb->semusb);
mutex_unlock(&ttusb->semusb);
return -1;
}
@ -174,7 +173,7 @@ static int ttusb_cmd(struct ttusb *ttusb,
if (err != 0) {
printk("%s: failed, receive error %d\n", __FUNCTION__,
err);
up(&ttusb->semusb);
mutex_unlock(&ttusb->semusb);
return err;
}
#if DEBUG >= 3
@ -185,14 +184,14 @@ static int ttusb_cmd(struct ttusb *ttusb,
printk("\n");
#endif
if (!needresult)
up(&ttusb->semusb);
mutex_unlock(&ttusb->semusb);
return 0;
}
static int ttusb_result(struct ttusb *ttusb, u8 * data, int len)
{
memcpy(data, ttusb->last_result, len);
up(&ttusb->semusb);
mutex_unlock(&ttusb->semusb);
return 0;
}
@ -250,7 +249,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num
int i = 0;
int inc;
if (down_interruptible(&ttusb->semi2c) < 0)
if (mutex_lock_interruptible(&ttusb->semi2c) < 0)
return -EAGAIN;
while (i < num) {
@ -284,7 +283,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num
i += inc;
}
up(&ttusb->semi2c);
mutex_unlock(&ttusb->semi2c);
return i;
}
@ -689,8 +688,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len)
memcpy(ttusb->muxpack + ttusb->muxpack_ptr,
data, avail);
ttusb->muxpack_ptr += avail;
if (ttusb->muxpack_ptr > 264)
BUG();
BUG_ON(ttusb->muxpack_ptr > 264);
data += avail;
len -= avail;
/* determine length */
@ -1495,8 +1493,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
ttusb->dev = udev;
ttusb->c = 0;
ttusb->mux_state = 0;
sema_init(&ttusb->semi2c, 0);
sema_init(&ttusb->semusb, 1);
mutex_init(&ttusb->semi2c);
mutex_lock(&ttusb->semi2c);
mutex_init(&ttusb->semusb);
ttusb_setup_interfaces(ttusb);
@ -1504,7 +1505,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
if (ttusb_init_controller(ttusb))
printk("ttusb_init_controller: error\n");
up(&ttusb->semi2c);
mutex_unlock(&ttusb->semi2c);
dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
ttusb->adapter.priv = ttusb;

View file

@ -20,7 +20,8 @@
*
*/
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
@ -115,7 +116,7 @@ struct ttusb_dec {
unsigned int out_pipe;
unsigned int irq_pipe;
enum ttusb_dec_interface interface;
struct semaphore usb_sem;
struct mutex usb_mutex;
void *irq_buffer;
struct urb *irq_urb;
@ -124,7 +125,7 @@ struct ttusb_dec {
dma_addr_t iso_dma_handle;
struct urb *iso_urb[ISO_BUF_COUNT];
int iso_stream_count;
struct semaphore iso_sem;
struct mutex iso_mutex;
u8 packet[MAX_PVA_LENGTH + 4];
enum ttusb_dec_packet_type packet_type;
@ -273,9 +274,9 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (!b)
return -ENOMEM;
if ((result = down_interruptible(&dec->usb_sem))) {
if ((result = mutex_lock_interruptible(&dec->usb_mutex))) {
kfree(b);
printk("%s: Failed to down usb semaphore.\n", __FUNCTION__);
printk("%s: Failed to lock usb mutex.\n", __FUNCTION__);
return result;
}
@ -300,7 +301,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (result) {
printk("%s: command bulk message failed: error %d\n",
__FUNCTION__, result);
up(&dec->usb_sem);
mutex_unlock(&dec->usb_mutex);
kfree(b);
return result;
}
@ -311,7 +312,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (result) {
printk("%s: result bulk message failed: error %d\n",
__FUNCTION__, result);
up(&dec->usb_sem);
mutex_unlock(&dec->usb_mutex);
kfree(b);
return result;
} else {
@ -327,7 +328,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (cmd_result && b[3] > 0)
memcpy(cmd_result, &b[4], b[3]);
up(&dec->usb_sem);
mutex_unlock(&dec->usb_mutex);
kfree(b);
return 0;
@ -835,7 +836,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
dprintk("%s\n", __FUNCTION__);
if (down_interruptible(&dec->iso_sem))
if (mutex_lock_interruptible(&dec->iso_mutex))
return;
dec->iso_stream_count--;
@ -845,7 +846,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
usb_kill_urb(dec->iso_urb[i]);
}
up(&dec->iso_sem);
mutex_unlock(&dec->iso_mutex);
}
/* Setting the interface of the DEC tends to take down the USB communications
@ -890,7 +891,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
dprintk("%s\n", __FUNCTION__);
if (down_interruptible(&dec->iso_sem))
if (mutex_lock_interruptible(&dec->iso_mutex))
return -EAGAIN;
if (!dec->iso_stream_count) {
@ -911,7 +912,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
i--;
}
up(&dec->iso_sem);
mutex_unlock(&dec->iso_mutex);
return result;
}
}
@ -919,7 +920,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
dec->iso_stream_count++;
up(&dec->iso_sem);
mutex_unlock(&dec->iso_mutex);
return 0;
}
@ -1229,8 +1230,8 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
{
dprintk("%s\n", __FUNCTION__);
sema_init(&dec->usb_sem, 1);
sema_init(&dec->iso_sem, 1);
mutex_init(&dec->usb_mutex);
mutex_init(&dec->iso_mutex);
dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE);
dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE);

View file

@ -18,14 +18,15 @@
#include <linux/string.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include "../../../sound/oss/aci.h"
#include "miropcm20-rds-core.h"
#define DEBUG 0
static struct semaphore aci_rds_sem;
static struct mutex aci_rds_mutex;
#define RDS_DATASHIFT 2 /* Bit 2 */
#define RDS_DATAMASK (1 << RDS_DATASHIFT)
@ -181,7 +182,7 @@ int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize)
{
int ret;
if (down_interruptible(&aci_rds_sem))
if (mutex_lock_interruptible(&aci_rds_mutex))
return -EINTR;
rds_write(cmd);
@ -192,7 +193,7 @@ int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize)
else
ret = 0;
up(&aci_rds_sem);
mutex_unlock(&aci_rds_mutex);
return ret;
}
@ -200,7 +201,7 @@ EXPORT_SYMBOL(aci_rds_cmd);
int __init attach_aci_rds(void)
{
init_MUTEX(&aci_rds_sem);
mutex_init(&aci_rds_mutex);
return 0;
}

View file

@ -43,7 +43,7 @@
static int io = CONFIG_RADIO_RTRACK_PORT;
static int radio_nr = -1;
static struct semaphore lock;
static struct mutex lock;
struct rt_device
{
@ -83,23 +83,23 @@ static void rt_incvol(void)
static void rt_mute(struct rt_device *dev)
{
dev->muted = 1;
down(&lock);
mutex_lock(&lock);
outb(0xd0, io); /* volume steady, off */
up(&lock);
mutex_unlock(&lock);
}
static int rt_setvol(struct rt_device *dev, int vol)
{
int i;
down(&lock);
mutex_lock(&lock);
if(vol == dev->curvol) { /* requested volume = current */
if (dev->muted) { /* user is unmuting the card */
dev->muted = 0;
outb (0xd8, io); /* enable card */
}
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -108,7 +108,7 @@ static int rt_setvol(struct rt_device *dev, int vol)
sleep_delay(2000000); /* make sure it's totally down */
outb(0xd0, io); /* volume steady, off */
dev->curvol = 0; /* track the volume state! */
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -121,7 +121,7 @@ static int rt_setvol(struct rt_device *dev, int vol)
rt_decvol();
dev->curvol = vol;
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -168,7 +168,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
freq += 171200; /* Add 10.7 MHz IF */
freq /= 800; /* Convert to 50 kHz units */
down(&lock); /* Stop other ops interfering */
mutex_lock(&lock); /* Stop other ops interfering */
send_0_byte (io, dev); /* 0: LSB of frequency */
@ -196,7 +196,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
else
outb (0xd8, io); /* volume steady + sigstr + on */
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -337,7 +337,7 @@ static int __init rtrack_init(void)
/* Set up the I/O locking */
init_MUTEX(&lock);
mutex_init(&lock);
/* mute card - prevents noisy bootups */

View file

@ -42,7 +42,7 @@
static int io = CONFIG_RADIO_AZTECH_PORT;
static int radio_nr = -1;
static int radio_wait_time = 1000;
static struct semaphore lock;
static struct mutex lock;
struct az_device
{
@ -87,9 +87,9 @@ static void send_1_byte (struct az_device *dev)
static int az_setvol(struct az_device *dev, int vol)
{
down(&lock);
mutex_lock(&lock);
outb (volconvert(vol), io);
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -122,7 +122,7 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
frequency += 171200; /* Add 10.7 MHz IF */
frequency /= 800; /* Convert to 50 kHz units */
down(&lock);
mutex_lock(&lock);
send_0_byte (dev); /* 0: LSB of frequency */
@ -152,7 +152,7 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
udelay (radio_wait_time);
outb_p(128+64+volconvert(dev->curvol), io);
up(&lock);
mutex_unlock(&lock);
return 0;
}
@ -283,7 +283,7 @@ static int __init aztech_init(void)
return -EBUSY;
}
init_MUTEX(&lock);
mutex_init(&lock);
aztech_radio.priv=&aztech_unit;
if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1)

View file

@ -23,10 +23,11 @@
#include <linux/sched.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/videodev.h>
#define DRIVER_VERSION "0.05"
#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */
@ -104,7 +105,7 @@ struct radio_device {
muted, /* VIDEO_AUDIO_MUTE */
stereo, /* VIDEO_TUNER_STEREO_ON */
tuned; /* signal strength (0 or 0xffff) */
struct semaphore lock;
struct mutex lock;
};
static u32 radio_bits_get(struct radio_device *dev)
@ -258,9 +259,9 @@ static int radio_ioctl(struct inode *inode, struct file *file,
struct radio_device *card = video_get_drvdata(dev);
int ret;
down(&card->lock);
mutex_lock(&card->lock);
ret = video_usercopy(inode, file, cmd, arg, radio_function);
up(&card->lock);
mutex_unlock(&card->lock);
return ret;
}
@ -311,7 +312,7 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
}
radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA;
init_MUTEX(&radio_unit->lock);
mutex_init(&radio_unit->lock);
maestro_radio_inst = video_device_alloc();
if (maestro_radio_inst == NULL) {

View file

@ -37,7 +37,8 @@
#include <linux/sched.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/videodev.h>
@ -101,7 +102,7 @@ static struct radio_device
unsigned long freq;
struct semaphore lock;
struct mutex lock;
} radio_unit = {0, 0, 0, 0, };
@ -267,9 +268,9 @@ static int radio_ioctl(struct inode *inode, struct file *file,
struct radio_device *card=dev->priv;
int ret;
down(&card->lock);
mutex_lock(&card->lock);
ret = video_usercopy(inode, file, cmd, arg, radio_function);
up(&card->lock);
mutex_unlock(&card->lock);
return ret;
}
@ -290,7 +291,7 @@ static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d
goto err_out_free_region;
radio_unit.io = pci_resource_start(pdev, 0);
init_MUTEX(&radio_unit.lock);
mutex_init(&radio_unit.lock);
maxiradio_radio.priv = &radio_unit;
if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) {

View file

@ -24,7 +24,7 @@
#include <linux/isapnp.h>
#include <asm/io.h> /* outb, outb_p */
#include <asm/uaccess.h> /* copy to/from user */
#include <asm/semaphore.h>
#include <linux/mutex.h>
struct fmi_device
{
@ -37,7 +37,7 @@ struct fmi_device
static int io = -1;
static int radio_nr = -1;
static struct pnp_dev *dev = NULL;
static struct semaphore lock;
static struct mutex lock;
/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
/* It is only useful to give freq in intervall of 800 (=0.05Mhz),
@ -68,16 +68,16 @@ static void outbits(int bits, unsigned int data, int port)
static inline void fmi_mute(int port)
{
down(&lock);
mutex_lock(&lock);
outb(0x00, port);
up(&lock);
mutex_unlock(&lock);
}
static inline void fmi_unmute(int port)
{
down(&lock);
mutex_lock(&lock);
outb(0x08, port);
up(&lock);
mutex_unlock(&lock);
}
static inline int fmi_setfreq(struct fmi_device *dev)
@ -85,12 +85,12 @@ static inline int fmi_setfreq(struct fmi_device *dev)
int myport = dev->port;
unsigned long freq = dev->curfreq;
down(&lock);
mutex_lock(&lock);
outbits(16, RSF16_ENCODE(freq), myport);
outbits(8, 0xC0, myport);
msleep(143); /* was schedule_timeout(HZ/7) */
up(&lock);
mutex_unlock(&lock);
if (dev->curvol) fmi_unmute(myport);
return 0;
}
@ -102,7 +102,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
int myport = dev->port;
down(&lock);
mutex_lock(&lock);
val = dev->curvol ? 0x08 : 0x00; /* unmute/mute */
outb(val, myport);
outb(val | 0x10, myport);
@ -110,7 +110,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
res = (int)inb(myport+1);
outb(val, myport);
up(&lock);
mutex_unlock(&lock);
return (res & 2) ? 0 : 0xFFFF;
}
@ -296,7 +296,7 @@ static int __init fmi_init(void)
fmi_unit.flags = VIDEO_TUNER_LOW;
fmi_radio.priv = &fmi_unit;
init_MUTEX(&lock);
mutex_init(&lock);
if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) {
release_region(io, 2);

View file

@ -19,9 +19,9 @@
#include <asm/io.h> /* outb, outb_p */
#include <asm/uaccess.h> /* copy to/from user */
#include <linux/videodev.h> /* kernel radio structs */
#include <asm/semaphore.h>
#include <linux/mutex.h>
static struct semaphore lock;
static struct mutex lock;
#undef DEBUG
//#define DEBUG 1
@ -238,9 +238,9 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
if (fmr2->mute)
v->flags |= VIDEO_AUDIO_MUTE;
v->mode=VIDEO_MODE_AUTO;
down(&lock);
mutex_lock(&lock);
v->signal = fmr2_getsigstr(fmr2);
up(&lock);
mutex_unlock(&lock);
return 0;
}
case VIDIOCSTUNER:
@ -274,9 +274,9 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
/* set card freq (if not muted) */
if (fmr2->curvol && !fmr2->mute)
{
down(&lock);
mutex_lock(&lock);
fmr2_setfreq(fmr2);
up(&lock);
mutex_unlock(&lock);
}
return 0;
}
@ -318,14 +318,14 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
else
printk(KERN_DEBUG "mute\n");
#endif
down(&lock);
mutex_lock(&lock);
if (fmr2->curvol && !fmr2->mute)
{
fmr2_setvolume(fmr2);
fmr2_setfreq(fmr2);
}
else fmr2_mute(fmr2->port);
up(&lock);
mutex_unlock(&lock);
return 0;
}
case VIDIOCGUNIT:
@ -380,7 +380,7 @@ static int __init fmr2_init(void)
fmr2_unit.card_type = 0;
fmr2_radio.priv = &fmr2_unit;
init_MUTEX(&lock);
mutex_init(&lock);
if (request_region(io, 2, "sf16fmr2"))
{
@ -397,10 +397,10 @@ static int __init fmr2_init(void)
printk(KERN_INFO "SF16FMR2 radio card driver at 0x%x.\n", io);
debug_print((KERN_DEBUG "Mute %d Low %d\n",VIDEO_AUDIO_MUTE,VIDEO_TUNER_LOW));
/* mute card - prevents noisy bootups */
down(&lock);
mutex_lock(&lock);
fmr2_mute(io);
fmr2_product_info(&fmr2_unit);
up(&lock);
mutex_unlock(&lock);
debug_print((KERN_DEBUG "card_type %d\n", fmr2_unit.card_type));
return 0;
}

View file

@ -59,7 +59,7 @@ struct typhoon_device {
int muted;
unsigned long curfreq;
unsigned long mutefreq;
struct semaphore lock;
struct mutex lock;
};
static void typhoon_setvol_generic(struct typhoon_device *dev, int vol);
@ -77,12 +77,12 @@ static int typhoon_get_info(char *buf, char **start, off_t offset, int len);
static void typhoon_setvol_generic(struct typhoon_device *dev, int vol)
{
down(&dev->lock);
mutex_lock(&dev->lock);
vol >>= 14; /* Map 16 bit to 2 bit */
vol &= 3;
outb_p(vol / 2, dev->iobase); /* Set the volume, high bit. */
outb_p(vol % 2, dev->iobase + 2); /* Set the volume, low bit. */
up(&dev->lock);
mutex_unlock(&dev->lock);
}
static int typhoon_setfreq_generic(struct typhoon_device *dev,
@ -102,7 +102,7 @@ static int typhoon_setfreq_generic(struct typhoon_device *dev,
*
*/
down(&dev->lock);
mutex_lock(&dev->lock);
x = frequency / 160;
outval = (x * x + 2500) / 5000;
outval = (outval * x + 5000) / 10000;
@ -112,7 +112,7 @@ static int typhoon_setfreq_generic(struct typhoon_device *dev,
outb_p((outval >> 8) & 0x01, dev->iobase + 4);
outb_p(outval >> 9, dev->iobase + 6);
outb_p(outval & 0xff, dev->iobase + 8);
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
@ -337,7 +337,7 @@ static int __init typhoon_init(void)
#endif /* MODULE */
printk(KERN_INFO BANNER);
init_MUTEX(&typhoon_unit.lock);
mutex_init(&typhoon_unit.lock);
io = typhoon_unit.iobase;
if (!request_region(io, 8, "typhoon")) {
printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n",

View file

@ -48,7 +48,7 @@ struct zol_device {
unsigned long curfreq;
int muted;
unsigned int stereo;
struct semaphore lock;
struct mutex lock;
};
static int zol_setvol(struct zol_device *dev, int vol)
@ -57,30 +57,30 @@ static int zol_setvol(struct zol_device *dev, int vol)
if (dev->muted)
return 0;
down(&dev->lock);
mutex_lock(&dev->lock);
if (vol == 0) {
outb(0, io);
outb(0, io);
inb(io + 3); /* Zoltrix needs to be read to confirm */
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
outb(dev->curvol-1, io);
msleep(10);
inb(io + 2);
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
static void zol_mute(struct zol_device *dev)
{
dev->muted = 1;
down(&dev->lock);
mutex_lock(&dev->lock);
outb(0, io);
outb(0, io);
inb(io + 3); /* Zoltrix needs to be read to confirm */
up(&dev->lock);
mutex_unlock(&dev->lock);
}
static void zol_unmute(struct zol_device *dev)
@ -104,7 +104,7 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
bitmask = 0xc480402c10080000ull;
i = 45;
down(&dev->lock);
mutex_lock(&dev->lock);
outb(0, io);
outb(0, io);
@ -149,7 +149,7 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
udelay(1000);
}
up(&dev->lock);
mutex_unlock(&dev->lock);
if(!dev->muted)
{
@ -164,7 +164,7 @@ static int zol_getsigstr(struct zol_device *dev)
{
int a, b;
down(&dev->lock);
mutex_lock(&dev->lock);
outb(0x00, io); /* This stuff I found to do nothing */
outb(dev->curvol, io);
msleep(20);
@ -173,7 +173,7 @@ static int zol_getsigstr(struct zol_device *dev)
msleep(10);
b = inb(io);
up(&dev->lock);
mutex_unlock(&dev->lock);
if (a != b)
return (0);
@ -188,7 +188,7 @@ static int zol_is_stereo (struct zol_device *dev)
{
int x1, x2;
down(&dev->lock);
mutex_lock(&dev->lock);
outb(0x00, io);
outb(dev->curvol, io);
@ -198,7 +198,7 @@ static int zol_is_stereo (struct zol_device *dev)
msleep(10);
x2 = inb(io);
up(&dev->lock);
mutex_unlock(&dev->lock);
if ((x1 == x2) && (x1 == 0xcf))
return 1;
@ -350,7 +350,7 @@ static int __init zoltrix_init(void)
}
printk(KERN_INFO "Zoltrix Radio Plus card driver.\n");
init_MUTEX(&zoltrix_unit.lock);
mutex_init(&zoltrix_unit.lock);
/* mute card - prevents noisy bootups */

View file

@ -26,6 +26,7 @@ config VIDEO_BT848
select VIDEO_IR
select VIDEO_TUNER
select VIDEO_TVEEPROM
select VIDEO_MSP3400
---help---
Support for BT848 based frame grabber/overlay boards. This includes
the Miro, Hauppauge and STB boards. Please read the material in
@ -142,6 +143,8 @@ config VIDEO_CPIA_USB
otherwise say N. This will not work with the Creative Webcam III.
It is also available as a module (cpia_usb).
source "drivers/media/video/cpia2/Kconfig"
config VIDEO_SAA5246A
tristate "SAA5246A, SAA5281 Teletext processor"
depends on VIDEO_DEV && I2C
@ -339,18 +342,53 @@ config VIDEO_M32R_AR_M64278
Say Y here to use the Renesas M64278E-800 camera module,
which supports VGA(640x480 pixcels) size of images.
config VIDEO_AUDIO_DECODER
tristate "Add support for additional audio chipsets"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
config VIDEO_MSP3400
tristate "Micronas MSP34xx audio decoders"
depends on VIDEO_DEV && I2C
---help---
Say Y here to compile drivers for WM8775 and CS53L32A audio
decoders.
Support for the Micronas MSP34xx series of audio decoders.
config VIDEO_DECODER
tristate "Add support for additional video chipsets"
To compile this driver as a module, choose M here: the
module will be called msp3400
config VIDEO_CS53L32A
tristate "Cirrus Logic CS53L32A audio ADC"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
Say Y here to compile drivers for SAA7115, SAA7127 and CX25840
video decoders.
Support for the Cirrus Logic CS53L32A low voltage
stereo A/D converter.
To compile this driver as a module, choose M here: the
module will be called cs53l32a
config VIDEO_WM8775
tristate "Wolfson Microelectronics WM8775 audio ADC"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
Support for the Wolfson Microelectronics WM8775
high performance stereo A/D Converter.
To compile this driver as a module, choose M here: the
module will be called wm8775
source "drivers/media/video/cx25840/Kconfig"
config VIDEO_SAA711X
tristate "Philips SAA7113/4/5 video decoders"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
Support for the Philips SAA7113/4/5 video decoders.
To compile this driver as a module, choose M here: the
module will be called saa7115
config VIDEO_SAA7127
tristate "Philips SAA7127/9 digital video encoders"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
---help---
Support for the Philips SAA7127/9 digital video encoders.
To compile this driver as a module, choose M here: the
module will be called saa7127
endmenu

View file

@ -15,7 +15,7 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o
obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
obj-$(CONFIG_VIDEO_BT848) += bttv.o tvaudio.o \
tda7432.o tda9875.o ir-kbd-i2c.o
obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
@ -44,10 +44,13 @@ obj-$(CONFIG_VIDEO_MEYE) += meye.o
obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
obj-$(CONFIG_VIDEO_CX88) += cx88/
obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o
obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o
obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o
obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
obj-$(CONFIG_VIDEO_MXB) += saa7111.o tda9840.o tea6415c.o tea6420.o mxb.o
obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
obj-$(CONFIG_VIDEO_DPC) += saa7111.o dpc7146.o
@ -61,6 +64,8 @@ obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
obj-$(CONFIG_VIDEO_DECODER) += saa7115.o cx25840/ saa7127.o
obj-$(CONFIG_VIDEO_CX25840) += cx25840/
obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core

View file

@ -31,8 +31,8 @@
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/videodev.h>
#include <linux/mutex.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
#include <asm/m32r.h>
#include <asm/io.h>
@ -117,7 +117,7 @@ struct ar_device {
int width, height;
int frame_bytes, line_bytes;
wait_queue_head_t wait;
struct semaphore lock;
struct mutex lock;
};
static int video_nr = -1; /* video device number (first free) */
@ -288,7 +288,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
if (ar->mode == AR_MODE_NORMAL)
arvcr1 |= ARVCR1_NORMAL;
down(&ar->lock);
mutex_lock(&ar->lock);
#if USE_INT
local_irq_save(flags);
@ -392,7 +392,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
}
DEBUG(1, "ret = %d\n", ret);
out_up:
up(&ar->lock);
mutex_unlock(&ar->lock);
return ret;
}
@ -456,7 +456,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
(w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA))
return -EINVAL;
down(&ar->lock);
mutex_lock(&ar->lock);
ar->width = w->width;
ar->height = w->height;
if (ar->width == AR_WIDTH_VGA) {
@ -473,7 +473,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
ar->line_bytes = AR_LINE_BYTES_QVGA;
ar->mode = AR_MODE_INTERLACE;
}
up(&ar->lock);
mutex_unlock(&ar->lock);
return 0;
}
case VIDIOCGFBUF:
@ -734,7 +734,7 @@ static int ar_initialize(struct video_device *dev)
void ar_release(struct video_device *vfd)
{
struct ar_device *ar = vfd->priv;
down(&ar->lock);
mutex_lock(&ar->lock);
video_device_release(vfd);
}
@ -824,7 +824,7 @@ static int __init ar_init(void)
ar->line_bytes = AR_LINE_BYTES_QVGA;
ar->mode = AR_MODE_INTERLACE;
}
init_MUTEX(&ar->lock);
mutex_init(&ar->lock);
init_waitqueue_head(&ar->wait);
#if USE_INT

View file

@ -137,6 +137,8 @@ MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a li
MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)");
MODULE_PARM_DESC(tuner,"specify installed tuner type");
MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
" [some VIA/SIS chipsets are known to have problem with overlay]");
/* ----------------------------------------------------------------------- */
/* list of card IDs for bt878+ cards */
@ -275,7 +277,6 @@ static struct CARD {
{ 0x03116000, BTTV_BOARD_SENSORAY311, "Sensoray 311" },
{ 0x00790e11, BTTV_BOARD_WINDVR, "Canopus WinDVR PCI" },
{ 0xa0fca1a0, BTTV_BOARD_ZOLTRIX, "Face to Face Tvmax" },
{ 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV"},
{ 0x82b2aa6a, BTTV_BOARD_SIMUS_GVC1100, "SIMUS GVC1100" },
{ 0x146caa0c, BTTV_BOARD_PV951, "ituner spectra8" },
{ 0x200a1295, BTTV_BOARD_PXC200, "ImageNation PXC200A" },
@ -297,13 +298,14 @@ static struct CARD {
* { 0x13eb0070, BTTV_BOARD_HAUPPAUGE_IMPACTVCB, "Hauppauge ImpactVCB" }, */
/* DVB cards (using pci function .1 for mpeg data xfer) */
{ 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
{ 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
{ 0x001c11bd, BTTV_BOARD_PINNACLESAT, "Pinnacle PCTV Sat" },
{ 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
{ 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV"},
{ 0x002611bd, BTTV_BOARD_TWINHAN_DST, "Pinnacle PCTV SAT CI" },
{ 0x00011822, BTTV_BOARD_TWINHAN_DST, "Twinhan VisionPlus DVB" },
{ 0xfc00270f, BTTV_BOARD_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" },
{ 0x07711461, BTTV_BOARD_AVDVBT_771, "AVermedia AverTV DVB-T 771" },
{ 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
{ 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" },
{ 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" },
@ -4944,12 +4946,14 @@ void __devinit bttv_check_chipset(void)
if (vsfx)
printk(KERN_INFO "bttv: Host bridge needs VSFX enabled.\n");
if (pcipci_fail) {
printk(KERN_WARNING "bttv: BT848 and your chipset may not work together.\n");
printk(KERN_INFO "bttv: bttv and your chipset may not work "
"together.\n");
if (!no_overlay) {
printk(KERN_WARNING "bttv: overlay will be disabled.\n");
printk(KERN_INFO "bttv: overlay will be disabled.\n");
no_overlay = 1;
} else {
printk(KERN_WARNING "bttv: overlay forced. Use this option at your own risk.\n");
printk(KERN_INFO "bttv: overlay forced. Use this "
"option at your own risk.\n");
}
}
if (UNSET != latency)

View file

@ -1965,7 +1965,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
BUG();
}
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
kfree(fh->ov.clips);
fh->ov.clips = clips;
fh->ov.nclips = n;
@ -1986,7 +1986,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
retval = bttv_switch_overlay(btv,fh,new);
}
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return retval;
}
@ -2166,7 +2166,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv,
fmt = format_by_fourcc(f->fmt.pix.pixelformat);
/* update our state informations */
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
fh->fmt = fmt;
fh->cap.field = f->fmt.pix.field;
fh->cap.last = V4L2_FIELD_NONE;
@ -2175,7 +2175,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv,
btv->init.fmt = fmt;
btv->init.width = f->fmt.pix.width;
btv->init.height = f->fmt.pix.height;
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return 0;
}
@ -2282,7 +2282,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
fmt = format_by_palette(pic->palette);
if (NULL == fmt)
return -EINVAL;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
if (fmt->depth != pic->depth) {
retval = -EINVAL;
goto fh_unlock_and_return;
@ -2313,7 +2313,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
bt848_contrast(btv,pic->contrast);
bt848_hue(btv,pic->hue);
bt848_sat(btv,pic->colour);
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return 0;
}
@ -2379,7 +2379,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
return -EPERM;
end = (unsigned long)fbuf->base +
fbuf->height * fbuf->bytesperline;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
retval = -EINVAL;
switch (fbuf->depth) {
@ -2417,7 +2417,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
btv->fbuf.fmt.bytesperline = fbuf->bytesperline;
else
btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8;
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return 0;
}
@ -2440,7 +2440,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY))
return -EBUSY;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
if (*on) {
fh->ov.tvnorm = btv->tvnorm;
new = videobuf_alloc(sizeof(*new));
@ -2451,7 +2451,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
/* switch over */
retval = bttv_switch_overlay(btv,fh,new);
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return retval;
}
@ -2460,7 +2460,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
struct video_mbuf *mbuf = arg;
unsigned int i;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize,
V4L2_MEMORY_MMAP);
if (retval < 0)
@ -2470,7 +2470,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
mbuf->size = gbuffers * gbufsize;
for (i = 0; i < gbuffers; i++)
mbuf->offsets[i] = i * gbufsize;
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return 0;
}
case VIDIOCMCAPTURE:
@ -2482,7 +2482,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
if (vm->frame >= VIDEO_MAX_FRAME)
return -EINVAL;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
retval = -EINVAL;
buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame];
if (NULL == buf)
@ -2504,7 +2504,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
spin_lock_irqsave(&btv->s_lock,flags);
buffer_queue(&fh->cap,&buf->vb);
spin_unlock_irqrestore(&btv->s_lock,flags);
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return 0;
}
case VIDIOCSYNC:
@ -2515,7 +2515,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
if (*frame >= VIDEO_MAX_FRAME)
return -EINVAL;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
retval = -EINVAL;
buf = (struct bttv_buffer *)fh->cap.bufs[*frame];
if (NULL == buf)
@ -2535,7 +2535,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
retval = -EINVAL;
break;
}
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return retval;
}
@ -2719,7 +2719,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
if (0 == (fmt->flags & FORMAT_FLAGS_PACKED))
return -EINVAL;
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
retval = -EINVAL;
if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) {
if (fb->fmt.width > bttv_tvnorms[btv->tvnorm].swidth)
@ -2759,7 +2759,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
retval = bttv_switch_overlay(btv,fh,new);
}
}
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return retval;
}
@ -2890,7 +2890,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
return 0;
fh_unlock_and_return:
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return retval;
}
@ -2957,16 +2957,16 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
} else {
/* read() capture */
down(&fh->cap.lock);
mutex_lock(&fh->cap.lock);
if (NULL == fh->cap.read_buf) {
/* need to capture a new frame */
if (locked_btres(fh->btv,RESOURCE_VIDEO)) {
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
fh->cap.read_buf = videobuf_alloc(fh->cap.msize);
if (NULL == fh->cap.read_buf) {
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
@ -2974,13 +2974,13 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
kfree (fh->cap.read_buf);
fh->cap.read_buf = NULL;
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
return POLLERR;
}
fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
fh->cap.read_off = 0;
}
up(&fh->cap.lock);
mutex_unlock(&fh->cap.lock);
buf = (struct bttv_buffer*)fh->cap.read_buf;
}

View file

@ -28,251 +28,6 @@
#include "bttv.h"
#include "bttvp.h"
/* ---------------------------------------------------------------------- */
static IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE] = {
[ 34 ] = KEY_KP0,
[ 40 ] = KEY_KP1,
[ 24 ] = KEY_KP2,
[ 56 ] = KEY_KP3,
[ 36 ] = KEY_KP4,
[ 20 ] = KEY_KP5,
[ 52 ] = KEY_KP6,
[ 44 ] = KEY_KP7,
[ 28 ] = KEY_KP8,
[ 60 ] = KEY_KP9,
[ 48 ] = KEY_EJECTCD, // Unmarked on my controller
[ 0 ] = KEY_POWER,
[ 18 ] = BTN_LEFT, // DISPLAY/L
[ 50 ] = BTN_RIGHT, // LOOP/R
[ 10 ] = KEY_MUTE,
[ 38 ] = KEY_RECORD,
[ 22 ] = KEY_PAUSE,
[ 54 ] = KEY_STOP,
[ 30 ] = KEY_VOLUMEDOWN,
[ 62 ] = KEY_VOLUMEUP,
[ 32 ] = KEY_TUNER, // TV/FM
[ 16 ] = KEY_CD,
[ 8 ] = KEY_VIDEO,
[ 4 ] = KEY_AUDIO,
[ 12 ] = KEY_ZOOM, // full screen
[ 2 ] = KEY_INFO, // preview
[ 42 ] = KEY_SEARCH, // autoscan
[ 26 ] = KEY_STOP, // freeze
[ 58 ] = KEY_RECORD, // capture
[ 6 ] = KEY_PLAY, // unmarked
[ 46 ] = KEY_RED, // unmarked
[ 14 ] = KEY_GREEN, // unmarked
[ 33 ] = KEY_YELLOW, // unmarked
[ 17 ] = KEY_CHANNELDOWN,
[ 49 ] = KEY_CHANNELUP,
[ 1 ] = KEY_BLUE, // unmarked
};
/* Matt Jesson <[email protected] */
static IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE] = {
[ 0x28 ] = KEY_KP0, //'0' / 'enter'
[ 0x22 ] = KEY_KP1, //'1'
[ 0x12 ] = KEY_KP2, //'2' / 'up arrow'
[ 0x32 ] = KEY_KP3, //'3'
[ 0x24 ] = KEY_KP4, //'4' / 'left arrow'
[ 0x14 ] = KEY_KP5, //'5'
[ 0x34 ] = KEY_KP6, //'6' / 'right arrow'
[ 0x26 ] = KEY_KP7, //'7'
[ 0x16 ] = KEY_KP8, //'8' / 'down arrow'
[ 0x36 ] = KEY_KP9, //'9'
[ 0x20 ] = KEY_LIST, // 'source'
[ 0x10 ] = KEY_TEXT, // 'teletext'
[ 0x00 ] = KEY_POWER, // 'power'
[ 0x04 ] = KEY_AUDIO, // 'audio'
[ 0x06 ] = KEY_ZOOM, // 'full screen'
[ 0x18 ] = KEY_VIDEO, // 'display'
[ 0x38 ] = KEY_SEARCH, // 'loop'
[ 0x08 ] = KEY_INFO, // 'preview'
[ 0x2a ] = KEY_REWIND, // 'backward <<'
[ 0x1a ] = KEY_FASTFORWARD, // 'forward >>'
[ 0x3a ] = KEY_RECORD, // 'capture'
[ 0x0a ] = KEY_MUTE, // 'mute'
[ 0x2c ] = KEY_RECORD, // 'record'
[ 0x1c ] = KEY_PAUSE, // 'pause'
[ 0x3c ] = KEY_STOP, // 'stop'
[ 0x0c ] = KEY_PLAY, // 'play'
[ 0x2e ] = KEY_RED, // 'red'
[ 0x01 ] = KEY_BLUE, // 'blue' / 'cancel'
[ 0x0e ] = KEY_YELLOW, // 'yellow' / 'ok'
[ 0x21 ] = KEY_GREEN, // 'green'
[ 0x11 ] = KEY_CHANNELDOWN, // 'channel -'
[ 0x31 ] = KEY_CHANNELUP, // 'channel +'
[ 0x1e ] = KEY_VOLUMEDOWN, // 'volume -'
[ 0x3e ] = KEY_VOLUMEUP, // 'volume +'
};
/* Attila Kondoros <[email protected]> */
static IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = {
[ 1 ] = KEY_KP1,
[ 2 ] = KEY_KP2,
[ 3 ] = KEY_KP3,
[ 4 ] = KEY_KP4,
[ 5 ] = KEY_KP5,
[ 6 ] = KEY_KP6,
[ 7 ] = KEY_KP7,
[ 8 ] = KEY_KP8,
[ 9 ] = KEY_KP9,
[ 0 ] = KEY_KP0,
[ 23 ] = KEY_LAST, // +100
[ 10 ] = KEY_LIST, // recall
[ 28 ] = KEY_TUNER, // TV/FM
[ 21 ] = KEY_SEARCH, // scan
[ 18 ] = KEY_POWER, // power
[ 31 ] = KEY_VOLUMEDOWN, // vol up
[ 27 ] = KEY_VOLUMEUP, // vol down
[ 30 ] = KEY_CHANNELDOWN, // chn up
[ 26 ] = KEY_CHANNELUP, // chn down
[ 17 ] = KEY_VIDEO, // video
[ 15 ] = KEY_ZOOM, // full screen
[ 19 ] = KEY_MUTE, // mute/unmute
[ 16 ] = KEY_TEXT, // min
[ 13 ] = KEY_STOP, // freeze
[ 14 ] = KEY_RECORD, // record
[ 29 ] = KEY_PLAYPAUSE, // stop
[ 25 ] = KEY_PLAY, // play
[ 22 ] = KEY_GOTO, // osd
[ 20 ] = KEY_REFRESH, // default
[ 12 ] = KEY_KPPLUS, // fine tune >>>>
[ 24 ] = KEY_KPMINUS // fine tune <<<<
};
/* ---------------------------------------------------------------------- */
static IR_KEYTAB_TYPE ir_codes_conceptronic[IR_KEYTAB_SIZE] = {
[ 30 ] = KEY_POWER, // power
[ 7 ] = KEY_MEDIA, // source
[ 28 ] = KEY_SEARCH, // scan
/* FIXME: duplicate keycodes?
*
* These four keys seem to share the same GPIO as CH+, CH-, <<< and >>>
* The GPIO values are
* 6397fb for both "Scan <" and "CH -",
* 639ffb for "Scan >" and "CH+",
* 6384fb for "Tune <" and "<<<",
* 638cfb for "Tune >" and ">>>", regardless of the mask.
*
* [ 23 ] = KEY_BACK, // fm scan <<
* [ 31 ] = KEY_FORWARD, // fm scan >>
*
* [ 4 ] = KEY_LEFT, // fm tuning <
* [ 12 ] = KEY_RIGHT, // fm tuning >
*
* For now, these four keys are disabled. Pressing them will generate
* the CH+/CH-/<<</>>> events
*/
[ 3 ] = KEY_TUNER, // TV/FM
[ 0 ] = KEY_RECORD,
[ 8 ] = KEY_STOP,
[ 17 ] = KEY_PLAY,
[ 26 ] = KEY_PLAYPAUSE, // freeze
[ 25 ] = KEY_ZOOM, // zoom
[ 15 ] = KEY_TEXT, // min
[ 1 ] = KEY_KP1,
[ 11 ] = KEY_KP2,
[ 27 ] = KEY_KP3,
[ 5 ] = KEY_KP4,
[ 9 ] = KEY_KP5,
[ 21 ] = KEY_KP6,
[ 6 ] = KEY_KP7,
[ 10 ] = KEY_KP8,
[ 18 ] = KEY_KP9,
[ 2 ] = KEY_KP0,
[ 16 ] = KEY_LAST, // +100
[ 19 ] = KEY_LIST, // recall
[ 31 ] = KEY_CHANNELUP, // chn down
[ 23 ] = KEY_CHANNELDOWN, // chn up
[ 22 ] = KEY_VOLUMEUP, // vol down
[ 20 ] = KEY_VOLUMEDOWN, // vol up
[ 4 ] = KEY_KPMINUS, // <<<
[ 14 ] = KEY_SETUP, // function
[ 12 ] = KEY_KPPLUS, // >>>
[ 13 ] = KEY_GOTO, // mts
[ 29 ] = KEY_REFRESH, // reset
[ 24 ] = KEY_MUTE // mute/unmute
};
static IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = {
[0x00] = KEY_KP0,
[0x01] = KEY_KP1,
[0x02] = KEY_KP2,
[0x03] = KEY_KP3,
[0x04] = KEY_KP4,
[0x05] = KEY_KP5,
[0x06] = KEY_KP6,
[0x07] = KEY_KP7,
[0x08] = KEY_KP8,
[0x09] = KEY_KP9,
[0x0a] = KEY_TV,
[0x0b] = KEY_AUX,
[0x0c] = KEY_DVD,
[0x0d] = KEY_POWER,
[0x0e] = KEY_MHP, /* labelled 'Picture' */
[0x0f] = KEY_AUDIO,
[0x10] = KEY_INFO,
[0x11] = KEY_F13, /* 16:9 */
[0x12] = KEY_F14, /* 14:9 */
[0x13] = KEY_EPG,
[0x14] = KEY_EXIT,
[0x15] = KEY_MENU,
[0x16] = KEY_UP,
[0x17] = KEY_DOWN,
[0x18] = KEY_LEFT,
[0x19] = KEY_RIGHT,
[0x1a] = KEY_ENTER,
[0x1b] = KEY_CHANNELUP,
[0x1c] = KEY_CHANNELDOWN,
[0x1d] = KEY_VOLUMEUP,
[0x1e] = KEY_VOLUMEDOWN,
[0x1f] = KEY_RED,
[0x20] = KEY_GREEN,
[0x21] = KEY_YELLOW,
[0x22] = KEY_BLUE,
[0x23] = KEY_SUBTITLE,
[0x24] = KEY_F15, /* AD */
[0x25] = KEY_TEXT,
[0x26] = KEY_MUTE,
[0x27] = KEY_REWIND,
[0x28] = KEY_STOP,
[0x29] = KEY_PLAY,
[0x2a] = KEY_FASTFORWARD,
[0x2b] = KEY_F16, /* chapter */
[0x2c] = KEY_PAUSE,
[0x2d] = KEY_PLAY,
[0x2e] = KEY_RECORD,
[0x2f] = KEY_F17, /* picture in picture */
[0x30] = KEY_KPPLUS, /* zoom in */
[0x31] = KEY_KPMINUS, /* zoom out */
[0x32] = KEY_F18, /* capture */
[0x33] = KEY_F19, /* web */
[0x34] = KEY_EMAIL,
[0x35] = KEY_PHONE,
[0x36] = KEY_PC
};
static int debug;
module_param(debug, int, 0644); /* debug level (0,1,2) */
@ -573,7 +328,8 @@ int bttv_input_init(struct bttv *btv)
ir->polling = 50; // ms
break;
case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
ir_codes = ir_codes_conceptronic;
case BTTV_BOARD_CONTVFMI:
ir_codes = ir_codes_pixelview;
ir->mask_keycode = 0x001F00;
ir->mask_keyup = 0x006000;
ir->polling = 50; // ms

View file

@ -51,8 +51,10 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
int rc;
/* estimate risc mem: worst case is one write per page border +
one write per scan line + sync + jump (all 2 dwords) */
instructions = (bpl * lines) / PAGE_SIZE + lines;
one write per scan line + sync + jump (all 2 dwords). padding
can cause next bpl to start close to a page border. First DMA
region may be smaller than PAGE_SIZE */
instructions = 1 + ((bpl + padding) * lines) / PAGE_SIZE + lines;
instructions += 2;
if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0)
return rc;
@ -104,7 +106,7 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
/* save pointer to jmp instruction address */
risc->jmp = rp;
BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
return 0;
}
@ -222,7 +224,7 @@ bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc,
/* save pointer to jmp instruction address */
risc->jmp = rp;
BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
return 0;
}
@ -274,6 +276,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
if (line > maxy)
btcx_calc_skips(line, ov->w.width, &maxy,
skips, &nskips, ov->clips, ov->nclips);
else
nskips = 0;
/* write out risc code */
for (start = 0, skip = 0; start < ov->w.width; start = end) {
@ -307,7 +311,7 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
/* save pointer to jmp instruction address */
risc->jmp = rp;
BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
kfree(skips);
return 0;
}
@ -507,8 +511,7 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
void
bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf)
{
if (in_interrupt())
BUG();
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);

View file

@ -73,7 +73,7 @@ OTHER DEALINGS IN THE SOFTWARE.
#include <linux/parport.h>
#include <linux/sched.h>
#include <linux/videodev.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include "bw-qcam.h"
@ -168,7 +168,7 @@ static struct qcam_device *qcam_init(struct parport *port)
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
init_MUTEX(&q->lock);
mutex_init(&q->lock);
q->port_mode = (QC_ANY | QC_NOTSET);
q->width = 320;
@ -772,9 +772,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->whitebal = p->whiteness>>8;
qcam->bpp = p->depth;
down(&qcam->lock);
mutex_lock(&qcam->lock);
qc_setscanmode(qcam);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
qcam->status |= QC_PARAM_CHANGE;
return 0;
@ -805,9 +805,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->height = 240;
qcam->transfer_scale = 1;
}
down(&qcam->lock);
mutex_lock(&qcam->lock);
qc_setscanmode(qcam);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
/* We must update the camera before we grab. We could
just have changed the grab size */
@ -854,7 +854,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
int len;
parport_claim_or_block(qcam->pdev);
down(&qcam->lock);
mutex_lock(&qcam->lock);
qc_reset(qcam);
@ -864,7 +864,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
len=qc_capture(qcam, buf,count);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
parport_release(qcam->pdev);
return len;

View file

@ -55,7 +55,7 @@ struct qcam_device {
struct video_device vdev;
struct pardevice *pdev;
struct parport *pport;
struct semaphore lock;
struct mutex lock;
int width, height;
int bpp;
int mode;

View file

@ -34,7 +34,8 @@
#include <linux/parport.h>
#include <linux/sched.h>
#include <linux/videodev.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
struct qcam_device {
@ -47,7 +48,7 @@ struct qcam_device {
int contrast, brightness, whitebal;
int top, left;
unsigned int bidirectional;
struct semaphore lock;
struct mutex lock;
};
/* cameras maximum */
@ -581,11 +582,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->contrast = p->contrast>>8;
qcam->whitebal = p->whiteness>>8;
down(&qcam->lock);
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
return 0;
}
case VIDIOCSWIN:
@ -628,11 +629,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
#endif
/* Ok we figured out what to use from our
wide choice */
down(&qcam->lock);
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
return 0;
}
case VIDIOCGWIN:
@ -672,12 +673,12 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
struct qcam_device *qcam=(struct qcam_device *)v;
int len;
down(&qcam->lock);
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
/* Probably should have a semaphore against multiple users */
len = qc_capture(qcam, buf,count);
parport_release(qcam->pdev);
up(&qcam->lock);
mutex_unlock(&qcam->lock);
return len;
}
@ -727,7 +728,7 @@ static struct qcam_device *qcam_init(struct parport *port)
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
init_MUTEX(&q->lock);
mutex_init(&q->lock);
q->width = q->ccd_width = 320;
q->height = q->ccd_height = 240;
q->mode = QC_MILLIONS | QC_DECIMATION_1;

View file

@ -39,7 +39,7 @@
#include <linux/pagemap.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
@ -622,7 +622,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
buffer = page;
if (down_interruptible(&cam->param_lock))
if (mutex_lock_interruptible(&cam->param_lock))
return -ERESTARTSYS;
/*
@ -1350,7 +1350,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
} else
DBG("error: %d\n", retval);
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
out:
free_page((unsigned long)page);
@ -1664,7 +1664,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
case CPIA_COMMAND_GetColourParams:
case CPIA_COMMAND_GetColourBalance:
case CPIA_COMMAND_GetExposure:
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
datasize=8;
break;
case CPIA_COMMAND_ReadMCPorts:
@ -1691,7 +1691,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
if (command == CPIA_COMMAND_GetColourParams ||
command == CPIA_COMMAND_GetColourBalance ||
command == CPIA_COMMAND_GetExposure)
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
} else {
switch(command) {
case CPIA_COMMAND_GetCPIAVersion:
@ -1726,13 +1726,13 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
cam->params.colourParams.brightness = data[0];
cam->params.colourParams.contrast = data[1];
cam->params.colourParams.saturation = data[2];
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
break;
case CPIA_COMMAND_GetColourBalance:
cam->params.colourBalance.redGain = data[0];
cam->params.colourBalance.greenGain = data[1];
cam->params.colourBalance.blueGain = data[2];
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
break;
case CPIA_COMMAND_GetExposure:
cam->params.exposure.gain = data[0];
@ -1743,7 +1743,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
cam->params.exposure.green1Comp = data[5];
cam->params.exposure.green2Comp = data[6];
cam->params.exposure.blueComp = data[7];
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
break;
case CPIA_COMMAND_ReadMCPorts:
@ -2059,7 +2059,7 @@ static int parse_picture(struct cam_data *cam, int size)
int rows, cols, linesize, subsample_422;
/* make sure params don't change while we are decoding */
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
obuf = cam->decompressed_frame.data;
end_obuf = obuf+CPIA_MAX_FRAME_SIZE;
@ -2069,26 +2069,26 @@ static int parse_picture(struct cam_data *cam, int size)
if ((ibuf[0] != MAGIC_0) || (ibuf[1] != MAGIC_1)) {
LOG("header not found\n");
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
if ((ibuf[16] != VIDEOSIZE_QCIF) && (ibuf[16] != VIDEOSIZE_CIF)) {
LOG("wrong video size\n");
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) {
LOG("illegal subtype %d\n",ibuf[17]);
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
subsample_422 = ibuf[17] == SUBSAMPLE_422;
if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) {
LOG("illegal yuvorder %d\n",ibuf[18]);
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
in_uyvy = ibuf[18] == YUVORDER_UYVY;
@ -2098,7 +2098,7 @@ static int parse_picture(struct cam_data *cam, int size)
(ibuf[26] != cam->params.roi.rowStart) ||
(ibuf[27] != cam->params.roi.rowEnd)) {
LOG("ROI mismatch\n");
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
cols = 8*(ibuf[25] - ibuf[24]);
@ -2107,14 +2107,14 @@ static int parse_picture(struct cam_data *cam, int size)
if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) {
LOG("illegal compression %d\n",ibuf[28]);
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
compressed = (ibuf[28] == COMPRESSED);
if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) {
LOG("illegal decimation %d\n",ibuf[29]);
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return -1;
}
decimation = (ibuf[29] == DECIMATION_ENAB);
@ -2130,7 +2130,7 @@ static int parse_picture(struct cam_data *cam, int size)
cam->params.status.vpStatus = ibuf[38];
cam->params.status.errorCode = ibuf[39];
cam->fps = ibuf[41];
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
linesize = skipcount(cols, out_fmt);
ibuf += FRAME_HEADER_SIZE;
@ -2271,9 +2271,9 @@ static int find_over_exposure(int brightness)
/* update various camera modes and settings */
static void dispatch_commands(struct cam_data *cam)
{
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
if (cam->cmd_queue==COMMAND_NONE) {
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return;
}
DEB_BYTE(cam->cmd_queue);
@ -2415,7 +2415,7 @@ static void dispatch_commands(struct cam_data *cam)
}
cam->cmd_queue = COMMAND_NONE;
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return;
}
@ -2562,7 +2562,7 @@ static void monitor_exposure(struct cam_data *cam)
gain = data[2];
coarseL = data[3];
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
light_exp = cam->params.colourParams.brightness +
TC - 50 + EXP_ACC_LIGHT;
if(light_exp > 255)
@ -2762,7 +2762,7 @@ static void monitor_exposure(struct cam_data *cam)
LOG("Automatically increasing sensor_fps\n");
}
}
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
}
/*-----------------------------------------------------------------*/
@ -2778,10 +2778,10 @@ static void restart_flicker(struct cam_data *cam)
int cam_exposure, old_exp;
if(!FIRMWARE_VERSION(1,2))
return;
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
if(cam->params.flickerControl.flickerMode == 0 ||
cam->raw_image[39] == 0) {
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
return;
}
cam_exposure = cam->raw_image[39]*2;
@ -2810,7 +2810,7 @@ static void restart_flicker(struct cam_data *cam)
cam->exposure_status = EXPOSURE_NORMAL;
}
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
}
#undef FIRMWARE_VERSION
@ -3186,7 +3186,7 @@ static int cpia_open(struct inode *inode, struct file *file)
if (!try_module_get(cam->ops->owner))
return -ENODEV;
down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);
err = -ENOMEM;
if (!cam->raw_image) {
cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE);
@ -3227,7 +3227,7 @@ static int cpia_open(struct inode *inode, struct file *file)
++cam->open_count;
file->private_data = dev;
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0;
oops:
@ -3239,7 +3239,7 @@ static int cpia_open(struct inode *inode, struct file *file)
rvfree(cam->raw_image, CPIA_MAX_IMAGE_SIZE);
cam->raw_image = NULL;
}
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
put_cam(cam->ops);
return err;
}
@ -3303,24 +3303,24 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
int err;
/* make this _really_ smp and multithread-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -EINTR;
if (!buf) {
DBG("buf NULL\n");
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EINVAL;
}
if (!count) {
DBG("count 0\n");
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0;
}
if (!cam->ops) {
DBG("ops NULL\n");
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -ENODEV;
}
@ -3329,7 +3329,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
cam->mmap_kludge=0;
if((err = fetch_frame(cam)) != 0) {
DBG("ERROR from fetch_frame: %d\n", err);
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return err;
}
cam->decompressed_frame.state = FRAME_UNUSED;
@ -3338,17 +3338,17 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
if (cam->decompressed_frame.count > count) {
DBG("count wrong: %d, %lu\n", cam->decompressed_frame.count,
(unsigned long) count);
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EFAULT;
}
if (copy_to_user(buf, cam->decompressed_frame.data,
cam->decompressed_frame.count)) {
DBG("copy_to_user failed\n");
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EFAULT;
}
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return cam->decompressed_frame.count;
}
@ -3363,7 +3363,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
return -ENODEV;
/* make this _really_ smp-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -EINTR;
//DBG("cpia_ioctl: %u\n", ioctlnr);
@ -3439,7 +3439,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
break;
}
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
/* brightness, colour, contrast need no check 0-65535 */
cam->vp = *vp;
/* update cam->params.colourParams */
@ -3466,7 +3466,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
/* queue command to update camera */
cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
DBG("VIDIOCSPICT: %d / %d // %d / %d / %d / %d\n",
vp->depth, vp->palette, vp->brightness, vp->hue, vp->colour,
vp->contrast);
@ -3501,13 +3501,13 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
/* we set the video window to something smaller or equal to what
* is requested by the user???
*/
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
if (vw->width != cam->vw.width || vw->height != cam->vw.height) {
int video_size = match_videosize(vw->width, vw->height);
if (video_size < 0) {
retval = -EINVAL;
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
break;
}
cam->video_size = video_size;
@ -3520,7 +3520,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
cam->cmd_queue |= COMMAND_SETFORMAT;
}
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
/* setformat ignored by camera during streaming,
* so stop/dispatch/start */
@ -3682,7 +3682,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
down(&cam->param_lock);
mutex_lock(&cam->param_lock);
cam->vc.x = vc->x;
cam->vc.y = vc->y;
@ -3692,7 +3692,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
set_vw_size(cam);
cam->cmd_queue |= COMMAND_SETFORMAT;
up(&cam->param_lock);
mutex_unlock(&cam->param_lock);
/* setformat ignored by camera during streaming,
* so stop/dispatch/start */
@ -3736,7 +3736,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
break;
}
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return retval;
}
@ -3769,12 +3769,12 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
return -ENODEV;
/* make this _really_ smp-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -EINTR;
if (!cam->frame_buf) { /* we do lazy allocation */
if ((retval = allocate_frame_buf(cam))) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return retval;
}
}
@ -3783,7 +3783,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
while (size > 0) {
page = vmalloc_to_pfn((void *)pos);
if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EAGAIN;
}
start += PAGE_SIZE;
@ -3795,7 +3795,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
}
DBG("cpia_mmap: %ld\n", size);
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0;
}
@ -3936,8 +3936,8 @@ static void init_camera_struct(struct cam_data *cam,
memset(cam, 0, sizeof(struct cam_data));
cam->ops = ops;
init_MUTEX(&cam->param_lock);
init_MUTEX(&cam->busy_lock);
mutex_init(&cam->param_lock);
mutex_init(&cam->busy_lock);
reset_camera_struct(cam);

View file

@ -47,6 +47,7 @@
#include <linux/videodev.h>
#include <linux/list.h>
#include <linux/smp_lock.h>
#include <linux/mutex.h>
struct cpia_camera_ops
{
@ -246,7 +247,7 @@ enum v4l_camstates {
struct cam_data {
struct list_head cam_data_list;
struct semaphore busy_lock; /* guard against SMP multithreading */
struct mutex busy_lock; /* guard against SMP multithreading */
struct cpia_camera_ops *ops; /* lowlevel driver operations */
void *lowlevel_data; /* private data for lowlevel driver */
u8 *raw_image; /* buffer for raw image data */
@ -261,7 +262,7 @@ struct cam_data {
u8 mainsFreq; /* for flicker control */
/* proc interface */
struct semaphore param_lock; /* params lock for this camera */
struct mutex param_lock; /* params lock for this camera */
struct cam_params params; /* camera settings */
struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */

View file

@ -0,0 +1,9 @@
config VIDEO_CPIA2
tristate "CPiA2 Video For Linux"
depends on VIDEO_DEV && USB
---help---
This is the video4linux driver for cameras based on Vision's CPiA2
(Colour Processor Interface ASIC), such as the Digital Blue QX5
Microscope. If you have one of these cameras, say Y here
This driver is also available as a module (cpia2).

View file

@ -0,0 +1,3 @@
cpia2-objs := cpia2_v4l.o cpia2_usb.o cpia2_core.o
obj-$(CONFIG_VIDEO_CPIA2) += cpia2.o

View file

@ -0,0 +1,497 @@
/****************************************************************************
*
* Filename: cpia2.h
*
* Copyright 2001, STMicrolectronics, Inc.
*
* Contact: steve.miller@st.com
*
* Description:
* This is a USB driver for CPiA2 based video cameras.
*
* This driver is modelled on the cpia usb driver by
* Jochen Scharrlach and Johannes Erdfeldt.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
****************************************************************************/
#ifndef __CPIA2_H__
#define __CPIA2_H__
#include <linux/version.h>
#include <linux/videodev.h>
#include <linux/usb.h>
#include <linux/poll.h>
#include "cpia2dev.h"
#include "cpia2_registers.h"
/* define for verbose debug output */
//#define _CPIA2_DEBUG_
#define CPIA2_MAJ_VER 2
#define CPIA2_MIN_VER 0
#define CPIA2_PATCH_VER 0
/***
* Image defines
***/
#ifndef true
#define true 1
#define false 0
#endif
/* Misc constants */
#define ALLOW_CORRUPT 0 /* Causes collater to discard checksum */
/* USB Transfer mode */
#define XFER_ISOC 0
#define XFER_BULK 1
/* USB Alternates */
#define USBIF_CMDONLY 0
#define USBIF_BULK 1
#define USBIF_ISO_1 2 /* 128 bytes/ms */
#define USBIF_ISO_2 3 /* 384 bytes/ms */
#define USBIF_ISO_3 4 /* 640 bytes/ms */
#define USBIF_ISO_4 5 /* 768 bytes/ms */
#define USBIF_ISO_5 6 /* 896 bytes/ms */
#define USBIF_ISO_6 7 /* 1023 bytes/ms */
/* Flicker Modes */
#define NEVER_FLICKER 0
#define ANTI_FLICKER_ON 1
#define FLICKER_60 60
#define FLICKER_50 50
/* Debug flags */
#define DEBUG_NONE 0
#define DEBUG_REG 0x00000001
#define DEBUG_DUMP_PATCH 0x00000002
#define DEBUG_DUMP_REGS 0x00000004
/***
* Video frame sizes
***/
enum {
VIDEOSIZE_VGA = 0, /* 640x480 */
VIDEOSIZE_CIF, /* 352x288 */
VIDEOSIZE_QVGA, /* 320x240 */
VIDEOSIZE_QCIF, /* 176x144 */
VIDEOSIZE_288_216,
VIDEOSIZE_256_192,
VIDEOSIZE_224_168,
VIDEOSIZE_192_144,
};
#define STV_IMAGE_CIF_ROWS 288
#define STV_IMAGE_CIF_COLS 352
#define STV_IMAGE_QCIF_ROWS 144
#define STV_IMAGE_QCIF_COLS 176
#define STV_IMAGE_VGA_ROWS 480
#define STV_IMAGE_VGA_COLS 640
#define STV_IMAGE_QVGA_ROWS 240
#define STV_IMAGE_QVGA_COLS 320
#define JPEG_MARKER_COM (1<<6) /* Comment segment */
/***
* Enums
***/
/* Sensor types available with cpia2 asics */
enum sensors {
CPIA2_SENSOR_410,
CPIA2_SENSOR_500
};
/* Asic types available in the CPiA2 architecture */
#define CPIA2_ASIC_672 0x67
/* Device types (stv672, stv676, etc) */
#define DEVICE_STV_672 0x0001
#define DEVICE_STV_676 0x0002
enum frame_status {
FRAME_EMPTY,
FRAME_READING, /* In the process of being grabbed into */
FRAME_READY, /* Ready to be read */
FRAME_ERROR,
};
/***
* Register access (for USB request byte)
***/
enum {
CAMERAACCESS_SYSTEM = 0,
CAMERAACCESS_VC,
CAMERAACCESS_VP,
CAMERAACCESS_IDATA
};
#define CAMERAACCESS_TYPE_BLOCK 0x00
#define CAMERAACCESS_TYPE_RANDOM 0x04
#define CAMERAACCESS_TYPE_MASK 0x08
#define CAMERAACCESS_TYPE_REPEAT 0x0C
#define TRANSFER_READ 0
#define TRANSFER_WRITE 1
#define DEFAULT_ALT USBIF_ISO_6
#define DEFAULT_BRIGHTNESS 0x46
#define DEFAULT_CONTRAST 0x93
#define DEFAULT_SATURATION 0x7f
#define DEFAULT_TARGET_KB 0x30
/* Power state */
#define HI_POWER_MODE CPIA2_SYSTEM_CONTROL_HIGH_POWER
#define LO_POWER_MODE CPIA2_SYSTEM_CONTROL_LOW_POWER
/********
* Commands
*******/
enum {
CPIA2_CMD_NONE = 0,
CPIA2_CMD_GET_VERSION,
CPIA2_CMD_GET_PNP_ID,
CPIA2_CMD_GET_ASIC_TYPE,
CPIA2_CMD_GET_SENSOR,
CPIA2_CMD_GET_VP_DEVICE,
CPIA2_CMD_GET_VP_BRIGHTNESS,
CPIA2_CMD_SET_VP_BRIGHTNESS,
CPIA2_CMD_GET_CONTRAST,
CPIA2_CMD_SET_CONTRAST,
CPIA2_CMD_GET_VP_SATURATION,
CPIA2_CMD_SET_VP_SATURATION,
CPIA2_CMD_GET_VP_GPIO_DIRECTION,
CPIA2_CMD_SET_VP_GPIO_DIRECTION,
CPIA2_CMD_GET_VP_GPIO_DATA,
CPIA2_CMD_SET_VP_GPIO_DATA,
CPIA2_CMD_GET_VC_MP_GPIO_DIRECTION,
CPIA2_CMD_SET_VC_MP_GPIO_DIRECTION,
CPIA2_CMD_GET_VC_MP_GPIO_DATA,
CPIA2_CMD_SET_VC_MP_GPIO_DATA,
CPIA2_CMD_ENABLE_PACKET_CTRL,
CPIA2_CMD_GET_FLICKER_MODES,
CPIA2_CMD_SET_FLICKER_MODES,
CPIA2_CMD_RESET_FIFO, /* clear fifo and enable stream block */
CPIA2_CMD_SET_HI_POWER,
CPIA2_CMD_SET_LOW_POWER,
CPIA2_CMD_CLEAR_V2W_ERR,
CPIA2_CMD_SET_USER_MODE,
CPIA2_CMD_GET_USER_MODE,
CPIA2_CMD_FRAMERATE_REQ,
CPIA2_CMD_SET_COMPRESSION_STATE,
CPIA2_CMD_GET_WAKEUP,
CPIA2_CMD_SET_WAKEUP,
CPIA2_CMD_GET_PW_CONTROL,
CPIA2_CMD_SET_PW_CONTROL,
CPIA2_CMD_GET_SYSTEM_CTRL,
CPIA2_CMD_SET_SYSTEM_CTRL,
CPIA2_CMD_GET_VP_SYSTEM_STATE,
CPIA2_CMD_GET_VP_SYSTEM_CTRL,
CPIA2_CMD_SET_VP_SYSTEM_CTRL,
CPIA2_CMD_GET_VP_EXP_MODES,
CPIA2_CMD_SET_VP_EXP_MODES,
CPIA2_CMD_GET_DEVICE_CONFIG,
CPIA2_CMD_SET_DEVICE_CONFIG,
CPIA2_CMD_SET_SERIAL_ADDR,
CPIA2_CMD_SET_SENSOR_CR1,
CPIA2_CMD_GET_VC_CONTROL,
CPIA2_CMD_SET_VC_CONTROL,
CPIA2_CMD_SET_TARGET_KB,
CPIA2_CMD_SET_DEF_JPEG_OPT,
CPIA2_CMD_REHASH_VP4,
CPIA2_CMD_GET_USER_EFFECTS,
CPIA2_CMD_SET_USER_EFFECTS
};
enum user_cmd {
COMMAND_NONE = 0x00000001,
COMMAND_SET_FPS = 0x00000002,
COMMAND_SET_COLOR_PARAMS = 0x00000004,
COMMAND_GET_COLOR_PARAMS = 0x00000008,
COMMAND_SET_FORMAT = 0x00000010, /* size, etc */
COMMAND_SET_FLICKER = 0x00000020
};
/***
* Some defines specific to the 676 chip
***/
#define CAMACC_CIF 0x01
#define CAMACC_VGA 0x02
#define CAMACC_QCIF 0x04
#define CAMACC_QVGA 0x08
struct cpia2_register {
u8 index;
u8 value;
};
struct cpia2_reg_mask {
u8 index;
u8 and_mask;
u8 or_mask;
u8 fill;
};
struct cpia2_command {
u32 command;
u8 req_mode; /* (Block or random) | registerBank */
u8 reg_count;
u8 direction;
u8 start;
union reg_types {
struct cpia2_register registers[32];
struct cpia2_reg_mask masks[16];
u8 block_data[64];
u8 *patch_data; /* points to function defined block */
} buffer;
};
struct camera_params {
struct {
u8 firmware_revision_hi; /* For system register set (bank 0) */
u8 firmware_revision_lo;
u8 asic_id; /* Video Compressor set (bank 1) */
u8 asic_rev;
u8 vp_device_hi; /* Video Processor set (bank 2) */
u8 vp_device_lo;
u8 sensor_flags;
u8 sensor_rev;
} version;
struct {
u32 device_type; /* enumerated from vendor/product ids.
* Currently, either STV_672 or STV_676 */
u16 vendor;
u16 product;
u16 device_revision;
} pnp_id;
struct {
u8 brightness; /* CPIA2_VP_EXPOSURE_TARGET */
u8 contrast; /* Note: this is CPIA2_VP_YRANGE */
u8 saturation; /* CPIA2_VP_SATURATION */
} color_params;
struct {
u8 cam_register;
u8 flicker_mode_req; /* 1 if flicker on, else never flicker */
int mains_frequency;
} flicker_control;
struct {
u8 jpeg_options;
u8 creep_period;
u8 user_squeeze;
u8 inhibit_htables;
} compression;
struct {
u8 ohsize; /* output image size */
u8 ovsize;
u8 hcrop; /* cropping start_pos/4 */
u8 vcrop;
u8 hphase; /* scaling registers */
u8 vphase;
u8 hispan;
u8 vispan;
u8 hicrop;
u8 vicrop;
u8 hifraction;
u8 vifraction;
} image_size;
struct {
int width; /* actual window width */
int height; /* actual window height */
} roi;
struct {
u8 video_mode;
u8 frame_rate;
u8 video_size; /* Not a register, just a convenience for cropped sizes */
u8 gpio_direction;
u8 gpio_data;
u8 system_ctrl;
u8 system_state;
u8 lowlight_boost; /* Bool: 0 = off, 1 = on */
u8 device_config;
u8 exposure_modes;
u8 user_effects;
} vp_params;
struct {
u8 pw_control;
u8 wakeup;
u8 vc_control;
u8 vc_mp_direction;
u8 vc_mp_data;
u8 target_kb;
} vc_params;
struct {
u8 power_mode;
u8 system_ctrl;
u8 stream_mode; /* This is the current alternate for usb drivers */
u8 allow_corrupt;
} camera_state;
};
#define NUM_SBUF 2
struct cpia2_sbuf {
char *data;
struct urb *urb;
};
struct framebuf {
struct timeval timestamp;
unsigned long seq;
int num;
int length;
int max_length;
volatile enum frame_status status;
u8 *data;
struct framebuf *next;
};
struct cpia2_fh {
enum v4l2_priority prio;
u8 mmapped;
};
struct camera_data {
/* locks */
struct semaphore busy_lock; /* guard against SMP multithreading */
struct v4l2_prio_state prio;
/* camera status */
volatile int present; /* Is the camera still present? */
int open_count; /* # of process that have camera open */
int first_image_seen;
u8 mains_freq; /* for flicker control */
enum sensors sensor_type;
u8 flush;
u8 mmapped;
int streaming; /* 0 = no, 1 = yes */
int xfer_mode; /* XFER_BULK or XFER_ISOC */
struct camera_params params; /* camera settings */
/* v4l */
int video_size; /* VIDEO_SIZE_ */
struct video_device *vdev; /* v4l videodev */
struct video_picture vp; /* v4l camera settings */
struct video_window vw; /* v4l capture area */
__u32 pixelformat; /* Format fourcc */
/* USB */
struct usb_device *dev;
unsigned char iface;
unsigned int cur_alt;
unsigned int old_alt;
struct cpia2_sbuf sbuf[NUM_SBUF]; /* Double buffering */
wait_queue_head_t wq_stream;
/* Buffering */
u32 frame_size;
int num_frames;
unsigned long frame_count;
u8 *frame_buffer; /* frame buffer data */
struct framebuf *buffers;
struct framebuf * volatile curbuff;
struct framebuf *workbuff;
/* MJPEG Extension */
int APPn; /* Number of APP segment to be written, must be 0..15 */
int APP_len; /* Length of data in JPEG APPn segment */
char APP_data[60]; /* Data in the JPEG APPn segment. */
int COM_len; /* Length of data in JPEG COM segment */
char COM_data[60]; /* Data in JPEG COM segment */
};
/* v4l */
int cpia2_register_camera(struct camera_data *cam);
void cpia2_unregister_camera(struct camera_data *cam);
/* core */
int cpia2_reset_camera(struct camera_data *cam);
int cpia2_set_low_power(struct camera_data *cam);
void cpia2_dbg_dump_registers(struct camera_data *cam);
int cpia2_match_video_size(int width, int height);
void cpia2_set_camera_state(struct camera_data *cam);
void cpia2_save_camera_state(struct camera_data *cam);
void cpia2_set_color_params(struct camera_data *cam);
void cpia2_set_brightness(struct camera_data *cam, unsigned char value);
void cpia2_set_contrast(struct camera_data *cam, unsigned char value);
void cpia2_set_saturation(struct camera_data *cam, unsigned char value);
int cpia2_set_flicker_mode(struct camera_data *cam, int mode);
void cpia2_set_format(struct camera_data *cam);
int cpia2_send_command(struct camera_data *cam, struct cpia2_command *cmd);
int cpia2_do_command(struct camera_data *cam,
unsigned int command,
unsigned char direction, unsigned char param);
struct camera_data *cpia2_init_camera_struct(void);
int cpia2_init_camera(struct camera_data *cam);
int cpia2_allocate_buffers(struct camera_data *cam);
void cpia2_free_buffers(struct camera_data *cam);
long cpia2_read(struct camera_data *cam,
char *buf, unsigned long count, int noblock);
unsigned int cpia2_poll(struct camera_data *cam,
struct file *filp, poll_table *wait);
int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma);
void cpia2_set_property_flip(struct camera_data *cam, int prop_val);
void cpia2_set_property_mirror(struct camera_data *cam, int prop_val);
int cpia2_set_target_kb(struct camera_data *cam, unsigned char value);
int cpia2_set_gpio(struct camera_data *cam, unsigned char setting);
int cpia2_set_fps(struct camera_data *cam, int framerate);
/* usb */
int cpia2_usb_init(void);
void cpia2_usb_cleanup(void);
int cpia2_usb_transfer_cmd(struct camera_data *cam, void *registers,
u8 request, u8 start, u8 count, u8 direction);
int cpia2_usb_stream_start(struct camera_data *cam, unsigned int alternate);
int cpia2_usb_stream_stop(struct camera_data *cam);
int cpia2_usb_stream_pause(struct camera_data *cam);
int cpia2_usb_stream_resume(struct camera_data *cam);
int cpia2_usb_change_streaming_alternate(struct camera_data *cam,
unsigned int alt);
/* ----------------------- debug functions ---------------------- */
#ifdef _CPIA2_DEBUG_
#define ALOG(lev, fmt, args...) printk(lev "%s:%d %s(): " fmt, __FILE__, __LINE__, __func__, ## args)
#define LOG(fmt, args...) ALOG(KERN_INFO, fmt, ## args)
#define ERR(fmt, args...) ALOG(KERN_ERR, fmt, ## args)
#define DBG(fmt, args...) ALOG(KERN_DEBUG, fmt, ## args)
#else
#define ALOG(fmt,args...) printk(fmt,##args)
#define LOG(fmt,args...) ALOG(KERN_INFO "cpia2: "fmt,##args)
#define ERR(fmt,args...) ALOG(KERN_ERR "cpia2: "fmt,##args)
#define DBG(fmn,args...) do {} while(0)
#endif
/* No function or lineno, for shorter lines */
#define KINFO(fmt, args...) printk(KERN_INFO fmt,##args)
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,476 @@
/****************************************************************************
*
* Filename: cpia2registers.h
*
* Copyright 2001, STMicrolectronics, Inc.
*
* Description:
* Definitions for the CPia2 register set
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
****************************************************************************/
#ifndef CPIA2_REGISTER_HEADER
#define CPIA2_REGISTER_HEADER
/***
* System register set (Bank 0)
***/
#define CPIA2_SYSTEM_DEVICE_HI 0x00
#define CPIA2_SYSTEM_DEVICE_LO 0x01
#define CPIA2_SYSTEM_SYSTEM_CONTROL 0x02
#define CPIA2_SYSTEM_CONTROL_LOW_POWER 0x00
#define CPIA2_SYSTEM_CONTROL_HIGH_POWER 0x01
#define CPIA2_SYSTEM_CONTROL_SUSPEND 0x02
#define CPIA2_SYSTEM_CONTROL_V2W_ERR 0x10
#define CPIA2_SYSTEM_CONTROL_RB_ERR 0x10
#define CPIA2_SYSTEM_CONTROL_CLEAR_ERR 0x80
#define CPIA2_SYSTEM_INT_PACKET_CTRL 0x04
#define CPIA2_SYSTEM_INT_PACKET_CTRL_ENABLE_SW_XX 0x01
#define CPIA2_SYSTEM_INT_PACKET_CTRL_ENABLE_EOF 0x02
#define CPIA2_SYSTEM_INT_PACKET_CTRL_ENABLE_INT1 0x04
#define CPIA2_SYSTEM_CACHE_CTRL 0x05
#define CPIA2_SYSTEM_CACHE_CTRL_CACHE_RESET 0x01
#define CPIA2_SYSTEM_CACHE_CTRL_CACHE_FLUSH 0x02
#define CPIA2_SYSTEM_SERIAL_CTRL 0x06
#define CPIA2_SYSTEM_SERIAL_CTRL_NULL_CMD 0x00
#define CPIA2_SYSTEM_SERIAL_CTRL_START_CMD 0x01
#define CPIA2_SYSTEM_SERIAL_CTRL_STOP_CMD 0x02
#define CPIA2_SYSTEM_SERIAL_CTRL_WRITE_CMD 0x03
#define CPIA2_SYSTEM_SERIAL_CTRL_READ_ACK_CMD 0x04
#define CPIA2_SYSTEM_SERIAL_CTRL_READ_NACK_CMD 0x05
#define CPIA2_SYSTEM_SERIAL_DATA 0x07
#define CPIA2_SYSTEM_VP_SERIAL_ADDR 0x08
/***
* I2C addresses for various devices in CPiA2
***/
#define CPIA2_SYSTEM_VP_SERIAL_ADDR_SENSOR 0x20
#define CPIA2_SYSTEM_VP_SERIAL_ADDR_VP 0x88
#define CPIA2_SYSTEM_VP_SERIAL_ADDR_676_VP 0x8A
#define CPIA2_SYSTEM_SPARE_REG1 0x09
#define CPIA2_SYSTEM_SPARE_REG2 0x0A
#define CPIA2_SYSTEM_SPARE_REG3 0x0B
#define CPIA2_SYSTEM_MC_PORT_0 0x0C
#define CPIA2_SYSTEM_MC_PORT_1 0x0D
#define CPIA2_SYSTEM_MC_PORT_2 0x0E
#define CPIA2_SYSTEM_MC_PORT_3 0x0F
#define CPIA2_SYSTEM_STATUS_PKT 0x20
#define CPIA2_SYSTEM_STATUS_PKT_END 0x27
#define CPIA2_SYSTEM_DESCRIP_VID_HI 0x30
#define CPIA2_SYSTEM_DESCRIP_VID_LO 0x31
#define CPIA2_SYSTEM_DESCRIP_PID_HI 0x32
#define CPIA2_SYSTEM_DESCRIP_PID_LO 0x33
#define CPIA2_SYSTEM_FW_VERSION_HI 0x34
#define CPIA2_SYSTEM_FW_VERSION_LO 0x35
#define CPIA2_SYSTEM_CACHE_START_INDEX 0x80
#define CPIA2_SYSTEM_CACHE_MAX_WRITES 0x10
/***
* VC register set (Bank 1)
***/
#define CPIA2_VC_ASIC_ID 0x80
#define CPIA2_VC_ASIC_REV 0x81
#define CPIA2_VC_PW_CTRL 0x82
#define CPIA2_VC_PW_CTRL_COLDSTART 0x01
#define CPIA2_VC_PW_CTRL_CP_CLK_EN 0x02
#define CPIA2_VC_PW_CTRL_VP_RESET_N 0x04
#define CPIA2_VC_PW_CTRL_VC_CLK_EN 0x08
#define CPIA2_VC_PW_CTRL_VC_RESET_N 0x10
#define CPIA2_VC_PW_CTRL_GOTO_SUSPEND 0x20
#define CPIA2_VC_PW_CTRL_UDC_SUSPEND 0x40
#define CPIA2_VC_PW_CTRL_PWR_DOWN 0x80
#define CPIA2_VC_WAKEUP 0x83
#define CPIA2_VC_WAKEUP_SW_ENABLE 0x01
#define CPIA2_VC_WAKEUP_XX_ENABLE 0x02
#define CPIA2_VC_WAKEUP_SW_ATWAKEUP 0x04
#define CPIA2_VC_WAKEUP_XX_ATWAKEUP 0x08
#define CPIA2_VC_CLOCK_CTRL 0x84
#define CPIA2_VC_CLOCK_CTRL_TESTUP72 0x01
#define CPIA2_VC_INT_ENABLE 0x88
#define CPIA2_VC_INT_ENABLE_XX_IE 0x01
#define CPIA2_VC_INT_ENABLE_SW_IE 0x02
#define CPIA2_VC_INT_ENABLE_VC_IE 0x04
#define CPIA2_VC_INT_ENABLE_USBDATA_IE 0x08
#define CPIA2_VC_INT_ENABLE_USBSETUP_IE 0x10
#define CPIA2_VC_INT_ENABLE_USBCFG_IE 0x20
#define CPIA2_VC_INT_FLAG 0x89
#define CPIA2_VC_INT_ENABLE_XX_FLAG 0x01
#define CPIA2_VC_INT_ENABLE_SW_FLAG 0x02
#define CPIA2_VC_INT_ENABLE_VC_FLAG 0x04
#define CPIA2_VC_INT_ENABLE_USBDATA_FLAG 0x08
#define CPIA2_VC_INT_ENABLE_USBSETUP_FLAG 0x10
#define CPIA2_VC_INT_ENABLE_USBCFG_FLAG 0x20
#define CPIA2_VC_INT_ENABLE_SET_RESET_BIT 0x80
#define CPIA2_VC_INT_STATE 0x8A
#define CPIA2_VC_INT_STATE_XX_STATE 0x01
#define CPIA2_VC_INT_STATE_SW_STATE 0x02
#define CPIA2_VC_MP_DIR 0x90
#define CPIA2_VC_MP_DIR_INPUT 0x00
#define CPIA2_VC_MP_DIR_OUTPUT 0x01
#define CPIA2_VC_MP_DATA 0x91
#define CPIA2_VC_DP_CTRL 0x98
#define CPIA2_VC_DP_CTRL_MODE_0 0x00
#define CPIA2_VC_DP_CTRL_MODE_A 0x01
#define CPIA2_VC_DP_CTRL_MODE_B 0x02
#define CPIA2_VC_DP_CTRL_MODE_C 0x03
#define CPIA2_VC_DP_CTRL_FAKE_FST 0x04
#define CPIA2_VC_AD_CTRL 0x99
#define CPIA2_VC_AD_CTRL_SRC_0 0x00
#define CPIA2_VC_AD_CTRL_SRC_DIGI_A 0x01
#define CPIA2_VC_AD_CTRL_SRC_REG 0x02
#define CPIA2_VC_AD_CTRL_DST_USB 0x00
#define CPIA2_VC_AD_CTRL_DST_REG 0x04
#define CPIA2_VC_AD_TEST_IN 0x9B
#define CPIA2_VC_AD_TEST_OUT 0x9C
#define CPIA2_VC_AD_STATUS 0x9D
#define CPIA2_VC_AD_STATUS_EMPTY 0x01
#define CPIA2_VC_AD_STATUS_FULL 0x02
#define CPIA2_VC_DP_DATA 0x9E
#define CPIA2_VC_ST_CTRL 0xA0
#define CPIA2_VC_ST_CTRL_SRC_VC 0x00
#define CPIA2_VC_ST_CTRL_SRC_DP 0x01
#define CPIA2_VC_ST_CTRL_SRC_REG 0x02
#define CPIA2_VC_ST_CTRL_RAW_SELECT 0x04
#define CPIA2_VC_ST_CTRL_DST_USB 0x00
#define CPIA2_VC_ST_CTRL_DST_DP 0x08
#define CPIA2_VC_ST_CTRL_DST_REG 0x10
#define CPIA2_VC_ST_CTRL_FIFO_ENABLE 0x20
#define CPIA2_VC_ST_CTRL_EOF_DETECT 0x40
#define CPIA2_VC_ST_TEST 0xA1
#define CPIA2_VC_ST_TEST_MODE_MANUAL 0x00
#define CPIA2_VC_ST_TEST_MODE_INCREMENT 0x02
#define CPIA2_VC_ST_TEST_AUTO_FILL 0x08
#define CPIA2_VC_ST_TEST_REPEAT_FIFO 0x10
#define CPIA2_VC_ST_TEST_IN 0xA2
#define CPIA2_VC_ST_TEST_OUT 0xA3
#define CPIA2_VC_ST_STATUS 0xA4
#define CPIA2_VC_ST_STATUS_EMPTY 0x01
#define CPIA2_VC_ST_STATUS_FULL 0x02
#define CPIA2_VC_ST_FRAME_DETECT_1 0xA5
#define CPIA2_VC_ST_FRAME_DETECT_2 0xA6
#define CPIA2_VC_USB_CTRL 0xA8
#define CPIA2_VC_USB_CTRL_CMD_STALLED 0x01
#define CPIA2_VC_USB_CTRL_CMD_READY 0x02
#define CPIA2_VC_USB_CTRL_CMD_STATUS 0x04
#define CPIA2_VC_USB_CTRL_CMD_STATUS_DIR 0x08
#define CPIA2_VC_USB_CTRL_CMD_NO_CLASH 0x10
#define CPIA2_VC_USB_CTRL_CMD_MICRO_ACCESS 0x80
#define CPIA2_VC_USB_STRM 0xA9
#define CPIA2_VC_USB_STRM_ISO_ENABLE 0x01
#define CPIA2_VC_USB_STRM_BLK_ENABLE 0x02
#define CPIA2_VC_USB_STRM_INT_ENABLE 0x04
#define CPIA2_VC_USB_STRM_AUD_ENABLE 0x08
#define CPIA2_VC_USB_STATUS 0xAA
#define CPIA2_VC_USB_STATUS_CMD_IN_PROGRESS 0x01
#define CPIA2_VC_USB_STATUS_CMD_STATUS_STALL 0x02
#define CPIA2_VC_USB_STATUS_CMD_HANDSHAKE 0x04
#define CPIA2_VC_USB_STATUS_CMD_OVERRIDE 0x08
#define CPIA2_VC_USB_STATUS_CMD_FIFO_BUSY 0x10
#define CPIA2_VC_USB_STATUS_BULK_REPEAT_TXN 0x20
#define CPIA2_VC_USB_STATUS_CONFIG_DONE 0x40
#define CPIA2_VC_USB_STATUS_USB_SUSPEND 0x80
#define CPIA2_VC_USB_CMDW 0xAB
#define CPIA2_VC_USB_DATARW 0xAC
#define CPIA2_VC_USB_INFO 0xAD
#define CPIA2_VC_USB_CONFIG 0xAE
#define CPIA2_VC_USB_SETTINGS 0xAF
#define CPIA2_VC_USB_SETTINGS_CONFIG_MASK 0x03
#define CPIA2_VC_USB_SETTINGS_INTERFACE_MASK 0x0C
#define CPIA2_VC_USB_SETTINGS_ALTERNATE_MASK 0x70
#define CPIA2_VC_USB_ISOLIM 0xB0
#define CPIA2_VC_USB_ISOFAILS 0xB1
#define CPIA2_VC_USB_ISOMAXPKTHI 0xB2
#define CPIA2_VC_USB_ISOMAXPKTLO 0xB3
#define CPIA2_VC_V2W_CTRL 0xB8
#define CPIA2_VC_V2W_SELECT 0x01
#define CPIA2_VC_V2W_SCL 0xB9
#define CPIA2_VC_V2W_SDA 0xBA
#define CPIA2_VC_VC_CTRL 0xC0
#define CPIA2_VC_VC_CTRL_RUN 0x01
#define CPIA2_VC_VC_CTRL_SINGLESHOT 0x02
#define CPIA2_VC_VC_CTRL_IDLING 0x04
#define CPIA2_VC_VC_CTRL_INHIBIT_H_TABLES 0x10
#define CPIA2_VC_VC_CTRL_INHIBIT_Q_TABLES 0x20
#define CPIA2_VC_VC_CTRL_INHIBIT_PRIVATE 0x40
#define CPIA2_VC_VC_RESTART_IVAL_HI 0xC1
#define CPIA2_VC_VC_RESTART_IVAL_LO 0xC2
#define CPIA2_VC_VC_FORMAT 0xC3
#define CPIA2_VC_VC_FORMAT_UFIRST 0x01
#define CPIA2_VC_VC_FORMAT_MONO 0x02
#define CPIA2_VC_VC_FORMAT_DECIMATING 0x04
#define CPIA2_VC_VC_FORMAT_SHORTLINE 0x08
#define CPIA2_VC_VC_FORMAT_SELFTEST 0x10
#define CPIA2_VC_VC_CLOCKS 0xC4
#define CPIA2_VC_VC_CLOCKS_CLKDIV_MASK 0x03
#define CPIA2_VC_VC_672_CLOCKS_CIF_DIV_BY_3 0x04
#define CPIA2_VC_VC_672_CLOCKS_SCALING 0x08
#define CPIA2_VC_VC_CLOCKS_LOGDIV0 0x00
#define CPIA2_VC_VC_CLOCKS_LOGDIV1 0x01
#define CPIA2_VC_VC_CLOCKS_LOGDIV2 0x02
#define CPIA2_VC_VC_CLOCKS_LOGDIV3 0x03
#define CPIA2_VC_VC_676_CLOCKS_CIF_DIV_BY_3 0x08
#define CPIA2_VC_VC_676_CLOCKS_SCALING 0x10
#define CPIA2_VC_VC_IHSIZE_LO 0xC5
#define CPIA2_VC_VC_XLIM_HI 0xC6
#define CPIA2_VC_VC_XLIM_LO 0xC7
#define CPIA2_VC_VC_YLIM_HI 0xC8
#define CPIA2_VC_VC_YLIM_LO 0xC9
#define CPIA2_VC_VC_OHSIZE 0xCA
#define CPIA2_VC_VC_OVSIZE 0xCB
#define CPIA2_VC_VC_HCROP 0xCC
#define CPIA2_VC_VC_VCROP 0xCD
#define CPIA2_VC_VC_HPHASE 0xCE
#define CPIA2_VC_VC_VPHASE 0xCF
#define CPIA2_VC_VC_HISPAN 0xD0
#define CPIA2_VC_VC_VISPAN 0xD1
#define CPIA2_VC_VC_HICROP 0xD2
#define CPIA2_VC_VC_VICROP 0xD3
#define CPIA2_VC_VC_HFRACT 0xD4
#define CPIA2_VC_VC_HFRACT_DEN_MASK 0x0F
#define CPIA2_VC_VC_HFRACT_NUM_MASK 0xF0
#define CPIA2_VC_VC_VFRACT 0xD5
#define CPIA2_VC_VC_VFRACT_DEN_MASK 0x0F
#define CPIA2_VC_VC_VFRACT_NUM_MASK 0xF0
#define CPIA2_VC_VC_JPEG_OPT 0xD6
#define CPIA2_VC_VC_JPEG_OPT_DOUBLE_SQUEEZE 0x01
#define CPIA2_VC_VC_JPEG_OPT_NO_DC_AUTO_SQUEEZE 0x02
#define CPIA2_VC_VC_JPEG_OPT_AUTO_SQUEEZE 0x04
#define CPIA2_VC_VC_JPEG_OPT_DEFAULT (CPIA2_VC_VC_JPEG_OPT_DOUBLE_SQUEEZE|\
CPIA2_VC_VC_JPEG_OPT_AUTO_SQUEEZE)
#define CPIA2_VC_VC_CREEP_PERIOD 0xD7
#define CPIA2_VC_VC_USER_SQUEEZE 0xD8
#define CPIA2_VC_VC_TARGET_KB 0xD9
#define CPIA2_VC_VC_AUTO_SQUEEZE 0xE6
/***
* VP register set (Bank 2)
***/
#define CPIA2_VP_DEVICEH 0
#define CPIA2_VP_DEVICEL 1
#define CPIA2_VP_SYSTEMSTATE 0x02
#define CPIA2_VP_SYSTEMSTATE_HK_ALIVE 0x01
#define CPIA2_VP_SYSTEMCTRL 0x03
#define CPIA2_VP_SYSTEMCTRL_REQ_CLEAR_ERROR 0x80
#define CPIA2_VP_SYSTEMCTRL_POWER_DOWN_PLL 0x20
#define CPIA2_VP_SYSTEMCTRL_REQ_SUSPEND_STATE 0x10
#define CPIA2_VP_SYSTEMCTRL_REQ_SERIAL_WAKEUP 0x08
#define CPIA2_VP_SYSTEMCTRL_REQ_AUTOLOAD 0x04
#define CPIA2_VP_SYSTEMCTRL_HK_CONTROL 0x02
#define CPIA2_VP_SYSTEMCTRL_POWER_CONTROL 0x01
#define CPIA2_VP_SENSOR_FLAGS 0x05
#define CPIA2_VP_SENSOR_FLAGS_404 0x01
#define CPIA2_VP_SENSOR_FLAGS_407 0x02
#define CPIA2_VP_SENSOR_FLAGS_409 0x04
#define CPIA2_VP_SENSOR_FLAGS_410 0x08
#define CPIA2_VP_SENSOR_FLAGS_500 0x10
#define CPIA2_VP_SENSOR_REV 0x06
#define CPIA2_VP_DEVICE_CONFIG 0x07
#define CPIA2_VP_DEVICE_CONFIG_SERIAL_BRIDGE 0x01
#define CPIA2_VP_GPIO_DIRECTION 0x08
#define CPIA2_VP_GPIO_READ 0xFF
#define CPIA2_VP_GPIO_WRITE 0x00
#define CPIA2_VP_GPIO_DATA 0x09
#define CPIA2_VP_RAM_ADDR_H 0x0A
#define CPIA2_VP_RAM_ADDR_L 0x0B
#define CPIA2_VP_RAM_DATA 0x0C
#define CPIA2_VP_PATCH_REV 0x0F
#define CPIA2_VP4_USER_MODE 0x10
#define CPIA2_VP5_USER_MODE 0x13
#define CPIA2_VP_USER_MODE_CIF 0x01
#define CPIA2_VP_USER_MODE_QCIFDS 0x02
#define CPIA2_VP_USER_MODE_QCIFPTC 0x04
#define CPIA2_VP_USER_MODE_QVGADS 0x08
#define CPIA2_VP_USER_MODE_QVGAPTC 0x10
#define CPIA2_VP_USER_MODE_VGA 0x20
#define CPIA2_VP4_FRAMERATE_REQUEST 0x11
#define CPIA2_VP5_FRAMERATE_REQUEST 0x14
#define CPIA2_VP_FRAMERATE_60 0x80
#define CPIA2_VP_FRAMERATE_50 0x40
#define CPIA2_VP_FRAMERATE_30 0x20
#define CPIA2_VP_FRAMERATE_25 0x10
#define CPIA2_VP_FRAMERATE_15 0x08
#define CPIA2_VP_FRAMERATE_12_5 0x04
#define CPIA2_VP_FRAMERATE_7_5 0x02
#define CPIA2_VP_FRAMERATE_6_25 0x01
#define CPIA2_VP4_USER_EFFECTS 0x12
#define CPIA2_VP5_USER_EFFECTS 0x15
#define CPIA2_VP_USER_EFFECTS_COLBARS 0x01
#define CPIA2_VP_USER_EFFECTS_COLBARS_GRAD 0x02
#define CPIA2_VP_USER_EFFECTS_MIRROR 0x04
#define CPIA2_VP_USER_EFFECTS_FLIP 0x40 // VP5 only
/* NOTE: CPIA2_VP_EXPOSURE_MODES shares the same register as VP5 User
* Effects */
#define CPIA2_VP_EXPOSURE_MODES 0x15
#define CPIA2_VP_EXPOSURE_MODES_INHIBIT_FLICKER 0x20
#define CPIA2_VP_EXPOSURE_MODES_COMPILE_EXP 0x10
#define CPIA2_VP4_EXPOSURE_TARGET 0x16 // VP4
#define CPIA2_VP5_EXPOSURE_TARGET 0x20 // VP5
#define CPIA2_VP_FLICKER_MODES 0x1B
#define CPIA2_VP_FLICKER_MODES_50HZ 0x80
#define CPIA2_VP_FLICKER_MODES_CUSTOM_FLT_FFREQ 0x40
#define CPIA2_VP_FLICKER_MODES_NEVER_FLICKER 0x20
#define CPIA2_VP_FLICKER_MODES_INHIBIT_RUB 0x10
#define CPIA2_VP_FLICKER_MODES_ADJUST_LINE_FREQ 0x08
#define CPIA2_VP_FLICKER_MODES_CUSTOM_INT_FFREQ 0x04
#define CPIA2_VP_UMISC 0x1D
#define CPIA2_VP_UMISC_FORCE_MONO 0x80
#define CPIA2_VP_UMISC_FORCE_ID_MASK 0x40
#define CPIA2_VP_UMISC_INHIBIT_AUTO_FGS 0x20
#define CPIA2_VP_UMISC_INHIBIT_AUTO_DIMS 0x08
#define CPIA2_VP_UMISC_OPT_FOR_SENSOR_DS 0x04
#define CPIA2_VP_UMISC_INHIBIT_AUTO_MODE_INT 0x02
#define CPIA2_VP5_ANTIFLKRSETUP 0x22 //34
#define CPIA2_VP_INTERPOLATION 0x24
#define CPIA2_VP_INTERPOLATION_EVEN_FIRST 0x40
#define CPIA2_VP_INTERPOLATION_HJOG 0x20
#define CPIA2_VP_INTERPOLATION_VJOG 0x10
#define CPIA2_VP_GAMMA 0x25
#define CPIA2_VP_DEFAULT_GAMMA 0x10
#define CPIA2_VP_YRANGE 0x26
#define CPIA2_VP_SATURATION 0x27
#define CPIA2_VP5_MYBLACK_LEVEL 0x3A //58
#define CPIA2_VP5_MCYRANGE 0x3B //59
#define CPIA2_VP5_MYCEILING 0x3C //60
#define CPIA2_VP5_MCUVSATURATION 0x3D //61
#define CPIA2_VP_REHASH_VALUES 0x60
/***
* Common sensor registers
***/
#define CPIA2_SENSOR_DEVICE_H 0x00
#define CPIA2_SENSOR_DEVICE_L 0x01
#define CPIA2_SENSOR_DATA_FORMAT 0x16
#define CPIA2_SENSOR_DATA_FORMAT_HMIRROR 0x08
#define CPIA2_SENSOR_DATA_FORMAT_VMIRROR 0x10
#define CPIA2_SENSOR_CR1 0x76
#define CPIA2_SENSOR_CR1_STAND_BY 0x01
#define CPIA2_SENSOR_CR1_DOWN_RAMP_GEN 0x02
#define CPIA2_SENSOR_CR1_DOWN_COLUMN_ADC 0x04
#define CPIA2_SENSOR_CR1_DOWN_CAB_REGULATOR 0x08
#define CPIA2_SENSOR_CR1_DOWN_AUDIO_REGULATOR 0x10
#define CPIA2_SENSOR_CR1_DOWN_VRT_AMP 0x20
#define CPIA2_SENSOR_CR1_DOWN_BAND_GAP 0x40
#endif

View file

@ -0,0 +1,907 @@
/****************************************************************************
*
* Filename: cpia2_usb.c
*
* Copyright 2001, STMicrolectronics, Inc.
* Contact: steve.miller@st.com
*
* Description:
* This is a USB driver for CPia2 based video cameras.
* The infrastructure of this driver is based on the cpia usb driver by
* Jochen Scharrlach and Johannes Erdfeldt.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Stripped of 2.4 stuff ready for main kernel submit by
* Alan Cox <alan@redhat.com>
****************************************************************************/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include "cpia2.h"
static int frame_sizes[] = {
0, // USBIF_CMDONLY
0, // USBIF_BULK
128, // USBIF_ISO_1
384, // USBIF_ISO_2
640, // USBIF_ISO_3
768, // USBIF_ISO_4
896, // USBIF_ISO_5
1023, // USBIF_ISO_6
};
#define FRAMES_PER_DESC 10
#define FRAME_SIZE_PER_DESC frame_sizes[cam->cur_alt]
static void process_frame(struct camera_data *cam);
static void cpia2_usb_complete(struct urb *urb, struct pt_regs *);
static int cpia2_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id);
static void cpia2_usb_disconnect(struct usb_interface *intf);
static void free_sbufs(struct camera_data *cam);
static void add_APPn(struct camera_data *cam);
static void add_COM(struct camera_data *cam);
static int submit_urbs(struct camera_data *cam);
static int set_alternate(struct camera_data *cam, unsigned int alt);
static int configure_transfer_mode(struct camera_data *cam, unsigned int alt);
static struct usb_device_id cpia2_id_table[] = {
{USB_DEVICE(0x0553, 0x0100)},
{USB_DEVICE(0x0553, 0x0140)},
{USB_DEVICE(0x0553, 0x0151)}, /* STV0676 */
{} /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, cpia2_id_table);
static struct usb_driver cpia2_driver = {
.name = "cpia2",
.probe = cpia2_usb_probe,
.disconnect = cpia2_usb_disconnect,
.id_table = cpia2_id_table
};
/******************************************************************************
*
* process_frame
*
*****************************************************************************/
static void process_frame(struct camera_data *cam)
{
static int frame_count = 0;
unsigned char *inbuff = cam->workbuff->data;
DBG("Processing frame #%d, current:%d\n",
cam->workbuff->num, cam->curbuff->num);
if(cam->workbuff->length > cam->workbuff->max_length)
cam->workbuff->max_length = cam->workbuff->length;
if ((inbuff[0] == 0xFF) && (inbuff[1] == 0xD8)) {
frame_count++;
} else {
cam->workbuff->status = FRAME_ERROR;
DBG("Start of frame not found\n");
return;
}
/***
* Now the output buffer should have a JPEG image in it.
***/
if(!cam->first_image_seen) {
/* Always skip the first image after streaming
* starts. It is almost certainly corrupt. */
cam->first_image_seen = 1;
cam->workbuff->status = FRAME_EMPTY;
return;
}
if (cam->workbuff->length > 3) {
if(cam->mmapped &&
cam->workbuff->length < cam->workbuff->max_length) {
/* No junk in the buffers */
memset(cam->workbuff->data+cam->workbuff->length,
0, cam->workbuff->max_length-
cam->workbuff->length);
}
cam->workbuff->max_length = cam->workbuff->length;
cam->workbuff->status = FRAME_READY;
if(!cam->mmapped && cam->num_frames > 2) {
/* During normal reading, the most recent
* frame will be read. If the current frame
* hasn't started reading yet, it will never
* be read, so mark it empty. If the buffer is
* mmapped, or we have few buffers, we need to
* wait for the user to free the buffer.
*
* NOTE: This is not entirely foolproof with 3
* buffers, but it would take an EXTREMELY
* overloaded system to cause problems (possible
* image data corruption). Basically, it would
* need to take more time to execute cpia2_read
* than it would for the camera to send
* cam->num_frames-2 frames before problems
* could occur.
*/
cam->curbuff->status = FRAME_EMPTY;
}
cam->curbuff = cam->workbuff;
cam->workbuff = cam->workbuff->next;
DBG("Changed buffers, work:%d, current:%d\n",
cam->workbuff->num, cam->curbuff->num);
return;
} else {
DBG("Not enough data for an image.\n");
}
cam->workbuff->status = FRAME_ERROR;
return;
}
/******************************************************************************
*
* add_APPn
*
* Adds a user specified APPn record
*****************************************************************************/
static void add_APPn(struct camera_data *cam)
{
if(cam->APP_len > 0) {
cam->workbuff->data[cam->workbuff->length++] = 0xFF;
cam->workbuff->data[cam->workbuff->length++] = 0xE0+cam->APPn;
cam->workbuff->data[cam->workbuff->length++] = 0;
cam->workbuff->data[cam->workbuff->length++] = cam->APP_len+2;
memcpy(cam->workbuff->data+cam->workbuff->length,
cam->APP_data, cam->APP_len);
cam->workbuff->length += cam->APP_len;
}
}
/******************************************************************************
*
* add_COM
*
* Adds a user specified COM record
*****************************************************************************/
static void add_COM(struct camera_data *cam)
{
if(cam->COM_len > 0) {
cam->workbuff->data[cam->workbuff->length++] = 0xFF;
cam->workbuff->data[cam->workbuff->length++] = 0xFE;
cam->workbuff->data[cam->workbuff->length++] = 0;
cam->workbuff->data[cam->workbuff->length++] = cam->COM_len+2;
memcpy(cam->workbuff->data+cam->workbuff->length,
cam->COM_data, cam->COM_len);
cam->workbuff->length += cam->COM_len;
}
}
/******************************************************************************
*
* cpia2_usb_complete
*
* callback when incoming packet is received
*****************************************************************************/
static void cpia2_usb_complete(struct urb *urb, struct pt_regs *regs)
{
int i;
unsigned char *cdata;
static int frame_ready = false;
struct camera_data *cam = (struct camera_data *) urb->context;
if (urb->status!=0) {
if (!(urb->status == -ENOENT ||
urb->status == -ECONNRESET ||
urb->status == -ESHUTDOWN))
{
DBG("urb->status = %d!\n", urb->status);
}
DBG("Stopping streaming\n");
return;
}
if (!cam->streaming || !cam->present || cam->open_count == 0) {
LOG("Will now stop the streaming: streaming = %d, "
"present=%d, open_count=%d\n",
cam->streaming, cam->present, cam->open_count);
return;
}
/***
* Packet collater
***/
//DBG("Collating %d packets\n", urb->number_of_packets);
for (i = 0; i < urb->number_of_packets; i++) {
u16 checksum, iso_checksum;
int j;
int n = urb->iso_frame_desc[i].actual_length;
int st = urb->iso_frame_desc[i].status;
if(cam->workbuff->status == FRAME_READY) {
struct framebuf *ptr;
/* Try to find an available buffer */
DBG("workbuff full, searching\n");
for (ptr = cam->workbuff->next;
ptr != cam->workbuff;
ptr = ptr->next)
{
if (ptr->status == FRAME_EMPTY) {
ptr->status = FRAME_READING;
ptr->length = 0;
break;
}
}
if (ptr == cam->workbuff)
break; /* No READING or EMPTY buffers left */
cam->workbuff = ptr;
}
if (cam->workbuff->status == FRAME_EMPTY ||
cam->workbuff->status == FRAME_ERROR) {
cam->workbuff->status = FRAME_READING;
cam->workbuff->length = 0;
}
//DBG(" Packet %d length = %d, status = %d\n", i, n, st);
cdata = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
if (st) {
LOG("cpia2 data error: [%d] len=%d, status = %d\n",
i, n, st);
if(!ALLOW_CORRUPT)
cam->workbuff->status = FRAME_ERROR;
continue;
}
if(n<=2)
continue;
checksum = 0;
for(j=0; j<n-2; ++j)
checksum += cdata[j];
iso_checksum = cdata[j] + cdata[j+1]*256;
if(checksum != iso_checksum) {
LOG("checksum mismatch: [%d] len=%d, calculated = %x, checksum = %x\n",
i, n, (int)checksum, (int)iso_checksum);
if(!ALLOW_CORRUPT) {
cam->workbuff->status = FRAME_ERROR;
continue;
}
}
n -= 2;
if(cam->workbuff->status != FRAME_READING) {
if((0xFF == cdata[0] && 0xD8 == cdata[1]) ||
(0xD8 == cdata[0] && 0xFF == cdata[1] &&
0 != cdata[2])) {
/* frame is skipped, but increment total
* frame count anyway */
cam->frame_count++;
}
DBG("workbuff not reading, status=%d\n",
cam->workbuff->status);
continue;
}
if (cam->frame_size < cam->workbuff->length + n) {
ERR("buffer overflow! length: %d, n: %d\n",
cam->workbuff->length, n);
cam->workbuff->status = FRAME_ERROR;
if(cam->workbuff->length > cam->workbuff->max_length)
cam->workbuff->max_length =
cam->workbuff->length;
continue;
}
if (cam->workbuff->length == 0) {
int data_offset;
if ((0xD8 == cdata[0]) && (0xFF == cdata[1])) {
data_offset = 1;
} else if((0xFF == cdata[0]) && (0xD8 == cdata[1])
&& (0xFF == cdata[2])) {
data_offset = 2;
} else {
DBG("Ignoring packet, not beginning!\n");
continue;
}
DBG("Start of frame pattern found\n");
do_gettimeofday(&cam->workbuff->timestamp);
cam->workbuff->seq = cam->frame_count++;
cam->workbuff->data[0] = 0xFF;
cam->workbuff->data[1] = 0xD8;
cam->workbuff->length = 2;
add_APPn(cam);
add_COM(cam);
memcpy(cam->workbuff->data+cam->workbuff->length,
cdata+data_offset, n-data_offset);
cam->workbuff->length += n-data_offset;
} else if (cam->workbuff->length > 0) {
memcpy(cam->workbuff->data + cam->workbuff->length,
cdata, n);
cam->workbuff->length += n;
}
if ((cam->workbuff->length >= 3) &&
(cam->workbuff->data[cam->workbuff->length - 3] == 0xFF) &&
(cam->workbuff->data[cam->workbuff->length - 2] == 0xD9) &&
(cam->workbuff->data[cam->workbuff->length - 1] == 0xFF)) {
frame_ready = true;
cam->workbuff->data[cam->workbuff->length - 1] = 0;
cam->workbuff->length -= 1;
} else if ((cam->workbuff->length >= 2) &&
(cam->workbuff->data[cam->workbuff->length - 2] == 0xFF) &&
(cam->workbuff->data[cam->workbuff->length - 1] == 0xD9)) {
frame_ready = true;
}
if (frame_ready) {
DBG("Workbuff image size = %d\n",cam->workbuff->length);
process_frame(cam);
frame_ready = false;
if (waitqueue_active(&cam->wq_stream))
wake_up_interruptible(&cam->wq_stream);
}
}
if(cam->streaming) {
/* resubmit */
urb->dev = cam->dev;
if ((i = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
ERR("%s: usb_submit_urb ret %d!\n", __func__, i);
}
}
/******************************************************************************
*
* configure_transfer_mode
*
*****************************************************************************/
static int configure_transfer_mode(struct camera_data *cam, unsigned int alt)
{
static unsigned char iso_regs[8][4] = {
{0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00},
{0xB9, 0x00, 0x00, 0x7E},
{0xB9, 0x00, 0x01, 0x7E},
{0xB9, 0x00, 0x02, 0x7E},
{0xB9, 0x00, 0x02, 0xFE},
{0xB9, 0x00, 0x03, 0x7E},
{0xB9, 0x00, 0x03, 0xFD}
};
struct cpia2_command cmd;
unsigned char reg;
if(!cam->present)
return -ENODEV;
/***
* Write the isoc registers according to the alternate selected
***/
cmd.direction = TRANSFER_WRITE;
cmd.buffer.block_data[0] = iso_regs[alt][0];
cmd.buffer.block_data[1] = iso_regs[alt][1];
cmd.buffer.block_data[2] = iso_regs[alt][2];
cmd.buffer.block_data[3] = iso_regs[alt][3];
cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
cmd.start = CPIA2_VC_USB_ISOLIM;
cmd.reg_count = 4;
cpia2_send_command(cam, &cmd);
/***
* Enable relevant streams before starting polling.
* First read USB Stream Config Register.
***/
cmd.direction = TRANSFER_READ;
cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
cmd.start = CPIA2_VC_USB_STRM;
cmd.reg_count = 1;
cpia2_send_command(cam, &cmd);
reg = cmd.buffer.block_data[0];
/* Clear iso, bulk, and int */
reg &= ~(CPIA2_VC_USB_STRM_BLK_ENABLE |
CPIA2_VC_USB_STRM_ISO_ENABLE |
CPIA2_VC_USB_STRM_INT_ENABLE);
if (alt == USBIF_BULK) {
DBG("Enabling bulk xfer\n");
reg |= CPIA2_VC_USB_STRM_BLK_ENABLE; /* Enable Bulk */
cam->xfer_mode = XFER_BULK;
} else if (alt >= USBIF_ISO_1) {
DBG("Enabling ISOC xfer\n");
reg |= CPIA2_VC_USB_STRM_ISO_ENABLE;
cam->xfer_mode = XFER_ISOC;
}
cmd.buffer.block_data[0] = reg;
cmd.direction = TRANSFER_WRITE;
cmd.start = CPIA2_VC_USB_STRM;
cmd.reg_count = 1;
cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
cpia2_send_command(cam, &cmd);
return 0;
}
/******************************************************************************
*
* cpia2_usb_change_streaming_alternate
*
*****************************************************************************/
int cpia2_usb_change_streaming_alternate(struct camera_data *cam,
unsigned int alt)
{
int ret = 0;
if(alt < USBIF_ISO_1 || alt > USBIF_ISO_6)
return -EINVAL;
if(alt == cam->params.camera_state.stream_mode)
return 0;
cpia2_usb_stream_pause(cam);
configure_transfer_mode(cam, alt);
cam->params.camera_state.stream_mode = alt;
/* Reset the camera to prevent image quality degradation */
cpia2_reset_camera(cam);
cpia2_usb_stream_resume(cam);
return ret;
}
/******************************************************************************
*
* set_alternate
*
*****************************************************************************/
int set_alternate(struct camera_data *cam, unsigned int alt)
{
int ret = 0;
if(alt == cam->cur_alt)
return 0;
if (cam->cur_alt != USBIF_CMDONLY) {
DBG("Changing from alt %d to %d\n", cam->cur_alt, USBIF_CMDONLY);
ret = usb_set_interface(cam->dev, cam->iface, USBIF_CMDONLY);
if (ret != 0)
return ret;
}
if (alt != USBIF_CMDONLY) {
DBG("Changing from alt %d to %d\n", USBIF_CMDONLY, alt);
ret = usb_set_interface(cam->dev, cam->iface, alt);
if (ret != 0)
return ret;
}
cam->old_alt = cam->cur_alt;
cam->cur_alt = alt;
return ret;
}
/******************************************************************************
*
* free_sbufs
*
* Free all cam->sbuf[]. All non-NULL .data and .urb members that are non-NULL
* are assumed to be allocated. Non-NULL .urb members are also assumed to be
* submitted (and must therefore be killed before they are freed).
*****************************************************************************/
static void free_sbufs(struct camera_data *cam)
{
int i;
for (i = 0; i < NUM_SBUF; i++) {
if(cam->sbuf[i].urb) {
usb_kill_urb(cam->sbuf[i].urb);
usb_free_urb(cam->sbuf[i].urb);
cam->sbuf[i].urb = NULL;
}
if(cam->sbuf[i].data) {
kfree(cam->sbuf[i].data);
cam->sbuf[i].data = NULL;
}
}
}
/*******
* Convenience functions
*******/
/****************************************************************************
*
* write_packet
*
***************************************************************************/
static int write_packet(struct usb_device *udev,
u8 request, u8 * registers, u16 start, size_t size)
{
if (!registers || size <= 0)
return -EINVAL;
return usb_control_msg(udev,
usb_sndctrlpipe(udev, 0),
request,
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
start, /* value */
0, /* index */
registers, /* buffer */
size,
HZ);
}
/****************************************************************************
*
* read_packet
*
***************************************************************************/
static int read_packet(struct usb_device *udev,
u8 request, u8 * registers, u16 start, size_t size)
{
if (!registers || size <= 0)
return -EINVAL;
return usb_control_msg(udev,
usb_rcvctrlpipe(udev, 0),
request,
USB_DIR_IN|USB_TYPE_VENDOR|USB_RECIP_DEVICE,
start, /* value */
0, /* index */
registers, /* buffer */
size,
HZ);
}
/******************************************************************************
*
* cpia2_usb_transfer_cmd
*
*****************************************************************************/
int cpia2_usb_transfer_cmd(struct camera_data *cam,
void *registers,
u8 request, u8 start, u8 count, u8 direction)
{
int err = 0;
struct usb_device *udev = cam->dev;
if (!udev) {
ERR("%s: Internal driver error: udev is NULL\n", __func__);
return -EINVAL;
}
if (!registers) {
ERR("%s: Internal driver error: register array is NULL\n", __func__);
return -EINVAL;
}
if (direction == TRANSFER_READ) {
err = read_packet(udev, request, (u8 *)registers, start, count);
if (err > 0)
err = 0;
} else if (direction == TRANSFER_WRITE) {
err =write_packet(udev, request, (u8 *)registers, start, count);
if (err < 0) {
LOG("Control message failed, err val = %d\n", err);
LOG("Message: request = 0x%0X, start = 0x%0X\n",
request, start);
LOG("Message: count = %d, register[0] = 0x%0X\n",
count, ((unsigned char *) registers)[0]);
} else
err=0;
} else {
LOG("Unexpected first byte of direction: %d\n",
direction);
return -EINVAL;
}
if(err != 0)
LOG("Unexpected error: %d\n", err);
return err;
}
/******************************************************************************
*
* submit_urbs
*
*****************************************************************************/
static int submit_urbs(struct camera_data *cam)
{
struct urb *urb;
int fx, err, i;
for(i=0; i<NUM_SBUF; ++i) {
if (cam->sbuf[i].data)
continue;
cam->sbuf[i].data =
kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL);
if (!cam->sbuf[i].data) {
return -ENOMEM;
}
}
/* We double buffer the Isoc lists, and also know the polling
* interval is every frame (1 == (1 << (bInterval -1))).
*/
for(i=0; i<NUM_SBUF; ++i) {
if(cam->sbuf[i].urb) {
continue;
}
urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
if (!urb) {
return -ENOMEM;
}
cam->sbuf[i].urb = urb;
urb->dev = cam->dev;
urb->context = cam;
urb->pipe = usb_rcvisocpipe(cam->dev, 1 /*ISOC endpoint*/);
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = cam->sbuf[i].data;
urb->complete = cpia2_usb_complete;
urb->number_of_packets = FRAMES_PER_DESC;
urb->interval = 1;
urb->transfer_buffer_length =
FRAME_SIZE_PER_DESC * FRAMES_PER_DESC;
for (fx = 0; fx < FRAMES_PER_DESC; fx++) {
urb->iso_frame_desc[fx].offset =
FRAME_SIZE_PER_DESC * fx;
urb->iso_frame_desc[fx].length = FRAME_SIZE_PER_DESC;
}
}
/* Queue the ISO urbs, and resubmit in the completion handler */
for(i=0; i<NUM_SBUF; ++i) {
err = usb_submit_urb(cam->sbuf[i].urb, GFP_KERNEL);
if (err) {
ERR("usb_submit_urb[%d]() = %d\n", i, err);
return err;
}
}
return 0;
}
/******************************************************************************
*
* cpia2_usb_stream_start
*
*****************************************************************************/
int cpia2_usb_stream_start(struct camera_data *cam, unsigned int alternate)
{
int ret;
int old_alt;
if(cam->streaming)
return 0;
if (cam->flush) {
int i;
DBG("Flushing buffers\n");
for(i=0; i<cam->num_frames; ++i) {
cam->buffers[i].status = FRAME_EMPTY;
cam->buffers[i].length = 0;
}
cam->curbuff = &cam->buffers[0];
cam->workbuff = cam->curbuff->next;
cam->flush = false;
}
old_alt = cam->params.camera_state.stream_mode;
cam->params.camera_state.stream_mode = 0;
ret = cpia2_usb_change_streaming_alternate(cam, alternate);
if (ret < 0) {
int ret2;
ERR("cpia2_usb_change_streaming_alternate() = %d!\n", ret);
cam->params.camera_state.stream_mode = old_alt;
ret2 = set_alternate(cam, USBIF_CMDONLY);
if (ret2 < 0) {
ERR("cpia2_usb_change_streaming_alternate(%d) =%d has already "
"failed. Then tried to call "
"set_alternate(USBIF_CMDONLY) = %d.\n",
alternate, ret, ret2);
}
} else {
cam->frame_count = 0;
cam->streaming = 1;
ret = cpia2_usb_stream_resume(cam);
}
return ret;
}
/******************************************************************************
*
* cpia2_usb_stream_pause
*
*****************************************************************************/
int cpia2_usb_stream_pause(struct camera_data *cam)
{
int ret = 0;
if(cam->streaming) {
ret = set_alternate(cam, USBIF_CMDONLY);
free_sbufs(cam);
}
return ret;
}
/******************************************************************************
*
* cpia2_usb_stream_resume
*
*****************************************************************************/
int cpia2_usb_stream_resume(struct camera_data *cam)
{
int ret = 0;
if(cam->streaming) {
cam->first_image_seen = 0;
ret = set_alternate(cam, cam->params.camera_state.stream_mode);
if(ret == 0) {
ret = submit_urbs(cam);
}
}
return ret;
}
/******************************************************************************
*
* cpia2_usb_stream_stop
*
*****************************************************************************/
int cpia2_usb_stream_stop(struct camera_data *cam)
{
int ret;
ret = cpia2_usb_stream_pause(cam);
cam->streaming = 0;
configure_transfer_mode(cam, 0);
return ret;
}
/******************************************************************************
*
* cpia2_usb_probe
*
* Probe and initialize.
*****************************************************************************/
static int cpia2_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_interface_descriptor *interface;
struct camera_data *cam;
int ret;
/* A multi-config CPiA2 camera? */
if (udev->descriptor.bNumConfigurations != 1)
return -ENODEV;
interface = &intf->cur_altsetting->desc;
/* If we get to this point, we found a CPiA2 camera */
LOG("CPiA2 USB camera found\n");
if((cam = cpia2_init_camera_struct()) == NULL)
return -ENOMEM;
cam->dev = udev;
cam->iface = interface->bInterfaceNumber;
ret = set_alternate(cam, USBIF_CMDONLY);
if (ret < 0) {
ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
kfree(cam);
return ret;
}
if ((ret = cpia2_register_camera(cam)) < 0) {
ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
kfree(cam);
return ret;
}
if((ret = cpia2_init_camera(cam)) < 0) {
ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
cpia2_unregister_camera(cam);
kfree(cam);
return ret;
}
LOG(" CPiA Version: %d.%02d (%d.%d)\n",
cam->params.version.firmware_revision_hi,
cam->params.version.firmware_revision_lo,
cam->params.version.asic_id,
cam->params.version.asic_rev);
LOG(" CPiA PnP-ID: %04x:%04x:%04x\n",
cam->params.pnp_id.vendor,
cam->params.pnp_id.product,
cam->params.pnp_id.device_revision);
LOG(" SensorID: %d.(version %d)\n",
cam->params.version.sensor_flags,
cam->params.version.sensor_rev);
usb_set_intfdata(intf, cam);
return 0;
}
/******************************************************************************
*
* cpia2_disconnect
*
*****************************************************************************/
static void cpia2_usb_disconnect(struct usb_interface *intf)
{
struct camera_data *cam = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
cam->present = 0;
DBG("Stopping stream\n");
cpia2_usb_stream_stop(cam);
DBG("Unregistering camera\n");
cpia2_unregister_camera(cam);
if(cam->buffers) {
DBG("Wakeup waiting processes\n");
cam->curbuff->status = FRAME_READY;
cam->curbuff->length = 0;
if (waitqueue_active(&cam->wq_stream))
wake_up_interruptible(&cam->wq_stream);
}
DBG("Releasing interface\n");
usb_driver_release_interface(&cpia2_driver, intf);
if (cam->open_count == 0) {
DBG("Freeing camera structure\n");
kfree(cam);
}
LOG("CPiA2 camera disconnected.\n");
}
/******************************************************************************
*
* usb_cpia2_init
*
*****************************************************************************/
int cpia2_usb_init(void)
{
return usb_register(&cpia2_driver);
}
/******************************************************************************
*
* usb_cpia_cleanup
*
*****************************************************************************/
void cpia2_usb_cleanup(void)
{
schedule_timeout(2 * HZ);
usb_deregister(&cpia2_driver);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
/****************************************************************************
*
* Filename: cpia2dev.h
*
* Copyright 2001, STMicrolectronics, Inc.
*
* Contact: steve.miller@st.com
*
* Description:
* This file provides definitions for applications wanting to use the
* cpia2 driver beyond the generic v4l capabilities.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
****************************************************************************/
#ifndef CPIA2_DEV_HEADER
#define CPIA2_DEV_HEADER
#include <linux/videodev.h>
/***
* The following defines are ioctl numbers based on video4linux private ioctls,
* which can range from 192 (BASE_VIDIOCPRIVATE) to 255. All of these take int
* args
*/
#define CPIA2_IOC_SET_GPIO _IOW('v', BASE_VIDIOCPRIVATE + 17, __u32)
/* V4L2 driver specific controls */
#define CPIA2_CID_TARGET_KB (V4L2_CID_PRIVATE_BASE+0)
#define CPIA2_CID_GPIO (V4L2_CID_PRIVATE_BASE+1)
#define CPIA2_CID_FLICKER_MODE (V4L2_CID_PRIVATE_BASE+2)
#define CPIA2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE+3)
#define CPIA2_CID_USB_ALT (V4L2_CID_PRIVATE_BASE+4)
#define CPIA2_CID_LIGHTS (V4L2_CID_PRIVATE_BASE+5)
#define CPIA2_CID_RESET_CAMERA (V4L2_CID_PRIVATE_BASE+6)
#endif

View file

@ -0,0 +1,233 @@
/****************************************************************************
*
* Filename: cpia2patch.h
*
* Copyright 2001, STMicrolectronics, Inc.
*
* Contact: steve.miller@st.com
*
* Description:
* This file contains patch data for the CPiA2 (stv0672) VP4.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
****************************************************************************/
#ifndef CPIA2_PATCH_HEADER
#define CPIA2_PATCH_HEADER
typedef struct {
unsigned char reg;
unsigned char count;
const unsigned char *data;
} cpia2_patch;
static const unsigned char start_address_hi[1] = {
0x01
};
static const unsigned char start_address_lo[1] = {
0xBC
};
static const unsigned char patch_block0[64] = {
0xE3, 0x02, 0xE3, 0x03, 0xE3, 0x04, 0xE3, 0x05,
0xE3, 0x06, 0xE3, 0x07, 0x93, 0x44, 0x56, 0xD4,
0x93, 0x4E, 0x56, 0x51, 0x93, 0x4E, 0x51, 0xD6,
0x93, 0x4E, 0x4F, 0x54, 0x93, 0x4E, 0x92, 0x4F,
0x92, 0xA4, 0x93, 0x05, 0x92, 0xF4, 0x93, 0x1B,
0x92, 0x92, 0x91, 0xE6, 0x92, 0x36, 0x92, 0x74,
0x92, 0x4A, 0x92, 0x8C, 0x92, 0x8E, 0xC8, 0xD0,
0x0B, 0x42, 0x02, 0xA0, 0xCA, 0x92, 0x09, 0x02
};
static const unsigned char patch_block1[64] = {
0xC9, 0x10, 0x0A, 0x0A, 0x0A, 0x81, 0xE3, 0xB8,
0xE3, 0xB0, 0xE3, 0xA8, 0xE3, 0xA0, 0xE3, 0x98,
0xE3, 0x90, 0xE1, 0x00, 0xCF, 0xD7, 0x0A, 0x12,
0xCC, 0x95, 0x08, 0xB2, 0x0A, 0x18, 0xE1, 0x00,
0x01, 0xEE, 0x0C, 0x08, 0x4A, 0x12, 0xC8, 0x18,
0xF0, 0x9A, 0xC0, 0x22, 0xF3, 0x1C, 0x4A, 0x13,
0xF3, 0x14, 0xC8, 0xA0, 0xF2, 0x14, 0xF2, 0x1C,
0xEB, 0x13, 0xD3, 0xA2, 0x63, 0x16, 0x48, 0x9E
};
static const unsigned char patch_block2[64] = {
0xF0, 0x18, 0xA4, 0x03, 0xF3, 0x93, 0xC0, 0x58,
0xF7, 0x13, 0x51, 0x9C, 0xE9, 0x20, 0xCF, 0xEF,
0x63, 0xF9, 0x92, 0x2E, 0xD3, 0x5F, 0x63, 0xFA,
0x92, 0x2E, 0xD3, 0x67, 0x63, 0xFB, 0x92, 0x2E,
0xD3, 0x6F, 0xE9, 0x1A, 0x63, 0x16, 0x48, 0xA7,
0xF0, 0x20, 0xA4, 0x06, 0xF3, 0x94, 0xC0, 0x27,
0xF7, 0x14, 0xF5, 0x13, 0x51, 0x9D, 0xF6, 0x13,
0x63, 0x18, 0xC4, 0x20, 0xCB, 0xEF, 0x63, 0xFC
};
static const unsigned char patch_block3[64] = {
0x92, 0x2E, 0xD3, 0x77, 0x63, 0xFD, 0x92, 0x2E,
0xD3, 0x7F, 0x63, 0xFE, 0x92, 0x2E, 0xD3, 0x87,
0x63, 0xFF, 0x92, 0x2E, 0xD3, 0x8F, 0x64, 0x38,
0x92, 0x2E, 0xD3, 0x97, 0x64, 0x39, 0x92, 0x2E,
0xD3, 0x9F, 0xE1, 0x00, 0xF5, 0x3A, 0xF4, 0x3B,
0xF7, 0xBF, 0xF2, 0xBC, 0xF2, 0x3D, 0xE1, 0x00,
0x80, 0x87, 0x90, 0x80, 0x51, 0xD5, 0x02, 0x22,
0x02, 0x32, 0x4B, 0xD3, 0xF7, 0x11, 0x0B, 0xDA
};
static const unsigned char patch_block4[64] = {
0xE1, 0x00, 0x0E, 0x02, 0x02, 0x40, 0x0D, 0xB5,
0xE3, 0x02, 0x48, 0x55, 0xE5, 0x12, 0xA4, 0x01,
0xE8, 0x1B, 0xE3, 0x90, 0xF0, 0x18, 0xA4, 0x01,
0xE8, 0xBF, 0x8D, 0xB8, 0x4B, 0xD1, 0x4B, 0xD8,
0x0B, 0xCB, 0x0B, 0xC2, 0xE1, 0x00, 0xE3, 0x02,
0xE3, 0x03, 0x52, 0xD3, 0x60, 0x59, 0xE6, 0x93,
0x0D, 0x22, 0x52, 0xD4, 0xE6, 0x93, 0x0D, 0x2A,
0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00, 0x02, 0x5D
};
static const unsigned char patch_block5[64] = {
0x02, 0x63, 0xE3, 0x02, 0xC8, 0x12, 0x02, 0xCA,
0xC8, 0x52, 0x02, 0xC2, 0x82, 0x68, 0xE3, 0x02,
0xC8, 0x14, 0x02, 0xCA, 0xC8, 0x90, 0x02, 0xC2,
0x0A, 0xD0, 0xC9, 0x93, 0x0A, 0xDA, 0xCC, 0xD2,
0x0A, 0xE2, 0x63, 0x12, 0x02, 0xDA, 0x0A, 0x98,
0x0A, 0xA0, 0x0A, 0xA8, 0xE3, 0x90, 0xE1, 0x00,
0xE3, 0x02, 0x0A, 0xD0, 0xC9, 0x93, 0x0A, 0xDA,
0xCC, 0xD2, 0x0A, 0xE2, 0x63, 0x12, 0x02, 0xDA
};
static const unsigned char patch_block6[64] = {
0x0A, 0x98, 0x0A, 0xA0, 0x0A, 0xA8, 0x49, 0x91,
0xE5, 0x6A, 0xA4, 0x04, 0xC8, 0x12, 0x02, 0xCA,
0xC8, 0x52, 0x82, 0x89, 0xC8, 0x14, 0x02, 0xCA,
0xC8, 0x90, 0x02, 0xC2, 0xE3, 0x90, 0xE1, 0x00,
0x08, 0x60, 0xE1, 0x00, 0x48, 0x53, 0xE8, 0x97,
0x08, 0x5A, 0xE1, 0x00, 0xE3, 0x02, 0xE3, 0x03,
0x54, 0xD3, 0x60, 0x59, 0xE6, 0x93, 0x0D, 0x52,
0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00, 0x02, 0x9C
};
static const unsigned char patch_block7[64] = {
0xE3, 0x02, 0x55, 0x13, 0x93, 0x17, 0x55, 0x13,
0x93, 0x17, 0xE3, 0x90, 0xE1, 0x00, 0x75, 0x30,
0xE3, 0x02, 0xE3, 0x03, 0x55, 0x55, 0x60, 0x59,
0xE6, 0x93, 0x0D, 0xB2, 0xE3, 0x98, 0xE3, 0x90,
0xE1, 0x00, 0x02, 0xAE, 0xE7, 0x92, 0xE9, 0x18,
0xEA, 0x9A, 0xE8, 0x98, 0xE8, 0x10, 0xE8, 0x11,
0xE8, 0x51, 0xD2, 0xDA, 0xD2, 0xF3, 0xE8, 0x13,
0xD2, 0xFA, 0xE8, 0x50, 0xD2, 0xEA, 0xE8, 0xD0
};
static const unsigned char patch_block8[64] = {
0xE8, 0xD1, 0xD3, 0x0A, 0x03, 0x09, 0x48, 0x23,
0xE5, 0x2C, 0xA0, 0x03, 0x48, 0x24, 0xEA, 0x1C,
0x03, 0x08, 0xD2, 0xE3, 0xD3, 0x03, 0xD3, 0x13,
0xE1, 0x00, 0x02, 0xCB, 0x05, 0x93, 0x57, 0x93,
0xF0, 0x9A, 0xAC, 0x0B, 0xE3, 0x07, 0x92, 0xEA,
0xE2, 0x9F, 0xE5, 0x06, 0xE3, 0xB0, 0xA0, 0x02,
0xEB, 0x1E, 0x82, 0xD7, 0xEA, 0x1E, 0xE2, 0x3B,
0x85, 0x9B, 0xE9, 0x1E, 0xC8, 0x90, 0x85, 0x94
};
static const unsigned char patch_block9[64] = {
0x02, 0xDE, 0x05, 0x80, 0x57, 0x93, 0xF0, 0xBA,
0xAC, 0x06, 0x92, 0xEA, 0xE2, 0xBF, 0xE5, 0x06,
0xA0, 0x01, 0xEB, 0xBF, 0x85, 0x88, 0xE9, 0x3E,
0xC8, 0x90, 0x85, 0x81, 0xE9, 0x3E, 0xF0, 0xBA,
0xF3, 0x39, 0xF0, 0x3A, 0x60, 0x17, 0xF0, 0x3A,
0xC0, 0x90, 0xF0, 0xBA, 0xE1, 0x00, 0x00, 0x3F,
0xE3, 0x02, 0xE3, 0x03, 0x58, 0x10, 0x60, 0x59,
0xE6, 0x93, 0x0D, 0xA2, 0x58, 0x12, 0xE6, 0x93
};
static const unsigned char patch_block10[64] = {
0x0D, 0xAA, 0xE3, 0x98, 0xE3, 0x90, 0xE1, 0x00,
0x03, 0x01, 0xE1, 0x00, 0x03, 0x03, 0x9B, 0x7D,
0x8B, 0x8B, 0xE3, 0x02, 0xE3, 0x03, 0x58, 0x56,
0x60, 0x59, 0xE6, 0x93, 0x0D, 0xBA, 0xE3, 0x98,
0xE3, 0x90, 0xE1, 0x00, 0x03, 0x0F, 0x93, 0x11,
0xE1, 0x00, 0xE3, 0x02, 0x4A, 0x11, 0x0B, 0x42,
0x91, 0xAF, 0xE3, 0x90, 0xE1, 0x00, 0xF2, 0x91,
0xF0, 0x91, 0xA3, 0xFE, 0xE1, 0x00, 0x60, 0x92
};
static const unsigned char patch_block11[64] = {
0xC0, 0x5F, 0xF0, 0x13, 0xF0, 0x13, 0x59, 0x5B,
0xE2, 0x13, 0xF0, 0x11, 0x5A, 0x19, 0xE2, 0x13,
0xE1, 0x00, 0x00, 0x00, 0x03, 0x27, 0x68, 0x61,
0x76, 0x61, 0x6E, 0x61, 0x00, 0x06, 0x03, 0x2C,
0xE3, 0x02, 0xE3, 0x03, 0xE9, 0x38, 0x59, 0x15,
0x59, 0x5A, 0xF2, 0x9A, 0xBC, 0x0B, 0xA4, 0x0A,
0x59, 0x1E, 0xF3, 0x11, 0xF0, 0x1A, 0xE2, 0xBB,
0x59, 0x15, 0xF0, 0x11, 0x19, 0x2A, 0xE5, 0x02
};
static const unsigned char patch_block12[54] = {
0xA4, 0x01, 0xEB, 0xBF, 0xE3, 0x98, 0xE3, 0x90,
0xE1, 0x00, 0x03, 0x42, 0x19, 0x28, 0xE1, 0x00,
0xE9, 0x30, 0x60, 0x79, 0xE1, 0x00, 0xE3, 0x03,
0xE3, 0x07, 0x60, 0x79, 0x93, 0x4E, 0xE3, 0xB8,
0xE3, 0x98, 0xE1, 0x00, 0xE9, 0x1A, 0xF0, 0x1F,
0xE2, 0x33, 0xF0, 0x91, 0xE2, 0x92, 0xE0, 0x32,
0xF0, 0x31, 0xE1, 0x00, 0x00, 0x00
};
static const unsigned char do_call[1] = {
0x01
};
#define PATCH_DATA_SIZE 18
static const cpia2_patch patch_data[PATCH_DATA_SIZE] = {
{0x0A, sizeof(start_address_hi), start_address_hi}
, // 0
{0x0B, sizeof(start_address_lo), start_address_lo}
, // 1
{0x0C, sizeof(patch_block0), patch_block0}
, // 2
{0x0C, sizeof(patch_block1), patch_block1}
, // 3
{0x0C, sizeof(patch_block2), patch_block2}
, // 4
{0x0C, sizeof(patch_block3), patch_block3}
, // 5
{0x0C, sizeof(patch_block4), patch_block4}
, // 6
{0x0C, sizeof(patch_block5), patch_block5}
, // 7
{0x0C, sizeof(patch_block6), patch_block6}
, // 8
{0x0C, sizeof(patch_block7), patch_block7}
, // 9
{0x0C, sizeof(patch_block8), patch_block8}
, // 10
{0x0C, sizeof(patch_block9), patch_block9}
, //11
{0x0C, sizeof(patch_block10), patch_block10}
, // 12
{0x0C, sizeof(patch_block11), patch_block11}
, // 13
{0x0C, sizeof(patch_block12), patch_block12}
, // 14
{0x0A, sizeof(start_address_hi), start_address_hi}
, // 15
{0x0B, sizeof(start_address_lo), start_address_lo}
, // 16
{0x0D, sizeof(do_call), do_call} //17
};
#endif

View file

@ -0,0 +1,9 @@
config VIDEO_CX25840
tristate "Conexant CX2584x audio/video decoders"
depends on VIDEO_DEV && I2C && EXPERIMENTAL
select FW_LOADER
---help---
Support for the Conexant CX2584x audio/video decoders.
To compile this driver as a module, choose M here: the
module will be called cx25840

View file

@ -1,6 +1,6 @@
cx25840-objs := cx25840-core.o cx25840-audio.o cx25840-firmware.o \
cx25840-vbi.o
obj-$(CONFIG_VIDEO_DECODER) += cx25840.o
obj-$(CONFIG_VIDEO_CX25840) += cx25840.o
EXTRA_CFLAGS += -I$(src)/..

View file

@ -743,6 +743,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
memset(input, 0, sizeof(*input));
input->index = state->aud_input;
input->capability = V4L2_AUDCAP_STEREO;
break;
}
@ -753,7 +754,6 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
case VIDIOC_G_TUNER:
{
u8 mode = cx25840_read(client, 0x804);
u8 pref = cx25840_read(client, 0x809) & 0xf;
u8 vpres = cx25840_read(client, 0x80a) & 0x10;
int val = 0;
@ -773,44 +773,49 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
val |= V4L2_TUNER_SUB_MONO;
if (mode == 2 || mode == 4)
val |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
val = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
if (mode & 0x10)
val |= V4L2_TUNER_SUB_SAP;
vt->rxsubchans = val;
switch (pref) {
case 0:
vt->audmode = V4L2_TUNER_MODE_MONO;
break;
case 1:
case 2:
vt->audmode = V4L2_TUNER_MODE_LANG2;
break;
case 4:
default:
vt->audmode = V4L2_TUNER_MODE_STEREO;
}
vt->audmode = state->audmode;
break;
}
case VIDIOC_S_TUNER:
if (state->radio)
break;
switch (vt->audmode) {
case V4L2_TUNER_MODE_MONO:
case V4L2_TUNER_MODE_LANG1:
/* Force PREF_MODE to MONO */
/* mono -> mono
stereo -> mono
bilingual -> lang1 */
cx25840_and_or(client, 0x809, ~0xf, 0x00);
break;
case V4L2_TUNER_MODE_STEREO:
/* Force PREF_MODE to STEREO */
case V4L2_TUNER_MODE_LANG1:
/* mono -> mono
stereo -> stereo
bilingual -> lang1 */
cx25840_and_or(client, 0x809, ~0xf, 0x04);
break;
case V4L2_TUNER_MODE_STEREO:
/* mono -> mono
stereo -> stereo
bilingual -> lang1/lang2 */
cx25840_and_or(client, 0x809, ~0xf, 0x07);
break;
case V4L2_TUNER_MODE_LANG2:
/* Force PREF_MODE to LANG2 */
/* mono -> mono
stereo ->stereo
bilingual -> lang2 */
cx25840_and_or(client, 0x809, ~0xf, 0x01);
break;
default:
return -EINVAL;
}
state->audmode = vt->audmode;
break;
case VIDIOC_G_FMT:
@ -891,6 +896,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
state->aud_input = CX25840_AUDIO8;
state->audclk_freq = 48000;
state->pvr150_workaround = 0;
state->audmode = V4L2_TUNER_MODE_LANG1;
cx25840_initialize(client, 1);

View file

@ -151,7 +151,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
case VIDIOC_G_FMT:
{
static u16 lcr2vbi[] = {
0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
0, V4L2_SLICED_TELETEXT_PAL_B, 0, /* 1 */
0, V4L2_SLICED_WSS_625, 0, /* 4 */
V4L2_SLICED_CAPTION_525, /* 6 */
0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
@ -231,7 +231,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
for (i = 7; i <= 23; i++) {
for (x = 0; x <= 1; x++) {
switch (svbi->service_lines[1-x][i]) {
case V4L2_SLICED_TELETEXT_B:
case V4L2_SLICED_TELETEXT_PAL_B:
lcr[i] |= 1 << (4 * x);
break;
case V4L2_SLICED_WSS_625:
@ -282,7 +282,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
switch (id2) {
case 1:
id2 = V4L2_SLICED_TELETEXT_B;
id2 = V4L2_SLICED_TELETEXT_PAL_B;
break;
case 4:
id2 = V4L2_SLICED_WSS_625;

View file

@ -78,6 +78,7 @@ struct cx25840_state {
enum cx25840_video_input vid_input;
enum cx25840_audio_input aud_input;
u32 audclk_freq;
int audmode;
};
/* ----------------------------------------------------------------------- */

View file

@ -50,6 +50,7 @@ config VIDEO_CX88_DVB_ALL_FRONTENDS
depends on VIDEO_CX88_DVB
select DVB_MT352
select VIDEO_CX88_VP3054
select DVB_ZL10353
select DVB_OR51132
select DVB_CX22702
select DVB_LGDT330X
@ -81,6 +82,16 @@ config VIDEO_CX88_VP3054
which also require support for the VP-3054
Secondary I2C bus, such at DNTV Live! DVB-T Pro.
config VIDEO_CX88_DVB_ZL10353
bool "Zarlink ZL10353 DVB-T Support"
default y
depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
select DVB_ZL10353
---help---
This adds DVB-T support for cards based on the
Connexant 2388x chip and the ZL10353 demodulator,
successor to the Zarlink MT352.
config VIDEO_CX88_DVB_OR51132
bool "OR51132 ATSC Support"
default y

View file

@ -17,6 +17,7 @@ extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
extra-cflags-$(CONFIG_DVB_OR51132) += -DHAVE_OR51132=1
extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
extra-cflags-$(CONFIG_DVB_ZL10353) += -DHAVE_ZL10353=1
extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1
extra-cflags-$(CONFIG_VIDEO_CX88_VP3054)+= -DHAVE_VP3054_I2C=1

View file

@ -676,6 +676,11 @@ static int __devinit snd_cx88_create(struct snd_card *card,
chip = (snd_cx88_card_t *) card->private_data;
core = cx88_core_get(pci);
if (NULL == core) {
err = -EINVAL;
kfree (chip);
return err;
}
if (!pci_dma_supported(pci,0xffffffff)) {
dprintk(0, "%s/1: Oops: no 32bit PCI DMA ???\n",core->name);
@ -692,11 +697,6 @@ static int __devinit snd_cx88_create(struct snd_card *card,
spin_lock_init(&chip->reg_lock);
cx88_reset(core);
if (NULL == core) {
err = -EINVAL;
kfree (chip);
return err;
}
chip->core = core;
/* get irq */

Some files were not shown because too many files have changed in this diff Show more