From 541e316aed6f7d6efeb427a88645c2a8f61418d6 Mon Sep 17 00:00:00 2001 From: Stephen Evanchik Date: Mon, 8 Aug 2005 01:26:18 -0500 Subject: Input: psmouse - add support for IBM TrackPoint devices. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/Makefile | 2 +- drivers/input/mouse/psmouse-base.c | 15 +- drivers/input/mouse/psmouse.h | 1 + drivers/input/mouse/trackpoint.c | 297 +++++++++++++++++++++++++++++++++++++ drivers/input/mouse/trackpoint.h | 147 ++++++++++++++++++ 5 files changed, 460 insertions(+), 2 deletions(-) create mode 100644 drivers/input/mouse/trackpoint.c create mode 100644 drivers/input/mouse/trackpoint.h (limited to 'drivers') diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index c4909b49337..82b330bbf06 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o -psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o +psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 2bb2fe78bdc..b3508276785 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -25,6 +25,7 @@ #include "logips2pp.h" #include "alps.h" #include "lifebook.h" +#include "trackpoint.h" #define DRIVER_DESC "PS/2 mouse driver" @@ -519,6 +520,12 @@ static int psmouse_extensions(struct psmouse *psmouse, if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0) return PSMOUSE_IMPS; +/* + * Try to initialize the IBM TrackPoint + */ + if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0) + return PSMOUSE_TRACKPOINT; + /* * Okay, all failed, we have a standard mouse here. The number of the buttons * is still a question, though. We assume 3. @@ -599,6 +606,12 @@ static struct psmouse_protocol psmouse_protocols[] = { .alias = "lifebook", .init = lifebook_init, }, + { + .type = PSMOUSE_TRACKPOINT, + .name = "TPPS/2", + .alias = "trackpoint", + .detect = trackpoint_detect, + }, { .type = PSMOUSE_AUTO, .name = "auto", @@ -1234,7 +1247,7 @@ static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) *((unsigned int *)kp->arg) = proto->type; - return 0; \ + return 0; } static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 86691cf4343..e312a6b4168 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ enum psmouse_type { PSMOUSE_SYNAPTICS, PSMOUSE_ALPS, PSMOUSE_LIFEBOOK, + PSMOUSE_TRACKPOINT, PSMOUSE_AUTO /* This one should always be last */ }; diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c new file mode 100644 index 00000000000..aee3b24a910 --- /dev/null +++ b/drivers/input/mouse/trackpoint.c @@ -0,0 +1,297 @@ +/* + * Stephen Evanchik + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Trademarks are the property of their respective owners. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "psmouse.h" +#include "trackpoint.h" + +PSMOUSE_DEFINE_ATTR(sensitivity); +PSMOUSE_DEFINE_ATTR(speed); +PSMOUSE_DEFINE_ATTR(inertia); +PSMOUSE_DEFINE_ATTR(reach); +PSMOUSE_DEFINE_ATTR(draghys); +PSMOUSE_DEFINE_ATTR(mindrag); +PSMOUSE_DEFINE_ATTR(thresh); +PSMOUSE_DEFINE_ATTR(upthresh); +PSMOUSE_DEFINE_ATTR(ztime); +PSMOUSE_DEFINE_ATTR(jenks); +PSMOUSE_DEFINE_ATTR(press_to_select); +PSMOUSE_DEFINE_ATTR(skipback); +PSMOUSE_DEFINE_ATTR(ext_dev); + +#define MAKE_ATTR_READ(_item) \ + static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \ + { \ + struct trackpoint_data *tp = psmouse->private; \ + return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \ + } + +#define MAKE_ATTR_WRITE(_item, command) \ + static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ + { \ + char *rest; \ + unsigned long value; \ + struct trackpoint_data *tp = psmouse->private; \ + value = simple_strtoul(buf, &rest, 10); \ + if (*rest) \ + return -EINVAL; \ + tp->_item = value; \ + trackpoint_write(&psmouse->ps2dev, command, tp->_item); \ + return count; \ + } + +#define MAKE_ATTR_TOGGLE(_item, command, mask) \ + static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ + { \ + unsigned char toggle; \ + struct trackpoint_data *tp = psmouse->private; \ + toggle = (buf[0] == '1') ? 1 : 0; \ + if (toggle != tp->_item) { \ + tp->_item = toggle; \ + trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \ + } \ + return count; \ + } + +/* + * Device IO: read, write and toggle bit + */ +static int trackpoint_read(struct ps2dev *ps2dev, unsigned char loc, unsigned char *results) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { + return -1; + } + + return 0; +} + +static int trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned char val) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val))) { + return -1; + } + + return 0; +} + +static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsigned char mask) +{ + /* Bad things will happen if the loc param isn't in this range */ + if (loc < 0x20 || loc >= 0x2F) + return -1; + + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_TOGGLE)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, mask))) { + return -1; + } + + return 0; +} + +MAKE_ATTR_WRITE(sensitivity, TP_SENS); +MAKE_ATTR_READ(sensitivity); + +MAKE_ATTR_WRITE(speed, TP_SPEED); +MAKE_ATTR_READ(speed); + +MAKE_ATTR_WRITE(inertia, TP_INERTIA); +MAKE_ATTR_READ(inertia); + +MAKE_ATTR_WRITE(reach, TP_REACH); +MAKE_ATTR_READ(reach); + +MAKE_ATTR_WRITE(draghys, TP_DRAGHYS); +MAKE_ATTR_READ(draghys); + +MAKE_ATTR_WRITE(mindrag, TP_MINDRAG); +MAKE_ATTR_READ(mindrag); + +MAKE_ATTR_WRITE(thresh, TP_THRESH); +MAKE_ATTR_READ(thresh); + +MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH); +MAKE_ATTR_READ(upthresh); + +MAKE_ATTR_WRITE(ztime, TP_Z_TIME); +MAKE_ATTR_READ(ztime); + +MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV); +MAKE_ATTR_READ(jenks); + +MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); +MAKE_ATTR_READ(press_to_select); + +MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +MAKE_ATTR_READ(skipback); + +MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); +MAKE_ATTR_READ(ext_dev); + +static struct attribute *trackpoint_attrs[] = { + &psmouse_attr_sensitivity.attr, + &psmouse_attr_speed.attr, + &psmouse_attr_inertia.attr, + &psmouse_attr_reach.attr, + &psmouse_attr_draghys.attr, + &psmouse_attr_mindrag.attr, + &psmouse_attr_thresh.attr, + &psmouse_attr_upthresh.attr, + &psmouse_attr_ztime.attr, + &psmouse_attr_jenks.attr, + &psmouse_attr_press_to_select.attr, + &psmouse_attr_skipback.attr, + &psmouse_attr_ext_dev.attr, + NULL +}; + +static struct attribute_group trackpoint_attr_group = { + .attrs = trackpoint_attrs, +}; + +static void trackpoint_disconnect(struct psmouse *psmouse) +{ + sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group); + + kfree(psmouse->private); + psmouse->private = NULL; +} + +static int trackpoint_sync(struct psmouse *psmouse) +{ + unsigned char toggle; + struct trackpoint_data *tp = psmouse->private; + + if (!tp) + return -1; + + /* Disable features that may make device unusable with this driver */ + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle); + if (toggle & TP_MASK_TWOHAND) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, TP_MASK_TWOHAND); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, &toggle); + if (toggle & TP_MASK_SOURCE_TAG) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, TP_MASK_SOURCE_TAG); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle); + if (toggle & TP_MASK_MB) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB); + + /* Push the config to the device */ + trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sensitivity); + trackpoint_write(&psmouse->ps2dev, TP_INERTIA, tp->inertia); + trackpoint_write(&psmouse->ps2dev, TP_SPEED, tp->speed); + + trackpoint_write(&psmouse->ps2dev, TP_REACH, tp->reach); + trackpoint_write(&psmouse->ps2dev, TP_DRAGHYS, tp->draghys); + trackpoint_write(&psmouse->ps2dev, TP_MINDRAG, tp->mindrag); + + trackpoint_write(&psmouse->ps2dev, TP_THRESH, tp->thresh); + trackpoint_write(&psmouse->ps2dev, TP_UP_THRESH, tp->upthresh); + + trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->ztime); + trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle); + if (((toggle & TP_MASK_PTSON) == TP_MASK_PTSON) != tp->press_to_select) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_PTSON, TP_MASK_PTSON); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, &toggle); + if (((toggle & TP_MASK_SKIPBACK) == TP_MASK_SKIPBACK) != tp->skipback) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, &toggle); + if (((toggle & TP_MASK_EXT_DEV) == TP_MASK_EXT_DEV) != tp->ext_dev) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); + + return 0; +} + +static void trackpoint_defaults(struct trackpoint_data *tp) +{ + tp->press_to_select = TP_DEF_PTSON; + tp->sensitivity = TP_DEF_SENS; + tp->speed = TP_DEF_SPEED; + tp->reach = TP_DEF_REACH; + + tp->draghys = TP_DEF_DRAGHYS; + tp->mindrag = TP_DEF_MINDRAG; + + tp->thresh = TP_DEF_THRESH; + tp->upthresh = TP_DEF_UP_THRESH; + + tp->ztime = TP_DEF_Z_TIME; + tp->jenks = TP_DEF_JENKS_CURV; + + tp->inertia = TP_DEF_INERTIA; + tp->skipback = TP_DEF_SKIPBACK; + tp->ext_dev = TP_DEF_EXT_DEV; +} + +int trackpoint_detect(struct psmouse *psmouse, int set_properties) +{ + struct trackpoint_data *priv; + struct ps2dev *ps2dev = &psmouse->ps2dev; + unsigned char firmware_id; + unsigned char button_info; + unsigned char param[2]; + + param[0] = param[1] = 0; + + if (ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) + return -1; + + if (param[0] != TP_MAGIC_IDENT) + return -1; + + if (!set_properties) + return 0; + + firmware_id = param[1]; + + if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { + printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); + button_info = 0; + } + + psmouse->private = priv = kcalloc(1, sizeof(struct trackpoint_data), GFP_KERNEL); + if (!priv) + return -1; + + psmouse->vendor = "IBM"; + psmouse->name = "TrackPoint"; + + psmouse->reconnect = trackpoint_sync; + psmouse->disconnect = trackpoint_disconnect; + + trackpoint_defaults(priv); + trackpoint_sync(psmouse); + + sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); + + printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", + firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); + + return 0; +} + diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h new file mode 100644 index 00000000000..9857d8b6ad6 --- /dev/null +++ b/drivers/input/mouse/trackpoint.h @@ -0,0 +1,147 @@ +/* + * IBM TrackPoint PS/2 mouse driver + * + * Stephen Evanchik + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#ifndef _TRACKPOINT_H +#define _TRACKPOINT_H + +/* + * These constants are from the TrackPoint System + * Engineering documentation Version 4 from IBM Watson + * research: + * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html + */ + +#define TP_COMMAND 0xE2 /* Commands start with this */ + +#define TP_READ_ID 0xE1 /* Sent for device identification */ +#define TP_MAGIC_IDENT 0x01 /* Sent after a TP_READ_ID followed */ + /* by the firmware ID */ + + +/* + * Commands + */ +#define TP_RECALIB 0x51 /* Recalibrate */ +#define TP_POWER_DOWN 0x44 /* Can only be undone through HW reset */ +#define TP_EXT_DEV 0x21 /* Determines if external device is connected (RO) */ +#define TP_EXT_BTN 0x4B /* Read extended button status */ +#define TP_POR 0x7F /* Execute Power on Reset */ +#define TP_POR_RESULTS 0x25 /* Read Power on Self test results */ +#define TP_DISABLE_EXT 0x40 /* Disable external pointing device */ +#define TP_ENABLE_EXT 0x41 /* Enable external pointing device */ + +/* + * Mode manipulation + */ +#define TP_SET_SOFT_TRANS 0x4E /* Set mode */ +#define TP_CANCEL_SOFT_TRANS 0xB9 /* Cancel mode */ +#define TP_SET_HARD_TRANS 0x45 /* Mode can only be set */ + + +/* + * Register oriented commands/properties + */ +#define TP_WRITE_MEM 0x81 +#define TP_READ_MEM 0x80 /* Not used in this implementation */ + +/* +* RAM Locations for properties + */ +#define TP_SENS 0x4A /* Sensitivity */ +#define TP_MB 0x4C /* Read Middle Button Status (RO) */ +#define TP_INERTIA 0x4D /* Negative Inertia */ +#define TP_SPEED 0x60 /* Speed of TP Cursor */ +#define TP_REACH 0x57 /* Backup for Z-axis press */ +#define TP_DRAGHYS 0x58 /* Drag Hysteresis */ + /* (how hard it is to drag */ + /* with Z-axis pressed) */ + +#define TP_MINDRAG 0x59 /* Minimum amount of force needed */ + /* to trigger dragging */ + +#define TP_THRESH 0x5C /* Minimum value for a Z-axis press */ +#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ +#define TP_Z_TIME 0x5E /* How sharp of a press */ +#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ + +/* + * Toggling Flag bits + */ +#define TP_TOGGLE 0x47 /* Toggle command */ + +#define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ +#define TP_MASK_MB 0x01 +#define TP_TOGGLE_EXT_DEV 0x23 /* Toggle external device */ +#define TP_MASK_EXT_DEV 0x02 +#define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ +#define TP_MASK_DRIFT 0x80 +#define TP_TOGGLE_BURST 0x28 /* Burst Mode */ +#define TP_MASK_BURST 0x80 +#define TP_TOGGLE_PTSON 0x2C /* Press to Select */ +#define TP_MASK_PTSON 0x01 +#define TP_TOGGLE_HARD_TRANS 0x2C /* Alternate method to set Hard Transparency */ +#define TP_MASK_HARD_TRANS 0x80 +#define TP_TOGGLE_TWOHAND 0x2D /* Two handed */ +#define TP_MASK_TWOHAND 0x01 +#define TP_TOGGLE_STICKY_TWO 0x2D /* Sticky two handed */ +#define TP_MASK_STICKY_TWO 0x04 +#define TP_TOGGLE_SKIPBACK 0x2D /* Suppress movement after drag release */ +#define TP_MASK_SKIPBACK 0x08 +#define TP_TOGGLE_SOURCE_TAG 0x20 /* Bit 3 of the first packet will be set to + to the origin of the packet (external or TP) */ +#define TP_MASK_SOURCE_TAG 0x80 +#define TP_TOGGLE_EXT_TAG 0x22 /* Bit 3 of the first packet coming from the + external device will be forced to 1 */ +#define TP_MASK_EXT_TAG 0x04 + + +/* Power on Self Test Results */ +#define TP_POR_SUCCESS 0x3B + +/* + * Default power on values + */ +#define TP_DEF_SENS 0x80 +#define TP_DEF_INERTIA 0x06 +#define TP_DEF_SPEED 0x61 +#define TP_DEF_REACH 0x0A + +#define TP_DEF_DRAGHYS 0xFF +#define TP_DEF_MINDRAG 0x14 + +#define TP_DEF_THRESH 0x08 +#define TP_DEF_UP_THRESH 0xFF +#define TP_DEF_Z_TIME 0x26 +#define TP_DEF_JENKS_CURV 0x87 + +/* Toggles */ +#define TP_DEF_MB 0x00 +#define TP_DEF_PTSON 0x00 +#define TP_DEF_SKIPBACK 0x00 +#define TP_DEF_EXT_DEV 0x01 + +#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) + +struct trackpoint_data +{ + unsigned char sensitivity, speed, inertia, reach; + unsigned char draghys, mindrag; + unsigned char thresh, upthresh; + unsigned char ztime, jenks; + + unsigned char press_to_select; + unsigned char skipback; + + unsigned char ext_dev; +}; + +extern int trackpoint_detect(struct psmouse *psmouse, int set_properties); + +#endif /* _TRACKPOINT_H */ -- cgit v1.2.3 From cfe9e88866fe892f4f71bf132c64ec8bd5256e5e Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:40:20 -0500 Subject: Input: rework psmouse attributes to reduce module size Rearrange attribute code to use generic show and set handlers instead of replicating them for every attribute; switch to using attribute_group instead of creating all attributes manually. All this saves about 4K. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/logips2pp.c | 12 ++- drivers/input/mouse/psmouse-base.c | 117 +++++++++++++----------- drivers/input/mouse/psmouse.h | 51 +++++++---- drivers/input/mouse/trackpoint.c | 183 +++++++++++++++++++------------------ 4 files changed, 200 insertions(+), 163 deletions(-) (limited to 'drivers') diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 48d2b20d264..e65c2798a49 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -150,12 +150,12 @@ static void ps2pp_set_smartscroll(struct psmouse *psmouse, unsigned int smartscr ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); } -static ssize_t psmouse_attr_show_smartscroll(struct psmouse *psmouse, char *buf) +static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%d\n", psmouse->smartscroll ? 1 : 0); } -static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -169,7 +169,8 @@ static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char return count; } -PSMOUSE_DEFINE_ATTR(smartscroll); +PSMOUSE_DEFINE_ATTR(smartscroll, S_IWUSR | S_IRUGO, NULL, + ps2pp_attr_show_smartscroll, ps2pp_attr_set_smartscroll); /* * Support 800 dpi resolution _only_ if the user wants it (there are good @@ -194,7 +195,7 @@ static void ps2pp_set_resolution(struct psmouse *psmouse, unsigned int resolutio static void ps2pp_disconnect(struct psmouse *psmouse) { - device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll.dattr); } static struct ps2pp_info *get_model_info(unsigned char model) @@ -379,7 +380,8 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties) psmouse->set_resolution = ps2pp_set_resolution; psmouse->disconnect = ps2pp_disconnect; - device_create_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_create_file(&psmouse->ps2dev.serio->dev, + &psmouse_attr_smartscroll.dattr); } } diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index b3508276785..0830c6e13ef 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -58,10 +58,30 @@ static unsigned int psmouse_resetafter; module_param_named(resetafter, psmouse_resetafter, uint, 0644); MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); -PSMOUSE_DEFINE_ATTR(protocol); -PSMOUSE_DEFINE_ATTR(rate); -PSMOUSE_DEFINE_ATTR(resolution); -PSMOUSE_DEFINE_ATTR(resetafter); +PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO, + NULL, + psmouse_attr_show_protocol, psmouse_attr_set_protocol); +PSMOUSE_DEFINE_ATTR(rate, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, rate), + psmouse_show_int_attr, psmouse_attr_set_rate); +PSMOUSE_DEFINE_ATTR(resolution, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resolution), + psmouse_show_int_attr, psmouse_attr_set_resolution); +PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resetafter), + psmouse_show_int_attr, psmouse_set_int_attr); + +static struct attribute *psmouse_attributes[] = { + &psmouse_attr_protocol.dattr.attr, + &psmouse_attr_rate.dattr.attr, + &psmouse_attr_resolution.dattr.attr, + &psmouse_attr_resetafter.dattr.attr, + NULL +}; + +static struct attribute_group psmouse_attribute_group = { + .attrs = psmouse_attributes, +}; __obsolete_setup("psmouse_noext"); __obsolete_setup("psmouse_resolution="); @@ -800,10 +820,7 @@ static void psmouse_disconnect(struct serio *serio) psmouse = serio_get_drvdata(serio); - device_remove_file(&serio->dev, &psmouse_attr_protocol); - device_remove_file(&serio->dev, &psmouse_attr_rate); - device_remove_file(&serio->dev, &psmouse_attr_resolution); - device_remove_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); down(&psmouse_sem); @@ -940,10 +957,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) if (parent && parent->pt_activate) parent->pt_activate(parent); - device_create_file(&serio->dev, &psmouse_attr_protocol); - device_create_file(&serio->dev, &psmouse_attr_rate); - device_create_file(&serio->dev, &psmouse_attr_resolution); - device_create_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); psmouse_activate(psmouse); @@ -1040,10 +1054,12 @@ static struct serio_driver psmouse_drv = { .cleanup = psmouse_cleanup, }; -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)) +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr, + char *buf) { struct serio *serio = to_serio_port(dev); + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse; int retval; retval = serio_pin_driver(serio); @@ -1055,19 +1071,21 @@ ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, goto out; } - retval = handler(serio_get_drvdata(serio), buf); + psmouse = serio_get_drvdata(serio); + + retval = attr->show(psmouse, attr->data, buf); out: serio_unpin_driver(serio); return retval; } -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)) +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct serio *serio = to_serio_port(dev); - struct psmouse *psmouse = serio_get_drvdata(serio); - struct psmouse *parent = NULL; + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse, *parent = NULL; int retval; retval = serio_pin_driver(serio); @@ -1083,6 +1101,8 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun if (retval) goto out_unpin; + psmouse = serio_get_drvdata(serio); + if (psmouse->state == PSMOUSE_IGNORE) { retval = -ENODEV; goto out_up; @@ -1095,7 +1115,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun psmouse_deactivate(psmouse); - retval = handler(psmouse, buf, count); + retval = attr->set(psmouse, attr->data, buf, count); if (retval != -ENODEV) psmouse_activate(psmouse); @@ -1110,12 +1130,34 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun return retval; } -static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) +static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + + return sprintf(buf, "%lu\n", *field); +} + +static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest) + return -EINVAL; + + *field = value; + + return count; +} + +static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); } -static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count) { struct serio *serio = psmouse->ps2dev.serio; struct psmouse *parent = NULL; @@ -1179,12 +1221,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *bu return count; } -static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->rate); -} - -static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1197,12 +1234,7 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, s return count; } -static ssize_t psmouse_attr_show_resolution(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resolution); -} - -static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1215,23 +1247,6 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char * return count; } -static ssize_t psmouse_attr_show_resetafter(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resetafter); -} - -static ssize_t psmouse_attr_set_resetafter(struct psmouse *psmouse, const char *buf, size_t count) -{ - unsigned long value; - char *rest; - - value = simple_strtoul(buf, &rest, 10); - if (*rest) - return -EINVAL; - - psmouse->resetafter = value; - return count; -} static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) { diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index e312a6b4168..45d2bd774f0 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -86,24 +86,37 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); int psmouse_reset(struct psmouse *psmouse); void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)); -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)); - -#define PSMOUSE_DEFINE_ATTR(_name) \ -static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ -static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ -static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ -{ \ - return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ -} \ -static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\ -{ \ - return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ -} \ -static struct device_attribute psmouse_attr_##_name = \ - __ATTR(_name, S_IWUSR | S_IRUGO, \ - psmouse_do_show_##_name, psmouse_do_set_##_name); + +struct psmouse_attribute { + struct device_attribute dattr; + void *data; + ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); + ssize_t (*set)(struct psmouse *psmouse, void *data, + const char *buf, size_t count); +}; +#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) + +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr, + char *buf); +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + +#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ +static ssize_t _show(struct psmouse *, void *data, char *); \ +static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ +static struct psmouse_attribute psmouse_attr_##_name = { \ + .dattr = { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + .owner = THIS_MODULE, \ + }, \ + .show = psmouse_attr_show_helper, \ + .store = psmouse_attr_set_helper, \ + }, \ + .data = _data, \ + .show = _show, \ + .set = _set, \ +} #endif /* _PSMOUSE_H */ diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index aee3b24a910..b4898d8a68e 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c @@ -19,54 +19,6 @@ #include "psmouse.h" #include "trackpoint.h" -PSMOUSE_DEFINE_ATTR(sensitivity); -PSMOUSE_DEFINE_ATTR(speed); -PSMOUSE_DEFINE_ATTR(inertia); -PSMOUSE_DEFINE_ATTR(reach); -PSMOUSE_DEFINE_ATTR(draghys); -PSMOUSE_DEFINE_ATTR(mindrag); -PSMOUSE_DEFINE_ATTR(thresh); -PSMOUSE_DEFINE_ATTR(upthresh); -PSMOUSE_DEFINE_ATTR(ztime); -PSMOUSE_DEFINE_ATTR(jenks); -PSMOUSE_DEFINE_ATTR(press_to_select); -PSMOUSE_DEFINE_ATTR(skipback); -PSMOUSE_DEFINE_ATTR(ext_dev); - -#define MAKE_ATTR_READ(_item) \ - static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \ - { \ - struct trackpoint_data *tp = psmouse->private; \ - return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \ - } - -#define MAKE_ATTR_WRITE(_item, command) \ - static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ - { \ - char *rest; \ - unsigned long value; \ - struct trackpoint_data *tp = psmouse->private; \ - value = simple_strtoul(buf, &rest, 10); \ - if (*rest) \ - return -EINVAL; \ - tp->_item = value; \ - trackpoint_write(&psmouse->ps2dev, command, tp->_item); \ - return count; \ - } - -#define MAKE_ATTR_TOGGLE(_item, command, mask) \ - static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \ - { \ - unsigned char toggle; \ - struct trackpoint_data *tp = psmouse->private; \ - toggle = (buf[0] == '1') ? 1 : 0; \ - if (toggle != tp->_item) { \ - tp->_item = toggle; \ - trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \ - } \ - return count; \ - } - /* * Device IO: read, write and toggle bit */ @@ -108,59 +60,114 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsig return 0; } -MAKE_ATTR_WRITE(sensitivity, TP_SENS); -MAKE_ATTR_READ(sensitivity); - -MAKE_ATTR_WRITE(speed, TP_SPEED); -MAKE_ATTR_READ(speed); -MAKE_ATTR_WRITE(inertia, TP_INERTIA); -MAKE_ATTR_READ(inertia); +/* + * Trackpoint-specific attributes + */ +struct trackpoint_attr_data { + size_t field_offset; + unsigned char command; + unsigned char mask; +}; -MAKE_ATTR_WRITE(reach, TP_REACH); -MAKE_ATTR_READ(reach); +static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); -MAKE_ATTR_WRITE(draghys, TP_DRAGHYS); -MAKE_ATTR_READ(draghys); + return sprintf(buf, "%u\n", *field); +} -MAKE_ATTR_WRITE(mindrag, TP_MINDRAG); -MAKE_ATTR_READ(mindrag); +static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; -MAKE_ATTR_WRITE(thresh, TP_THRESH); -MAKE_ATTR_READ(thresh); + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 255) + return -EINVAL; -MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH); -MAKE_ATTR_READ(upthresh); + *field = value; + trackpoint_write(&psmouse->ps2dev, attr->command, value); -MAKE_ATTR_WRITE(ztime, TP_Z_TIME); -MAKE_ATTR_READ(ztime); + return count; +} -MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV); -MAKE_ATTR_READ(jenks); +#define TRACKPOINT_INT_ATTR(_name, _command) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_int_attr) + +static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 1) + return -EINVAL; + + if (*field != value) { + *field = value; + trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); + } -MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); -MAKE_ATTR_READ(press_to_select); + return count; +} -MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); -MAKE_ATTR_READ(skipback); -MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); -MAKE_ATTR_READ(ext_dev); +#define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + .mask = _mask, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_bit_attr) + +TRACKPOINT_INT_ATTR(sensitivity, TP_SENS); +TRACKPOINT_INT_ATTR(speed, TP_SPEED); +TRACKPOINT_INT_ATTR(inertia, TP_INERTIA); +TRACKPOINT_INT_ATTR(reach, TP_REACH); +TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS); +TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG); +TRACKPOINT_INT_ATTR(thresh, TP_THRESH); +TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); +TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); +TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); + +TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); +TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); static struct attribute *trackpoint_attrs[] = { - &psmouse_attr_sensitivity.attr, - &psmouse_attr_speed.attr, - &psmouse_attr_inertia.attr, - &psmouse_attr_reach.attr, - &psmouse_attr_draghys.attr, - &psmouse_attr_mindrag.attr, - &psmouse_attr_thresh.attr, - &psmouse_attr_upthresh.attr, - &psmouse_attr_ztime.attr, - &psmouse_attr_jenks.attr, - &psmouse_attr_press_to_select.attr, - &psmouse_attr_skipback.attr, - &psmouse_attr_ext_dev.attr, + &psmouse_attr_sensitivity.dattr.attr, + &psmouse_attr_speed.dattr.attr, + &psmouse_attr_inertia.dattr.attr, + &psmouse_attr_reach.dattr.attr, + &psmouse_attr_draghys.dattr.attr, + &psmouse_attr_mindrag.dattr.attr, + &psmouse_attr_thresh.dattr.attr, + &psmouse_attr_upthresh.dattr.attr, + &psmouse_attr_ztime.dattr.attr, + &psmouse_attr_jenks.dattr.attr, + &psmouse_attr_press_to_select.dattr.attr, + &psmouse_attr_skipback.dattr.attr, + &psmouse_attr_ext_dev.dattr.attr, NULL }; -- cgit v1.2.3 From e6c047b98bbd09473c586744c681e877ebf954ff Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Sun, 4 Sep 2005 01:40:43 -0500 Subject: Input: ALPS - fix wheel decoding Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0d68e5e0182..b20783f9748 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -170,7 +170,7 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) input_report_key(dev, BTN_TOOL_FINGER, z > 0); if (priv->i->flags & ALPS_WHEEL) - input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); + input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07)); if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { input_report_key(dev, BTN_FORWARD, forward); -- cgit v1.2.3 From d2b5ffca73594e4046f405e3ef2438ce41f76fb2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Sun, 4 Sep 2005 01:40:55 -0500 Subject: Input: psmouse - add new Logitech wheel mouse model Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/logips2pp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index e65c2798a49..7df96525222 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -223,6 +223,7 @@ static struct ps2pp_info *get_model_info(unsigned char model) { 80, PS2PP_KIND_WHEEL, PS2PP_SIDE_BTN | PS2PP_WHEEL }, { 81, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 83, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, + { 86, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 96, 0, 0 }, { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, -- cgit v1.2.3 From 4cee99564db7f65a6f88e4b752da52768cde3802 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Sun, 4 Sep 2005 01:41:14 -0500 Subject: Input: fix checking whether new keycode fits size-wise When dev->keycodesize == sizeof(int) the old code produces incorrect result. Signed-off-by: Ian Campbell Signed-off-by: Dmitry Torokhov --- drivers/char/keyboard.c | 2 +- drivers/input/evdev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 523fd3c8bba..1ddaabeb8ef 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode) return -EINVAL; if (keycode < 0 || keycode > KEY_MAX) return -EINVAL; - if (keycode >> (dev->keycodesize * 8)) + if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8))) return -EINVAL; oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 20e3a165989..3a8314bb790 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -320,7 +320,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL; if (get_user(v, ip + 1)) return -EFAULT; if (v < 0 || v > KEY_MAX) return -EINVAL; - if (v >> (dev->keycodesize * 8)) return -EINVAL; + if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL; u = SET_INPUT_KEYCODE(dev, t, v); clear_bit(u, dev->keybit); set_bit(v, dev->keybit); -- cgit v1.2.3 From 0854e52d86080c1043bc8988daef2ebda4775f64 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:27 -0500 Subject: Input: i8042 - clean up initialization code; abort if we can't create all ports. Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042.c | 178 +++++++++++++++++++++++++------------------- 1 file changed, 100 insertions(+), 78 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 708a1d3beab..f0d9c5f9cc3 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -338,10 +338,10 @@ static int i8042_open(struct serio *serio) return 0; -activate_fail: + activate_fail: free_irq(port->irq, i8042_request_irq_cookie); -irq_fail: + irq_fail: serio_unregister_port_delayed(serio); return -1; @@ -485,7 +485,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs) serio_interrupt(port->serio, data, dfl, regs); ret = 1; -out: + out: return IRQ_RETVAL(ret); } @@ -552,7 +552,7 @@ static int i8042_enable_mux_ports(void) * Enable all muxed ports. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { i8042_command(¶m, I8042_CMD_MUX_PFX + i); i8042_command(¶m, I8042_CMD_AUX_ENABLE); } @@ -682,7 +682,7 @@ static int __init i8042_port_register(struct i8042_port *port) kfree(port->serio); port->serio = NULL; i8042_ctr |= port->disable; - return -1; + return -EIO; } printk(KERN_INFO "serio: i8042 %s port at %#lx,%#lx irq %d\n", @@ -977,80 +977,83 @@ static struct device_driver i8042_driver = { .shutdown = i8042_shutdown, }; -static void __init i8042_create_kbd_port(void) +static int __init i8042_create_kbd_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; - serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; + serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_aux_port(void) +static int __init i8042_create_aux_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_AUX_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_mux_port(int index) +static int __init i8042_create_mux_port(int index) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_MUX_PORT_NO + index]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); - snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); - - *port = i8042_ports[I8042_AUX_PORT_NO]; - port->exists = 0; - snprintf(port->name, sizeof(port->name), "AUX%d", index); - port->mux = index; - port->serio = serio; - i8042_port_register(port); - } + serio = kcalloc(1, sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); + snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); + + *port = i8042_ports[I8042_AUX_PORT_NO]; + port->exists = 0; + snprintf(port->name, sizeof(port->name), "AUX%d", index); + port->mux = index; + port->serio = serio; + + return i8042_port_register(port); } static int __init i8042_init(void) @@ -1070,36 +1073,55 @@ static int __init i8042_init(void) i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ; if (i8042_controller_init()) { - i8042_platform_exit(); - return -ENODEV; + err = -ENODEV; + goto err_platform_exit; } err = driver_register(&i8042_driver); - if (err) { - i8042_platform_exit(); - return err; - } + if (err) + goto err_controller_cleanup; i8042_platform_device = platform_device_register_simple("i8042", -1, NULL, 0); if (IS_ERR(i8042_platform_device)) { - driver_unregister(&i8042_driver); - i8042_platform_exit(); - return PTR_ERR(i8042_platform_device); + err = PTR_ERR(i8042_platform_device); + goto err_unregister_driver; } if (!i8042_noaux && !i8042_check_aux()) { - if (!i8042_nomux && !i8042_check_mux()) - for (i = 0; i < I8042_NUM_MUX_PORTS; i++) - i8042_create_mux_port(i); - else - i8042_create_aux_port(); + if (!i8042_nomux && !i8042_check_mux()) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { + err = i8042_create_mux_port(i); + if (err) + goto err_unregister_ports; + } + } else { + err = i8042_create_aux_port(); + if (err) + goto err_unregister_ports; + } } - i8042_create_kbd_port(); + err = i8042_create_kbd_port(); + if (err) + goto err_unregister_ports; mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); return 0; + + err_unregister_ports: + for (i = 0; i < I8042_NUM_PORTS; i++) + if (i8042_ports[i].serio) + serio_unregister_port(i8042_ports[i].serio); + platform_device_unregister(i8042_platform_device); + err_unregister_driver: + driver_unregister(&i8042_driver); + err_controller_cleanup: + i8042_controller_cleanup(); + err_platform_exit: + i8042_platform_exit(); + + return err; } static void __exit i8042_exit(void) -- cgit v1.2.3 From 8d5987a6e17fa36776a0c9964db0f24c3d070862 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:38 -0500 Subject: Input: make i8042_platform_init return 'real' error code Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-io.h | 6 +++--- drivers/input/serio/i8042-ip22io.h | 2 +- drivers/input/serio/i8042-jazzio.h | 2 +- drivers/input/serio/i8042-sparcio.h | 12 ++++++------ drivers/input/serio/i8042-x86ia64io.h | 22 ++++++++++++---------- drivers/input/serio/i8042.c | 5 +++-- 6 files changed, 26 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h index c9e633d21d9..9a922164425 100644 --- a/drivers/input/serio/i8042-io.h +++ b/drivers/input/serio/i8042-io.h @@ -69,16 +69,16 @@ static inline int i8042_platform_init(void) */ #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC64) if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif i8042_reset = 1; #if defined(CONFIG_PPC64) if (check_legacy_ioport(I8042_DATA_REG)) - return -1; + return -EBUSY; if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif return 0; } diff --git a/drivers/input/serio/i8042-ip22io.h b/drivers/input/serio/i8042-ip22io.h index 863b9c95fbb..ee1ad27d6ed 100644 --- a/drivers/input/serio/i8042-ip22io.h +++ b/drivers/input/serio/i8042-ip22io.h @@ -58,7 +58,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX sgi_kh is a virtual address */ if (!request_mem_region(sgi_kh, sizeof(struct hpc_keyb), "i8042")) - return 1; + return -EBUSY; #endif i8042_reset = 1; diff --git a/drivers/input/serio/i8042-jazzio.h b/drivers/input/serio/i8042-jazzio.h index 5c20ab13148..13fd7108eb2 100644 --- a/drivers/input/serio/i8042-jazzio.h +++ b/drivers/input/serio/i8042-jazzio.h @@ -53,7 +53,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX JAZZ_KEYBOARD_ADDRESS is a virtual address */ if (!request_mem_region(JAZZ_KEYBOARD_ADDRESS, 2, "i8042")) - return 1; + return -EBUSY; #endif return 0; diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index da2a1981248..ed9446f6d7e 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h @@ -48,10 +48,10 @@ static inline void i8042_write_command(int val) #define OBP_PS2MS_NAME1 "kdmouse" #define OBP_PS2MS_NAME2 "mouse" -static int i8042_platform_init(void) +static int __init i8042_platform_init(void) { #ifndef CONFIG_PCI - return -1; + return -ENODEV; #else char prop[128]; int len; @@ -59,14 +59,14 @@ static int i8042_platform_init(void) len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); if (len < 0) { printk("i8042: Cannot get name property of root OBP node.\n"); - return -1; + return -ENODEV; } if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) { /* Hardcoded values for MrCoffee. */ i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; kbd_iobase = ioremap(0x71300060, 8); if (!kbd_iobase) - return -1; + return -ENODEV; } else { struct linux_ebus *ebus; struct linux_ebus_device *edev; @@ -78,7 +78,7 @@ static int i8042_platform_init(void) goto edev_found; } } - return -1; + return -ENODEV; edev_found: for_each_edevchild(edev, child) { @@ -96,7 +96,7 @@ static int i8042_platform_init(void) i8042_aux_irq == -1) { printk("i8042: Error, 8042 device lacks both kbd and " "mouse nodes.\n"); - return -1; + return -ENODEV; } } diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 03877c84e6f..02bc23142ce 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -256,7 +256,7 @@ static void i8042_pnp_exit(void) } } -static int i8042_pnp_init(void) +static int __init i8042_pnp_init(void) { int result_kbd, result_aux; @@ -322,25 +322,29 @@ static int i8042_pnp_init(void) return 0; } +#else +static inline int i8042_pnp_init(void) { return 0; } +static inline void i8042_pnp_exit(void) { } #endif -static inline int i8042_platform_init(void) +static int __init i8042_platform_init(void) { + int retval; + /* * On ix86 platforms touching the i8042 data register region can do really * bad things. Because of this the region is always reserved on ix86 boxes. * * if (!request_region(I8042_DATA_REG, 16, "i8042")) - * return -1; + * return -EBUSY; */ i8042_kbd_irq = I8042_MAP_IRQ(1); i8042_aux_irq = I8042_MAP_IRQ(12); -#ifdef CONFIG_PNP - if (i8042_pnp_init()) - return -1; -#endif + retval = i8042_pnp_init(); + if (retval) + return retval; #if defined(__ia64__) i8042_reset = 1; @@ -354,14 +358,12 @@ static inline int i8042_platform_init(void) i8042_nomux = 1; #endif - return 0; + return retval; } static inline void i8042_platform_exit(void) { -#ifdef CONFIG_PNP i8042_pnp_exit(); -#endif } #endif /* _I8042_X86IA64IO_H */ diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index f0d9c5f9cc3..2a76d08c4d3 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -1066,8 +1066,9 @@ static int __init i8042_init(void) init_timer(&i8042_timer); i8042_timer.function = i8042_timer_func; - if (i8042_platform_init()) - return -EBUSY; + err = i8042_platform_init(); + if (err) + return err; i8042_ports[I8042_AUX_PORT_NO].irq = I8042_AUX_IRQ; i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ; -- cgit v1.2.3 From c3d31e7f9a94800ba895a081e143e79954f6c62f Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:41:51 -0500 Subject: Input: i8042 - fix IRQ printing when either KBD or AUX port is absent from ACPI/PNP tables. Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-x86ia64io.h | 39 ++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 02bc23142ce..84a73bc6afd 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -258,7 +258,8 @@ static void i8042_pnp_exit(void) static int __init i8042_pnp_init(void) { - int result_kbd, result_aux; + int result_kbd = 0, result_aux = 0; + char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 }; if (i8042_nopnp) { printk(KERN_INFO "i8042: PNP detection disabled\n"); @@ -267,6 +268,7 @@ static int __init i8042_pnp_init(void) if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0) i8042_pnp_kbd_registered = 1; + if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0) i8042_pnp_aux_registered = 1; @@ -280,6 +282,25 @@ static int __init i8042_pnp_init(void) #endif } + if (result_kbd > 0) + snprintf(kbd_irq_str, sizeof(kbd_irq_str), + "%d", i8042_pnp_kbd_irq); + if (result_aux > 0) + snprintf(aux_irq_str, sizeof(aux_irq_str), + "%d", i8042_pnp_aux_irq); + + printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", + i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", + i8042_pnp_aux_name, + i8042_pnp_data_reg, i8042_pnp_command_reg, + kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "", + aux_irq_str); + +#if defined(__ia64__) + if (result_aux <= 0) + i8042_noaux = 1; +#endif + if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) && i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) { printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n", @@ -295,30 +316,20 @@ static int __init i8042_pnp_init(void) } if (!i8042_pnp_kbd_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %#x\n", i8042_kbd_irq); + printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq); i8042_pnp_kbd_irq = i8042_kbd_irq; } - if (!i8042_pnp_aux_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq); + if (!i8042_noaux && !i8042_pnp_aux_irq) { + printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %d\n", i8042_aux_irq); i8042_pnp_aux_irq = i8042_aux_irq; } -#if defined(__ia64__) - if (result_aux <= 0) - i8042_noaux = 1; -#endif - i8042_data_reg = i8042_pnp_data_reg; i8042_command_reg = i8042_pnp_command_reg; i8042_kbd_irq = i8042_pnp_kbd_irq; i8042_aux_irq = i8042_pnp_aux_irq; - printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %d%s%d\n", - i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", i8042_pnp_aux_name, - i8042_data_reg, i8042_command_reg, i8042_kbd_irq, - (result_aux > 0) ? "," : "", i8042_aux_irq); - return 0; } -- cgit v1.2.3 From 945ef0d428bc33c639e49d27fb8cc765adec3fdf Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:42:00 -0500 Subject: Input: i8042 - add i8042.nokbd module option to allow supressing creation of keyboard port. Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-x86ia64io.h | 4 +++- drivers/input/serio/i8042.c | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 84a73bc6afd..d5ea3cf0946 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -297,6 +297,8 @@ static int __init i8042_pnp_init(void) aux_irq_str); #if defined(__ia64__) + if (result_kbd <= 0) + i8042_nokbd = 1; if (result_aux <= 0) i8042_noaux = 1; #endif @@ -315,7 +317,7 @@ static int __init i8042_pnp_init(void) i8042_pnp_command_reg = i8042_command_reg; } - if (!i8042_pnp_kbd_irq) { + if (!i8042_nokbd && !i8042_pnp_kbd_irq) { printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq); i8042_pnp_kbd_irq = i8042_kbd_irq; } diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 2a76d08c4d3..19ef35db342 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -27,6 +27,10 @@ MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); MODULE_LICENSE("GPL"); +static unsigned int i8042_nokbd; +module_param_named(nokbd, i8042_nokbd, bool, 0); +MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); + static unsigned int i8042_noaux; module_param_named(noaux, i8042_noaux, bool, 0); MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); @@ -1058,7 +1062,7 @@ static int __init i8042_create_mux_port(int index) static int __init i8042_init(void) { - int i; + int i, have_ports = 0; int err; dbg_init(); @@ -1100,11 +1104,20 @@ static int __init i8042_init(void) if (err) goto err_unregister_ports; } + have_ports = 1; } - err = i8042_create_kbd_port(); - if (err) - goto err_unregister_ports; + if (!i8042_nokbd) { + err = i8042_create_kbd_port(); + if (err) + goto err_unregister_ports; + have_ports = 1; + } + + if (!have_ports) { + err = -ENODEV; + goto err_unregister_device; + } mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); @@ -1114,6 +1127,7 @@ static int __init i8042_init(void) for (i = 0; i < I8042_NUM_PORTS; i++) if (i8042_ports[i].serio) serio_unregister_port(i8042_ports[i].serio); + err_unregister_device: platform_device_unregister(i8042_platform_device); err_unregister_driver: driver_unregister(&i8042_driver); -- cgit v1.2.3 From 7545c24c6a6ab62922266197a72119212280ea2a Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 4 Sep 2005 01:42:10 -0500 Subject: Input: i8042 - add Lifebook E4010 to MUX blacklist Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index d5ea3cf0946..273bb3b08cf 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -137,6 +137,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"), }, }, + { + .ident = "Fujitsu-Siemens Lifebook E4010", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"), + }, + }, { .ident = "Toshiba P10", .matches = { -- cgit v1.2.3 From b8c9c642db4ab0811cc5bb0d8b90cc7819055c95 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:07:37 -0500 Subject: Inpur: recognize and ignore Logitech vendor usages in HID These get in our way with MX mice. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-input.c | 1 + drivers/usb/input/hid.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 63a4db721f7..3b162a19d7b 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -296,6 +296,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel break; case HID_UP_MSVENDOR: + case HID_UP_LOGIVENDOR: goto ignore; diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index c1b6b69bc4a..f3b85a0c200 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -182,6 +182,7 @@ struct hid_item { #define HID_UP_PID 0x000f0000 #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 +#define HID_UP_LOGIVENDOR 0x00ff0000 #define HID_USAGE 0x0000ffff -- cgit v1.2.3 From 0aebfdac042b63d0f2625414062e138a4333181c Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:07:59 -0500 Subject: Input: add HID simulation mappings Add simulation usage page mappings to hid-input.c to support a new crop of joysticks using them to designate Rudder and Throttle controls. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-debug.h | 17 +++++++++++++++++ drivers/usb/input/hid-input.c | 9 +++++++++ drivers/usb/input/hid.h | 1 + 3 files changed, 27 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 52437e5e2e7..789df807b11 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -85,6 +85,23 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x91, "D-PadDown"}, {0, 0x92, "D-PadRight"}, {0, 0x93, "D-PadLeft"}, + { 2, 0, "Simulation" }, + {0, 0xb0, "Aileron"}, + {0, 0xb1, "AileronTrim"}, + {0, 0xb2, "Anti-Torque"}, + {0, 0xb3, "Autopilot"}, + {0, 0xb4, "Chaff"}, + {0, 0xb5, "Collective"}, + {0, 0xb6, "DiveBrake"}, + {0, 0xb7, "ElectronicCountermeasures"}, + {0, 0xb8, "Elevator"}, + {0, 0xb9, "ElevatorTrim"}, + {0, 0xba, "Rudder"}, + {0, 0xbb, "Throttle"}, + {0, 0xbc, "FlightCommunications"}, + {0, 0xbd, "FlareRelease"}, + {0, 0xbe, "LandingGear"}, + {0, 0xbf, "ToeBrake"}, { 7, 0, "Keyboard" }, { 8, 0, "LED" }, {0, 0x01, "NumLock"}, diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 3b162a19d7b..fa4f79d88aa 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -131,6 +131,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel map_key(code); break; + + case HID_UP_SIMULATION: + + switch (usage->hid & 0xffff) { + case 0xba: map_abs(ABS_RUDDER); break; + case 0xbb: map_abs(ABS_THROTTLE); break; + } + break; + case HID_UP_GENDESK: if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index f3b85a0c200..cea5cf34b5f 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -173,6 +173,7 @@ struct hid_item { #define HID_UP_UNDEFINED 0x00000000 #define HID_UP_GENDESK 0x00010000 +#define HID_UP_SIMULATION 0x00020000 #define HID_UP_KEYBOARD 0x00070000 #define HID_UP_LED 0x00080000 #define HID_UP_BUTTON 0x00090000 -- cgit v1.2.3 From 8a409b0118c2d78f84f740f60fe03abda1fe3333 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:08:08 -0500 Subject: Input: HID - add more consumer usages Extend mapping of the consumer usage page in hid-input.c to handle more cases appearing on new USB keyboards. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-debug.h | 17 +++++++++++------ drivers/usb/input/hid-input.c | 19 ++++++++++++++++--- drivers/usb/input/hid.h | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 789df807b11..ceebab99eff 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -109,6 +109,7 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x03, "ScrollLock"}, {0, 0x04, "Compose"}, {0, 0x05, "Kana"}, + {0, 0x4b, "GenericIndicator"}, { 9, 0, "Button" }, { 10, 0, "Ordinal" }, { 12, 0, "Consumer" }, @@ -591,7 +592,8 @@ static char *keys[KEY_MAX + 1] = { [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", - [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13", + [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New", + [KEY_REDO] = "Redo", [KEY_F13] = "F13", [KEY_F14] = "F14", [KEY_F15] = "F15", [KEY_F16] = "F16", [KEY_F17] = "F17", [KEY_F18] = "F18", [KEY_F19] = "F19", @@ -601,15 +603,15 @@ static char *keys[KEY_MAX + 1] = { [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", - [KEY_FASTFORWARD] = "Fast Forward", [KEY_BASSBOOST] = "Bass Boost", + [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost", [KEY_PRINT] = "Print", [KEY_HP] = "HP", [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", - [KEY_ALTERASE] = "Alternate Erase", [KEY_CANCEL] = "Cancel", - [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up", + [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel", + [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp", [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", [BTN_0] = "Btn0", [BTN_1] = "Btn1", [BTN_2] = "Btn2", [BTN_3] = "Btn3", @@ -639,8 +641,8 @@ static char *keys[KEY_MAX + 1] = { [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", - [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "Tool Doubletap", - [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_GEAR_DOWN] = "WheelBtn", + [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap", + [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn", [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", @@ -676,6 +678,9 @@ static char *keys[KEY_MAX + 1] = { [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL", [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine", [KEY_DEL_LINE] = "DeleteLine", + [KEY_SEND] = "Send", [KEY_REPLY] = "Reply", + [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save", + [KEY_DOCUMENTS] = "Documents", }; static char *relatives[REL_MAX + 1] = { diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index fa4f79d88aa..b28cf8593b4 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -78,8 +78,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel { struct input_dev *input = &hidinput->input; struct hid_device *device = hidinput->input.private; - int max, code; - unsigned long *bit; + int max = 0, code; + unsigned long *bit = NULL; field->hidinput = hidinput; @@ -248,7 +248,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x034: map_key_clear(KEY_SLEEP); break; case 0x036: map_key_clear(BTN_MISC); break; case 0x08a: map_key_clear(KEY_WWW); break; + case 0x08d: map_key_clear(KEY_PROGRAM); break; case 0x095: map_key_clear(KEY_HELP); break; + case 0x09c: map_key_clear(KEY_CHANNELUP); break; + case 0x09d: map_key_clear(KEY_CHANNELDOWN); break; case 0x0b0: map_key_clear(KEY_PLAY); break; case 0x0b1: map_key_clear(KEY_PAUSE); break; case 0x0b2: map_key_clear(KEY_RECORD); break; @@ -268,6 +271,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x18a: map_key_clear(KEY_MAIL); break; case 0x192: map_key_clear(KEY_CALC); break; case 0x194: map_key_clear(KEY_FILE); break; + case 0x1a7: map_key_clear(KEY_DOCUMENTS); break; + case 0x201: map_key_clear(KEY_NEW); break; + case 0x207: map_key_clear(KEY_SAVE); break; + case 0x208: map_key_clear(KEY_PRINT); break; + case 0x209: map_key_clear(KEY_PROPS); break; case 0x21a: map_key_clear(KEY_UNDO); break; case 0x21b: map_key_clear(KEY_COPY); break; case 0x21c: map_key_clear(KEY_CUT); break; @@ -280,7 +288,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x227: map_key_clear(KEY_REFRESH); break; case 0x22a: map_key_clear(KEY_BOOKMARKS); break; case 0x238: map_rel(REL_HWHEEL); break; - default: goto unknown; + case 0x279: map_key_clear(KEY_REDO); break; + case 0x289: map_key_clear(KEY_REPLY); break; + case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; + case 0x28c: map_key_clear(KEY_SEND); break; + default: goto ignore; } break; @@ -306,6 +318,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case HID_UP_MSVENDOR: case HID_UP_LOGIVENDOR: + case HID_UP_LOGIVENDOR2: goto ignore; diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index cea5cf34b5f..ca3e170ce0b 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -184,6 +184,7 @@ struct hid_item { #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 #define HID_UP_LOGIVENDOR 0x00ff0000 +#define HID_UP_LOGIVENDOR2 0xffbc0000 #define HID_USAGE 0x0000ffff -- cgit v1.2.3 From 903b126bffb77dc313b7c2971880df408bf41a9e Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:11:41 -0500 Subject: Input: atkbd - handle keyboards generating scancode 0x7f Extend bat_xl handling to do err_xl handling, so that keyboards using 0x7f scancode for regular keys can work. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/atkbd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 4d4985b59ab..1ad8c2ee7db 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -208,6 +208,7 @@ struct atkbd { unsigned char resend; unsigned char release; unsigned char bat_xl; + unsigned char err_xl; unsigned int last; unsigned long time; }; @@ -296,15 +297,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, if (atkbd->emul || !(code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1 || code == ATKBD_RET_HANGUEL || code == ATKBD_RET_HANJA || - code == ATKBD_RET_ERR || + (code == ATKBD_RET_ERR && !atkbd->err_xl) || (code == ATKBD_RET_BAT && !atkbd->bat_xl))) { atkbd->release = code >> 7; code &= 0x7f; } - if (!atkbd->emul && - (code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) + if (!atkbd->emul) { + if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) atkbd->bat_xl = !atkbd->release; + if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) + atkbd->err_xl = !atkbd->release; + } } switch (code) { -- cgit v1.2.3 From bf0964dcda97e42964d312d0ff73a832171e080a Mon Sep 17 00:00:00 2001 From: Michael Haboustak Date: Mon, 5 Sep 2005 00:12:01 -0500 Subject: Input: HID - handle multi-transascion reports Fixes handling of multi-transaction reports for HID devices. New function hid_size_buffers() that calculates the longest report for each endpoint and stores the result in the hid_device object. These lengths are used to allocate buffers that are large enough to store any report on the endpoint. For compatibility, the minimum size for an endpoint buffer set to HID_BUFFER_SIZE rather than the known optimal case (the longest report length). It fixes bug #3063 in bugzilla. Signed-off-by: Michael Haboustak I simplified the patch a bit to use just a single buffer size. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-core.c | 62 +++++++++++++++++++++++++++++++------------- drivers/usb/input/hid.h | 5 +++- 2 files changed, 48 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b2cb2b35892..376b6043bbf 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -2,7 +2,8 @@ * USB HID support for Linux * * Copyright (c) 1999 Andreas Gal - * Copyright (c) 2000-2001 Vojtech Pavlik + * Copyright (c) 2000-2005 Vojtech Pavlik + * Copyright (c) 2005 Michael Haboustak for Concept2, Inc */ /* @@ -38,7 +39,7 @@ * Version Information */ -#define DRIVER_VERSION "v2.01" +#define DRIVER_VERSION "v2.6" #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" #define DRIVER_DESC "USB HID core driver" #define DRIVER_LICENSE "GPL" @@ -1058,8 +1059,8 @@ static int hid_submit_ctrl(struct hid_device *hid) if (maxpacket > 0) { padlen = (len + maxpacket - 1) / maxpacket; padlen *= maxpacket; - if (padlen > HID_BUFFER_SIZE) - padlen = HID_BUFFER_SIZE; + if (padlen > hid->bufsize) + padlen = hid->bufsize; } else padlen = 0; hid->urbctrl->transfer_buffer_length = padlen; @@ -1284,13 +1285,8 @@ void hid_init_reports(struct hid_device *hid) struct hid_report *report; int err, ret; - list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) { - int size = ((report->size - 1) >> 3) + 1 + hid->report_enum[HID_INPUT_REPORT].numbered; - if (size > HID_BUFFER_SIZE) size = HID_BUFFER_SIZE; - if (size > hid->urbin->transfer_buffer_length) - hid->urbin->transfer_buffer_length = size; + list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); - } list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); @@ -1564,15 +1560,32 @@ static struct hid_blacklist { { 0, 0 } }; +/* + * Traverse the supplied list of reports and find the longest + */ +static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max) +{ + struct hid_report *report; + int size; + + list_for_each_entry(report, &hid->report_enum[type].report_list, list) { + size = ((report->size - 1) >> 3) + 1; + if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered) + size++; + if (*max < size) + *max = size; + } +} + static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) { - if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->inbuf_dma))) + if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) return -1; - if (!(hid->outbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->outbuf_dma))) + if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) return -1; if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) return -1; - if (!(hid->ctrlbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->ctrlbuf_dma))) + if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) return -1; return 0; @@ -1581,13 +1594,13 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) { if (hid->inbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->inbuf, hid->inbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma); if (hid->outbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->outbuf, hid->outbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma); if (hid->cr) usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); if (hid->ctrlbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma); } static struct hid_device *usb_hid_configure(struct usb_interface *intf) @@ -1598,7 +1611,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) struct hid_device *hid; unsigned quirks = 0, rsize = 0; char *buf, *rdesc; - int n; + int n, insize = 0; for (n = 0; hid_blacklist[n].idVendor; n++) if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && @@ -1652,6 +1665,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) kfree(rdesc); hid->quirks = quirks; + hid->bufsize = HID_MIN_BUFFER_SIZE; + hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize); + + if (hid->bufsize > HID_MAX_BUFFER_SIZE) + hid->bufsize = HID_MAX_BUFFER_SIZE; + + hid_find_max_report(hid, HID_INPUT_REPORT, &insize); + + if (insize > HID_MAX_BUFFER_SIZE) + insize = HID_MAX_BUFFER_SIZE; + if (hid_alloc_buffers(dev, hid)) { hid_free_buffers(dev, hid); goto fail; @@ -1682,7 +1708,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) goto fail; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); - usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, + usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, hid_irq_in, hid, interval); hid->urbin->transfer_dma = hid->inbuf_dma; hid->urbin->transfer_flags |=(URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ca3e170ce0b..d76bbc81f6a 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -351,7 +351,8 @@ struct hid_report_enum { #define HID_REPORT_TYPES 3 -#define HID_BUFFER_SIZE 64 /* use 64 for compatibility with all possible packetlen */ +#define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ +#define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ #define HID_OUTPUT_FIFO_SIZE 64 @@ -389,6 +390,8 @@ struct hid_device { /* device report descriptor */ unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ + unsigned int bufsize; /* URB buffer size */ + struct urb *urbin; /* Input URB */ char *inbuf; /* Input buffer */ dma_addr_t inbuf_dma; /* Input buffer dma */ -- cgit v1.2.3 From 39fd748f56012fdde4cf862f127ce4cdec50d661 Mon Sep 17 00:00:00 2001 From: "Micah F. Galizia" Date: Mon, 5 Sep 2005 00:12:15 -0500 Subject: Input: HID - add support for Logitech UltraX Media Remote control The hid now supports the Logitech UltraX Media Remote control. For now, ID 45 on the consumer usage page has been incorrectly mapped to KEY_RADIO since no other devices uses it. Signed-off-by: Micah F. Galizia Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-input.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index b28cf8593b4..22f9d919a3f 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -247,6 +247,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x000: goto ignore; case 0x034: map_key_clear(KEY_SLEEP); break; case 0x036: map_key_clear(BTN_MISC); break; + case 0x045: map_key_clear(KEY_RADIO); break; case 0x08a: map_key_clear(KEY_WWW); break; case 0x08d: map_key_clear(KEY_PROGRAM); break; case 0x095: map_key_clear(KEY_HELP); break; @@ -318,10 +319,33 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case HID_UP_MSVENDOR: case HID_UP_LOGIVENDOR: - case HID_UP_LOGIVENDOR2: - goto ignore; + case HID_UP_LOGIVENDOR2: /* Reported on Logitech Ultra X Media Remote */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x004: map_key_clear(KEY_AGAIN); break; + case 0x00d: map_key_clear(KEY_HOME); break; + case 0x024: map_key_clear(KEY_SHUFFLE); break; + case 0x025: map_key_clear(KEY_TV); break; + case 0x026: map_key_clear(KEY_MENU); break; + case 0x031: map_key_clear(KEY_AUDIO); break; + case 0x032: map_key_clear(KEY_SUBTITLE); break; + case 0x033: map_key_clear(KEY_LAST); break; + case 0x047: map_key_clear(KEY_MP3); break; + case 0x048: map_key_clear(KEY_DVD); break; + case 0x049: map_key_clear(KEY_MEDIA); break; + case 0x04a: map_key_clear(KEY_VIDEO); break; + case 0x04b: map_key_clear(KEY_ANGLE); break; + case 0x04c: map_key_clear(KEY_LANGUAGE); break; + case 0x04d: map_key_clear(KEY_SUBTITLE); break; + case 0x051: map_key_clear(KEY_RED); break; + case 0x052: map_key_clear(KEY_CLOSE); break; + default: goto ignore; + } + break; + case HID_UP_PID: set_bit(EV_FF, input->evbit); -- cgit v1.2.3 From fb76b099f86624d3c629cfab071aa2296f65b7bb Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:12:39 -0500 Subject: Input: iforce - use wait_event_interruptible_timeout The timeout while() loops in iforce-packets.c lack a set_current_state(TASK_INTERRUPTIBLE); call. The right solution is to replace them with wait_event_interruptible_timeout(). Reported-by: Nishanth Aravamudan Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-packets.c | 32 ++++++-------------------- drivers/input/joystick/iforce/iforce-usb.c | 1 + 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 58728ebaaf8..e5a31e55d3e 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c @@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, int iforce_get_id_packet(struct iforce *iforce, char *packet) { - DECLARE_WAITQUEUE(wait, current); - int timeout = HZ; /* 1 second */ - switch (iforce->bus) { case IFORCE_USB: @@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->cr.bRequest = packet[0]; iforce->ctrl->dev = iforce->usbdev; - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) { - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) return -1; - } - while (timeout && iforce->ctrl->status == -EINPROGRESS) - timeout = schedule_timeout(timeout); + wait_event_interruptible_timeout(iforce->wait, + iforce->ctrl->status != -EINPROGRESS, HZ); - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); - - if (!timeout) { + if (iforce->ctrl->status != -EINPROGRESS) { usb_unlink_urb(iforce->ctrl); return -1; } @@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->expect_packet = FF_CMD_QUERY; iforce_send_packet(iforce, FF_CMD_QUERY, packet); - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - while (timeout && iforce->expect_packet) - timeout = schedule_timeout(timeout); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + wait_event_interruptible_timeout(iforce->wait, + !iforce->expect_packet, HZ); - if (!timeout) { + if (iforce->expect_packet) { iforce->expect_packet = 0; return -1; } diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 6369a24684f..58600f91eff 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) goto exit; } + wake_up(&iforce->wait); iforce_process_packet(iforce, (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); -- cgit v1.2.3 From 8d9a9ae3b2941d94bb0023a3aca2ec2bfa83d0c2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:12:47 -0500 Subject: Input: sunkbd - extend mapping to handle Type-6 Sun keyboards Map an unmarked key at 'Esc' position to KEY_MACRO Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/sunkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 596964ceb96..4bae5d89348 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -44,7 +44,7 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); static unsigned char sunkbd_keycode[128] = { - 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64, 0, + 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64,112, 65, 66, 67, 56,103,119, 99, 70,105,130,131,108,106, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 41, 14,110,113, 98, 55, 116,132, 83,133,102, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -- cgit v1.2.3 From c4786ca8a4274a0bbffe217917972943348bed64 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:03 -0500 Subject: Input: HID - fix URB success status handling Add a missing break; statement to the URB status handling in hid-core.c, avoiding flushing the request queue on success. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 376b6043bbf..7d5eb4deb1e 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1097,6 +1097,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) switch (urb->status) { case 0: /* success */ + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timeout on uhci */ unplug = 1; @@ -1144,6 +1145,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) case 0: /* success */ if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timectrl on uhci */ unplug = 1; -- cgit v1.2.3 From c58de6d949a9d2c386c4d814013b6c967c14ea5a Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:15 -0500 Subject: Input: HID - add a quirk for the Apple Powermouse Add a quirk for the Apple Powermouse, remapping GenericDesktop.Z to Rel.HWheel, to allow horizontal scrolling in Linux. Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-core.c | 3 +++ drivers/usb/input/hid-input.c | 3 +++ drivers/usb/input/hid.h | 1 + 3 files changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 7d5eb4deb1e..661709a35b0 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1442,6 +1442,8 @@ void hid_init_reports(struct hid_device *hid) #define USB_DEVICE_ID_NETWORKANALYSER 0x2020 #define USB_DEVICE_ID_POWERCONTROL 0x2030 +#define USB_VENDOR_ID_APPLE 0x05ac +#define USB_DEVICE_ID_APPLE_POWERMOUSE 0x0304 /* * Alphabetically sorted blacklist by quirk type. @@ -1546,6 +1548,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE }, { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 22f9d919a3f..14acfc579f8 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -396,6 +396,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel if (usage->code > max) goto ignore; + if (((device->quirks & (HID_QUIRK_2WHEEL_POWERMOUSE)) && (usage->hid == 0x00010032))) + map_rel(REL_HWHEEL); + if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && (usage->type == EV_REL) && (usage->code == REL_WHEEL)) set_bit(REL_HWHEEL, bit); diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index d76bbc81f6a..47f75a43a46 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -245,6 +245,7 @@ struct hid_item { #define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x080 #define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x100 #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x200 +#define HID_QUIRK_2WHEEL_POWERMOUSE 0x400 /* * This is the global environment of the parser. This information is -- cgit v1.2.3 From 61cdecd9f5f602775af1e89c200179d093a94ae2 Mon Sep 17 00:00:00 2001 From: Vojtech Pavlik Date: Mon, 5 Sep 2005 00:13:32 -0500 Subject: Input: HID - add the Trust Predator TH 400 gamepad to the badpad list Reported-by: Karl Relton Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 661709a35b0..485575a70be 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1370,8 +1370,9 @@ void hid_init_reports(struct hid_device *hid) #define USB_VENDOR_ID_A4TECH 0x09da #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 -#define USB_VENDOR_ID_AASHIMA 0x06D6 +#define USB_VENDOR_ID_AASHIMA 0x06d6 #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 +#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 #define USB_VENDOR_ID_CYPRESS 0x04b4 #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 @@ -1553,6 +1554,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, + { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, -- cgit v1.2.3 From e875ce374759087771313c9e76b672b86ac20950 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Mon, 5 Sep 2005 01:57:33 -0500 Subject: Input: HID - add mapping for Powerbook USB keyboard Map custom HID events (such as the ones generated by some Logitech and Apple Powerbooks USB keyboards) to the FN keycode. Signed-off-by: Stelian Pop Signed-off-by: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-input.c | 12 ++++++++++-- drivers/usb/input/hid.h | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 14acfc579f8..0b6452248a3 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -318,10 +318,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel break; case HID_UP_MSVENDOR: - case HID_UP_LOGIVENDOR: goto ignore; - case HID_UP_LOGIVENDOR2: /* Reported on Logitech Ultra X Media Remote */ + case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x003: map_key_clear(KEY_FN); break; + default: goto ignore; + } + break; + + case HID_UP_LOGIVENDOR: /* Reported on Logitech Ultra X Media Remote */ set_bit(EV_REP, input->evbit); switch(usage->hid & HID_USAGE) { diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index 47f75a43a46..ec2412c42f1 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -183,8 +183,8 @@ struct hid_item { #define HID_UP_PID 0x000f0000 #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 -#define HID_UP_LOGIVENDOR 0x00ff0000 -#define HID_UP_LOGIVENDOR2 0xffbc0000 +#define HID_UP_CUSTOM 0x00ff0000 +#define HID_UP_LOGIVENDOR 0xffbc0000 #define HID_USAGE 0x0000ffff -- cgit v1.2.3 From 7d25258f69cedc2f2e55eb25ba2e2078060b44f4 Mon Sep 17 00:00:00 2001 From: Brian Schau Date: Mon, 5 Sep 2005 01:57:41 -0500 Subject: Input: HID - add Wireless Security Lock to HID blacklist The device is a Wireless Security Lock (WSL). The device identifies itself as a Cypress Ultra Mouse. It is, however, not a mouse at all and as such, shouldn't be handled as one. Signed-off-by: Brian Schau Signed-off-by: Vojtech Pavlik Signed-off-by: Andrew Morton Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hid-core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 485575a70be..a7212990045 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1377,6 +1377,7 @@ void hid_init_reports(struct hid_device *hid) #define USB_VENDOR_ID_CYPRESS 0x04b4 #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 +#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 #define USB_VENDOR_ID_BERKSHIRE 0x0c98 #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 @@ -1469,6 +1470,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, + { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, -- cgit v1.2.3 From 010988e888a0abbe7118635c1b33d049caae6b29 Mon Sep 17 00:00:00 2001 From: Stefan Nickl Date: Mon, 5 Sep 2005 01:57:46 -0500 Subject: Input: HIDDEV - make HIDIOCSREPORT wait IO completion When trying to make the hiddev driver issue several Set_Report control transfers to a custom device with 2.6.13-rc6, only the first transfer in a row is carried out, while others immediately following it are silently dropped. This happens where hid_submit_report() (in hid-core.c) tests for HID_CTRL_RUNNING, which seems to be still set because the first transfer is not finished yet. As a workaround, inserting a delay between the two calls to ioctl(HIDIOCSREPORT) in userspace "solves" the problem. The straightforward fix is to add a call to hid_wait_io() to the implementation of HIDIOCSREPORT (in hiddev.c), just like for HIDIOCGREPORT. Works fine for me. Apparently, this issue has some history: http://marc.theaimsgroup.com/?l=linux-usb-users&m=111100670105558&w=2 Signed-off-by: Stefan Nickl Signed-off-by: Andrew Morton Signed-off-by: Vojtech Pavlik Signed-off-by: Dmitry Torokhov --- drivers/usb/input/hiddev.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 4c13331b5f4..d32427818af 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -507,6 +507,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd return -EINVAL; hid_submit_report(hid, report, USB_DIR_OUT); + hid_wait_io(hid); return 0; -- cgit v1.2.3 From 06c56e44f3e32a859420ecac97996cc6f12827bb Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 1 Sep 2005 09:19:02 -0700 Subject: [PATCH] IPoIB: fix memory leak Fix IPoIB memory leak on device removal. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0e8ac138e35..49d120d2b92 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1062,6 +1062,8 @@ static void ipoib_remove_one(struct ib_device *device) ipoib_dev_cleanup(priv->dev); free_netdev(priv->dev); } + + kfree(dev_list); } static int __init ipoib_init_module(void) -- cgit v1.2.3 From 1d6801f9dd3ebb054ae685153a01b1a4ec817f46 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 1 Sep 2005 09:19:44 -0700 Subject: [PATCH] IB/sa_query: avoid unnecessary list scan Using ib_get_client_data in SA event handler performs a list scan. It's better to use container_of to get the sa device directly. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- drivers/infiniband/core/sa_query.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 126ac80db7b..9191793c900 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -431,8 +431,8 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event event->event == IB_EVENT_LID_CHANGE || event->event == IB_EVENT_PKEY_CHANGE || event->event == IB_EVENT_SM_CHANGE) { - struct ib_sa_device *sa_dev = - ib_get_client_data(event->device, &sa_client); + struct ib_sa_device *sa_dev; + sa_dev = container_of(handler, typeof(*sa_dev), event_handler); schedule_work(&sa_dev->port[event->element.port_num - sa_dev->start_port].update_task); -- cgit v1.2.3 From 0b2b35f68140ceeb1b78ef85680198e63ebc8649 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Thu, 1 Sep 2005 09:28:03 -0700 Subject: [PATCH] IB: Add user-supplied context to userspace CM ABI - Add user specified context to all uCM events. Users will not retrieve any events associated with the context after destroying the corresponding cm_id. - Provide the ib_cm_init_qp_attr() call to userspace clients of the CM. This call may be used to set QP attributes properly before modifying the QP. - Fixes some error handling synchonization and cleanup issues. - Performs some minor code cleanup. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucm.c | 287 +++++++++++++++++++++++++++--------------- drivers/infiniband/core/ucm.h | 11 +- 2 files changed, 192 insertions(+), 106 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 79595826ccc..d0f0b0a2edd 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -72,7 +72,6 @@ enum { static struct semaphore ctx_id_mutex; static struct idr ctx_id_table; -static int ctx_id_rover = 0; static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) { @@ -97,33 +96,16 @@ static void ib_ucm_ctx_put(struct ib_ucm_context *ctx) wake_up(&ctx->wait); } -static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) +static inline int ib_ucm_new_cm_id(int event) { - struct ib_ucm_context *ctx; - struct ib_ucm_event *uevent; - - down(&ctx_id_mutex); - ctx = idr_find(&ctx_id_table, id); - if (!ctx) - ctx = ERR_PTR(-ENOENT); - else if (ctx->file != file) - ctx = ERR_PTR(-EINVAL); - else - idr_remove(&ctx_id_table, ctx->id); - up(&ctx_id_mutex); - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); - - atomic_dec(&ctx->ref); - wait_event(ctx->wait, !atomic_read(&ctx->ref)); + return event == IB_CM_REQ_RECEIVED || event == IB_CM_SIDR_REQ_RECEIVED; +} - /* No new events will be generated after destroying the cm_id. */ - if (!IS_ERR(ctx->cm_id)) - ib_destroy_cm_id(ctx->cm_id); +static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx) +{ + struct ib_ucm_event *uevent; - /* Cleanup events not yet reported to the user. */ - down(&file->mutex); + down(&ctx->file->mutex); list_del(&ctx->file_list); while (!list_empty(&ctx->events)) { @@ -133,15 +115,12 @@ static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) list_del(&uevent->ctx_list); /* clear incoming connections. */ - if (uevent->cm_id) + if (ib_ucm_new_cm_id(uevent->resp.event)) ib_destroy_cm_id(uevent->cm_id); kfree(uevent); } - up(&file->mutex); - - kfree(ctx); - return 0; + up(&ctx->file->mutex); } static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) @@ -153,36 +132,31 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) if (!ctx) return NULL; + memset(ctx, 0, sizeof *ctx); atomic_set(&ctx->ref, 1); init_waitqueue_head(&ctx->wait); ctx->file = file; - INIT_LIST_HEAD(&ctx->events); - list_add_tail(&ctx->file_list, &file->ctxs); - - ctx_id_rover = (ctx_id_rover + 1) & INT_MAX; -retry: - result = idr_pre_get(&ctx_id_table, GFP_KERNEL); - if (!result) - goto error; + do { + result = idr_pre_get(&ctx_id_table, GFP_KERNEL); + if (!result) + goto error; - down(&ctx_id_mutex); - result = idr_get_new_above(&ctx_id_table, ctx, ctx_id_rover, &ctx->id); - up(&ctx_id_mutex); + down(&ctx_id_mutex); + result = idr_get_new(&ctx_id_table, ctx, &ctx->id); + up(&ctx_id_mutex); + } while (result == -EAGAIN); - if (result == -EAGAIN) - goto retry; if (result) goto error; + list_add_tail(&ctx->file_list, &file->ctxs); ucm_dbg("Allocated CM ID <%d>\n", ctx->id); - return ctx; + error: - list_del(&ctx->file_list); kfree(ctx); - return NULL; } /* @@ -219,12 +193,9 @@ static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath, kpath->packet_life_time_selector; } -static void ib_ucm_event_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_req_event_resp *ureq, +static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq, struct ib_cm_req_event_param *kreq) { - ureq->listen_id = ctx->id; - ureq->remote_ca_guid = kreq->remote_ca_guid; ureq->remote_qkey = kreq->remote_qkey; ureq->remote_qpn = kreq->remote_qpn; @@ -259,14 +230,6 @@ static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep, urep->srq = krep->srq; } -static void ib_ucm_event_sidr_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_sidr_req_event_resp *ureq, - struct ib_cm_sidr_req_event_param *kreq) -{ - ureq->listen_id = ctx->id; - ureq->pkey = kreq->pkey; -} - static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, struct ib_cm_sidr_rep_event_param *krep) { @@ -275,15 +238,14 @@ static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, urep->qpn = krep->qpn; }; -static int ib_ucm_event_process(struct ib_ucm_context *ctx, - struct ib_cm_event *evt, +static int ib_ucm_event_process(struct ib_cm_event *evt, struct ib_ucm_event *uvt) { void *info = NULL; switch (evt->event) { case IB_CM_REQ_RECEIVED: - ib_ucm_event_req_get(ctx, &uvt->resp.u.req_resp, + ib_ucm_event_req_get(&uvt->resp.u.req_resp, &evt->param.req_rcvd); uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE; uvt->resp.present = IB_UCM_PRES_PRIMARY; @@ -331,8 +293,8 @@ static int ib_ucm_event_process(struct ib_ucm_context *ctx, info = evt->param.apr_rcvd.apr_info; break; case IB_CM_SIDR_REQ_RECEIVED: - ib_ucm_event_sidr_req_get(ctx, &uvt->resp.u.sidr_req_resp, - &evt->param.sidr_req_rcvd); + uvt->resp.u.sidr_req_resp.pkey = + evt->param.sidr_req_rcvd.pkey; uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; break; case IB_CM_SIDR_REP_RECEIVED: @@ -378,31 +340,24 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id, struct ib_ucm_event *uevent; struct ib_ucm_context *ctx; int result = 0; - int id; ctx = cm_id->context; - if (event->event == IB_CM_REQ_RECEIVED || - event->event == IB_CM_SIDR_REQ_RECEIVED) - id = IB_UCM_CM_ID_INVALID; - else - id = ctx->id; - uevent = kmalloc(sizeof(*uevent), GFP_KERNEL); if (!uevent) goto err1; memset(uevent, 0, sizeof(*uevent)); - uevent->resp.id = id; + uevent->ctx = ctx; + uevent->cm_id = cm_id; + uevent->resp.uid = ctx->uid; + uevent->resp.id = ctx->id; uevent->resp.event = event->event; - result = ib_ucm_event_process(ctx, event, uevent); + result = ib_ucm_event_process(event, uevent); if (result) goto err2; - uevent->ctx = ctx; - uevent->cm_id = (id == IB_UCM_CM_ID_INVALID) ? cm_id : NULL; - down(&ctx->file->mutex); list_add_tail(&uevent->file_list, &ctx->file->events); list_add_tail(&uevent->ctx_list, &ctx->events); @@ -414,7 +369,7 @@ err2: kfree(uevent); err1: /* Destroy new cm_id's */ - return (id == IB_UCM_CM_ID_INVALID); + return ib_ucm_new_cm_id(event->event); } static ssize_t ib_ucm_event(struct ib_ucm_file *file, @@ -423,7 +378,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, { struct ib_ucm_context *ctx; struct ib_ucm_event_get cmd; - struct ib_ucm_event *uevent = NULL; + struct ib_ucm_event *uevent; int result = 0; DEFINE_WAIT(wait); @@ -436,7 +391,6 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, * wait */ down(&file->mutex); - while (list_empty(&file->events)) { if (file->filp->f_flags & O_NONBLOCK) { @@ -463,21 +417,18 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, uevent = list_entry(file->events.next, struct ib_ucm_event, file_list); - if (!uevent->cm_id) - goto user; + if (ib_ucm_new_cm_id(uevent->resp.event)) { + ctx = ib_ucm_ctx_alloc(file); + if (!ctx) { + result = -ENOMEM; + goto done; + } - ctx = ib_ucm_ctx_alloc(file); - if (!ctx) { - result = -ENOMEM; - goto done; + ctx->cm_id = uevent->cm_id; + ctx->cm_id->context = ctx; + uevent->resp.id = ctx->id; } - ctx->cm_id = uevent->cm_id; - ctx->cm_id->context = ctx; - - uevent->resp.id = ctx->id; - -user: if (copy_to_user((void __user *)(unsigned long)cmd.response, &uevent->resp, sizeof(uevent->resp))) { result = -EFAULT; @@ -485,12 +436,10 @@ user: } if (uevent->data) { - if (cmd.data_len < uevent->data_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.data, uevent->data, uevent->data_len)) { result = -EFAULT; @@ -499,12 +448,10 @@ user: } if (uevent->info) { - if (cmd.info_len < uevent->info_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.info, uevent->info, uevent->info_len)) { result = -EFAULT; @@ -514,6 +461,7 @@ user: list_del(&uevent->file_list); list_del(&uevent->ctx_list); + uevent->ctx->events_reported++; kfree(uevent->data); kfree(uevent->info); @@ -545,6 +493,7 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, if (!ctx) return -ENOMEM; + ctx->uid = cmd.uid; ctx->cm_id = ib_create_cm_id(ib_ucm_event_handler, ctx); if (IS_ERR(ctx->cm_id)) { result = PTR_ERR(ctx->cm_id); @@ -561,7 +510,14 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, return 0; err: - ib_ucm_destroy_ctx(file, ctx->id); + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (!IS_ERR(ctx->cm_id)) + ib_destroy_cm_id(ctx->cm_id); + + kfree(ctx); return result; } @@ -570,11 +526,44 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, int in_len, int out_len) { struct ib_ucm_destroy_id cmd; + struct ib_ucm_destroy_id_resp resp; + struct ib_ucm_context *ctx; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - return ib_ucm_destroy_ctx(file, cmd.id); + down(&ctx_id_mutex); + ctx = idr_find(&ctx_id_table, cmd.id); + if (!ctx) + ctx = ERR_PTR(-ENOENT); + else if (ctx->file != file) + ctx = ERR_PTR(-EINVAL); + else + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + atomic_dec(&ctx->ref); + wait_event(ctx->wait, !atomic_read(&ctx->ref)); + + /* No new events will be generated after destroying the cm_id. */ + ib_destroy_cm_id(ctx->cm_id); + /* Cleanup events not yet reported to the user. */ + ib_ucm_cleanup_events(ctx); + + resp.events_reported = ctx->events_reported; + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + + kfree(ctx); + return result; } static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, @@ -609,6 +598,98 @@ static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, return result; } +static void ib_ucm_copy_ah_attr(struct ib_ucm_ah_attr *dest_attr, + struct ib_ah_attr *src_attr) +{ + memcpy(dest_attr->grh_dgid, src_attr->grh.dgid.raw, + sizeof src_attr->grh.dgid); + dest_attr->grh_flow_label = src_attr->grh.flow_label; + dest_attr->grh_sgid_index = src_attr->grh.sgid_index; + dest_attr->grh_hop_limit = src_attr->grh.hop_limit; + dest_attr->grh_traffic_class = src_attr->grh.traffic_class; + + dest_attr->dlid = src_attr->dlid; + dest_attr->sl = src_attr->sl; + dest_attr->src_path_bits = src_attr->src_path_bits; + dest_attr->static_rate = src_attr->static_rate; + dest_attr->is_global = (src_attr->ah_flags & IB_AH_GRH); + dest_attr->port_num = src_attr->port_num; +} + +static void ib_ucm_copy_qp_attr(struct ib_ucm_init_qp_attr_resp *dest_attr, + struct ib_qp_attr *src_attr) +{ + dest_attr->cur_qp_state = src_attr->cur_qp_state; + dest_attr->path_mtu = src_attr->path_mtu; + dest_attr->path_mig_state = src_attr->path_mig_state; + dest_attr->qkey = src_attr->qkey; + dest_attr->rq_psn = src_attr->rq_psn; + dest_attr->sq_psn = src_attr->sq_psn; + dest_attr->dest_qp_num = src_attr->dest_qp_num; + dest_attr->qp_access_flags = src_attr->qp_access_flags; + + dest_attr->max_send_wr = src_attr->cap.max_send_wr; + dest_attr->max_recv_wr = src_attr->cap.max_recv_wr; + dest_attr->max_send_sge = src_attr->cap.max_send_sge; + dest_attr->max_recv_sge = src_attr->cap.max_recv_sge; + dest_attr->max_inline_data = src_attr->cap.max_inline_data; + + ib_ucm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr); + ib_ucm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr); + + dest_attr->pkey_index = src_attr->pkey_index; + dest_attr->alt_pkey_index = src_attr->alt_pkey_index; + dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify; + dest_attr->sq_draining = src_attr->sq_draining; + dest_attr->max_rd_atomic = src_attr->max_rd_atomic; + dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic; + dest_attr->min_rnr_timer = src_attr->min_rnr_timer; + dest_attr->port_num = src_attr->port_num; + dest_attr->timeout = src_attr->timeout; + dest_attr->retry_cnt = src_attr->retry_cnt; + dest_attr->rnr_retry = src_attr->rnr_retry; + dest_attr->alt_port_num = src_attr->alt_port_num; + dest_attr->alt_timeout = src_attr->alt_timeout; +} + +static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct ib_ucm_init_qp_attr_resp resp; + struct ib_ucm_init_qp_attr cmd; + struct ib_ucm_context *ctx; + struct ib_qp_attr qp_attr; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + ctx = ib_ucm_ctx_get(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + resp.qp_attr_mask = 0; + memset(&qp_attr, 0, sizeof qp_attr); + qp_attr.qp_state = cmd.qp_state; + result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask); + if (result) + goto out; + + ib_ucm_copy_qp_attr(&resp, &qp_attr); + + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + +out: + ib_ucm_ctx_put(ctx); + return result; +} + static ssize_t ib_ucm_listen(struct ib_ucm_file *file, const char __user *inbuf, int in_len, int out_len) @@ -808,6 +889,7 @@ static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file, ctx = ib_ucm_ctx_get(file, cmd.id); if (!IS_ERR(ctx)) { + ctx->uid = cmd.uid; result = ib_send_cm_rep(ctx->cm_id, ¶m); ib_ucm_ctx_put(ctx); } else @@ -1086,6 +1168,7 @@ static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file, [IB_USER_CM_CMD_SEND_SIDR_REQ] = ib_ucm_send_sidr_req, [IB_USER_CM_CMD_SEND_SIDR_REP] = ib_ucm_send_sidr_rep, [IB_USER_CM_CMD_EVENT] = ib_ucm_event, + [IB_USER_CM_CMD_INIT_QP_ATTR] = ib_ucm_init_qp_attr, }; static ssize_t ib_ucm_write(struct file *filp, const char __user *buf, @@ -1161,12 +1244,18 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) down(&file->mutex); while (!list_empty(&file->ctxs)) { - ctx = list_entry(file->ctxs.next, struct ib_ucm_context, file_list); - up(&file->mutex); - ib_ucm_destroy_ctx(file, ctx->id); + + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + ib_destroy_cm_id(ctx->cm_id); + ib_ucm_cleanup_events(ctx); + kfree(ctx); + down(&file->mutex); } up(&file->mutex); diff --git a/drivers/infiniband/core/ucm.h b/drivers/infiniband/core/ucm.h index c8819b928a1..f46f37bc120 100644 --- a/drivers/infiniband/core/ucm.h +++ b/drivers/infiniband/core/ucm.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -43,8 +44,6 @@ #include #include -#define IB_UCM_CM_ID_INVALID 0xffffffff - struct ib_ucm_file { struct semaphore mutex; struct file *filp; @@ -58,9 +57,11 @@ struct ib_ucm_context { int id; wait_queue_head_t wait; atomic_t ref; + int events_reported; struct ib_ucm_file *file; struct ib_cm_id *cm_id; + __u64 uid; struct list_head events; /* list of pending events. */ struct list_head file_list; /* member in file ctx list */ @@ -71,16 +72,12 @@ struct ib_ucm_event { struct list_head file_list; /* member in file event list */ struct list_head ctx_list; /* member in ctx event list */ + struct ib_cm_id *cm_id; struct ib_ucm_event_resp resp; void *data; void *info; int data_len; int info_len; - /* - * new connection identifiers needs to be saved until - * userspace can get a handle on them. - */ - struct ib_cm_id *cm_id; }; #endif /* UCM_H */ -- cgit v1.2.3 From c9fe2b3287498b80781284306064104ef9c8a31a Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 7 Sep 2005 09:43:23 -0700 Subject: [PATCH] IB: really reset QPs When we modify a QP to the RESET state, completely clean up the QP so that it is really and truly reset. Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_qp.c | 44 ++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 0164b84d4ec..c753f7375a5 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -220,6 +220,16 @@ static void *get_send_wqe(struct mthca_qp *qp, int n) (PAGE_SIZE - 1)); } +static void mthca_wq_init(struct mthca_wq *wq) +{ + spin_lock_init(&wq->lock); + wq->next_ind = 0; + wq->last_comp = wq->max - 1; + wq->head = 0; + wq->tail = 0; + wq->last = NULL; +} + void mthca_qp_event(struct mthca_dev *dev, u32 qpn, enum ib_event_type event_type) { @@ -833,8 +843,8 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) store_attrs(to_msqp(qp), attr, attr_mask); /* - * If we are moving QP0 to RTR, bring the IB link up; if we - * are moving QP0 to RESET or ERROR, bring the link back down. + * If we moved QP0 to RTR, bring the IB link up; if we moved + * QP0 to RESET or ERROR, bring the link back down. */ if (is_qp0(dev, qp)) { if (cur_state != IB_QPS_RTR && @@ -848,6 +858,26 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) mthca_CLOSE_IB(dev, to_msqp(qp)->port, &status); } + /* + * If we moved a kernel QP to RESET, clean up all old CQ + * entries and reinitialize the QP. + */ + if (!err && new_state == IB_QPS_RESET && !qp->ibqp.uobject) { + mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + if (qp->ibqp.send_cq != qp->ibqp.recv_cq) + mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + + mthca_wq_init(&qp->sq); + mthca_wq_init(&qp->rq); + + if (mthca_is_memfree(dev)) { + *qp->sq.db = 0; + *qp->rq.db = 0; + } + } + return err; } @@ -1003,16 +1033,6 @@ static void mthca_free_memfree(struct mthca_dev *dev, } } -static void mthca_wq_init(struct mthca_wq* wq) -{ - spin_lock_init(&wq->lock); - wq->next_ind = 0; - wq->last_comp = wq->max - 1; - wq->head = 0; - wq->tail = 0; - wq->last = NULL; -} - static int mthca_alloc_qp_common(struct mthca_dev *dev, struct mthca_pd *pd, struct mthca_cq *send_cq, -- cgit v1.2.3 From 30a7e8ef13b2ff0db7b15af9afdd12b93783f01e Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 7 Sep 2005 09:45:00 -0700 Subject: [PATCH] IB: Initialize qp->wait Add missing call to init_waitqueue_head(). Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mthca/mthca_qp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index c753f7375a5..bcef06bf15e 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -1044,6 +1044,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, int i; atomic_set(&qp->refcount, 1); + init_waitqueue_head(&qp->wait); qp->state = IB_QPS_RESET; qp->atomic_rd_en = 0; qp->resp_depth = 0; -- cgit v1.2.3 From b5dcbf47e10e568273213a4410daa27c11cdba3a Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Wed, 7 Sep 2005 11:03:41 -0700 Subject: [PATCH] IB: RMPP fixes - Fix payload length of middle RMPP sent segments. Middle payload lengths should be 0 on the send side. (This is perhaps a compliance and should not be an interop issue as middle payload lengths are supposed to be ignored on receive). - Fix length in first segment of multipacket sends (This is a compliance issue but does not affect at least OpenIB to OpenIB RMPP transfers). Signed-off-by: Hal Rosenstock Signed-off-by: Roland Dreier --- drivers/infiniband/core/mad_rmpp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 43fd805e026..2bd8b1cc57c 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c @@ -593,7 +593,8 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(mad_send_wr->total_seg * (sizeof(struct ib_rmpp_mad) - - offsetof(struct ib_rmpp_mad, data))); + offsetof(struct ib_rmpp_mad, data)) - + mad_send_wr->pad); mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); } else { mad_send_wr->send_wr.num_sge = 2; @@ -602,6 +603,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) mad_send_wr->sg_list[1].length = sizeof(struct ib_rmpp_mad) - mad_send_wr->data_offset; mad_send_wr->sg_list[1].lkey = mad_send_wr->sg_list[0].lkey; + rmpp_mad->rmpp_hdr.paylen_newwin = 0; } if (mad_send_wr->seg_num == mad_send_wr->total_seg) { -- cgit v1.2.3 From 17781cd6186cb3472ff34b2d9a15e647bd311e8b Mon Sep 17 00:00:00 2001 From: James Lentini Date: Wed, 7 Sep 2005 12:43:08 -0700 Subject: [PATCH] IB: clean up user access config options Add a new config option INFINIBAND_USER_MAD to control whether we build ib_umad. Change INFINIBAND_USER_VERBS to INFINIBAND_USER_ACCESS, and have it control ib_ucm and ib_uat as well as ib_uverbs. Signed-off-by: James Lentini Signed-off-by: Roland Dreier --- drivers/infiniband/Kconfig | 25 ++++++++++++++++++------- drivers/infiniband/core/Makefile | 5 +++-- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 32cdfb30e9b..325d502e25c 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig @@ -8,15 +8,26 @@ config INFINIBAND any protocols you wish to use as well as drivers for your InfiniBand hardware. -config INFINIBAND_USER_VERBS - tristate "InfiniBand userspace verbs support" +config INFINIBAND_USER_MAD + tristate "InfiniBand userspace MAD support" depends on INFINIBAND ---help--- - Userspace InfiniBand verbs support. This is the kernel side - of userspace verbs, which allows userspace processes to - directly access InfiniBand hardware for fast-path - operations. You will also need libibverbs and a hardware - driver library from . + Userspace InfiniBand Management Datagram (MAD) support. This + is the kernel side of the userspace MAD support, which allows + userspace processes to send and receive MADs. You will also + need libibumad from . + +config INFINIBAND_USER_ACCESS + tristate "InfiniBand userspace access (verbs and CM)" + depends on INFINIBAND + ---help--- + Userspace InfiniBand access support. This enables the + kernel side of userspace verbs and the userspace + communication manager (CM). This allows userspace processes + to set up connections and directly access InfiniBand + hardware for fast-path operations. You will also need + libibverbs, libibcm and a hardware driver library from + . source "drivers/infiniband/hw/mthca/Kconfig" diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile index 678a7e097f3..ec3353f24b2 100644 --- a/drivers/infiniband/core/Makefile +++ b/drivers/infiniband/core/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ - ib_cm.o ib_umad.o ib_ucm.o -obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o + ib_cm.o +obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o +obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ device.o fmr_pool.o cache.o -- cgit v1.2.3 From 6f0d618f0e9b8025d1c3531e82d7cc8455e79394 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 16:17:58 +0100 Subject: [SERIAL] Spelling fix in 8250.c Signed-off-by: Russell King --- drivers/serial/8250.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 5b65e208893..4d75cdfa0a0 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -864,7 +864,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) /* * We're pretty sure there's a port here. Lets find out what * type of port it is. The IIR top two bits allows us to find - * out if its 8250 or 16450, 16550, 16550A or later. This + * out if it's 8250 or 16450, 16550, 16550A or later. This * determines what we test for next. * * We also initialise the EFR (if any) to zero for later. The -- cgit v1.2.3 From 7bcf5c0e7fd9ab4ddb9e24d7e91bda2ac23e5678 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Aug 2005 14:33:01 +1000 Subject: [PATCH] PCI: move pci core to use add_hotplug_env_var() This fixes a bug in the environment variables for all PCI device hotplug calls. Thanks to Kay Sievers for pointing out the problem. Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug.c | 53 ++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index b844bc97232..10444988a10 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c @@ -20,46 +20,35 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, scratch = buffer; - /* stuff we want to pass to /sbin/hotplug */ - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", - pdev->class); - if ((buffer_size - length <= 0) || (i >= num_envp)) + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_CLASS=%04X", pdev->class)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", - pdev->vendor, pdev->device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, - pdev->subsystem_device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, + pdev->subsystem_device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", - pci_name(pdev)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SLOT_NAME=%s", pci_name(pdev))) return -ENOMEM; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", - pdev->vendor, pdev->device, - pdev->subsystem_vendor, pdev->subsystem_device, - (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), - (u8)(pdev->class)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", + pdev->vendor, pdev->device, + pdev->subsystem_vendor, pdev->subsystem_device, + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), + (u8)(pdev->class))) return -ENOMEM; envp[i] = NULL; -- cgit v1.2.3 From f5ee56cc184e0944ebc9ff1691985219959596f6 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 9 Sep 2005 13:01:32 -0700 Subject: [PATCH] txx9 serial update Support for the new RBHMA4500 eval board for the TX4938. General update from the 8250 ancestor of this driver. Replace use of deprecated interfaces. Signed-off-by: Ralf Baechle Signed-off-by: Atsushi Nemoto Acked-by: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/serial_txx9.c | 118 +++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 27 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 49afadbe461..f10c86d60b6 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c @@ -31,6 +31,8 @@ * 1.01 Set fifosize to make tx_empry called properly. * Use standard uart_get_divisor. * 1.02 Cleanup. (import 8250.c changes) + * 1.03 Fix low-latency mode. (import 8250.c changes) + * 1.04 Remove usage of deprecated functions, cleanup. */ #include @@ -54,7 +56,7 @@ #include #include -static char *serial_version = "1.02"; +static char *serial_version = "1.04"; static char *serial_name = "TX39/49 Serial driver"; #define PASS_LIMIT 256 @@ -86,9 +88,9 @@ static char *serial_name = "TX39/49 Serial driver"; */ #ifdef ENABLE_SERIAL_TXX9_PCI #define NR_PCI_BOARDS 4 -#define UART_NR (2 + NR_PCI_BOARDS) +#define UART_NR (4 + NR_PCI_BOARDS) #else -#define UART_NR 2 +#define UART_NR 4 #endif struct uart_txx9_port { @@ -304,8 +306,11 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r /* The following is not allowed by the tty layer and unsafe. It should be fixed ASAP */ if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if(tty->low_latency) + if (tty->low_latency) { + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); + } /* If this failed then we will throw away the bytes but must do so to clear interrupts */ } @@ -356,7 +361,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r ignore_char: disr = sio_in(up, TXX9_SIDISR); } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); *status = disr; } @@ -667,17 +674,8 @@ serial_txx9_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) { struct uart_txx9_port *up = (struct uart_txx9_port *)port; - if (state) { - /* sleep */ - - if (up->pm) - up->pm(port, state, oldstate); - } else { - /* wake */ - - if (up->pm) - up->pm(port, state, oldstate); - } + if (up->pm) + up->pm(port, state, oldstate); } static int serial_txx9_request_resource(struct uart_txx9_port *up) @@ -979,14 +977,6 @@ static int __init serial_txx9_console_init(void) } console_initcall(serial_txx9_console_init); -static int __init serial_txx9_late_console_init(void) -{ - if (!(serial_txx9_console.flags & CON_ENABLED)) - register_console(&serial_txx9_console); - return 0; -} -late_initcall(serial_txx9_late_console_init); - #define SERIAL_TXX9_CONSOLE &serial_txx9_console #else #define SERIAL_TXX9_CONSOLE NULL @@ -1039,6 +1029,73 @@ static void serial_txx9_resume_port(int line) uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); } +static DECLARE_MUTEX(serial_txx9_sem); + +/** + * serial_txx9_register_port - register a serial port + * @port: serial port template + * + * Configure the serial port specified by the request. + * + * The port is then probed and if necessary the IRQ is autodetected + * If this fails an error is returned. + * + * On success the port is ready to use and the line number is returned. + */ +static int __devinit serial_txx9_register_port(struct uart_port *port) +{ + int i; + struct uart_txx9_port *uart; + int ret = -ENOSPC; + + down(&serial_txx9_sem); + for (i = 0; i < UART_NR; i++) { + uart = &serial_txx9_ports[i]; + if (uart->port.type == PORT_UNKNOWN) + break; + } + if (i < UART_NR) { + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.iobase = port->iobase; + uart->port.membase = port->membase; + uart->port.irq = port->irq; + uart->port.uartclk = port->uartclk; + uart->port.iotype = port->iotype; + uart->port.flags = port->flags | UPF_BOOT_AUTOCONF; + uart->port.mapbase = port->mapbase; + if (port->dev) + uart->port.dev = port->dev; + ret = uart_add_one_port(&serial_txx9_reg, &uart->port); + if (ret == 0) + ret = uart->port.line; + } + up(&serial_txx9_sem); + return ret; +} + +/** + * serial_txx9_unregister_port - remove a txx9 serial port at runtime + * @line: serial line number + * + * Remove one serial port. This may not be called from interrupt + * context. We hand the port back to the our control. + */ +static void __devexit serial_txx9_unregister_port(int line) +{ + struct uart_txx9_port *uart = &serial_txx9_ports[line]; + + down(&serial_txx9_sem); + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.flags = 0; + uart->port.type = PORT_UNKNOWN; + uart->port.iobase = 0; + uart->port.mapbase = 0; + uart->port.membase = 0; + uart->port.dev = NULL; + uart_add_one_port(&serial_txx9_reg, &uart->port); + up(&serial_txx9_sem); +} + /* * Probe one serial board. Unfortunately, there is no rhyme nor reason * to the arrangement of serial ports on a PCI card. @@ -1056,13 +1113,13 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent) memset(&port, 0, sizeof(port)); port.ops = &serial_txx9_pops; - port.flags |= UPF_BOOT_AUTOCONF; /* uart_ops.config_port will be called */ port.flags |= UPF_TXX9_HAVE_CTS_LINE; port.uartclk = 66670000; port.irq = dev->irq; port.iotype = UPIO_PORT; port.iobase = pci_resource_start(dev, 1); - line = uart_register_port(&serial_txx9_reg, &port); + port.dev = &dev->dev; + line = serial_txx9_register_port(&port); if (line < 0) { printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), line); } @@ -1078,7 +1135,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev) pci_set_drvdata(dev, NULL); if (line) { - uart_unregister_port(&serial_txx9_reg, line); + serial_txx9_unregister_port(line); pci_disable_device(dev); } } @@ -1089,6 +1146,8 @@ static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) if (line) serial_txx9_suspend_port(line); + pci_save_state(dev); + pci_set_power_state(dev, pci_choose_state(dev, state)); return 0; } @@ -1096,8 +1155,13 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev) { int line = (int)(long)pci_get_drvdata(dev); - if (line) + pci_set_power_state(dev, PCI_D0); + pci_restore_state(dev); + + if (line) { + pci_enable_device(dev); serial_txx9_resume_port(line); + } return 0; } -- cgit v1.2.3 From ff55fe2075e3901db4dbdc00e0b44a71bef97afd Mon Sep 17 00:00:00 2001 From: Jason Baron Date: Fri, 9 Sep 2005 13:01:57 -0700 Subject: [PATCH] pty_chars_in_buffer oops fix The idea of this patch is to lock both sides of a ptmx/pty pair during line discipline changing. This is needed to ensure that say a poll on one side of the pty doesn't occur while the line discipline is actively being changed. This resulted in an oops reported on lkml, see: http://marc.theaimsgroup.com/?l=linux-kernel&m=111342171410005&w=2 A 'hacky' approach was previously implmemented which served to eliminate the poll vs. line discipline changing race. However, this patch takes a more general approach to the issue. The patch only adds locking on a less often used path, the line-discipline changing path, as opposed to locking the ptmx/pty pair on read/write/poll paths. The patch below, takes both ldisc locks in either order b/c the locks are both taken under the same spinlock(). I thought about locking the ptmx/pty separately, such as master always first but that introduces a 3 way deadlock. For example, process 1 does a blocking read on the slave side. Then, process 2 does an ldisc change on the slave side, which acquires the master ldisc lock but not the slave's. Finally, process 3 does a write which blocks on the process 2's ldisc reference. This patch does introduce some changes in semantics. For example, a line discipline change on side 'a' of a ptmx/pty pair, will now wait for a read/write to complete on the other side, or side 'b'. The current behavior is to simply wait for any read/writes on only side 'a', not both sides 'a' and 'b'. I think this behavior makes sense, but I wanted to point it out. I've tested the patch with a bunch of read/write/poll while changing the line discipline out from underneath. This patch obviates the need for the above "hide the problem" patch. Signed-off-by: Jason Baron Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pty.c | 5 ++-- drivers/char/tty_io.c | 79 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/char/pty.c b/drivers/char/pty.c index da32889d22c..49f3997fd25 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -149,15 +149,14 @@ static int pty_write_room(struct tty_struct *tty) static int pty_chars_in_buffer(struct tty_struct *tty) { struct tty_struct *to = tty->link; - ssize_t (*chars_in_buffer)(struct tty_struct *); int count; /* We should get the line discipline lock for "tty->link" */ - if (!to || !(chars_in_buffer = to->ldisc.chars_in_buffer)) + if (!to || !to->ldisc.chars_in_buffer) return 0; /* The ldisc must report 0 if no characters available to be read */ - count = chars_in_buffer(to); + count = to->ldisc.chars_in_buffer(to); if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9d657127f31..6a56ae4f772 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -469,21 +469,19 @@ static void tty_ldisc_enable(struct tty_struct *tty) static int tty_set_ldisc(struct tty_struct *tty, int ldisc) { - int retval = 0; - struct tty_ldisc o_ldisc; + int retval = 0; + struct tty_ldisc o_ldisc; char buf[64]; int work; unsigned long flags; struct tty_ldisc *ld; + struct tty_struct *o_tty; if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) return -EINVAL; restart: - if (tty->ldisc.num == ldisc) - return 0; /* We are already in the desired discipline */ - ld = tty_ldisc_get(ldisc); /* Eduardo Blanco */ /* Cyrus Durgin */ @@ -494,45 +492,74 @@ restart: if (ld == NULL) return -EINVAL; - o_ldisc = tty->ldisc; - tty_wait_until_sent(tty, 0); + if (tty->ldisc.num == ldisc) { + tty_ldisc_put(ldisc); + return 0; + } + + o_ldisc = tty->ldisc; + o_tty = tty->link; + /* * Make sure we don't change while someone holds a * reference to the line discipline. The TTY_LDISC bit * prevents anyone taking a reference once it is clear. * We need the lock to avoid racing reference takers. */ - + spin_lock_irqsave(&tty_ldisc_lock, flags); - if(tty->ldisc.refcount) - { - /* Free the new ldisc we grabbed. Must drop the lock - first. */ + if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { + if(tty->ldisc.refcount) { + /* Free the new ldisc we grabbed. Must drop the lock + first. */ + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + /* + * There are several reasons we may be busy, including + * random momentary I/O traffic. We must therefore + * retry. We could distinguish between blocking ops + * and retries if we made tty_ldisc_wait() smarter. That + * is up for discussion. + */ + if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + if(o_tty && o_tty->ldisc.refcount) { + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + } + + /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ + + if (!test_bit(TTY_LDISC, &tty->flags)) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); tty_ldisc_put(ldisc); - /* - * There are several reasons we may be busy, including - * random momentary I/O traffic. We must therefore - * retry. We could distinguish between blocking ops - * and retries if we made tty_ldisc_wait() smarter. That - * is up for discussion. - */ - if(wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) - return -ERESTARTSYS; + ld = tty_ldisc_ref_wait(tty); + tty_ldisc_deref(ld); goto restart; } - clear_bit(TTY_LDISC, &tty->flags); + + clear_bit(TTY_LDISC, &tty->flags); clear_bit(TTY_DONT_FLIP, &tty->flags); + if (o_tty) { + clear_bit(TTY_LDISC, &o_tty->flags); + clear_bit(TTY_DONT_FLIP, &o_tty->flags); + } spin_unlock_irqrestore(&tty_ldisc_lock, flags); - + /* * From this point on we know nobody has an ldisc * usage reference, nor can they obtain one until * we say so later on. */ - + work = cancel_delayed_work(&tty->flip.work); /* * Wait for ->hangup_work and ->flip.work handlers to terminate @@ -583,10 +610,12 @@ restart: */ tty_ldisc_enable(tty); + if (o_tty) + tty_ldisc_enable(o_tty); /* Restart it in case no characters kick it off. Safe if already running */ - if(work) + if (work) schedule_delayed_work(&tty->flip.work, 1); return retval; } -- cgit v1.2.3 From 28254d439b8c65f93cb331f5aa741efa6a8ec62f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 9 Sep 2005 13:01:58 -0700 Subject: [PATCH] vga text console and stty cols/rows Some people use 66-cells braille devices for reading the console, and hence would like to reduce the width of the screen by using: stty cols 66 However, the vga text console doesn't behave correctly: the 14 first characters of the second line are put on the right of the first line and so forth. Here is a patch to correct that. It corrects the disp_end and offset registers of the vga board on console resize and console switch. On usual screens, you then correctly get a right and/or bottom blank margin. On some laptop panels, the output is resized so that text actually gets magnified, which can be great for some people (see http://dept-info.labri.fr/~thibault/ls.jpg ). Signed-off-by: Samuel Thibault Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/console/vgacon.c | 71 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index d27fa91e588..0705cd74141 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -497,6 +497,57 @@ static void vgacon_cursor(struct vc_data *c, int mode) } } +static int vgacon_doresize(struct vc_data *c, + unsigned int width, unsigned int height) +{ + unsigned long flags; + unsigned int scanlines = height * c->vc_font.height; + u8 scanlines_lo, r7, vsync_end, mode; + + spin_lock_irqsave(&vga_lock, flags); + + outb_p(VGA_CRTC_MODE, vga_video_port_reg); + mode = inb_p(vga_video_port_val); + + if (mode & 0x04) + scanlines >>= 1; + + scanlines -= 1; + scanlines_lo = scanlines & 0xff; + + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + r7 = inb_p(vga_video_port_val) & ~0x42; + + if (scanlines & 0x100) + r7 |= 0x02; + if (scanlines & 0x200) + r7 |= 0x40; + + /* deprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + vsync_end = inb_p(vga_video_port_val); + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end & ~0x80, vga_video_port_val); + + outb_p(VGA_CRTC_H_DISP, vga_video_port_reg); + outb_p(width - 1, vga_video_port_val); + outb_p(VGA_CRTC_OFFSET, vga_video_port_reg); + outb_p(width >> 1, vga_video_port_val); + + outb_p(VGA_CRTC_V_DISP_END, vga_video_port_reg); + outb_p(scanlines_lo, vga_video_port_val); + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + outb_p(r7,vga_video_port_val); + + /* reprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end, vga_video_port_val); + + spin_unlock_irqrestore(&vga_lock, flags); + + return 0; +} + static int vgacon_switch(struct vc_data *c) { /* @@ -510,9 +561,13 @@ static int vgacon_switch(struct vc_data *c) /* We can only copy out the size of the video buffer here, * otherwise we get into VGA BIOS */ - if (!vga_is_gfx) + if (!vga_is_gfx) { scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, - c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); + c->vc_screenbuf_size > vga_vram_size ? + vga_vram_size : c->vc_screenbuf_size); + vgacon_doresize(c, c->vc_cols, c->vc_rows); + } + return 0; /* Redrawing not needed */ } @@ -962,6 +1017,17 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font) #endif +static int vgacon_resize(struct vc_data *c, unsigned int width, + unsigned int height) +{ + if (width % 2 || width > ORIG_VIDEO_COLS || height > ORIG_VIDEO_LINES) + return -EINVAL; + + if (CON_IS_VISIBLE(c) && !vga_is_gfx) /* who knows */ + vgacon_doresize(c, width, height); + return 0; +} + static int vgacon_scrolldelta(struct vc_data *c, int lines) { if (!lines) /* Turn scrollback off */ @@ -1103,6 +1169,7 @@ const struct consw vga_con = { .con_blank = vgacon_blank, .con_font_set = vgacon_font_set, .con_font_get = vgacon_font_get, + .con_resize = vgacon_resize, .con_set_palette = vgacon_set_palette, .con_scrolldelta = vgacon_scrolldelta, .con_set_origin = vgacon_set_origin, -- cgit v1.2.3 From 6f519165a97924ab3eeb99f388718d12ff97f1f4 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Fri, 9 Sep 2005 13:02:07 -0700 Subject: [PATCH] cs89x0: add netpoll support Signed-off-by: Deepak Saxena Cc: Matt Mackall Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/cs89x0.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers') diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index b780307093e..cdc07ccd733 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -247,6 +247,9 @@ static int get_eeprom_data(struct net_device *dev, int off, int len, int *buffer static int get_eeprom_cksum(int off, int len, int *buffer); static int set_mac_address(struct net_device *dev, void *addr); static void count_rx_errors(int status, struct net_local *lp); +#ifdef CONFIG_NET_POLL_CONTROLLER +static void net_poll_controller(struct net_device *dev); +#endif #if ALLOW_DMA static void get_dma_channel(struct net_device *dev); static void release_dma_buff(struct net_local *lp); @@ -405,6 +408,19 @@ get_eeprom_cksum(int off, int len, int *buffer) return -1; } +#ifdef CONFIG_NET_POLL_CONTROLLER +/* + * Polling receive - used by netconsole and other diagnostic tools + * to allow network i/o with interrupts disabled. + */ +static void net_poll_controller(struct net_device *dev) +{ + disable_irq(dev->irq); + net_interrupt(dev->irq, dev, NULL); + enable_irq(dev->irq); +} +#endif + /* This is the real probe routine. Linux has a history of friendly device probes on the ISA bus. A good device probes avoids doing writes, and verifies that the correct device exists and functions. @@ -760,6 +776,9 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) dev->get_stats = net_get_stats; dev->set_multicast_list = set_multicast_list; dev->set_mac_address = set_mac_address; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = net_poll_controller; +#endif printk("\n"); if (net_debug) -- cgit v1.2.3 From 9d5c1e1bf2b906966609f8cf4a844e61adb86bcd Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 9 Sep 2005 13:02:12 -0700 Subject: [PATCH] deadline: clean up question mark operator That ?: trick gives us the creeps. Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/deadline-iosched.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 24594c57c32..52a3ae5289a 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c @@ -512,7 +512,10 @@ static int deadline_dispatch_requests(struct deadline_data *dd) /* * batches are currently reads XOR writes */ - drq = dd->next_drq[WRITE] ? : dd->next_drq[READ]; + if (dd->next_drq[WRITE]) + drq = dd->next_drq[WRITE]; + else + drq = dd->next_drq[READ]; if (drq) { /* we have a "next request" */ -- cgit v1.2.3 From 4a918bc233c8b9537fbc05a8bbb33928a4980cc5 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:12 -0700 Subject: [PATCH] synclink.c: compiler optimisation fix Make some fields of DMA descriptor volatile to prevent compiler optimizations. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 37c8bea8e2b..747eb8d1816 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1,7 +1,7 @@ /* * linux/drivers/char/synclink.c * - * $Id: synclink.c,v 4.28 2004/08/11 19:30:01 paulkf Exp $ + * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $ * * Device driver for Microgate SyncLink ISA and PCI * high speed multiprotocol serial adapters. @@ -141,9 +141,9 @@ static MGSL_PARAMS default_params = { typedef struct _DMABUFFERENTRY { u32 phys_addr; /* 32-bit flat physical address of data buffer */ - u16 count; /* buffer size/data count */ - u16 status; /* Control/status field */ - u16 rcc; /* character count field */ + volatile u16 count; /* buffer size/data count */ + volatile u16 status; /* Control/status field */ + volatile u16 rcc; /* character count field */ u16 reserved; /* padding required by 16C32 */ u32 link; /* 32-bit flat link to next buffer entry */ char *virt_addr; /* virtual address of data buffer */ @@ -896,7 +896,7 @@ module_param_array(txdmabufs, int, NULL, 0); module_param_array(txholdbufs, int, NULL, 0); static char *driver_name = "SyncLink serial driver"; -static char *driver_version = "$Revision: 4.28 $"; +static char *driver_version = "$Revision: 4.37 $"; static int synclink_init_one (struct pci_dev *dev, const struct pci_device_id *ent); -- cgit v1.2.3 From 9661239f7f698ba3a79db5e8ab5bb2f4090663d9 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:13 -0700 Subject: [PATCH] synclink.c: add clear stats Add the ability to clear statistics. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 747eb8d1816..26b421b74bb 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1814,6 +1814,8 @@ static int startup(struct mgsl_struct * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + init_timer(&info->tx_timer); info->tx_timer.data = (unsigned long)info; info->tx_timer.function = mgsl_tx_timeout; @@ -2470,12 +2472,12 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user * printk("%s(%d):mgsl_get_params(%s)\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):mgsl_get_stats(%s) user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; -- cgit v1.2.3 From 7c1fff58cfaaf1c4b6a31a569e18cb7d2d8db0a6 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:14 -0700 Subject: [PATCH] synclink.c: add loopback to async mode Add internal loopback support for asynchronous mode operation. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclink.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 26b421b74bb..ea2d54be484 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -6151,6 +6151,11 @@ static void usc_set_async_mode( struct mgsl_struct *info ) usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) & ~BIT12)); } + if (info->params.loopback) { + info->loopback_bits = 0x300; + outw(0x0300, info->io_base + CCAR); + } + } /* end of usc_set_async_mode() */ /* usc_loopback_frame() -- cgit v1.2.3 From 7f3edb94564d319cd58cc11c2c986b7ec25643d8 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:14 -0700 Subject: [PATCH] synclinkmp.c: fix double mapping of signals Serial signals were incorrectly mapped twice to events. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclinkmp.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 8982eafd0fb..1bde04d66cd 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -1,5 +1,5 @@ /* - * $Id: synclinkmp.c,v 4.34 2005/03/04 15:07:10 paulkf Exp $ + * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $ * * Device driver for Microgate SyncLink Multiport * high speed multiprotocol serial adapter. @@ -486,7 +486,7 @@ module_param_array(maxframe, int, NULL, 0); module_param_array(dosyncppp, int, NULL, 0); static char *driver_name = "SyncLink MultiPort driver"; -static char *driver_version = "$Revision: 4.34 $"; +static char *driver_version = "$Revision: 4.38 $"; static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); static void synclinkmp_remove_one(struct pci_dev *dev); @@ -555,7 +555,6 @@ static int set_txidle(SLMP_INFO *info, int idle_mode); static int tx_enable(SLMP_INFO *info, int enable); static int tx_abort(SLMP_INFO *info); static int rx_enable(SLMP_INFO *info, int enable); -static int map_status(int signals); static int modem_input_wait(SLMP_INFO *info,int arg); static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); @@ -3108,16 +3107,6 @@ static int rx_enable(SLMP_INFO * info, int enable) return 0; } -static int map_status(int signals) -{ - /* Map status bits to API event bits */ - - return ((signals & SerialSignal_DSR) ? MgslEvent_DsrActive : MgslEvent_DsrInactive) + - ((signals & SerialSignal_CTS) ? MgslEvent_CtsActive : MgslEvent_CtsInactive) + - ((signals & SerialSignal_DCD) ? MgslEvent_DcdActive : MgslEvent_DcdInactive) + - ((signals & SerialSignal_RI) ? MgslEvent_RiActive : MgslEvent_RiInactive); -} - /* wait for specified event to occur */ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) @@ -3144,7 +3133,7 @@ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) /* return immediately if state matches requested events */ get_signals(info); - s = map_status(info->serial_signals); + s = info->serial_signals; events = mask & ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) + -- cgit v1.2.3 From 761a444d8d059e4e2de326383b1dec4a636e0a92 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:15 -0700 Subject: [PATCH] synclinkmp.c: disable burst transfers Disable burst transfers on adapter local bus. Hardware feature does not work on latest version of adapter. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclinkmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 1bde04d66cd..d55dbf1f9e1 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -643,7 +643,7 @@ static unsigned char tx_active_fifo_level = 16; // tx request FIFO activation le static unsigned char tx_negate_fifo_level = 32; // tx request FIFO negation level in bytes static u32 misc_ctrl_value = 0x007e4040; -static u32 lcr1_brdr_value = 0x00800029; +static u32 lcr1_brdr_value = 0x00800028; static u32 read_ahead_count = 8; -- cgit v1.2.3 From 166692e4a045348109f66b493e1b41afde6f3769 Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:16 -0700 Subject: [PATCH] synclinkmp.c: add statistics clear Add ability to clear statistics. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclinkmp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index d55dbf1f9e1..eb31a3b865d 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -2748,6 +2748,8 @@ static int startup(SLMP_INFO * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + /* program hardware for current parameters */ reset_port(info); @@ -2951,12 +2953,12 @@ static int get_stats(SLMP_INFO * info, struct mgsl_icount __user *user_icount) printk("%s(%d):%s get_params()\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):%s get_stats() user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; -- cgit v1.2.3 From 6e8dcee3e63f5a2cba4affff4bbb6e228f4b258a Mon Sep 17 00:00:00 2001 From: Paul Fulghum Date: Fri, 9 Sep 2005 13:02:17 -0700 Subject: [PATCH] synclinkmp.c: fix async internal loopback Fix async internal loopback by not using enable_loopback function which reprograms clocking and should only be used for hdlc mode. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/synclinkmp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index eb31a3b865d..6fb165cf8a6 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -4479,11 +4479,13 @@ void async_mode(SLMP_INFO *info) /* MD2, Mode Register 2 * * 07..02 Reserved, must be 0 - * 01..00 CNCT<1..0> Channel connection, 0=normal + * 01..00 CNCT<1..0> Channel connection, 00=normal 11=local loopback * * 0000 0000 */ RegValue = 0x00; + if (info->params.loopback) + RegValue |= (BIT1 + BIT0); write_reg(info, MD2, RegValue); /* RXS, Receive clock source @@ -4564,9 +4566,6 @@ void async_mode(SLMP_INFO *info) write_reg(info, IE2, info->ie2_value); set_rate( info, info->params.data_rate * 16 ); - - if (info->params.loopback) - enable_loopback(info,1); } /* Program the SCA for HDLC communications. -- cgit v1.2.3 From a8d995c99ef56a3dbcdbe291bb71658bf00e9ad6 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:19 -0700 Subject: [PATCH] dvb: email address update Update email address of Peter Hettkamp. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/bt878.c | 2 +- drivers/media/dvb/bt8xx/bt878.h | 2 +- drivers/media/dvb/bt8xx/dvb-bt8xx.h | 2 +- drivers/media/dvb/frontends/cx24110.c | 2 +- drivers/media/dvb/frontends/cx24110.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3c5a8e273c4..3bfbba3d9df 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -1,7 +1,7 @@ /* * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card * - * Copyright (C) 2002 Peter Hettkamp + * Copyright (C) 2002 Peter Hettkamp * * large parts based on the bttv driver * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h index 837623f7fcd..a73baf00ca3 100644 --- a/drivers/media/dvb/bt8xx/bt878.h +++ b/drivers/media/dvb/bt8xx/bt878.h @@ -1,7 +1,7 @@ /* bt878.h - Bt878 audio module (register offsets) - Copyright (C) 2002 Peter Hettkamp + Copyright (C) 2002 Peter Hettkamp 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 diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index 2923b3b0dd3..9ec8e5bd6c1 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h @@ -2,7 +2,7 @@ * Bt8xx based DVB adapter driver * * Copyright (C) 2002,2003 Florian Schirmer - * Copyright (C) 2002 Peter Hettkamp + * Copyright (C) 2002 Peter Hettkamp * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH * Copyright (C) 1998,1999 Christian Theiss * diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 8222b88cb48..555d472e42d 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp based on + Copyright (C) 2002 Peter Hettkamp based on work Copyright (C) 1999 Convergence Integrated Media GmbH diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index 6b663f4744e..b63ecf26421 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp based on + Copyright (C) 2002 Peter Hettkamp based on work Copyright (C) 1999 Convergence Integrated Media GmbH -- cgit v1.2.3 From 34f7373aaec80564cc87b7829e4e2a0e3c20c4b7 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 9 Sep 2005 13:02:20 -0700 Subject: [PATCH] dvb: remove version.h dependencies Remove all #include and all references to LINUX_VERSION_CODE and KERNEL_VERSION. Based on patch by Olaf Hering. Signed-off-by: Olaf Hering Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/common/saa7146_fops.c | 1 - drivers/media/common/saa7146_i2c.c | 5 ----- drivers/media/dvb/cinergyT2/cinergyT2.c | 1 - drivers/media/dvb/dvb-core/dvb_net.c | 5 ----- drivers/media/dvb/frontends/dib3000mb.c | 1 - drivers/media/dvb/frontends/dib3000mc.c | 1 - drivers/media/dvb/ttusb-dec/ttusb_dec.c | 1 - 7 files changed, 15 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c04fd11526e..37888989ea2 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c @@ -1,5 +1,4 @@ #include -#include #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 6284894505c..45f86737699 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -1,4 +1,3 @@ -#include #include static u32 saa7146_i2c_func(struct i2c_adapter *adapter) @@ -402,12 +401,8 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c saa7146_i2c_reset(dev); if( NULL != i2c_adapter ) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - i2c_adapter->data = dev; -#else BUG_ON(!i2c_adapter->class); i2c_set_adapdata(i2c_adapter,dev); -#endif i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; i2c_adapter->id = I2C_HW_SAA7146; diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 9ea5747b121..c52e9d5c3d9 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6a968c346a3..33a357c48a1 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -62,7 +62,6 @@ #include #include #include -#include #include "dvb_demux.h" #include "dvb_net.h" @@ -171,11 +170,7 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, skb->mac.raw=skb->data; skb_pull(skb,dev->hard_header_len); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8) - eth = skb->mac.ethernet; -#else eth = eth_hdr(skb); -#endif if (*eth->h_dest & 1) { if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c index cd434b7cf9d..21433e1831e 100644 --- a/drivers/media/dvb/frontends/dib3000mb.c +++ b/drivers/media/dvb/frontends/dib3000mb.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index cd33705a432..441de665fec 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c @@ -22,7 +22,6 @@ */ #include #include -#include #include #include #include diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 45c9a9a08e4..3d08fc83a75 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 3cc2176cbbee6adfaceac2df6d77312cf30cee83 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:20 -0700 Subject: [PATCH] dvb: avoid building empty built-in.o Don't build empty built-in.o when DVB/V4L is not configured. Thanks to Sam Ravnborg and Keith Owens. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 772d6112fb3..c578a529e7a 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile @@ -2,4 +2,7 @@ # Makefile for the kernel multimedia device drivers. # -obj-y := video/ radio/ dvb/ common/ +obj-y := common/ +obj-$(CONFIG_VIDEO_DEV) += video/ +obj-$(CONFIG_VIDEO_DEV) += radio/ +obj-$(CONFIG_DVB) += dvb/ -- cgit v1.2.3 From c05100528efe997a27d841230f9f5b2f4adf3d0f Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:21 -0700 Subject: [PATCH] dvb: core: glue code for DMX_GET_CAPS and DMX_SET_SOURCE Glue code for DMX_GET_CAPS and DMX_SET_SOURCE ioctls. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/demux.h | 5 +++++ drivers/media/dvb/dvb-core/dmxdev.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index fb55eaa5c8e..b86d03f5100 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -30,6 +30,7 @@ #include #include #include +#include /*--------------------------------------------------------------------------*/ /* Common definitions */ @@ -282,6 +283,10 @@ struct dmx_demux { int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); + int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); + + int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); + int (*get_stc) (struct dmx_demux* demux, unsigned int num, u64 *stc, unsigned int *base); }; diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 68050cd527c..6059562f4d4 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -929,6 +929,22 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg); break; + case DMX_GET_CAPS: + if (!dmxdev->demux->get_caps) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->get_caps(dmxdev->demux, parg); + break; + + case DMX_SET_SOURCE: + if (!dmxdev->demux->set_source) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->set_source(dmxdev->demux, parg); + break; + case DMX_GET_STC: if (!dmxdev->demux->get_stc) { ret=-EINVAL; -- cgit v1.2.3 From 1e0ae280e91a4f69b08770c6ab72808711dd4f2b Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:22 -0700 Subject: [PATCH] dvb: core: dvb_demux: fix continuity counter error handling Don't return immediately from dvb_dmx_swfilter_section_packet() if CC is not ok. Otherwise a new feed drops all packets until the first packet with CC=0 arrives. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/dvb_demux.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index ac9889d2228..3d18d3eebcf 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -336,7 +336,6 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 */ feed->pusi_seen = 0; dvb_dmx_swfilter_section_new(feed); - return 0; } if (buf[1] & 0x40) { -- cgit v1.2.3 From 936534676ef6c6af389eb9e61de7d725ee79a316 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:23 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove unused cruft Removed some useless functions and variables. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/demux.h | 13 ------------ drivers/media/dvb/dvb-core/dvb_demux.c | 39 ++-------------------------------- drivers/media/dvb/dvb-core/dvb_demux.h | 2 +- 3 files changed, 3 insertions(+), 51 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index b86d03f5100..608461f090f 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -245,7 +245,6 @@ struct dmx_frontend { struct dmx_demux { u32 capabilities; /* Bitfield of capability flags */ struct dmx_frontend* frontend; /* Front-end connected to the demux */ - struct list_head reg_list; /* List of registered demuxes */ void* priv; /* Pointer to private data of the API client */ int users; /* Number of users */ int (*open) (struct dmx_demux* demux); @@ -291,16 +290,4 @@ struct dmx_demux { u64 *stc, unsigned int *base); }; -/*--------------------------------------------------------------------------*/ -/* Demux directory */ -/*--------------------------------------------------------------------------*/ - -/* - * DMX_DIR_ENTRY(): Casts elements in the list of registered - * demuxes from the generic type struct list_head* to the type struct dmx_demux - *. - */ - -#define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list) - #endif /* #ifndef __DEMUX_H */ diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 3d18d3eebcf..8774a94ef01 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -39,33 +39,6 @@ // #define DVB_DEMUX_SECTION_LOSS_LOG -static LIST_HEAD(dmx_muxs); - - -static int dmx_register_demux(struct dmx_demux *demux) -{ - demux->users = 0; - list_add(&demux->reg_list, &dmx_muxs); - return 0; -} - -static int dmx_unregister_demux(struct dmx_demux* demux) -{ - struct list_head *pos, *n, *head=&dmx_muxs; - - list_for_each_safe (pos, n, head) { - if (DMX_DIR_ENTRY(pos) == demux) { - if (demux->users>0) - return -EINVAL; - list_del(pos); - return 0; - } - } - - return -ENODEV; -} - - /****************************************************************************** * static inlined helper functions ******************************************************************************/ @@ -1207,7 +1180,7 @@ static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) int dvb_dmx_init(struct dvb_demux *dvbdemux) { - int i, err; + int i; struct dmx_demux *dmx = &dvbdemux->dmx; dvbdemux->users = 0; @@ -1250,7 +1223,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dvbdemux->memcopy = dvb_dmx_memcopy; dmx->frontend = NULL; - dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list; dmx->priv = (void *) dvbdemux; dmx->open = dvbdmx_open; dmx->close = dvbdmx_close; @@ -1273,21 +1245,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) sema_init(&dvbdemux->mutex, 1); spin_lock_init(&dvbdemux->lock); - if ((err = dmx_register_demux(dmx)) < 0) - return err; - return 0; } EXPORT_SYMBOL(dvb_dmx_init); -int dvb_dmx_release(struct dvb_demux *dvbdemux) +void dvb_dmx_release(struct dvb_demux *dvbdemux) { - struct dmx_demux *dmx = &dvbdemux->dmx; - - dmx_unregister_demux(dmx); vfree(dvbdemux->filter); vfree(dvbdemux->feed); - return 0; } EXPORT_SYMBOL(dvb_dmx_release); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index c09beb39162..20275a2f6ec 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -138,7 +138,7 @@ struct dvb_demux { int dvb_dmx_init(struct dvb_demux *dvbdemux); -int dvb_dmx_release(struct dvb_demux *dvbdemux); +void dvb_dmx_release(struct dvb_demux *dvbdemux); void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); -- cgit v1.2.3 From 218721b8ef334a7c778fe3bc033922edef911a1f Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:24 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove unsused descramble callbacks Removed unused descramble_mac_address and descramble_section_payload callbacks. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/demux.h | 11 ----------- drivers/media/dvb/dvb-core/dvb_demux.c | 3 --- 2 files changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index 608461f090f..ee5be59759e 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -260,17 +260,6 @@ struct dmx_demux { dmx_section_cb callback); int (*release_section_feed) (struct dmx_demux* demux, struct dmx_section_feed* feed); - int (*descramble_mac_address) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, - size_t buffer2_length, - u16 pid); - int (*descramble_section_payload) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, size_t buffer2_length, - u16 pid); int (*add_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); int (*remove_frontend) (struct dmx_demux* demux, diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 8774a94ef01..6488206f54c 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -1232,9 +1232,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dmx->allocate_section_feed = dvbdmx_allocate_section_feed; dmx->release_section_feed = dvbdmx_release_section_feed; - dmx->descramble_mac_address = NULL; - dmx->descramble_section_payload = NULL; - dmx->add_frontend = dvbdmx_add_frontend; dmx->remove_frontend = dvbdmx_remove_frontend; dmx->get_frontends = dvbdmx_get_frontends; -- cgit v1.2.3 From 5d2cd1631e97f5eb9c8666ff9cd8011cd5c12e7d Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:24 -0700 Subject: [PATCH] dvb: core: dvb_demux: remove more unused cruft Removed more unused variables and constants. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/demux.h | 7 ------- drivers/media/dvb/dvb-core/dmxdev.c | 4 ++-- drivers/media/dvb/dvb-core/dvb_demux.c | 18 ++---------------- drivers/media/dvb/dvb-core/dvb_demux.h | 7 +------ drivers/media/dvb/dvb-core/dvb_net.c | 4 +--- 5 files changed, 6 insertions(+), 34 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index ee5be59759e..9719a3b30f7 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -125,9 +125,7 @@ struct dmx_ts_feed { u16 pid, int type, enum dmx_ts_pes pes_type, - size_t callback_length, size_t circular_buffer_size, - int descramble, struct timespec timeout); int (*start_filtering) (struct dmx_ts_feed* feed); int (*stop_filtering) (struct dmx_ts_feed* feed); @@ -160,7 +158,6 @@ struct dmx_section_feed { int (*set) (struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, - int descramble, int check_crc); int (*allocate_filter) (struct dmx_section_feed* feed, struct dmx_section_filter** filter); @@ -208,7 +205,6 @@ struct dmx_frontend { struct list_head connectivity_list; /* List of front-ends that can be connected to a particular demux */ - void* priv; /* Pointer to private data of the API client */ enum dmx_frontend_source source; }; @@ -226,8 +222,6 @@ struct dmx_frontend { #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ #define DMX_CRC_CHECKING 16 #define DMX_TS_DESCRAMBLING 32 -#define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 -#define DMX_MAC_ADDRESS_DESCRAMBLING 128 /* * Demux resource type identifier. @@ -246,7 +240,6 @@ struct dmx_demux { u32 capabilities; /* Bitfield of capability flags */ struct dmx_frontend* frontend; /* Front-end connected to the demux */ void* priv; /* Pointer to private data of the API client */ - int users; /* Number of users */ int (*open) (struct dmx_demux* demux); int (*close) (struct dmx_demux* demux); int (*write) (struct dmx_demux* demux, const char* buf, size_t count); diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 6059562f4d4..8028c3a5e28 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -571,7 +571,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) return ret; } - ret=(*secfeed)->set(*secfeed, para->pid, 32768, 0, + ret=(*secfeed)->set(*secfeed, para->pid, 32768, (para->flags & DMX_CHECK_CRC) ? 1 : 0); if (ret<0) { @@ -654,7 +654,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) (*tsfeed)->priv = (void *) filter; ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, - 188, 32768, 0, timeout); + 32768, timeout); if (ret < 0) { dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 6488206f54c..b9cb671b938 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -577,8 +577,7 @@ out: } static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, - enum dmx_ts_pes pes_type, size_t callback_length, - size_t circular_buffer_size, int descramble, + enum dmx_ts_pes pes_type, size_t circular_buffer_size, struct timespec timeout) { struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; @@ -610,17 +609,10 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, feed->pid = pid; feed->buffer_size = circular_buffer_size; - feed->descramble = descramble; feed->timeout = timeout; - feed->cb_length = callback_length; feed->ts_type = ts_type; feed->pes_type = pes_type; - if (feed->descramble) { - up(&demux->mutex); - return -ENOSYS; - } - if (feed->buffer_size) { #ifdef NOBUFS feed->buffer=NULL; @@ -819,7 +811,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, static int dmx_section_feed_set(struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, - int descramble, int check_crc) + int check_crc) { struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; @@ -834,12 +826,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, dvbdmxfeed->pid = pid; dvbdmxfeed->buffer_size = circular_buffer_size; - dvbdmxfeed->descramble = descramble; - if (dvbdmxfeed->descramble) { - up(&dvbdmx->mutex); - return -ENOSYS; - } - dvbdmxfeed->feed.sec.check_crc = check_crc; #ifdef NOBUFS diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index 20275a2f6ec..d149f2a96d0 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -54,12 +54,9 @@ struct dvb_demux_filter { int index; int state; int type; - int pesto; - u16 handle; u16 hw_handle; struct timer_list timer; - int ts_state; }; @@ -83,11 +80,9 @@ struct dvb_demux_feed { u16 pid; u8 *buffer; int buffer_size; - int descramble; struct timespec timeout; struct dvb_demux_filter *filter; - int cb_length; int ts_type; enum dmx_ts_pes pes_type; @@ -98,7 +93,7 @@ struct dvb_demux_feed { u16 peslen; struct list_head list_head; - int index; /* a unique index for each feed (can be used as hardware pid filter index) */ + unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ }; struct dvb_demux { diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 33a357c48a1..87935490bfb 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -903,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev) return ret; } - ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1); + ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); if (ret<0) { printk("%s: could not set section feed\n", dev->name); @@ -955,9 +955,7 @@ static int dvb_net_feed_start(struct net_device *dev) priv->tsfeed->priv = (void *)dev; ret = priv->tsfeed->set(priv->tsfeed, priv->pid, TS_PACKET, DMX_TS_PES_OTHER, - 188 * 100, /* nr. of bytes delivered per callback */ 32768, /* circular buffer size */ - 0, /* descramble */ timeout); if (ret < 0) { -- cgit v1.2.3 From db574d7d6e38fe37bbb97e2b0a0363b5d2ffa203 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:26 -0700 Subject: [PATCH] dvb: core: dvb_demux: use INIT_LIST_HEAD Use INIT_LIST_HEAD for frontend_list. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/dvb_demux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index b9cb671b938..528ca463a6d 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -1188,9 +1188,9 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].index = i; } - dvbdemux->frontend_list.next= - dvbdemux->frontend_list.prev= - &dvbdemux->frontend_list; + + INIT_LIST_HEAD(&dvbdemux->frontend_list); + for (i=0; ipesfilter[i] = NULL; dvbdemux->pids[i] = 0xffff; -- cgit v1.2.3 From dad4a73071532448f6cee29791476494a8eb3a58 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:26 -0700 Subject: [PATCH] dvb: core: dvb_demux formatting fixes Formatting fixes (Lindent + some handwork). Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/dvb_demux.c | 469 ++++++++++++++++----------------- drivers/media/dvb/dvb-core/dvb_demux.h | 107 ++++---- 2 files changed, 283 insertions(+), 293 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 528ca463a6d..dc476dda2b7 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -38,55 +38,52 @@ */ // #define DVB_DEMUX_SECTION_LOSS_LOG - /****************************************************************************** * static inlined helper functions ******************************************************************************/ - static inline u16 section_length(const u8 *buf) { - return 3+((buf[1]&0x0f)<<8)+buf[2]; + return 3 + ((buf[1] & 0x0f) << 8) + buf[2]; } - static inline u16 ts_pid(const u8 *buf) { - return ((buf[1]&0x1f)<<8)+buf[2]; + return ((buf[1] & 0x1f) << 8) + buf[2]; } - static inline u8 payload(const u8 *tsp) { - if (!(tsp[3] & 0x10)) // no payload? + if (!(tsp[3] & 0x10)) // no payload? return 0; - if (tsp[3] & 0x20) { // adaptation field? - if (tsp[4] > 183) // corrupted data? + + if (tsp[3] & 0x20) { // adaptation field? + if (tsp[4] > 183) // corrupted data? return 0; else - return 184-1-tsp[4]; + return 184 - 1 - tsp[4]; } + return 184; } - -static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len) +static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len) { - return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len)); + return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len)); } - -static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len) +static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s, + size_t len) { - memcpy (d, s, len); + memcpy(d, s, len); } - /****************************************************************************** * Software filter functions ******************************************************************************/ -static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf) +static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, + const u8 *buf) { int count = payload(buf); int p; @@ -96,32 +93,31 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u if (count == 0) return -1; - p = 188-count; + p = 188 - count; /* - cc=buf[3]&0x0f; - ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0; - dvbdmxfeed->cc=cc; + cc = buf[3] & 0x0f; + ccok = ((feed->cc + 1) & 0x0f) == cc; + feed->cc = cc; if (!ccok) printk("missed packet!\n"); */ - if (buf[1] & 0x40) // PUSI ? + if (buf[1] & 0x40) // PUSI ? feed->peslen = 0xfffa; feed->peslen += count; - return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); + return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); } - -static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, - struct dvb_demux_filter *f) +static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed, + struct dvb_demux_filter *f) { u8 neq = 0; int i; - for (i=0; ifilter.filter_value[i] ^ feed->feed.sec.secbuf[i]; if (f->maskandmode[i] & xor) @@ -133,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, if (f->doneq && !neq) return 0; - return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen, - NULL, 0, &f->filter, DMX_OK); + return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen, + NULL, 0, &f->filter, DMX_OK); } - -static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) +static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed) { struct dvb_demux *demux = feed->demux; struct dvb_demux_filter *f = feed->filter; @@ -168,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) return 0; } - static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) { struct dmx_section_feed *sec = &feed->feed.sec; #ifdef DVB_DEMUX_SECTION_LOSS_LOG - if(sec->secbufp < sec->tsfeedp) - { + if (sec->secbufp < sec->tsfeedp) { int i, n = sec->tsfeedp - sec->secbufp; - /* section padding is done with 0xff bytes entirely. - ** due to speed reasons, we won't check all of them - ** but just first and last - */ - if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff) - { + /* + * Section padding is done with 0xff bytes entirely. + * Due to speed reasons, we won't check all of them + * but just first and last. + */ + if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) { printk("dvb_demux.c section ts padding loss: %d/%d\n", n, sec->tsfeedp); printk("dvb_demux.c pad data:"); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) printk(" %02x", sec->secbuf[i]); printk("\n"); } @@ -199,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) } /* -** Losless Section Demux 1.4.1 by Emard -** Valsecchi Patrick: -** - middle of section A (no PUSI) -** - end of section A and start of section B -** (with PUSI pointing to the start of the second section) -** -** In this case, without feed->pusi_seen you'll receive a garbage section -** consisting of the end of section A. Basically because tsfeedp -** is incemented and the use=0 condition is not raised -** when the second packet arrives. -** -** Fix: -** when demux is started, let feed->pusi_seen = 0 to -** prevent initial feeding of garbage from the end of -** previous section. When you for the first time see PUSI=1 -** then set feed->pusi_seen = 1 -*/ -static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) + * Losless Section Demux 1.4.1 by Emard + * Valsecchi Patrick: + * - middle of section A (no PUSI) + * - end of section A and start of section B + * (with PUSI pointing to the start of the second section) + * + * In this case, without feed->pusi_seen you'll receive a garbage section + * consisting of the end of section A. Basically because tsfeedp + * is incemented and the use=0 condition is not raised + * when the second packet arrives. + * + * Fix: + * when demux is started, let feed->pusi_seen = 0 to + * prevent initial feeding of garbage from the end of + * previous section. When you for the first time see PUSI=1 + * then set feed->pusi_seen = 1 + */ +static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, + const u8 *buf, u8 len) { struct dvb_demux *demux = feed->demux; struct dmx_section_feed *sec = &feed->feed.sec; u16 limit, seclen, n; - if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) + if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) return 0; - if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) - { + if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG printk("dvb_demux.c section buffer full loss: %d/%d\n", - sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE); + sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, + DMX_MAX_SECFEED_SIZE); #endif len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; } - if(len <= 0) + if (len <= 0) return 0; demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); sec->tsfeedp += len; - /* ----------------------------------------------------- - ** Dump all the sections we can find in the data (Emard) - */ - + /* + * Dump all the sections we can find in the data (Emard) + */ limit = sec->tsfeedp; - if(limit > DMX_MAX_SECFEED_SIZE) - return -1; /* internal error should never happen */ + if (limit > DMX_MAX_SECFEED_SIZE) + return -1; /* internal error should never happen */ /* to be sure always set secbuf */ sec->secbuf = sec->secbuf_base + sec->secbufp; - for(n = 0; sec->secbufp + 2 < limit; n++) - { + for (n = 0; sec->secbufp + 2 < limit; n++) { seclen = section_length(sec->secbuf); - if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE - || seclen + sec->secbufp > limit) + if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE + || seclen + sec->secbufp > limit) return 0; sec->seclen = seclen; sec->crc_val = ~0; /* dump [secbuf .. secbuf+seclen) */ - if(feed->pusi_seen) + if (feed->pusi_seen) dvb_dmx_swfilter_section_feed(feed); #ifdef DVB_DEMUX_SECTION_LOSS_LOG else printk("dvb_demux.c pusi not seen, discarding section data\n"); #endif - sec->secbufp += seclen; /* secbufp and secbuf moving together is */ - sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ + sec->secbufp += seclen; /* secbufp and secbuf moving together is */ + sec->secbuf += seclen; /* redundant but saves pointer arithmetic */ } return 0; } - -static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) +static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, + const u8 *buf) { u8 p, count; int ccok, dc_i = 0; @@ -282,10 +274,10 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 count = payload(buf); - if (count == 0) /* count == 0 if no payload or out of range */ + if (count == 0) /* count == 0 if no payload or out of range */ return -1; - p = 188 - count; /* payload start */ + p = 188 - count; /* payload start */ cc = buf[3] & 0x0f; ccok = ((feed->cc + 1) & 0x0f) == cc; @@ -299,51 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 if (!ccok || dc_i) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG - printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); - /* those bytes under sume circumstances will again be reported - ** in the following dvb_dmx_swfilter_section_new - */ + printk("dvb_demux.c discontinuity detected %d bytes lost\n", + count); + /* + * those bytes under sume circumstances will again be reported + * in the following dvb_dmx_swfilter_section_new + */ #endif - /* Discontinuity detected. Reset pusi_seen = 0 to - ** stop feeding of suspicious data until next PUSI=1 arrives - */ + /* + * Discontinuity detected. Reset pusi_seen = 0 to + * stop feeding of suspicious data until next PUSI=1 arrives + */ feed->pusi_seen = 0; dvb_dmx_swfilter_section_new(feed); } if (buf[1] & 0x40) { - // PUSI=1 (is set), section boundary is here + /* PUSI=1 (is set), section boundary is here */ if (count > 1 && buf[p] < count) { - const u8 *before = buf+p+1; + const u8 *before = &buf[p + 1]; u8 before_len = buf[p]; - const u8 *after = before+before_len; - u8 after_len = count-1-before_len; + const u8 *after = &before[before_len]; + u8 after_len = count - 1 - before_len; - dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); + dvb_dmx_swfilter_section_copy_dump(feed, before, + before_len); /* before start of new section, set pusi_seen = 1 */ feed->pusi_seen = 1; dvb_dmx_swfilter_section_new(feed); - dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); + dvb_dmx_swfilter_section_copy_dump(feed, after, + after_len); } #ifdef DVB_DEMUX_SECTION_LOSS_LOG - else - if (count > 0) - printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); + else if (count > 0) + printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); #endif } else { - // PUSI=0 (is not set), no section boundary - const u8 *entire = buf+p; - u8 entire_len = count; - - dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len); + /* PUSI=0 (is not set), no section boundary */ + dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count); } + return 0; } - -static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) +static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, + const u8 *buf) { - switch(feed->type) { + switch (feed->type) { case DMX_TYPE_TS: if (!feed->feed.ts.is_filtering) break; @@ -351,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (feed->ts_type & TS_PAYLOAD_ONLY) dvb_dmx_swfilter_payload(feed, buf); else - feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); + feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, + DMX_OK); } if (feed->ts_type & TS_DECODER) if (feed->demux->write_to_decoder) @@ -362,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (!feed->feed.sec.is_filtering) break; if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) - feed->feed.sec.seclen = feed->feed.sec.secbufp=0; + feed->feed.sec.seclen = feed->feed.sec.secbufp = 0; break; default: @@ -378,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) { struct dvb_demux_feed *feed; - struct list_head *pos, *head=&demux->feed_list; + struct list_head *pos, *head = &demux->feed_list; u16 pid = ts_pid(buf); int dvr_done = 0; @@ -404,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) } } -void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) +void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, + size_t count) { spin_lock(&demux->lock); while (count--) { - if(buf[0] == 0x47) { - dvb_dmx_swfilter_packet(demux, buf); - } + if (buf[0] == 0x47) + dvb_dmx_swfilter_packet(demux, buf); buf += 188; } spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_packets); +EXPORT_SYMBOL(dvb_dmx_swfilter_packets); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) { @@ -426,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=188-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 188 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; @@ -441,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) while (p < count) { if (buf[p] == 0x47) { - if (count-p >= 188) { - dvb_dmx_swfilter_packet(demux, buf+p); + if (count - p >= 188) { + dvb_dmx_swfilter_packet(demux, &buf[p]); p += 188; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else @@ -457,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } + EXPORT_SYMBOL(dvb_dmx_swfilter); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) { - int p = 0,i, j; + int p = 0, i, j; u8 tmppack[188]; + spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=204-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 204 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; } memcpy(&demux->tsbuf[i], buf, j); - if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8)) { + if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) { memcpy(tmppack, demux->tsbuf, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); } demux->tsbufp = 0; @@ -482,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) } while (p < count) { - if ((buf[p] == 0x47)|(buf[p] == 0xB8)) { - if (count-p >= 204) { - memcpy(tmppack, buf+p, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if ((buf[p] == 0x47) | (buf[p] == 0xB8)) { + if (count - p >= 204) { + memcpy(tmppack, &buf[p], 188); + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); p += 204; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else { @@ -502,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_204); +EXPORT_SYMBOL(dvb_dmx_swfilter_204); -static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) +static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux) { int i; - for (i=0; ifilternum; i++) + for (i = 0; i < demux->filternum; i++) if (demux->filter[i].state == DMX_STATE_FREE) break; @@ -521,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) return &demux->filter[i]; } -static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) +static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux) { int i; - for (i=0; ifeednum; i++) + for (i = 0; i < demux->feednum; i++) if (demux->feed[i].state == DMX_STATE_FREE) break; @@ -553,7 +556,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (dvb_demux_feed_find(feed)) { printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -567,7 +570,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (!(dvb_demux_feed_find(feed))) { printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -576,17 +579,17 @@ out: spin_unlock_irq(&feed->demux->lock); } -static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, - enum dmx_ts_pes pes_type, size_t circular_buffer_size, - struct timespec timeout) +static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, + enum dmx_ts_pes pes_type, + size_t circular_buffer_size, struct timespec timeout) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; if (pid > DMX_MAX_PID) return -EINVAL; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (ts_type & TS_DECODER) { @@ -615,7 +618,7 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, if (feed->buffer_size) { #ifdef NOBUFS - feed->buffer=NULL; + feed->buffer = NULL; #else feed->buffer = vmalloc(feed->buffer_size); if (!feed->buffer) { @@ -631,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, return 0; } - -static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { @@ -665,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) return 0; } -static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state < DMX_STATE_GO) { @@ -695,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) return ret; } -static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed, - dmx_ts_cb callback) +static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed **ts_feed, + dmx_ts_cb callback) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; + struct dvb_demux *demux = (struct dvb_demux *)dmx; struct dvb_demux_feed *feed; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (!(feed = dvb_dmx_feed_alloc(demux))) { @@ -724,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; (*ts_feed)->set = dmx_ts_feed_set; - if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { feed->state = DMX_STATE_FREE; up(&demux->mutex); @@ -740,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** return 0; } -static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed) +static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed *ts_feed) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + 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 (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state == DMX_STATE_FREE) { up(&demux->mutex); return -EINVAL; } - #ifndef NOBUFS vfree(feed->buffer); - feed->buffer=0; + feed->buffer = NULL; #endif feed->state = DMX_STATE_FREE; @@ -772,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ return 0; } - /****************************************************************************** * dmx_section_feed API calls ******************************************************************************/ -static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, - struct dmx_section_filter** filter) +static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, + struct dmx_section_filter **filter) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdemux = dvbdmxfeed->demux; struct dvb_demux_filter *dvbdmxfilter; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); @@ -808,18 +809,17 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, return 0; } - -static int dmx_section_feed_set(struct dmx_section_feed* feed, - u16 pid, size_t circular_buffer_size, - int check_crc) +static int dmx_section_feed_set(struct dmx_section_feed *feed, + u16 pid, size_t circular_buffer_size, + int check_crc) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; if (pid > 0x1fff) return -EINVAL; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; dvb_demux_feed_add(dvbdmxfeed); @@ -831,7 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, #ifdef NOBUFS dvbdmxfeed->buffer = NULL; #else - dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size); + dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); if (!dvbdmxfeed->buffer) { up(&dvbdmx->mutex); return -ENOMEM; @@ -843,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, return 0; } - static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) { int i; @@ -851,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) struct dmx_section_filter *sf; u8 mask, mode, doneq; - if (!(f=dvbdmxfeed->filter)) + if (!(f = dvbdmxfeed->filter)) return; do { sf = &f->filter; doneq = 0; - for (i=0; ifilter_mode[i]; mask = sf->filter_mask[i]; f->maskandmode[i] = mask & mode; @@ -866,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) } while ((f = f->next)); } - static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (feed->is_filtering) { @@ -912,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) return 0; } - -static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) +static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!dvbdmx->stop_feed) { @@ -938,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) return ret; } - static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, - struct dmx_section_filter* filter) + struct dmx_section_filter *filter) { - struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f; - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (dvbdmxfilter->feed != dvbdmxfeed) { @@ -963,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, if (f == dvbdmxfilter) { dvbdmxfeed->filter = dvbdmxfilter->next; } else { - while(f->next != dvbdmxfilter) + while (f->next != dvbdmxfilter) f = f->next; f->next = f->next->next; } @@ -978,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback) { - struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; + struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; struct dvb_demux_feed *dvbdmxfeed; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { @@ -999,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, dvbdmxfeed->filter = NULL; dvbdmxfeed->buffer = NULL; - (*feed)=&dvbdmxfeed->feed.sec; + (*feed) = &dvbdmxfeed->feed.sec; (*feed)->is_filtering = 0; (*feed)->parent = demux; (*feed)->priv = NULL; @@ -1017,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, static int dvbdmx_release_section_feed(struct dmx_demux *demux, struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; - struct dvb_demux *dvbdmx = (struct dvb_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 (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; - if (dvbdmxfeed->state==DMX_STATE_FREE) { + if (dvbdmxfeed->state == DMX_STATE_FREE) { up(&dvbdmx->mutex); return -EINVAL; } #ifndef NOBUFS vfree(dvbdmxfeed->buffer); - dvbdmxfeed->buffer=0; + dvbdmxfeed->buffer = NULL; #endif - dvbdmxfeed->state=DMX_STATE_FREE; + dvbdmxfeed->state = DMX_STATE_FREE; dvb_demux_feed_del(dvbdmxfeed); @@ -1041,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, return 0; } - /****************************************************************************** * dvb_demux kernel data API calls ******************************************************************************/ static int dvbdmx_open(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) return -EUSERS; @@ -1057,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux) return 0; } - static int dvbdmx_close(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users == 0) return -ENODEV; @@ -1070,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux) return 0; } - static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) { - struct dvb_demux *dvbdemux=(struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvb_dmx_swfilter(dvbdemux, buf, count); up(&dvbdemux->mutex); @@ -1088,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) return count; } - -static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_add_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *head = &dvbdemux->frontend_list; list_add(&(frontend->connectivity_list), head); @@ -1099,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro return 0; } - -static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_remove_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *pos, *n, *head = &dvbdemux->frontend_list; - list_for_each_safe (pos, n, head) { + list_for_each_safe(pos, n, head) { if (DMX_FE_ENTRY(pos) == frontend) { list_del(pos); return 0; @@ -1115,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend * return -ENODEV; } - -static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux) +static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (list_empty(&dvbdemux->frontend_list)) return NULL; + return &dvbdemux->frontend_list; } - -static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_connect_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (demux->frontend) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = frontend; @@ -1141,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend return 0; } - static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = NULL; @@ -1154,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) return 0; } - -static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) +static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - memcpy(pids, dvbdemux->pids, 5*sizeof(u16)); + memcpy(pids, dvbdemux->pids, 5 * sizeof(u16)); return 0; } - int dvb_dmx_init(struct dvb_demux *dvbdemux) { int i; struct dmx_demux *dmx = &dvbdemux->dmx; dvbdemux->users = 0; - dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter)); + dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); if (!dvbdemux->filter) return -ENOMEM; - dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed)); + dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); if (!dvbdemux->feed) { vfree(dvbdemux->filter); return -ENOMEM; } - for (i=0; ifilternum; i++) { + for (i = 0; i < dvbdemux->filternum; i++) { dvbdemux->filter[i].state = DMX_STATE_FREE; dvbdemux->filter[i].index = i; } - for (i=0; ifeednum; i++) { + for (i = 0; i < dvbdemux->feednum; i++) { dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].index = i; } INIT_LIST_HEAD(&dvbdemux->frontend_list); - for (i=0; ipesfilter[i] = NULL; dvbdemux->pids[i] = 0xffff; } @@ -1205,11 +1195,11 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) if (!dvbdemux->check_crc32) dvbdemux->check_crc32 = dvb_dmx_crc32; - if (!dvbdemux->memcopy) - dvbdemux->memcopy = dvb_dmx_memcopy; + if (!dvbdemux->memcopy) + dvbdemux->memcopy = dvb_dmx_memcopy; dmx->frontend = NULL; - dmx->priv = (void *) dvbdemux; + dmx->priv = dvbdemux; dmx->open = dvbdmx_open; dmx->close = dvbdmx_close; dmx->write = dvbdmx_write; @@ -1230,12 +1220,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) return 0; } -EXPORT_SYMBOL(dvb_dmx_init); +EXPORT_SYMBOL(dvb_dmx_init); void dvb_dmx_release(struct dvb_demux *dvbdemux) { vfree(dvbdemux->filter); vfree(dvbdemux->feed); } + EXPORT_SYMBOL(dvb_dmx_release); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index d149f2a96d0..0cc888339d5 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -20,7 +20,6 @@ * */ - #ifndef _DVB_DEMUX_H_ #define _DVB_DEMUX_H_ @@ -44,98 +43,98 @@ #define DVB_DEMUX_MASK_MAX 18 struct dvb_demux_filter { - struct dmx_section_filter filter; - u8 maskandmode [DMX_MAX_FILTER_SIZE]; - u8 maskandnotmode [DMX_MAX_FILTER_SIZE]; + struct dmx_section_filter filter; + u8 maskandmode[DMX_MAX_FILTER_SIZE]; + u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; int doneq; - struct dvb_demux_filter *next; - struct dvb_demux_feed *feed; - int index; - int state; - int type; + struct dvb_demux_filter *next; + struct dvb_demux_feed *feed; + int index; + int state; + int type; - u16 hw_handle; - struct timer_list timer; + u16 hw_handle; + struct timer_list timer; }; - #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) struct dvb_demux_feed { - union { - struct dmx_ts_feed ts; - struct dmx_section_feed sec; + union { + struct dmx_ts_feed ts; + struct dmx_section_feed sec; } feed; - union { - dmx_ts_cb ts; - dmx_section_cb sec; + union { + dmx_ts_cb ts; + dmx_section_cb sec; } cb; - struct dvb_demux *demux; + struct dvb_demux *demux; void *priv; - int type; - int state; - u16 pid; - u8 *buffer; - int buffer_size; + int type; + int state; + u16 pid; + u8 *buffer; + int buffer_size; - struct timespec timeout; - struct dvb_demux_filter *filter; + struct timespec timeout; + struct dvb_demux_filter *filter; - int ts_type; - enum dmx_ts_pes pes_type; + int ts_type; + enum dmx_ts_pes pes_type; - int cc; - int pusi_seen; /* prevents feeding of garbage from previous section */ + int cc; + int pusi_seen; /* prevents feeding of garbage from previous section */ - u16 peslen; + u16 peslen; struct list_head list_head; - unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ + unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ }; struct dvb_demux { - struct dmx_demux dmx; - void *priv; - int filternum; - int feednum; - int (*start_feed) (struct dvb_demux_feed *feed); - int (*stop_feed) (struct dvb_demux_feed *feed); - int (*write_to_decoder) (struct dvb_demux_feed *feed, + struct dmx_demux dmx; + void *priv; + int filternum; + int feednum; + int (*start_feed)(struct dvb_demux_feed *feed); + int (*stop_feed)(struct dvb_demux_feed *feed); + int (*write_to_decoder)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - u32 (*check_crc32) (struct dvb_demux_feed *feed, + u32 (*check_crc32)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst, + void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, const u8 *src, size_t len); - int users; + int users; #define MAX_DVB_DEMUX_USERS 10 - struct dvb_demux_filter *filter; - struct dvb_demux_feed *feed; + struct dvb_demux_filter *filter; + struct dvb_demux_feed *feed; - struct list_head frontend_list; + struct list_head frontend_list; - struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; - u16 pids[DMX_TS_PES_OTHER]; - int playing; - int recording; + struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; + u16 pids[DMX_TS_PES_OTHER]; + int playing; + int recording; #define DMX_MAX_PID 0x2000 struct list_head feed_list; - u8 tsbuf[204]; - int tsbufp; + u8 tsbuf[204]; + int tsbufp; struct semaphore mutex; spinlock_t lock; }; - int dvb_dmx_init(struct dvb_demux *dvbdemux); void dvb_dmx_release(struct dvb_demux *dvbdemux); -void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); +void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, + size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); -void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); +void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, + size_t count); #endif /* _DVB_DEMUX_H_ */ -- cgit v1.2.3 From 50b447d5b70dc4021ae3b4eaf8ce98932f61a413 Mon Sep 17 00:00:00 2001 From: Dominique Dumont Date: Fri, 9 Sep 2005 13:02:27 -0700 Subject: [PATCH] dvb: core: CI timeout fix Patch from Dominique Dumont to get the SCM Red Viaccess CAM working with the budget-ci. Signed-off-by: Dominique Dumont Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 0eb9aa711fb..88757e2634e 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -47,7 +47,7 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages"); #define dprintk if (dvb_ca_en50221_debug) printk -#define INIT_TIMEOUT_SECS 5 +#define INIT_TIMEOUT_SECS 10 #define HOST_LINK_BUF_SIZE 0x200 -- cgit v1.2.3 From 4ff4ac1beae58a2fea7ec2ad43d6c3b60d90ec61 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Fri, 9 Sep 2005 13:02:29 -0700 Subject: [PATCH] dvb: frontend: mt352: fix signal strength reading Fix two problems with the signal strength value in the mt352.c frontend: 1. the 4 most significant bits are zeroed - shift and mask wrong way round 2. need to align the 12 bits from the registers at the top of the 16 bit returned value - otherwise the range is not 0 to 0xffff its 0xf000 to 0xffff Signed-off-by: Barry Scott Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/mt352.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index d32dc4de9e7..cc1bc0edd65 100644 --- a/drivers/media/dvb/frontends/mt352.c +++ b/drivers/media/dvb/frontends/mt352.c @@ -462,9 +462,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct mt352_state* state = fe->demodulator_priv; - u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) | - (mt352_read_register(state, AGC_GAIN_0)); + /* align the 12 bit AGC gain with the most significant bits */ + u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) | + (mt352_read_register(state, AGC_GAIN_0) << 4); + /* inverse of gain is signal strength */ *strength = ~signal; return 0; } -- cgit v1.2.3 From cfbfce1566f11c0dbad8a16173f0448b0c78cecb Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:30 -0700 Subject: [PATCH] dvb: frontend: stv0299: pass i2c bus to pll callback Pass a pointer to the i2c bus to the pll callbacks (stv0299 only). It was not possible to tell which i2c bus should be used if an adapter has multiple frontends on multiple i2c buses. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/b2c2/flexcop-fe-tuner.c | 5 ++--- drivers/media/dvb/frontends/stv0299.c | 6 +++--- drivers/media/dvb/frontends/stv0299.h | 4 ++-- drivers/media/dvb/ttpci/av7110.c | 10 ++++------ drivers/media/dvb/ttpci/budget-av.c | 4 ++-- drivers/media/dvb/ttpci/budget-ci.c | 9 ++++----- drivers/media/dvb/ttpci/budget-patch.c | 5 ++--- drivers/media/dvb/ttpci/budget.c | 5 ++--- drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 4 ++-- 9 files changed, 23 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0410cc96a48..a36bec3a2be 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c @@ -164,12 +164,11 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, return 0; } -static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int samsung_tbmu24112_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) }; - struct flexcop_device *fc = fe->dvb->priv; div = params->frequency / 125; @@ -180,7 +179,7 @@ static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_fronten if (params->frequency < 1500000) buf[3] |= 0x10; - if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index cfa3928bb48..db66d417df3 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c @@ -481,7 +481,7 @@ static int stv0299_init (struct dvb_frontend* fe) if (state->config->pll_init) { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ } @@ -603,7 +603,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } else { /* A "normal" tune is requested */ stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_writeregI(state, 0x32, 0x80); @@ -615,7 +615,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } } else { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_set_FEC (state, p->u.qpsk.fec_inner); diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h index 79457a80a11..d0c4484861e 100644 --- a/drivers/media/dvb/frontends/stv0299.h +++ b/drivers/media/dvb/frontends/stv0299.h @@ -92,8 +92,8 @@ struct stv0299_config int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params); }; extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index e4c6e87f6c5..c91cf8958b3 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -1668,9 +1668,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1687,7 +1686,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) return -EIO; return 0; @@ -1751,9 +1750,8 @@ static u8 alps_bsbe1_inittab[] = { 0xff, 0xff }; -static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1768,7 +1766,7 @@ static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); return (ret != 1) ? -EIO : 0; } diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 9746d2bb916..311be50b2fc 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -453,9 +453,9 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra } static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -481,7 +481,7 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index a1267054bc0..88f27a53216 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -548,9 +548,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u8 buf[4]; u32 div; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -567,7 +566,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param if (params->frequency > 1530000) buf[3] = 0xc0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -669,9 +668,9 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, } static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -697,7 +696,7 @@ static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index 8142e26b47f..b1f21ef0e3b 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c @@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 9961917e8a7..5552ef50199 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c @@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget* budget = (struct budget*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 7daf7b1598a..c1acd4bb349 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1299,7 +1299,7 @@ static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 return 0; } -static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; u8 buf[4]; @@ -1322,7 +1322,7 @@ static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_ if (ttusb->revision == TTUSB_REV_2_2) buf[3] |= 0x20; - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; -- cgit v1.2.3 From a9d6a80b41c04e8ff4c7442cc35f5df610863841 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:31 -0700 Subject: [PATCH] dvb: frontend: s5h1420: fixes Misc. fixes. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/s5h1420.c | 162 +++++++++++++++++++--------------- drivers/media/dvb/frontends/s5h1420.h | 3 + drivers/media/dvb/ttpci/budget.c | 1 + 3 files changed, 97 insertions(+), 69 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 4f396ac8de7..c7fe27fd530 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c @@ -48,7 +48,8 @@ struct s5h1420_state { }; static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings); +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings); static int debug = 0; @@ -91,7 +92,8 @@ static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag switch(voltage) { case SEC_VOLTAGE_13: - s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); + s5h1420_writereg(state, 0x3c, + (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); break; case SEC_VOLTAGE_18: @@ -112,18 +114,21 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) switch(tone) { case SEC_TONE_ON: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); break; case SEC_TONE_OFF: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); break; } return 0; } -static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int s5h1420_send_master_cmd (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd* cmd) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -131,6 +136,9 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m unsigned long timeout; int result = 0; + if (cmd->msg_len > 8) + return -EINVAL; + /* setup for DISEQC */ val = s5h1420_readreg(state, 0x3b); s5h1420_writereg(state, 0x3b, 0x02); @@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m /* write the DISEQC command bytes */ for(i=0; i< cmd->msg_len; i++) { - s5h1420_writereg(state, 0x3c + i, cmd->msg[i]); + s5h1420_writereg(state, 0x3d + i, cmd->msg[i]); } /* kick off transmission */ - s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08); + s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | + ((cmd->msg_len-1) << 4) | 0x08); /* wait for transmission to complete */ timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { - if (s5h1420_readreg(state, 0x3b) & 0x08) + if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; msleep(5); @@ -161,7 +170,8 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m return result; } -static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply) +static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, + struct dvb_diseqc_slave_reply* reply) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -205,7 +215,7 @@ static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_ /* extract data */ for(i=0; i< length; i++) { - reply->msg[i] = s5h1420_readreg(state, 0x3c + i); + reply->msg[i] = s5h1420_readreg(state, 0x3d + i); } exit: @@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicm s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08); /* wait for transmission to complete */ - timeout = jiffies + ((20*HZ) / 1000); + timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; @@ -259,9 +269,9 @@ static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state) val = s5h1420_readreg(state, 0x14); if (val & 0x02) - status |= FE_HAS_SIGNAL; // FIXME: not sure if this is right + status |= FE_HAS_SIGNAL; if (val & 0x01) - status |= FE_HAS_CARRIER; // FIXME: not sure if this is right + status |= FE_HAS_CARRIER; val = s5h1420_readreg(state, 0x36); if (val & 0x01) status |= FE_HAS_VITERBI; @@ -284,8 +294,8 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) /* determine lock state */ *status = s5h1420_get_status_bits(state); - /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion, - wait a bit and check again */ + /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert + the inversion, wait a bit and check again */ if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { val = s5h1420_readreg(state, 0x32); if ((val & 0x07) == 0x03) { @@ -330,6 +340,10 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) tmp = (tmp * 2 * 7) / 8; break; } + if (tmp == 0) { + printk("s5h1420: avoided division by 0\n"); + tmp = 1; + } tmp = state->fclk / tmp; /* set the MPEG_CLK_INTL for the calculated data rate */ @@ -368,16 +382,21 @@ static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber) s5h1420_writereg(state, 0x46, 0x1d); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct s5h1420_state* state = fe->demodulator_priv; - u8 val = 0xff - s5h1420_readreg(state, 0x15); + u8 val = s5h1420_readreg(state, 0x15); - return (int) ((val << 8) | val); + *strength = (u16) ((val << 8) | val); + + return 0; } static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) @@ -386,7 +405,10 @@ static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) s5h1420_writereg(state, 0x46, 0x1f); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static void s5h1420_reset(struct s5h1420_state* state) @@ -396,11 +418,12 @@ static void s5h1420_reset(struct s5h1420_state* state) udelay(10); } -static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setsymbolrate(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { u64 val; - val = (p->u.qpsk.symbol_rate / 1000) * (1<<24); + val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); if (p->u.qpsk.symbol_rate <= 21000000) { val *= 2; } @@ -415,7 +438,7 @@ static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_fronte static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) { - u64 val; + u64 val = 0; int sampling = 2; if (s5h1420_readreg(state, 0x05) & 0x2) @@ -427,10 +450,10 @@ static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) val |= s5h1420_readreg(state, 0x13); s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); - val *= (state->fclk / 1000); + val *= (state->fclk / 1000ULL); do_div(val, ((1<<24) * sampling)); - return (u32) (val * 1000); + return (u32) (val * 1000ULL); } static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) @@ -463,46 +486,55 @@ static int s5h1420_getfreqoffset(struct s5h1420_state* state) /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so * divide fclk by 1000000 to get the correct value. */ - val = - ((val * (state->fclk/1000000)) / (1<<24)); + val = (((-val) * (state->fclk/1000000)) / (1<<24)); return val; } -static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setfec_inversion(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { + u8 inversion = 0; + + if (p->inversion == INVERSION_OFF) { + inversion = state->config->invert ? 0x08 : 0; + } else if (p->inversion == INVERSION_ON) { + inversion = state->config->invert ? 0 : 0x08; + } + if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); s5h1420_writereg(state, 0x30, 0x3f); + s5h1420_writereg(state, 0x31, 0x00 | inversion); } else { switch(p->u.qpsk.fec_inner) { case FEC_1_2: - s5h1420_writereg(state, 0x31, 0x10); s5h1420_writereg(state, 0x30, 0x01); + s5h1420_writereg(state, 0x31, 0x10 | inversion); break; case FEC_2_3: - s5h1420_writereg(state, 0x31, 0x11); s5h1420_writereg(state, 0x30, 0x02); + s5h1420_writereg(state, 0x31, 0x11 | inversion); break; case FEC_3_4: - s5h1420_writereg(state, 0x31, 0x12); s5h1420_writereg(state, 0x30, 0x04); - break; + s5h1420_writereg(state, 0x31, 0x12 | inversion); + break; case FEC_5_6: - s5h1420_writereg(state, 0x31, 0x13); s5h1420_writereg(state, 0x30, 0x08); + s5h1420_writereg(state, 0x31, 0x13 | inversion); break; case FEC_6_7: - s5h1420_writereg(state, 0x31, 0x14); s5h1420_writereg(state, 0x30, 0x10); + s5h1420_writereg(state, 0x31, 0x14 | inversion); break; case FEC_7_8: - s5h1420_writereg(state, 0x31, 0x15); s5h1420_writereg(state, 0x30, 0x20); + s5h1420_writereg(state, 0x31, 0x15 | inversion); break; default: @@ -536,22 +568,6 @@ static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) return FEC_NONE; } -static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p) -{ - if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); - s5h1420_writereg(state, 0x30, 0x3f); - } else { - u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7; - tmp |= 0x10; - - if (p->inversion == INVERSION_ON) - tmp |= 0x80; - - s5h1420_writereg(state, 0x31, tmp); - } -} - static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) { if (s5h1420_readreg(state, 0x32) & 0x08) @@ -560,35 +576,35 @@ static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) return INVERSION_OFF; } -static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; - u32 frequency_delta; + int frequency_delta; struct dvb_frontend_tune_settings fesettings; + u32 tmp; /* check if we should do a fast-tune */ memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); s5h1420_get_tune_settings(fe, &fesettings); frequency_delta = p->frequency - state->tunedfreq; - if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) && + if ((frequency_delta > -fesettings.max_drift) && + (frequency_delta < fesettings.max_drift) && (frequency_delta != 0) && (state->fec_inner == p->u.qpsk.fec_inner) && (state->symbol_rate == p->u.qpsk.symbol_rate)) { - s5h1420_setfreqoffset(state, frequency_delta); + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, p->frequency - tmp); + } return 0; } /* first of all, software reset */ s5h1420_reset(state); - /* set tuner PLL */ - if (state->config->pll_set) { - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); - state->config->pll_set(fe, p, &state->tunedfreq); - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe); - } - /* set s5h1420 fclk PLL according to desired symbol rate */ if (p->u.qpsk.symbol_rate > 28000000) { state->fclk = 88000000; @@ -609,8 +625,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* set misc registers */ s5h1420_writereg(state, 0x02, 0x00); + s5h1420_writereg(state, 0x06, 0x00); s5h1420_writereg(state, 0x07, 0xb0); - s5h1420_writereg(state, 0x0a, 0x67); + s5h1420_writereg(state, 0x0a, 0xe7); s5h1420_writereg(state, 0x0b, 0x78); s5h1420_writereg(state, 0x0c, 0x48); s5h1420_writereg(state, 0x0d, 0x6b); @@ -626,21 +643,26 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* start QPSK */ s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); - /* set the frequency offset to adjust for PLL inaccuracy */ - s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq); + /* set tuner PLL */ + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, 0); + } /* set the reset of the parameters */ s5h1420_setsymbolrate(state, p); - s5h1420_setinversion(state, p); - s5h1420_setfec(state, p); + s5h1420_setfec_inversion(state, p); state->fec_inner = p->u.qpsk.fec_inner; state->symbol_rate = p->u.qpsk.symbol_rate; state->postlocked = 0; + state->tunedfreq = p->frequency; return 0; } -static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; @@ -652,7 +674,8 @@ static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par return 0; } -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings) { if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) { fesettings->min_delay_ms = 50; @@ -717,7 +740,8 @@ static void s5h1420_release(struct dvb_frontend* fe) static struct dvb_frontend_ops s5h1420_ops; -struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c) +struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, + struct i2c_adapter* i2c) { struct s5h1420_state* state = NULL; u8 identity; diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h index b687fc77ceb..872028ddf2a 100644 --- a/drivers/media/dvb/frontends/s5h1420.h +++ b/drivers/media/dvb/frontends/s5h1420.h @@ -30,6 +30,9 @@ struct s5h1420_config /* the demodulator's i2c address */ u8 demod_address; + /* does the inversion require inversion? */ + u8 invert:1; + /* PLL maintenance */ int (*pll_init)(struct dvb_frontend* fe); int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout); diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 5552ef50199..43d6c826864 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c @@ -480,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete static struct s5h1420_config s5h1420_config = { .demod_address = 0x53, + .invert = 1, .pll_set = s5h1420_pll_set, }; -- cgit v1.2.3 From 78639a3f81d14117d1841476771d7a4736e7b9d1 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:32 -0700 Subject: [PATCH] dvb: frontend: stv0299: support reading both BER and UCBLOCKS Allow the stv0299 to read the BER and UCBLOCKS. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/stv0299.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index db66d417df3..2d62931f20b 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c @@ -63,12 +63,8 @@ struct stv0299_state { u32 tuner_frequency; u32 symbol_rate; fe_code_rate_t fec_inner; - int errmode; }; -#define STATUS_BER 0 -#define STATUS_UCBLOCKS 1 - static int debug; static int debug_legacy_dish_switch; #define dprintk(args...) \ @@ -520,7 +516,8 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_BER) return 0; + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x10); + msleep(100); *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; @@ -559,8 +556,9 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; - else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x30); + msleep(100); + *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; } @@ -709,7 +707,6 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, state->tuner_frequency = 0; state->symbol_rate = 0; state->fec_inner = 0; - state->errmode = STATUS_BER; /* check if the demod is there */ stv0299_writeregI(state, 0x02, 0x34); /* standby off */ -- cgit v1.2.3 From c2026b3af0c8ad33ef253a950c271f2d0da111b6 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:02:33 -0700 Subject: [PATCH] dvb: frontend: tda1004x: fix SNR reading Fix SNR reading Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/tda1004x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index ab0c032472c..74cea9f8d72 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c @@ -1046,8 +1046,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) tmp = tda1004x_read_byte(state, TDA1004X_SNR); if (tmp < 0) return -EIO; - if (tmp) - tmp = 255 - tmp; + tmp = 255 - tmp; *snr = ((tmp << 8) | tmp); dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); -- cgit v1.2.3 From 6816a4c183e62bca1fa4812214e483ab503dcb7d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:34 -0700 Subject: [PATCH] dvb: frontend: ves1820: improve tuning Reset acgconf register after tuning to improve locking, as suggested by Marco Schluessler. Minor cleanups in ves1820_init(). Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/ves1820.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 70fb44b391a..c6d276618e8 100644 --- a/drivers/media/dvb/frontends/ves1820.c +++ b/drivers/media/dvb/frontends/ves1820.c @@ -194,19 +194,18 @@ static int ves1820_init(struct dvb_frontend* fe) { struct ves1820_state* state = fe->demodulator_priv; int i; - int val; ves1820_writereg(state, 0, 0); - for (i = 0; i < 53; i++) { - val = ves1820_inittab[i]; - if ((i == 2) && (state->config->selagc)) val |= 0x08; - ves1820_writereg(state, i, val); - } + for (i = 0; i < sizeof(ves1820_inittab); i++) + ves1820_writereg(state, i, ves1820_inittab[i]); + if (state->config->selagc) + ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08); ves1820_writereg(state, 0x34, state->pwm); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe); return 0; } @@ -234,7 +233,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p ves1820_writereg(state, 0x09, reg0x09[real_qam]); ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion); - + ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0)); return 0; } -- cgit v1.2.3 From d897275500d8fac919a11073eb587ce0e3fcc36c Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:34 -0700 Subject: [PATCH] dvb: frontend: cx24110: DiSEqC fix Fix DiSEqC switching (one bug fix suggested by Peter Hettkamp, and one experimentally determined msleep(30) suggested by Adam Szalkowski). Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/cx24110.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 555d472e42d..71b54094bda 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -398,7 +398,7 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t return -EINVAL; rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + cx24110_writereg(state, 0x77, rv | 0x04); rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); @@ -418,7 +418,8 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, cx24110_writereg(state, 0x79 + i, cmd->msg[i]); rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + cx24110_writereg(state, 0x77, rv & ~0x04); + msleep(30); /* reportedly fixes switching problems */ rv = cx24110_readreg(state, 0x76); -- cgit v1.2.3 From 296c786a0d2122b1e47c80ca717d8a8ac36402c1 Mon Sep 17 00:00:00 2001 From: Adam Szalkowski Date: Fri, 9 Sep 2005 13:02:35 -0700 Subject: [PATCH] dvb: frontend: cx24110: another DiSEqC fix Fix DiSEqC problems. Signed-off-by: Adam Szalkowski Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/cx24110.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 71b54094bda..eb4833ee72b 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -398,7 +398,8 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t return -EINVAL; rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv | 0x04); + if (!(rv & 0x04)) + cx24110_writereg(state, 0x77, rv | 0x04); rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); @@ -418,14 +419,16 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, cx24110_writereg(state, 0x79 + i, cmd->msg[i]); rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv & ~0x04); - msleep(30); /* reportedly fixes switching problems */ + if (rv & 0x04) { + cx24110_writereg(state, 0x77, rv & ~0x04); + msleep(30); /* reportedly fixes switching problems */ + } rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); - for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) - ; /* wait for LNB ready */ + for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) + msleep(1); /* wait for LNB ready */ return 0; } -- cgit v1.2.3 From c589ebfce79834a9617c44d7ec0f608fa70eb42d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:37 -0700 Subject: [PATCH] dvb: frontend: cx24110: clean up timeout handling. Clean up timeout handling. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/cx24110.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index eb4833ee72b..d4b97989e3e 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -387,8 +387,9 @@ static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) { - int rv, bit, i; + int rv, bit; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; if (burst == SEC_MINI_A) bit = 0x00; @@ -403,8 +404,9 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); - for (i = 500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40) ; ) - ; /* wait for LNB ready */ + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) + ; /* wait for LNB ready */ return 0; } @@ -414,6 +416,7 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, { int i, rv; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; for (i = 0; i < cmd->msg_len; i++) cx24110_writereg(state, 0x79 + i, cmd->msg[i]); @@ -427,8 +430,9 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); - for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) - msleep(1); /* wait for LNB ready */ + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) + ; /* wait for LNB ready */ return 0; } -- cgit v1.2.3 From 593cbf3dcbffc852cf91a30951eb518b59bf7322 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:38 -0700 Subject: [PATCH] dvb: frontend: stv0297: QAM128 tuning improvement while investigating the QAM_128-issue with the stv0297-driver for the Cablestar (which is not the same as the one in dvb-kernel CVS, yet), I fixed it, not by increasing the timeout, but by disabling the corner-detection for QAM_128 and higher. This patch has been tested on dvb-kernel cvs, and has been reported to work by multiple users. Some cards still need timeout increase on top of this patch. This will be addressed later. Signed-off-by: Patrick Boettcher Signed-off-by: Michael Krufky Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/stv0297.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 928aca052af..01eb41990e8 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -606,7 +606,13 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par stv0297_set_inversion(state, inversion); /* kick off lock */ - stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + /* Disable corner detection for higher QAMs */ + if (p->u.qam.modulation == QAM_128 || + p->u.qam.modulation == QAM_256) + stv0297_writereg_mask(state, 0x88, 0x08, 0x00); + else + stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); stv0297_writereg_mask(state, 0x43, 0x40, 0x40); -- cgit v1.2.3 From 80e27e20619902b11aa255081fd83eab10fc0839 Mon Sep 17 00:00:00 2001 From: Mac Michaels Date: Fri, 9 Sep 2005 13:02:40 -0700 Subject: [PATCH] dvb: frontend: or51132: remove bogus optimization attempt This fix has also been applied to lgdt330x. There is an optimization that keeps track of the frequency tuned by the digital decoder. The digital driver does not set the frequency if it has not changed since it was tuned. The analog tuner driver knows nothing about the frequency saved by the digital driver. When the frequency is set using the video4linux code with tvtime, the hardware get changed but the digital driver's state does not get updated. Switch back to the same digital channel and the driver finds no change in frequency so the tuner is not reset to the digital frequency. The work around is to remove the check and always set the tuner to the specified frequency. Signed-off-by: Mac Michaels Signed-off-by: Michael Krufky Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/or51132.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index cc0a77c790f..b6d0eecc59e 100644 --- a/drivers/media/dvb/frontends/or51132.c +++ b/drivers/media/dvb/frontends/or51132.c @@ -370,22 +370,19 @@ static int or51132_set_parameters(struct dvb_frontend* fe, or51132_setmode(fe); } - /* Change only if we are actually changing the channel */ - if (state->current_frequency != param->frequency) { - dvb_pll_configure(state->config->pll_desc, buf, - param->frequency, 0); - dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " - "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); - if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) - printk(KERN_WARNING "or51132: set_parameters error " - "writing to tuner\n"); - - /* Set to current mode */ - or51132_setmode(fe); - - /* Update current frequency */ - state->current_frequency = param->frequency; - } + dvb_pll_configure(state->config->pll_desc, buf, + param->frequency, 0); + dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " + "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); + if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) + printk(KERN_WARNING "or51132: set_parameters error " + "writing to tuner\n"); + + /* Set to current mode */ + or51132_setmode(fe); + + /* Update current frequency */ + state->current_frequency = param->frequency; return 0; } -- cgit v1.2.3 From 3706a4da2012679631da6d22e86c6a34cde7419a Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:41 -0700 Subject: [PATCH] dvb: usb: add TwinhanDTV StarBox support Add driver for the TwinhanDTV StarBox and clones. Thanks to Ralph Metzler for his initial work on this box and thanks to Twinhan for their support. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/Kconfig | 23 ++- drivers/media/dvb/dvb-usb/Makefile | 3 + drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 6 +- drivers/media/dvb/dvb-usb/vp702x-fe.c | 339 ++++++++++++++++++++++++++++++++ drivers/media/dvb/dvb-usb/vp702x.c | 290 +++++++++++++++++++++++++++ drivers/media/dvb/dvb-usb/vp702x.h | 109 ++++++++++ 6 files changed, 765 insertions(+), 5 deletions(-) create mode 100644 drivers/media/dvb/dvb-usb/vp702x-fe.c create mode 100644 drivers/media/dvb/dvb-usb/vp702x.c create mode 100644 drivers/media/dvb/dvb-usb/vp702x.h (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 612e5b087b1..54e2b29076b 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -93,13 +93,30 @@ config DVB_USB_DIGITV Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. config DVB_USB_VP7045 - tristate "TwinhanDTV Alpha/MagicBoxII and DNTV tinyUSB2 DVB-T USB2.0 support" + tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support" depends on DVB_USB help Say Y here to support the + TwinhanDTV Alpha (stick) (VP-7045), - TwinhanDTV MagicBox II (VP-7046) and - DigitalNow TinyUSB 2 DVB-t DVB-T USB2.0 receivers. + TwinhanDTV MagicBox II (VP-7046), + DigitalNow TinyUSB 2 DVB-t, + DigitalRise USB 2.0 Ter (Beetle) and + TYPHOON DVB-T USB DRIVE + + DVB-T USB2.0 receivers. + +config DVB_USB_VP702X + tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support" + depends on DVB_USB + help + Say Y here to support the + + TwinhanDTV StarBox, + DigitalRise USB Starbox and + TYPHOON DVB-S USB 2.0 BOX + + DVB-S USB2.0 receivers. config DVB_USB_NOVA_T_USB2 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 746d87ed6f3..2dc9aad9681 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile @@ -4,6 +4,9 @@ obj-$(CONFIG_DVB_USB) += dvb-usb.o dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o +dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o +obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o + dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 794d513a848..2b249c75fb0 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -52,12 +52,14 @@ #define USB_PID_KWORLD_VSTREAM_WARM 0x17df #define USB_PID_TWINHAN_VP7041_COLD 0x3201 #define USB_PID_TWINHAN_VP7041_WARM 0x3202 +#define USB_PID_TWINHAN_VP7020_COLD 0x3203 +#define USB_PID_TWINHAN_VP7020_WARM 0x3204 #define USB_PID_TWINHAN_VP7045_COLD 0x3205 #define USB_PID_TWINHAN_VP7045_WARM 0x3206 -#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 -#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_TWINHAN_VP7021_COLD 0x3207 #define USB_PID_TWINHAN_VP7021_WARM 0x3208 +#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 +#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_ULTIMA_TVBOX_COLD 0x8105 #define USB_PID_ULTIMA_TVBOX_WARM 0x8106 #define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c new file mode 100644 index 00000000000..f20d8dbd0be --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c @@ -0,0 +1,339 @@ +/* DVB frontend part of the Linux driver for the TwinhanDTV StarBox USB2.0 + * DVB-S receiver. + * + * Copyright (C) 2005 Ralph Metzler + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * This file can be removed soon, after the DST-driver is rewritten to provice + * the frontend-controlling separately. + * + * 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, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + * + */ +#include "vp702x.h" + +struct vp702x_fe_state { + struct dvb_frontend fe; + struct dvb_usb_device *d; + + fe_sec_voltage_t voltage; + fe_sec_tone_mode_t tone_mode; + + u8 lnb_buf[8]; + + u8 lock; + u8 sig; + u8 snr; + + unsigned long next_status_check; + unsigned long status_check_interval; +}; + +static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) +{ + u8 buf[10]; + if (time_after(jiffies,st->next_status_check)) { + vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10); + + st->lock = buf[4]; + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1); + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1); + + st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; + } + return 0; +} + +static u8 vp702x_chksum(u8 *buf,int f, int count) +{ + u8 s = 0; + int i; + for (i = f; i < f+count; i++) + s += buf[i]; + return ~s+1; +} + +static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + deb_fe("%s\n",__FUNCTION__); + + if (st->lock == 0) + *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; + else + *status = 0; + + deb_fe("real state: %x\n",*status); + *status = 0x1f; + + if (*status & FE_HAS_LOCK) + st->status_check_interval = 1000; + else + st->status_check_interval = 250; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *ber = 0; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *unc = 0; + return 0; +} + +static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + *strength = (st->sig << 8) | st->sig; + return 0; +} + +static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr) +{ + u8 _snr; + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + _snr = (st->snr & 0x1f) * 0xff / 0x1f; + *snr = (_snr << 8) | _snr; + return 0; +} + +static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + deb_fe("%s\n",__FUNCTION__); + tune->min_delay_ms = 2000; + return 0; +} + +static int vp702x_fe_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u32 freq = fep->frequency/1000; + /*CalFrequency*/ +/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ + u64 sr; + u8 cmd[8] = { 0 },ibuf[10]; + + cmd[0] = (freq >> 8) & 0x7f; + cmd[1] = freq & 0xff; + cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */ + + sr = (u64) (fep->u.qpsk.symbol_rate/1000) << 20; + do_div(sr,88000); + cmd[3] = (sr >> 12) & 0xff; + cmd[4] = (sr >> 4) & 0xff; + cmd[5] = (sr << 4) & 0xf0; + + deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %Lu (%Lx)\n", + fep->frequency,freq,freq, fep->u.qpsk.symbol_rate, sr, sr); + +/* if (fep->inversion == INVERSION_ON) + cmd[6] |= 0x80; */ + + if (st->voltage == SEC_VOLTAGE_18) + cmd[6] |= 0x40; + +/* if (fep->u.qpsk.symbol_rate > 8000000) + cmd[6] |= 0x20; + + if (fep->frequency < 1531000) + cmd[6] |= 0x04; + + if (st->tone_mode == SEC_TONE_ON) + cmd[6] |= 0x01;*/ + + cmd[7] = vp702x_chksum(cmd,0,7); + + st->status_check_interval = 250; + st->next_status_check = jiffies; + + vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); + msleep(30); + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("tuning failed.\n"); + else + deb_fe("tuning succeeded.\n"); + + return 0; +} + +static int vp702x_fe_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd *m) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 cmd[8],ibuf[10]; + memset(cmd,0,8); + + deb_fe("%s\n",__FUNCTION__); + + if (m->msg_len > 4) + return -EINVAL; + + cmd[1] = SET_DISEQC_CMD; + cmd[2] = m->msg_len; + memcpy(&cmd[3], m->msg, m->msg_len); + cmd[7] = vp702x_chksum(cmd,0,7); + + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("diseqc cmd failed.\n"); + else + deb_fe("diseqc cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->tone_mode = tone; + + if (tone == SEC_TONE_ON) + st->lnb_buf[2] = 0x02; + else + st->lnb_buf[2] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_tone cmd failed.\n"); + else + deb_fe("set_tone cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t + voltage) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->voltage = voltage; + + if (voltage != SEC_VOLTAGE_OFF) + st->lnb_buf[4] = 0x01; + else + st->lnb_buf[4] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_voltage cmd failed.\n"); + else + deb_fe("set_voltage cmd succeeded.\n"); + + return 0; +} + +static void vp702x_fe_release(struct dvb_frontend* fe) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + kfree(st); +} + +static struct dvb_frontend_ops vp702x_fe_ops; + +struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) +{ + struct vp702x_fe_state *s = kmalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL); + if (s == NULL) + goto error; + memset(s,0,sizeof(struct vp702x_fe_state)); + + s->d = d; + s->fe.ops = &vp702x_fe_ops; + s->fe.demodulator_priv = s; + + s->lnb_buf[1] = SET_LNB_POWER; + s->lnb_buf[3] = 0xff; /* 0=tone burst, 2=data burst, ff=off */ + + goto success; +error: + return NULL; +success: + return &s->fe; +} + + +static struct dvb_frontend_ops vp702x_fe_ops = { + .info = { + .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S", + .type = FE_QPSK, + .frequency_min = 950000, + .frequency_max = 2150000, + .frequency_stepsize = 1000, /* kHz for QPSK frontends */ + .frequency_tolerance = 0, + .symbol_rate_min = 1000000, + .symbol_rate_max = 45000000, + .symbol_rate_tolerance = 500, /* ppm */ + .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_QPSK | + FE_CAN_FEC_AUTO + }, + .release = vp702x_fe_release, + + .init = NULL, + .sleep = NULL, + + .set_frontend = vp702x_fe_set_frontend, + .get_frontend = vp702x_fe_get_frontend, + .get_tune_settings = vp702x_fe_get_tune_settings, + + .read_status = vp702x_fe_read_status, + .read_ber = vp702x_fe_read_ber, + .read_signal_strength = vp702x_fe_read_signal_strength, + .read_snr = vp702x_fe_read_snr, + .read_ucblocks = vp702x_fe_read_unc_blocks, + + .diseqc_send_master_cmd = vp702x_fe_send_diseqc_msg, + .diseqc_send_burst = vp702x_fe_send_diseqc_burst, + .set_tone = vp702x_fe_set_tone, + .set_voltage = vp702x_fe_set_voltage, +}; diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c new file mode 100644 index 00000000000..1f5034ca115 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -0,0 +1,290 @@ +/* DVB USB compliant Linux driver for the TwinhanDTV StarBox USB2.0 DVB-S + * receiver. + * + * Copyright (C) 2005 Ralph Metzler + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * 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, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + */ +#include "vp702x.h" + +/* debug */ +int dvb_usb_vp702x_debug; +module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); +MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); + +struct vp702x_state { + u8 pid_table[17]; /* [16] controls the pid_table state */ +}; + +/* check for mutex FIXME */ +int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + int ret = 0,try = 0; + + while (ret >= 0 && ret != blen && try < 3) { + ret = usb_control_msg(d->udev, + usb_rcvctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_IN, + value,index,b,blen, + 2000); + deb_info("reading number %d (ret: %d)\n",try,ret); + try++; + } + + if (ret < 0 || ret != blen) { + warn("usb in operation failed."); + ret = -EIO; + } else + ret = 0; + + deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + return ret; +} + +int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + if (usb_control_msg(d->udev, + usb_sndctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_OUT, + value,index,b,blen, + 2000) != blen) { + warn("usb out operation failed."); + return -EIO; + } else + return 0; +} + +int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + int ret; + + if ((ret = down_interruptible(&d->usb_sem))) + return ret; + + if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) + goto unlock; + msleep(msec); + ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); + +unlock: + up(&d->usb_sem); + + return ret; +} + +int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + u8 bout[olen+2]; + u8 bin[ilen+1]; + int ret = 0; + + bout[0] = 0x00; + bout[1] = cmd; + memcpy(&bout[2],o,olen); + + ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec); + + if (ret == 0) + memcpy(i,&bin[1],ilen); + + return ret; +} + +static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +{ + struct vp702x_state *st = d->priv; + u8 buf[9]; + + if (onoff) { + st->pid_table[16] |= 1 << index; + st->pid_table[index*2] = (pid >> 8) & 0xff; + st->pid_table[index*2+1] = pid & 0xff; + } else { + st->pid_table[16] &= ~(1 << index); + st->pid_table[index*2] = st->pid_table[index*2+1] = 0; + } + + return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); +} + +static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) +{ + vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0); + + vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); + return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); +} + +/* keys for the enclosed remote control */ +static struct dvb_usb_rc_key vp702x_rc_keys[] = { + { 0x00, 0x01, KEY_1 }, + { 0x00, 0x02, KEY_2 }, +}; + +/* remote control stuff (does not work with my box) */ +static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) +{ + u8 key[10]; + int i; + +/* remove the following return to enabled remote querying */ + return 0; + + vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); + + deb_rc("remote query key: %x %d\n",key[1],key[1]); + + if (key[1] == 0x44) { + *state = REMOTE_NO_KEY_PRESSED; + return 0; + } + + for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) + if (vp702x_rc_keys[i].custom == key[1]) { + *state = REMOTE_KEY_PRESSED; + *event = vp702x_rc_keys[i].event; + break; + } + return 0; +} + +static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) +{ + u8 macb[9]; + if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10)) + return -EIO; + memcpy(mac,&macb[3],6); + return 0; +} + +static int vp702x_frontend_attach(struct dvb_usb_device *d) +{ + u8 buf[9] = { 0 }; + + if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) + return -EIO; + + buf[8] = '\0'; + info("system string: %s",&buf[1]); + + d->fe = vp702x_fe_attach(d); + return 0; +} + +static struct dvb_usb_properties vp702x_properties; + +static int vp702x_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); + usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); + + return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE); +} + +static struct usb_device_id vp702x_usb_table [] = { + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) }, + { 0 }, +}; +MODULE_DEVICE_TABLE(usb, vp702x_usb_table); + +static struct dvb_usb_properties vp702x_properties = { + .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, + .pid_filter_count = 8, /* !!! */ + + .usb_ctrl = CYPRESS_FX2, + .firmware = "dvb-usb-vp702x-01.fw", + + .pid_filter = vp702x_pid_filter, + .power_ctrl = vp702x_power_ctrl, + .frontend_attach = vp702x_frontend_attach, + .read_mac_address = vp702x_read_mac_addr, + + .rc_key_map = vp702x_rc_keys, + .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), + .rc_interval = 400, + .rc_query = vp702x_rc_query, + + .size_of_priv = sizeof(struct vp702x_state), + + /* parameter for the MPEG2-data transfer */ + .urb = { + .type = DVB_USB_BULK, + .count = 7, + .endpoint = 0x02, + .u = { + .bulk = { + .buffersize = 4096, + } + } + }, + + .num_device_descs = 2, + .devices = { + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)", + .cold_ids = { &vp702x_usb_table[0], NULL }, + .warm_ids = { &vp702x_usb_table[1], NULL }, + }, + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)", + .cold_ids = { &vp702x_usb_table[2], NULL }, + .warm_ids = { &vp702x_usb_table[3], NULL }, + }, + { 0 }, + } +}; + +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver vp702x_usb_driver = { + .owner = THIS_MODULE, + .name = "dvb-usb-vp702x", + .probe = vp702x_usb_probe, + .disconnect = dvb_usb_device_exit, + .id_table = vp702x_usb_table, +}; + +/* module stuff */ +static int __init vp702x_usb_module_init(void) +{ + int result; + if ((result = usb_register(&vp702x_usb_driver))) { + err("usb_register failed. (%d)",result); + return result; + } + + return 0; +} + +static void __exit vp702x_usb_module_exit(void) +{ + /* deregister this driver from the USB subsystem */ + usb_deregister(&vp702x_usb_driver); +} + +module_init(vp702x_usb_module_init); +module_exit(vp702x_usb_module_exit); + +MODULE_AUTHOR("Patrick Boettcher "); +MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); +MODULE_VERSION("1.0-alpha"); +MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h new file mode 100644 index 00000000000..4a3e8c7eca2 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.h @@ -0,0 +1,109 @@ +#ifndef _DVB_USB_VP7021_H_ +#define _DVB_USB_VP7021_H_ + +#define DVB_USB_LOG_PREFIX "vp702x" +#include "dvb-usb.h" + +extern int dvb_usb_vp702x_debug; +#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args) +#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args) +#define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args) +#define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args) + +/* commands are read and written with USB control messages */ + +/* consecutive read/write operation */ +#define REQUEST_OUT 0xB2 +#define REQUEST_IN 0xB3 + +/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 + * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer + * the returning buffer looks as follows + * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ + +#define GET_TUNER_STATUS 0x05 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ + +#define GET_SYSTEM_STRING 0x06 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ + +#define SET_DISEQC_CMD 0x08 +/* additional out buffer: + * 0 1 2 3 4 + * len X1 X2 X3 X4 + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define SET_LNB_POWER 0x09 +/* additional out buffer: + * 0 1 2 + * 0x00 0xff 1 = on, 0 = off + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define GET_MAC_ADDRESS 0x0A +/* #define GET_MAC_ADDRESS 0x0B */ +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ + +#define SET_PID_FILTER 0x11 +/* additional in buffer: + * 0 1 ... 14 15 16 + * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ + +/* request: 0xB2; i: 0; v: 0; + * b[0] != 0 -> tune and lock a channel + * 0 1 2 3 4 5 6 7 + * freq0 freq1 divstep srate0 srate1 srate2 flag chksum + */ + + +/* one direction requests */ +#define READ_REMOTE_REQ 0xB4 +/* IN i: 0; v: 0; b[0] == request, b[1] == key */ + +#define READ_PID_NUMBER_REQ 0xB5 +/* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ + +#define WRITE_EEPROM_REQ 0xB6 +/* OUT i: offset; v: value to write; no extra buffer */ + +#define READ_EEPROM_REQ 0xB7 +/* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ + +#define READ_STATUS 0xB8 +/* IN i: 0; v: 0; bufferlen 10 */ + +#define READ_TUNER_REG_REQ 0xB9 +/* IN i: 0; v: register; b[0] = value */ + +#define READ_FX2_REG_REQ 0xBA +/* IN i: offset; v: 0; b[0] = value */ + +#define WRITE_FX2_REG_REQ 0xBB +/* OUT i: offset; v: value to write; 1 byte extra buffer */ + +#define SET_TUNER_POWER_REQ 0xBC +/* IN i: 0 = power off, 1 = power on */ + +#define WRITE_TUNER_REG_REQ 0xBD +/* IN i: register, v: value to write, no extra buffer */ + +#define RESET_TUNER 0xBE +/* IN i: 0, v: 0, no extra buffer */ + +extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); + +extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); +extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); + +#endif -- cgit v1.2.3 From e69339d9a43d4691f6a05c5a54a00d54814aaa68 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:42 -0700 Subject: [PATCH] dvb: usb: dibusb: Kworld Xpert DVB-T USB2.0 support Add USB IDs of the Kworld Xpert DVB-T USB2.0 (clone of the ADStech box). Thanks to Marcus Hagn for testing. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/dibusb-mb.c | 14 ++++++++++---- drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 828b5182e16..c9f3e90ee25 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -126,10 +126,12 @@ static struct usb_device_id dibusb_dib3000mb_table [] = { /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, +/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) }, + // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs -/* 27 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, +/* 28 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, #endif { } /* Terminating entry */ }; @@ -262,7 +264,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { }, #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", - { &dibusb_dib3000mb_table[27], NULL }, + { &dibusb_dib3000mb_table[28], NULL }, { NULL }, }, #endif @@ -306,12 +308,16 @@ static struct dvb_usb_properties dibusb2_0b_properties = { } }, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { - { "KWorld/ADSTech Instant DVB-T USB 2.0", + { "KWorld/ADSTech Instant DVB-T USB2.0", { &dibusb_dib3000mb_table[23], NULL }, { &dibusb_dib3000mb_table[24], NULL }, }, + { "KWorld Xpert DVB-T USB2.0", + { &dibusb_dib3000mb_table[27], NULL }, + { NULL } + }, } }; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 2b249c75fb0..1b978389e4e 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -24,6 +24,7 @@ #define USB_VID_HANFTEK 0x15f4 #define USB_VID_HAUPPAUGE 0x2040 #define USB_VID_HYPER_PALTEK 0x1025 +#define USB_VID_KWORLD 0xeb2a #define USB_VID_KYE 0x0458 #define USB_VID_MEDION 0x1660 #define USB_VID_VISIONPLUS 0x13d3 -- cgit v1.2.3 From 54127d64d2094207e0e12a4a9eec33573f25f7ac Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 9 Sep 2005 13:02:43 -0700 Subject: [PATCH] dvb: usb: removed empty module_init/exit calls Removed empty module_init/exit calls. Signed-off-by: Andreas Oberritter Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/dvb-usb-init.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 65f0c095abc..ea1098a6c7a 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -196,19 +196,6 @@ void dvb_usb_device_exit(struct usb_interface *intf) } EXPORT_SYMBOL(dvb_usb_device_exit); -/* module stuff */ -static int __init dvb_usb_module_init(void) -{ - return 0; -} - -static void __exit dvb_usb_module_exit(void) -{ -} - -module_init (dvb_usb_module_init); -module_exit (dvb_usb_module_exit); - MODULE_VERSION("0.3"); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); -- cgit v1.2.3 From 43bc3f41e4b1bb88adaef593f50c1f032bf0e876 Mon Sep 17 00:00:00 2001 From: "Ye Jianjun (Joey" Date: Fri, 9 Sep 2005 13:02:44 -0700 Subject: [PATCH] dvb: usb: dtt200u: copy frontend_ops before modifying Fix: copy frontend_ops before modifying Signed-off-by: Ye Jianjun (Joey) Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/dtt200u-fe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index b032523b07b..0a94ec22aeb 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c +++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c @@ -18,6 +18,7 @@ struct dtt200u_fe_state { struct dvb_frontend_parameters fep; struct dvb_frontend frontend; + struct dvb_frontend_ops ops; }; static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) @@ -163,8 +164,9 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) deb_info("attaching frontend dtt200u\n"); state->d = d; + memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); - state->frontend.ops = &dtt200u_fe_ops; + state->frontend.ops = &state->ops; state->frontend.demodulator_priv = state; goto success; -- cgit v1.2.3 From 62703b9d72114a563488cd4be6d0827618395589 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:46 -0700 Subject: [PATCH] dvb: usb: dtt200u: add proper device names Added names for clones of the DVB-T stick. Whitespace cleanups. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/dtt200u.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 47dba6e4596..9d74f48284f 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -106,12 +106,11 @@ static int dtt200u_usb_probe(struct usb_interface *intf, } static struct usb_device_id dtt200u_usb_table [] = { -// { USB_DEVICE(0x04b4,0x8613) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, - { 0 }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, + { 0 }, }; MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); @@ -189,7 +188,7 @@ static struct dvb_usb_properties wt220u_properties = { .num_device_descs = 1, .devices = { - { .name = "WideView WT-220U PenType Receiver (and clones)", + { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)", .cold_ids = { &dtt200u_usb_table[2], NULL }, .warm_ids = { &dtt200u_usb_table[3], NULL }, }, @@ -201,9 +200,9 @@ static struct dvb_usb_properties wt220u_properties = { static struct usb_driver dtt200u_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_dtt200u", - .probe = dtt200u_usb_probe, + .probe = dtt200u_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = dtt200u_usb_table, + .id_table = dtt200u_usb_table, }; /* module stuff */ -- cgit v1.2.3 From 47dc3d688d04f06d8ef90a06c48930906fbc4a8c Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:47 -0700 Subject: [PATCH] dvb: usb: core: change dvb_usb_device_init() API Change the init call to optionally return the new dvb_usb_device directly. Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/a800.c | 2 +- drivers/media/dvb/dvb-usb/cxusb.c | 2 +- drivers/media/dvb/dvb-usb/dibusb-mb.c | 6 +++--- drivers/media/dvb/dvb-usb/dibusb-mc.c | 2 +- drivers/media/dvb/dvb-usb/digitv.c | 2 +- drivers/media/dvb/dvb-usb/dtt200u.c | 4 ++-- drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 3 +++ drivers/media/dvb/dvb-usb/dvb-usb-init.c | 7 ++++++- drivers/media/dvb/dvb-usb/dvb-usb.h | 4 ++-- drivers/media/dvb/dvb-usb/nova-t-usb2.c | 2 +- drivers/media/dvb/dvb-usb/umt-010.c | 2 +- drivers/media/dvb/dvb-usb/vp702x.c | 2 +- drivers/media/dvb/dvb-usb/vp7045.c | 2 +- 13 files changed, 24 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index f2fcc2f1f84..e55322ef76b 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -90,7 +90,7 @@ static struct dvb_usb_properties a800_properties; static int a800_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 9e96a188f1e..d2be0351401 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -211,7 +211,7 @@ static struct dvb_usb_properties cxusb_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL); } static struct usb_device_id cxusb_table [] = { diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index c9f3e90ee25..0058505634a 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -86,9 +86,9 @@ static struct dvb_usb_properties dibusb2_0b_properties; static int dibusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index e9dac430f37..6a0912eab39 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -20,7 +20,7 @@ static struct dvb_usb_properties dibusb_mc_properties; static int dibusb_mc_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f70e0be0920..24d2bc6ca97 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -173,7 +173,7 @@ static struct dvb_usb_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL); } static struct usb_device_id digitv_table [] = { diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 9d74f48284f..5aa12ebab34 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -98,8 +98,8 @@ static struct dvb_usb_properties wt220u_properties; static int dtt200u_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0) return 0; return -ENODEV; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 1b978389e4e..0818996bf15 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -27,6 +27,7 @@ #define USB_VID_KWORLD 0xeb2a #define USB_VID_KYE 0x0458 #define USB_VID_MEDION 0x1660 +#define USB_VID_PINNACLE 0x2304 #define USB_VID_VISIONPLUS 0x13d3 #define USB_VID_TWINHAN 0x1822 #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 @@ -88,5 +89,7 @@ #define USB_PID_MEDION_MD95700 0x0932 #define USB_PID_KYE_DVB_T_COLD 0x701e #define USB_PID_KYE_DVB_T_WARM 0x701f +#define USB_PID_PCTV_200E 0x020e +#define USB_PID_PCTV_400E 0x020f #endif diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index ea1098a6c7a..a902059812a 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -128,7 +128,9 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device /* * USB */ -int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *props, struct module *owner) + +int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties + *props, struct module *owner,struct dvb_usb_device **du) { struct usb_device *udev = interface_to_usbdev(intf); struct dvb_usb_device *d = NULL; @@ -170,6 +172,9 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *p usb_set_intfdata(intf, d); + if (du != NULL) + *du = d; + ret = dvb_usb_init(d); } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index a80567caf50..0e4f1035b0d 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -127,7 +127,7 @@ struct dvb_usb_device; * helper functions. * * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. - * Currently only BULK is implemented + * (BULK or ISOC) * * @num_device_descs: number of struct dvb_usb_device_description in @devices * @devices: array of struct dvb_usb_device_description compatibles with these @@ -310,7 +310,7 @@ struct dvb_usb_device { void *priv; }; -extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *); +extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); extern void dvb_usb_device_exit(struct usb_interface *); /* the generic read/write method for device control */ diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 258a92bfbcc..1841a66427b 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -144,7 +144,7 @@ static struct dvb_usb_properties nova_t_properties; static int nova_t_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 2112ac3cf5e..6fd67657c26 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -77,7 +77,7 @@ static struct dvb_usb_properties umt_properties; static int umt_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; } diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 1f5034ca115..de13c04e8e6 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -197,7 +197,7 @@ static int vp702x_usb_probe(struct usb_interface *intf, usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); - return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); } static struct usb_device_id vp702x_usb_table [] = { diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 9ac95f54f9f..13406a8da24 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -199,7 +199,7 @@ static struct dvb_usb_properties vp7045_properties; static int vp7045_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL); } static struct usb_device_id vp7045_usb_table [] = { -- cgit v1.2.3 From 115eea4e91049a42d81e5284cbb0f50acab6eb39 Mon Sep 17 00:00:00 2001 From: Svante Olofsson Date: Fri, 9 Sep 2005 13:02:48 -0700 Subject: [PATCH] dvb: usb: digitv: support for nxt6000 demod Add support for the NXT6000-based digitv-box. Add .get_tune_settings callback for the NXT6000 to have a min_tune_delay of 500ms. Signed-off-by: Svante Olofsson Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/digitv.c | 40 +++++++++++++++++++++-------------- drivers/media/dvb/frontends/nxt6000.c | 9 ++++++++ 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 24d2bc6ca97..74545f82eff 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -111,31 +111,28 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe) } static struct mt352_config digitv_mt352_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ .demod_init = digitv_mt352_demod_init, .pll_set = dvb_usb_pll_set, }; -static struct nxt6000_config digitv_nxt6000_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ - .clock_inversion = 0x0, +static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) +{ + struct dvb_usb_device *d = fe->dvb->priv; + u8 b[5]; + dvb_usb_pll_set(fe,fep,b); + return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); +} - .pll_init = NULL, - .pll_set = NULL, +static struct nxt6000_config digitv_nxt6000_config = { + .clock_inversion = 1, + .pll_set = digitv_nxt6000_pll_set, }; static int digitv_frontend_attach(struct dvb_usb_device *d) { - if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) + if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL || + (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) return 0; - if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { - - warn("nxt6000 support is not done yet, in fact you are one of the first " - "person who wants to use this device in Linux. Please report to " - "linux-dvb@linuxtv.org"); - - return 0; - } return -EIO; } @@ -173,7 +170,18 @@ static struct dvb_usb_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL); + struct dvb_usb_device *d; + int ret; + if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { + u8 b[4] = { 0 }; + + b[0] = 1; + digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0); + + b[0] = 0; + digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); + } + return ret; } static struct usb_device_id digitv_table [] = { diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index 966de9853d1..88a57b79111 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c @@ -482,6 +482,7 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par if ((result = nxt6000_set_inversion(state, param->inversion)) < 0) return result; + msleep(500); return 0; } @@ -525,6 +526,12 @@ static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_str return 0; } +static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + tune->min_delay_ms = 500; + return 0; +} + static struct dvb_frontend_ops nxt6000_ops; struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, @@ -578,6 +585,8 @@ static struct dvb_frontend_ops nxt6000_ops = { .init = nxt6000_init, + .get_tune_settings = nxt6000_fe_get_tune_settings, + .set_frontend = nxt6000_set_frontend, .read_status = nxt6000_read_status, -- cgit v1.2.3 From 3beab78f8ad5a483fdbdcbb8599fb06da102b8b7 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:50 -0700 Subject: [PATCH] dvb: usb: white space cleanup white space cleanup Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/vp7045.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 13406a8da24..0f57abeb6d6 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -164,7 +164,6 @@ static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int off return 0; } - static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) { return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); @@ -256,9 +255,9 @@ static struct dvb_usb_properties vp7045_properties = { static struct usb_driver vp7045_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_vp7045", - .probe = vp7045_usb_probe, + .probe = vp7045_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = vp7045_usb_table, + .id_table = vp7045_usb_table, }; /* module stuff */ -- cgit v1.2.3 From e2efeab26b77061ba5418f4c98c3b3ed100fb608 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Fri, 9 Sep 2005 13:02:51 -0700 Subject: [PATCH] dvb: usb: cxusb: fixes for new firmware This patch changes two things: 1) a firmware update made by the vendor, which has to be done in Windows for now, changes the DVB-data-pipe from isochronous to bulk: it fixes the data distortions (and thus the video-distortions) in DVB-T mode; there is no backwards compatibility with the old firmware as it didn't work anyway 2) with the help of Steve Toth some reverse-engineered functionality is now named correctly, thank you Signed-off-by: Patrick Boettcher Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-usb/cxusb.c | 64 ++++++++++++++------------------------- drivers/media/dvb/dvb-usb/cxusb.h | 27 +++++++++-------- 2 files changed, 37 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index d2be0351401..3fe383f4bb4 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -48,35 +48,26 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, return 0; } -/* I2C */ -static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path) +/* GPIO */ +static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff) { struct cxusb_state *st = d->priv; u8 o[2],i; - if (path == st->cur_i2c_path) + if (st->gpio_write_state[GPIO_TUNER] == onoff) return; - o[0] = IOCTL_SET_I2C_PATH; - switch (path) { - case PATH_CX22702: - o[1] = 0; - break; - case PATH_TUNER_OTHER: - o[1] = 1; - break; - default: - err("unkown i2c path"); - return; - } - cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1); + o[0] = GPIO_TUNER; + o[1] = onoff; + cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1); if (i != 0x01) - deb_info("i2c_path setting failed.\n"); + deb_info("gpio_write failed.\n"); - st->cur_i2c_path = path; + st->gpio_write_state[GPIO_TUNER] = onoff; } +/* I2C */ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); @@ -92,10 +83,10 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) switch (msg[i].addr) { case 0x63: - cxusb_set_i2c_path(d,PATH_CX22702); + cxusb_gpio_tuner(d,0); break; default: - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); + cxusb_gpio_tuner(d,1); break; } @@ -147,16 +138,20 @@ static struct i2c_algorithm cxusb_i2c_algo = { static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) { - return 0; + u8 b = 0; + if (onoff) + return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); + else + return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); } static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) { u8 buf[2] = { 0x03, 0x00 }; if (onoff) - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); else - cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); return 0; } @@ -182,22 +177,11 @@ static int cxusb_tuner_attach(struct dvb_usb_device *d) static int cxusb_frontend_attach(struct dvb_usb_device *d) { - u8 buf[2] = { 0x03, 0x00 }; - u8 b = 0; - - if (usb_set_interface(d->udev,0,0) < 0) - err("set interface to alts=0 failed"); - - cxusb_ctrl_msg(d,0xde,&b,0,NULL,0); - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); - cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1); - + u8 b; if (usb_set_interface(d->udev,0,6) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); - cxusb_set_i2c_path(d,PATH_CX22702); - cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1); + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) return 0; @@ -237,14 +221,12 @@ static struct dvb_usb_properties cxusb_properties = { .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ .urb = { - .type = DVB_USB_ISOC, + .type = DVB_USB_BULK, .count = 5, .endpoint = 0x02, .u = { - .isoc = { - .framesperurb = 32, - .framesize = 940, - .interval = 5, + .bulk = { + .buffersize = 8192, } } }, diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h index 1d79016e319..135c2a81f58 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.h +++ b/drivers/media/dvb/dvb-usb/cxusb.h @@ -1,30 +1,31 @@ #ifndef _DVB_USB_CXUSB_H_ #define _DVB_USB_CXUSB_H_ -#define DVB_USB_LOG_PREFIX "digitv" +#define DVB_USB_LOG_PREFIX "cxusb" #include "dvb-usb.h" extern int dvb_usb_cxusb_debug; #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) /* usb commands - some of it are guesses, don't have a reference yet */ -#define CMD_I2C_WRITE 0x08 -#define CMD_I2C_READ 0x09 +#define CMD_I2C_WRITE 0x08 +#define CMD_I2C_READ 0x09 -#define CMD_IOCTL 0x0e -#define IOCTL_SET_I2C_PATH 0x02 +#define CMD_GPIO_READ 0x0d +#define CMD_GPIO_WRITE 0x0e +#define GPIO_TUNER 0x02 -#define CMD_POWER_OFF 0x50 -#define CMD_POWER_ON 0x51 +#define CMD_POWER_OFF 0xdc +#define CMD_POWER_ON 0xde -enum cxusb_i2c_pathes { - PATH_UNDEF = 0x00, - PATH_CX22702 = 0x01, - PATH_TUNER_OTHER = 0x02, -}; +#define CMD_STREAMING_ON 0x36 +#define CMD_STREAMING_OFF 0x37 + +#define CMD_ANALOG 0x50 +#define CMD_DIGITAL 0x51 struct cxusb_state { - enum cxusb_i2c_pathes cur_i2c_path; + u8 gpio_write_state[3]; }; #endif -- cgit v1.2.3 From 5b5b53452be0b1132cfb8e22fbe5fe43c25140a0 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:52 -0700 Subject: [PATCH] dvb: remove noisy debug print comment out noisy dprintk in dst_get_signal() (why are errors only visible with debug on? this needs to be cleaned up so we can disable debug by default) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 07a0b0a968a..6c34ac9cefd 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -928,7 +928,7 @@ static int dst_get_signal(struct dst_state* state) { int retval; u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; - dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); + //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { state->decode_lock = state->decode_strength = state->decode_snr = 0; return 0; -- cgit v1.2.3 From 466d725ac8d9c58a5de87f72b4fe066c4bad3d9d Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:02:53 -0700 Subject: [PATCH] dvb: bt8xx: endianness fix Endianness fix for risc DMA start address setting. (reported by Stefan Haubenthal/Peter Hettkamp) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/bt878.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3bfbba3d9df..f2957145003 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, controlreg &= ~0x1f; controlreg |= 0x1b; - btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START); + btwrite(bt->risc_dma, BT878_ARISC_START); /* original int mask had : * 6 2 8 4 0 -- cgit v1.2.3 From 1f15ddd0b79d1722049952b7359533a18a72f106 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Fri, 9 Sep 2005 13:02:54 -0700 Subject: [PATCH] dvb: bt8xx: cleanup Indentation fixes and remove unnecessary braces. Signed-off-by: David Johnson Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dvb-bt8xx.c | 225 ++++++++++++++++++------------------ 1 file changed, 114 insertions(+), 111 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 6f857c6091f..b29b0f558c7 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -32,9 +32,7 @@ #include "dvbdev.h" #include "dvb_demux.h" #include "dvb_frontend.h" - #include "dvb-bt8xx.h" - #include "bt878.h" static int debug; @@ -43,9 +41,9 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); #define dprintk( args... ) \ - do { \ + do \ if (debug) printk(KERN_DEBUG args); \ - } while (0) + while (0) static void dvb_bt8xx_task(unsigned long data) { @@ -119,14 +117,12 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci unsigned int card_nr; /* Hmm, n squared. Hope n is small */ - for (card_nr = 0; card_nr < bt878_num; card_nr++) { + for (card_nr = 0; card_nr < bt878_num; card_nr++) if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) return &bt878[card_nr]; - } return NULL; } - static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; @@ -157,13 +153,19 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 542000000) cp = 0xb4; - else if (params->frequency < 771000000) cp = 0xbc; - else cp = 0xf4; + if (params->frequency < 542000000) + cp = 0xb4; + else if (params->frequency < 771000000) + cp = 0xbc; + else + cp = 0xf4; - if (params->frequency == 0) bs = 0x03; - else if (params->frequency < 443250000) bs = 0x02; - else bs = 0x08; + if (params->frequency == 0) + bs = 0x03; + else if (params->frequency < 443250000) + bs = 0x02; + else + bs = 0x08; pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -175,7 +177,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ } static struct mt352_config thomson_dtt7579_config = { - .demod_address = 0x0f, .demod_init = thomson_dtt7579_demod_init, .pll_set = thomson_dtt7579_pll_set, @@ -183,25 +184,26 @@ static struct mt352_config thomson_dtt7579_config = { static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { - u32 freq = params->frequency; - - int i, a, n, pump; - u32 band, pll; + u32 freq = params->frequency; + int i, a, n, pump; + u32 band, pll; - u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, - 1576000,1718000,1856000,2036000,2150000}; - u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, - 0x00102000,0x00104000,0x00108000,0x00110000, - 0x00120000,0x00140000}; + u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, + 1576000,1718000,1856000,2036000,2150000}; + u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, + 0x00102000,0x00104000,0x00108000,0x00110000, + 0x00120000,0x00140000}; -#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ + #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); /* This is really the bit driving the tuner chip cx24108 */ - if(freq<950000) freq=950000; /* kHz */ - if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ + if (freq<950000) + freq = 950000; /* kHz */ + else if (freq>2150000) + freq = 2150000; /* satellite IF is 950..2150MHz */ /* decide which VCO to use for the input frequency */ for(i=1;(idvb->priv; @@ -258,15 +257,23 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front div = (36000000 + params->frequency + 83333) / 166666; cfg = 0x88; - if (params->frequency < 175000000) cpump = 2; - else if (params->frequency < 390000000) cpump = 1; - else if (params->frequency < 470000000) cpump = 2; - else if (params->frequency < 750000000) cpump = 2; - else cpump = 3; + if (params->frequency < 175000000) + cpump = 2; + else if (params->frequency < 390000000) + cpump = 1; + else if (params->frequency < 470000000) + cpump = 2; + else if (params->frequency < 750000000) + cpump = 2; + else + cpump = 3; - if (params->frequency < 175000000) band_select = 0x0e; - else if (params->frequency < 470000000) band_select = 0x05; - else band_select = 0x03; + if (params->frequency < 175000000) + band_select = 0x0e; + else if (params->frequency < 470000000) + band_select = 0x05; + else + band_select = 0x03; data[0] = (div >> 8) & 0x7f; data[1] = div & 0xff; @@ -285,14 +292,11 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s } static struct sp887x_config microtune_mt7202dtf_config = { - .demod_address = 0x70, .pll_set = microtune_mt7202dtf_pll_set, .request_firmware = microtune_mt7202dtf_request_firmware, }; - - static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; @@ -303,7 +307,6 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; - mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); udelay(2000); mt352_write(fe, mt352_reset, sizeof(mt352_reset)); @@ -326,25 +329,43 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 150000000) cp = 0xB4; - else if (params->frequency < 173000000) cp = 0xBC; - else if (params->frequency < 250000000) cp = 0xB4; - else if (params->frequency < 400000000) cp = 0xBC; - else if (params->frequency < 420000000) cp = 0xF4; - else if (params->frequency < 470000000) cp = 0xFC; - else if (params->frequency < 600000000) cp = 0xBC; - else if (params->frequency < 730000000) cp = 0xF4; - else cp = 0xFC; - - if (params->frequency < 150000000) bs = 0x01; - else if (params->frequency < 173000000) bs = 0x01; - else if (params->frequency < 250000000) bs = 0x02; - else if (params->frequency < 400000000) bs = 0x02; - else if (params->frequency < 420000000) bs = 0x02; - else if (params->frequency < 470000000) bs = 0x02; - else if (params->frequency < 600000000) bs = 0x08; - else if (params->frequency < 730000000) bs = 0x08; - else bs = 0x08; + if (params->frequency < 150000000) + cp = 0xB4; + else if (params->frequency < 173000000) + cp = 0xBC; + else if (params->frequency < 250000000) + cp = 0xB4; + else if (params->frequency < 400000000) + cp = 0xBC; + else if (params->frequency < 420000000) + cp = 0xF4; + else if (params->frequency < 470000000) + cp = 0xFC; + else if (params->frequency < 600000000) + cp = 0xBC; + else if (params->frequency < 730000000) + cp = 0xF4; + else + cp = 0xFC; + + if (params->frequency < 150000000) + bs = 0x01; + else if (params->frequency < 173000000) + bs = 0x01; + else if (params->frequency < 250000000) + bs = 0x02; + else if (params->frequency < 400000000) + bs = 0x02; + else if (params->frequency < 420000000) + bs = 0x02; + else if (params->frequency < 470000000) + bs = 0x02; + else if (params->frequency < 600000000) + bs = 0x08; + else if (params->frequency < 730000000) + bs = 0x08; + else + bs = 0x08; pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct } static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { - .demod_address = 0x0f, .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, }; - static struct dst_config dst_config = { - .demod_address = 0x55, }; - static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) { struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; @@ -398,10 +415,9 @@ static void or51211_reset(struct dvb_frontend * fe) */ /* reset & PRM1,2&4 are outputs */ int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); - if (ret != 0) { + if (ret != 0) printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " "(%i)\n", ret); - } bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ msleep(20); /* Now set for normal operation */ @@ -417,7 +433,6 @@ static void or51211_sleep(struct dvb_frontend * fe) } static struct or51211_config or51211_config = { - .demod_address = 0x15, .request_firmware = or51211_request_firmware, .setmode = or51211_setmode, @@ -425,7 +440,6 @@ static struct or51211_config or51211_config = { .sleep = or51211_sleep, }; - static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; @@ -454,13 +468,11 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten } static struct nxt6000_config vp3021_alps_tded4_config = { - .demod_address = 0x0a, .clock_inversion = 1, .pll_set = vp3021_alps_tded4_pll_set, }; - static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { int ret; @@ -468,7 +480,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) switch(type) { #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; @@ -479,24 +491,22 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) #endif #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_AVDVBT_771: + case BTTV_AVDVBT_771: card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; @@ -505,7 +515,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) } break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: /* DST is not a frontend driver !!! */ state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); /* Setup the Card */ @@ -522,54 +532,48 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Attach other DST peripherals if any */ /* Conditional Access device */ - if (state->dst_hw_cap & DST_TYPE_HAS_CA) { + if (state->dst_hw_cap & DST_TYPE_HAS_CA) ret = dst_ca_attach(state, &card->dvb_adapter); - } - if (card->fe != NULL) { + + if (card->fe != NULL) break; - } break; - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->fe = or51211_attach(&or51211_config, card->i2c_adapter); - if (card->fe != NULL) { + if (card->fe != NULL) break; - } break; } - if (card->fe == NULL) { + if (card->fe == NULL) printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", card->bt->dev->vendor, card->bt->dev->device, card->bt->dev->subsystem_vendor, card->bt->dev->subsystem_device); - } else { + else if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { printk("dvb-bt8xx: Frontend registration failed!\n"); if (card->fe->ops->release) card->fe->ops->release(card->fe); card->fe = NULL; } - } } static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) { int result; - if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, - THIS_MODULE)) < 0) { + if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) { printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); return result; - } card->dvb_adapter.priv = card; @@ -664,9 +668,8 @@ static int dvb_bt8xx_probe(struct device *dev) strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); card->i2c_adapter = &sub->core->i2c_adap; - switch(sub->core->type) - { - case BTTV_PINNACLESAT: + switch(sub->core->type) { + case BTTV_PINNACLESAT: 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. */ @@ -675,7 +678,7 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: #endif card->gpio_mode = 0x0400C060; card->op_sync_orin = 0; @@ -686,25 +689,25 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); card->op_sync_orin = 0; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP (high speed serial) */ break; - case BTTV_AVDVBT_771: //case 0x07711461: + case BTTV_AVDVBT_771: //case 0x07711461: card->gpio_mode = 0x0400402B; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/ break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: card->gpio_mode = 0x2204f2c; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | @@ -722,13 +725,13 @@ static int dvb_bt8xx_probe(struct device *dev) * RISC+FIFO ENABLE */ break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->gpio_mode = 0x0100EC7B; card->op_sync_orin = 0; card->irq_err_ignore = 0; break; - default: + default: printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n", sub->core->type); kfree(card); @@ -751,7 +754,6 @@ static int dvb_bt8xx_probe(struct device *dev) kfree(card); return -EFAULT; - } init_MUTEX(&card->bt->gpio_lock); @@ -779,7 +781,8 @@ static int dvb_bt8xx_remove(struct device *dev) card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); dvb_dmxdev_release(&card->dmxdev); dvb_dmx_release(&card->demux); - if (card->fe) dvb_unregister_frontend(card->fe); + if (card->fe) + dvb_unregister_frontend(card->fe); dvb_unregister_adapter(&card->dvb_adapter); kfree(card); -- cgit v1.2.3 From 05ade5a5cd32f8393c22fc454b0546df2ed497c5 Mon Sep 17 00:00:00 2001 From: David Johnson Date: Fri, 9 Sep 2005 13:02:55 -0700 Subject: [PATCH] dvb: bt8xx: Nebula DigiTV mt352 support Add support for Nebula DigiTV PCI cards with the MT352 frontend. Signed-off-by: David Johnson Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dvb-bt8xx.c | 141 +++++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index b29b0f558c7..514dff36e6e 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -45,6 +45,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); if (debug) printk(KERN_DEBUG args); \ while (0) +#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ + static void dvb_bt8xx_task(unsigned long data) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; @@ -150,7 +152,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; if (params->frequency < 542000000) @@ -326,7 +327,6 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; if (params->frequency < 150000000) @@ -416,8 +416,7 @@ static void or51211_reset(struct dvb_frontend * fe) /* reset & PRM1,2&4 are outputs */ int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); if (ret != 0) - printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " - "(%i)\n", ret); + printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret); bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ msleep(20); /* Now set for normal operation */ @@ -473,6 +472,80 @@ static struct nxt6000_config vp3021_alps_tded4_config = { .pll_set = vp3021_alps_tded4_pll_set, }; +static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe) +{ + static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; + static u8 mt352_reset [] = { 0x50, 0x80 }; + static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; + static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 }; + static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; + + mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); + udelay(2000); + mt352_write(fe, mt352_reset, sizeof(mt352_reset)); + mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); + mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg)); + mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); + + return 0; +} + +static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) +{ + u32 div; + struct dvb_ofdm_parameters *op = ¶ms->u.ofdm; + + div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; + + pllbuf[0] = 0xc2; + pllbuf[1] = (div >> 8) & 0x7F; + pllbuf[2] = div & 0xFF; + pllbuf[3] = 0x85; + + dprintk("frequency %u, div %u\n", params->frequency, div); + + if (params->frequency < 470000000) + pllbuf[4] = 0x02; + else if (params->frequency > 823000000) + pllbuf[4] = 0x88; + else + pllbuf[4] = 0x08; + + if (op->bandwidth == 8) + pllbuf[4] |= 0x04; + + return 0; +} + +static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt) +{ + /* + * Reset the frontend, must be called before trying + * to initialise the MT352 or mt352_attach + * will fail. + * + * Presumably not required for the NXT6000 frontend. + * + */ + + int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08); + if (ret != 0) + printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret); + + /* Pulse the reset line */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */ + msleep(100); + + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ +} + +static struct mt352_config digitv_alps_tded4_config = { + .demod_address = 0x0a, + .demod_init = digitv_alps_tded4_demod_init, + .pll_set = digitv_alps_tded4_pll_set, +}; + static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { int ret; @@ -480,42 +553,51 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) switch(type) { #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; #endif #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif + /* + * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK); + * this would be a cleaner solution than trying each frontend in turn. + */ + + /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); if (card->fe != NULL) - break; + dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); + + /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ + digitv_alps_tded4_reset(card); + card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); + + if (card->fe != NULL) + dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); break; - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; - case BTTV_AVDVBT_771: + case BTTV_AVDVBT_771: card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: /* DST is not a frontend driver !!! */ state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); /* Setup the Card */ @@ -534,21 +616,14 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Conditional Access device */ if (state->dst_hw_cap & DST_TYPE_HAS_CA) ret = dst_ca_attach(state, &card->dvb_adapter); - - if (card->fe != NULL) - break; break; - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->fe = or51211_attach(&or51211_config, card->i2c_adapter); - if (card->fe != NULL) - break; break; } @@ -669,7 +744,7 @@ static int dvb_bt8xx_probe(struct device *dev) card->i2c_adapter = &sub->core->i2c_adap; switch(sub->core->type) { - case BTTV_PINNACLESAT: + case BTTV_PINNACLESAT: 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. */ @@ -678,7 +753,7 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_DVICO_DVBT_LITE - case BTTV_DVICO_DVBT_LITE: + case BTTV_DVICO_DVBT_LITE: #endif card->gpio_mode = 0x0400C060; card->op_sync_orin = 0; @@ -689,25 +764,25 @@ static int dvb_bt8xx_probe(struct device *dev) break; #ifdef BTTV_TWINHAN_VP3021 - case BTTV_TWINHAN_VP3021: + case BTTV_TWINHAN_VP3021: #else - case BTTV_NEBULA_DIGITV: + case BTTV_NEBULA_DIGITV: #endif - case BTTV_AVDVBT_761: + case BTTV_AVDVBT_761: card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); card->op_sync_orin = 0; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP (high speed serial) */ break; - case BTTV_AVDVBT_771: //case 0x07711461: + case BTTV_AVDVBT_771: //case 0x07711461: card->gpio_mode = 0x0400402B; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = 0; /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/ break; - case BTTV_TWINHAN_DST: + case BTTV_TWINHAN_DST: card->gpio_mode = 0x2204f2c; card->op_sync_orin = BT878_RISC_SYNC_MASK; card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | @@ -725,13 +800,13 @@ static int dvb_bt8xx_probe(struct device *dev) * RISC+FIFO ENABLE */ break; - case BTTV_PC_HDTV: + case BTTV_PC_HDTV: card->gpio_mode = 0x0100EC7B; card->op_sync_orin = 0; card->irq_err_ignore = 0; break; - default: + default: printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n", sub->core->type); kfree(card); -- cgit v1.2.3 From f30db067a593aeb3fdd97ec0a3e6399ea566f2ad Mon Sep 17 00:00:00 2001 From: Stuart Auchterlonie Date: Fri, 9 Sep 2005 13:02:56 -0700 Subject: [PATCH] dvb: nebula DigiTV nxt6000 fix Fix bug in Nebula DigiTV frontend detection for nxt6000. Signed-off-by: Stuart Auchterlonie Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dvb-bt8xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 514dff36e6e..c5c7672cd53 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -574,8 +574,10 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); - if (card->fe != NULL) + if (card->fe != NULL) { dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); + break; + } /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ digitv_alps_tded4_reset(card); -- cgit v1.2.3 From f612c5793449ac653b2f4531696d8e74e771e3d3 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:02:58 -0700 Subject: [PATCH] dvb: dst: fix symbol rate setting Make the Symbolrate setting card specific. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 6c34ac9cefd..66e69b8e1a0 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -324,12 +324,12 @@ static int dst_set_polarization(struct dst_state *state) { switch (state->voltage) { case SEC_VOLTAGE_13: // vertical - printk("%s: Polarization=[Vertical]\n", __FUNCTION__); + dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__); state->tx_tuna[8] &= ~0x40; //1 break; case SEC_VOLTAGE_18: // horizontal - printk("%s: Polarization=[Horizontal]\n", __FUNCTION__); + dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__); state->tx_tuna[8] |= 0x40; // 0 break; @@ -344,7 +344,7 @@ static int dst_set_polarization(struct dst_state *state) static int dst_set_freq(struct dst_state *state, u32 freq) { state->frequency = freq; - if (debug > 4) + if (verbose > 4) dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); if (state->dst_type == DST_TYPE_IS_SAT) { @@ -451,7 +451,6 @@ static fe_code_rate_t dst_get_fec(struct dst_state* state) static int dst_set_symbolrate(struct dst_state* state, u32 srate) { - u8 *val; u32 symcalc; u64 sval; @@ -463,7 +462,6 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate) if (debug > 4) dprintk("%s: set symrate %u\n", __FUNCTION__, srate); srate /= 1000; - val = &state->tx_tuna[0]; if (state->type_flags & DST_TYPE_HAS_SYMDIV) { sval = srate; @@ -474,17 +472,19 @@ static int dst_set_symbolrate(struct dst_state* state, u32 srate) if (debug > 4) dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); - val[5] = (u8) (symcalc >> 12); - val[6] = (u8) (symcalc >> 4); - val[7] = (u8) (symcalc << 4); + state->tx_tuna[5] = (u8) (symcalc >> 12); + state->tx_tuna[6] = (u8) (symcalc >> 4); + state->tx_tuna[7] = (u8) (symcalc << 4); } else { - val[5] = (u8) (srate >> 16) & 0x7f; - val[6] = (u8) (srate >> 8); - val[7] = (u8) srate; + state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f; + state->tx_tuna[6] = (u8) (srate >> 8); + state->tx_tuna[7] = (u8) srate; + } + state->tx_tuna[8] &= ~0x20; + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { + if (srate > 8000) + state->tx_tuna[8] |= 0x20; } - val[8] &= ~0x20; - if (srate > 8000) - val[8] |= 0x20; return 0; } -- cgit v1.2.3 From 94b7410c8a2d23fad5937b326a0a9e8c5a876e2d Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:02:59 -0700 Subject: [PATCH] dvb: dst: remove unnecessary code Code Simplification: CA PMT object is not parsed in the driver anymore. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst_ca.c | 115 +++++++-------------------------------- 1 file changed, 20 insertions(+), 95 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index bfaacd5fc20..d2e0b1cb39d 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -260,8 +260,6 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s } - - static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) { u8 i = 0; @@ -298,10 +296,14 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) { if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { - hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ - hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ - } - else { + hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ + hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ + } else { + if (length > 247) { + dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__); + return -1; + } + hw_buffer->msg[0] = (length & 0xff) + 7; hw_buffer->msg[1] = 0x40; hw_buffer->msg[2] = 0x03; @@ -309,6 +311,11 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, hw_buffer->msg[4] = 0x03; hw_buffer->msg[5] = length & 0xff; hw_buffer->msg[6] = 0x00; + /* + * Need to compute length for EN50221 section 8.3.2, for the time being + * assuming 8.3.2 is not applicable + */ + memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length); } return 0; } @@ -348,15 +355,6 @@ u32 asn_1_decode(u8 *asn_1_array) return length; } -static int init_buffer(u8 *buffer, u32 length) -{ - u32 i; - for (i = 0; i < length; i++) - buffer[i] = 0; - - return 0; -} - static int debug_string(u8 *msg, u32 length, u32 offset) { u32 i; @@ -369,95 +367,22 @@ static int debug_string(u8 *msg, u32 length, u32 offset) return 0; } -static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length) -{ - u32 i; - dprintk("%s: Copying [", __FUNCTION__); - for (i = 0; i < length; i++) { - destination[i + dest_offset] = source[i + source_offset]; - dprintk(" %02x", source[i + source_offset]); - } - dprintk("]\n"); - - return i; -} - -static int modify_4_bits(u8 *message, u32 pos) -{ - message[pos] &= 0x0f; - - return 0; -} - - - static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) { - u32 length = 0, count = 0; - u8 asn_1_words, program_header_length; - u16 program_info_length = 0, es_info_length = 0; - u32 hw_offset = 0, buf_offset = 0, i; - u8 dst_tag_length; + u32 length = 0; + u8 tag_length = 8; length = asn_1_decode(&p_ca_message->msg[3]); dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); dprintk("%s: ASN.1 ", __FUNCTION__); - debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length + debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ - init_buffer(hw_buffer->msg, length); + memset(hw_buffer->msg, '\0', length); handle_dst_tag(state, p_ca_message, hw_buffer, length); + put_checksum(hw_buffer->msg, hw_buffer->msg[0]); - hw_offset = 7; - asn_1_words = 1; // just a hack to test, should compute this one - buf_offset = 3; - program_header_length = 6; - dst_tag_length = 7; - -// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset); -// dprintk("%s: Program Header(BUF)", __FUNCTION__); -// debug_string(&p_ca_message->msg[4], program_header_length, 0); -// dprintk("%s: Copying Program header\n", __FUNCTION__); - copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length); - buf_offset += program_header_length, hw_offset += program_header_length; - modify_4_bits(hw_buffer->msg, (hw_offset - 2)); - if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround - dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__); - debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0); - hw_buffer->msg[hw_offset - 1] += 1; - } - -// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count); -// debug_string(hw_buffer->msg, hw_offset, 0); - - program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length); - if (program_info_length) { - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current - buf_offset += count, hw_offset += count; -// dprintk("%s: Program level ", __FUNCTION__); -// debug_string(hw_buffer->msg, hw_offset, 0); - } - - buf_offset += 1;// hw_offset += 1; - for (i = buf_offset; i < length; i++) { -// dprintk("%s: Stream Header ", __FUNCTION__); - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5); - modify_4_bits(hw_buffer->msg, (hw_offset + 3)); - - hw_offset += 5, buf_offset += 5, i += 4; -// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5)); - es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length); - if (es_info_length) { - // copy descriptors @ STREAM level - dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__); - } - - } - hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length)); -// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]); - debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also - write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum + debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */ + write_to_8820(state, hw_buffer, (length + tag_length), reply); return 0; } -- cgit v1.2.3 From a427de6f72bc0d83ebb1d87f9003c5e1009f21cd Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:00 -0700 Subject: [PATCH] dvb: dst: dprrintk cleanup Code Cleanup: o Remove debug noise o Remove debug module parameter debug level is achieved using the verbosity level o Updated to kernel coding style (case labels should not be indented) Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst.c | 649 +++++++++++++++-------------------- drivers/media/dvb/bt8xx/dst_ca.c | 443 ++++++++++-------------- drivers/media/dvb/bt8xx/dst_common.h | 4 - 3 files changed, 461 insertions(+), 635 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 66e69b8e1a0..39835edba1d 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -1,5 +1,4 @@ /* - Frontend/Card driver for TwinHan DST Frontend Copyright (C) 2003 Jamie Honan Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) @@ -19,7 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include @@ -28,31 +26,45 @@ #include #include #include - #include "dvb_frontend.h" #include "dst_priv.h" #include "dst_common.h" - static unsigned int verbose = 1; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)"); - static unsigned int dst_addons; module_param(dst_addons, int, 0644); MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); -#define dprintk if (debug) printk - -#define HAS_LOCK 1 -#define ATTEMPT_TUNE 2 -#define HAS_POWER 4 - -static void dst_packsize(struct dst_state* state, int psize) +#define HAS_LOCK 1 +#define ATTEMPT_TUNE 2 +#define HAS_POWER 4 + +#define DST_ERROR 0 +#define DST_NOTICE 1 +#define DST_INFO 2 +#define DST_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ##arg); \ + } \ +} while(0) + + +static void dst_packsize(struct dst_state *state, int psize) { union dst_gpio_packet bits; @@ -60,7 +72,7 @@ static void dst_packsize(struct dst_state* state, int psize) bt878_device_control(state->bt, DST_IG_TS, &bits); } -int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) +int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay) { union dst_gpio_packet enb; union dst_gpio_packet bits; @@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int enb.enb.mask = mask; enb.enb.enable = enbb; - if (verbose > 4) - dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh); if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { - dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb); + dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb); return -EREMOTEIO; } udelay(1000); /* because complete disabling means no output, no need to do output packet */ if (enbb == 0) return 0; - if (delay) msleep(10); - bits.outp.mask = enbb; bits.outp.highvals = outhigh; - if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { - dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh); return -EREMOTEIO; } + return 0; } EXPORT_SYMBOL(dst_gpio_outb); -int dst_gpio_inb(struct dst_state *state, u8 * result) +int dst_gpio_inb(struct dst_state *state, u8 *result) { union dst_gpio_packet rd_packet; int err; *result = 0; - if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { - dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err); return -EREMOTEIO; } - *result = (u8) rd_packet.rd.value; + return 0; } EXPORT_SYMBOL(dst_gpio_inb); int rdc_reset_state(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting state machine\n", __FUNCTION__); - + dprintk(verbose, DST_INFO, 1, "Resetting state machine"); if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } - msleep(10); - if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); msleep(10); return -1; } @@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state); int rdc_8820_reset(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - + dprintk(verbose, DST_DEBUG, 1, "Resetting DST"); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } @@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset); int dst_pio_enable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); + return 0; } EXPORT_SYMBOL(dst_pio_enable); @@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable); int dst_pio_disable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) for (i = 0; i < 200; i++) { if (dst_gpio_inb(state, &reply) < 0) { - dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); return -1; } - if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { - if (verbose > 4) - dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i); return 1; } msleep(10); } - if (verbose > 1) - dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); return 0; } @@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready); int dst_error_recovery(struct dst_state *state) { - dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors."); dst_pio_disable(state); msleep(10); dst_pio_enable(state); @@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery); int dst_error_bailout(struct dst_state *state) { - dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error."); rdc_8820_reset(state); dst_pio_disable(state); msleep(10); @@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *state) } EXPORT_SYMBOL(dst_error_bailout); - -int dst_comm_init(struct dst_state* state) +int dst_comm_init(struct dst_state *state) { - if (verbose > 1) - dprintk ("%s: Initializing DST..\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Initializing DST."); if ((dst_pio_enable(state)) < 0) { - dprintk("%s: PIO Enable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed"); return -1; } if ((rdc_reset_state(state)) < 0) { - dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* state) } EXPORT_SYMBOL(dst_comm_init); - int write_dst(struct dst_state *state, u8 *data, u8 len) { struct i2c_msg msg = { - .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len + .addr = state->config->demod_address, + .flags = 0, + .buf = data, + .len = len }; int err; - int cnt; - if (debug && (verbose > 4)) { - u8 i; - if (verbose > 4) { - dprintk("%s writing [ ", __FUNCTION__); - for (i = 0; i < len; i++) - dprintk("%02x ", data[i]); - dprintk("]\n"); - } - } + u8 cnt, i; + + dprintk(verbose, DST_NOTICE, 0, "writing [ "); + for (i = 0; i < len; i++) + dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]); + dprintk(verbose, DST_NOTICE, 0, "]\n"); + for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); + dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]); dst_error_recovery(state); continue; } else break; } - if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; @@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u8 *data, u8 len) } EXPORT_SYMBOL(write_dst); -int read_dst(struct dst_state *state, u8 * ret, u8 len) +int read_dst(struct dst_state *state, u8 *ret, u8 len) { - struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; + struct i2c_msg msg = { + .addr = state->config->demod_address, + .flags = I2C_M_RD, + .buf = ret, + .len = len + }; + int err; int cnt; for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - - dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]); + dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]); dst_error_recovery(state); - continue; } else break; } if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; } - if (debug && (verbose > 4)) { - dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); - for (err = 1; err < len; err++) - dprintk(" 0x%x", ret[err]); - if (err > 1) - dprintk("\n"); - } + dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]); + for (err = 1; err < len; err++) + dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]); + if (err > 1) + dprintk(verbose, DST_DEBUG, 0, "\n"); return 0; } @@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst); static int dst_set_polarization(struct dst_state *state) { switch (state->voltage) { - case SEC_VOLTAGE_13: // vertical - dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__); - state->tx_tuna[8] &= ~0x40; //1 - break; - - case SEC_VOLTAGE_18: // horizontal - dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__); - state->tx_tuna[8] |= 0x40; // 0 - break; - - case SEC_VOLTAGE_OFF: - - break; + case SEC_VOLTAGE_13: /* Vertical */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); + state->tx_tuna[8] &= ~0x40; + break; + case SEC_VOLTAGE_18: /* Horizontal */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); + state->tx_tuna[8] |= 0x40; + break; + case SEC_VOLTAGE_OFF: + break; } return 0; @@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state) static int dst_set_freq(struct dst_state *state, u32 freq) { state->frequency = freq; - if (verbose > 4) - dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); + dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); if (state->dst_type == DST_TYPE_IS_SAT) { freq = freq / 1000; if (freq < 950 || freq > 2150) return -EINVAL; - state->tx_tuna[2] = (freq >> 8); state->tx_tuna[3] = (u8) freq; state->tx_tuna[4] = 0x01; @@ -360,27 +351,24 @@ static int dst_set_freq(struct dst_state *state, u32 freq) if (freq < 1531) state->tx_tuna[8] |= 0x04; } - } else if (state->dst_type == DST_TYPE_IS_TERR) { freq = freq / 1000; if (freq < 137000 || freq > 858000) return -EINVAL; - state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else if (state->dst_type == DST_TYPE_IS_CABLE) { state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else return -EINVAL; + return 0; } -static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) +static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth) { state->bandwidth = bandwidth; @@ -388,90 +376,82 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) return 0; switch (bandwidth) { - case BANDWIDTH_6_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x06; - else { - state->tx_tuna[6] = 0x06; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_7_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x07; - else { - state->tx_tuna[6] = 0x07; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_8_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x08; - else { - state->tx_tuna[6] = 0x08; - state->tx_tuna[7] = 0x00; - } - break; - - default: - return -EINVAL; + case BANDWIDTH_6_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x06; + else { + state->tx_tuna[6] = 0x06; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_7_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x07; + else { + state->tx_tuna[6] = 0x07; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_8_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x08; + else { + state->tx_tuna[6] = 0x08; + state->tx_tuna[7] = 0x00; + } + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) +static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion) { state->inversion = inversion; switch (inversion) { - case INVERSION_OFF: // Inversion = Normal - state->tx_tuna[8] &= ~0x80; - break; - - case INVERSION_ON: - state->tx_tuna[8] |= 0x80; - break; - default: - return -EINVAL; + case INVERSION_OFF: /* Inversion = Normal */ + state->tx_tuna[8] &= ~0x80; + break; + case INVERSION_ON: + state->tx_tuna[8] |= 0x80; + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) +static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec) { state->fec = fec; return 0; } -static fe_code_rate_t dst_get_fec(struct dst_state* state) +static fe_code_rate_t dst_get_fec(struct dst_state *state) { return state->fec; } -static int dst_set_symbolrate(struct dst_state* state, u32 srate) +static int dst_set_symbolrate(struct dst_state *state, u32 srate) { u32 symcalc; u64 sval; state->symbol_rate = srate; - if (state->dst_type == DST_TYPE_IS_TERR) { return 0; } - if (debug > 4) - dprintk("%s: set symrate %u\n", __FUNCTION__, srate); + dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); srate /= 1000; - if (state->type_flags & DST_TYPE_HAS_SYMDIV) { sval = srate; sval <<= 20; do_div(sval, 88000); symcalc = (u32) sval; - - if (debug > 4) - dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); - + dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); state->tx_tuna[5] = (u8) (symcalc >> 12); state->tx_tuna[6] = (u8) (symcalc >> 4); state->tx_tuna[7] = (u8) (symcalc << 4); @@ -496,32 +476,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio state->modulation = modulation; switch (modulation) { - case QAM_16: - state->tx_tuna[8] = 0x10; - break; - - case QAM_32: - state->tx_tuna[8] = 0x20; - break; - - case QAM_64: - state->tx_tuna[8] = 0x40; - break; - - case QAM_128: - state->tx_tuna[8] = 0x80; - break; - - case QAM_256: - state->tx_tuna[8] = 0x00; - break; - - case QPSK: - case QAM_AUTO: - case VSB_8: - case VSB_16: - default: - return -EINVAL; + case QAM_16: + state->tx_tuna[8] = 0x10; + break; + case QAM_32: + state->tx_tuna[8] = 0x20; + break; + case QAM_64: + state->tx_tuna[8] = 0x40; + break; + case QAM_128: + state->tx_tuna[8] = 0x80; + break; + case QAM_256: + state->tx_tuna[8] = 0x00; + break; + case QPSK: + case QAM_AUTO: + case VSB_8: + case VSB_16: + default: + return -EINVAL; } @@ -534,7 +509,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state) } -u8 dst_check_sum(u8 * buf, u32 len) +u8 dst_check_sum(u8 *buf, u32 len) { u32 i; u8 val = 0; @@ -549,26 +524,24 @@ EXPORT_SYMBOL(dst_check_sum); static void dst_type_flags_print(u32 type_flags) { - printk("DST type flags :"); + dprintk(verbose, DST_ERROR, 0, "DST type flags :"); if (type_flags & DST_TYPE_HAS_NEWTUNE) - printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); + dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); if (type_flags & DST_TYPE_HAS_TS204) - printk(" 0x%x ts204", DST_TYPE_HAS_TS204); + dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); if (type_flags & DST_TYPE_HAS_SYMDIV) - printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); + dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); if (type_flags & DST_TYPE_HAS_FW_1) - printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); if (type_flags & DST_TYPE_HAS_FW_2) - printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); if (type_flags & DST_TYPE_HAS_FW_3) - printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); -// if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) - - printk("\n"); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); + dprintk(verbose, DST_ERROR, 0, "\n"); } -static int dst_type_print (u8 type) +static int dst_type_print(u8 type) { char *otype; switch (type) { @@ -585,10 +558,10 @@ static int dst_type_print (u8 type) break; default: - printk("%s: invalid dst type %d\n", __FUNCTION__, type); + dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); return -EINVAL; } - printk("DST type : %s\n", otype); + dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); return 0; } @@ -772,53 +745,45 @@ static int dst_get_device_id(struct dst_state *state) if (write_dst(state, device_type, FIXED_COMM)) return -1; /* Write failed */ - if ((dst_pio_disable(state)) < 0) return -1; - if (read_dst(state, &reply, GET_ACK)) return -1; /* Read failure */ - if (reply != ACK) { - dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); return -1; /* Unack'd write */ } - if (!dst_wait_dst_ready(state, DEVICE_INIT)) return -1; /* DST not ready yet */ - if (read_dst(state, state->rxbuffer, FIXED_COMM)) return -1; dst_pio_disable(state); - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: Checksum failure! \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Checksum failure!"); return -1; /* Checksum failure */ } - state->rxbuffer[7] = '\0'; - for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { + for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) { if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { use_type_flags = p_dst_type->type_flags; use_dst_type = p_dst_type->dst_type; /* Card capabilities */ state->dst_hw_cap = p_dst_type->dst_feature; - printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); + dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id); break; } } if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { - printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); - printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); + dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); use_dst_type = DST_TYPE_IS_SAT; use_type_flags = DST_TYPE_HAS_SYMDIV; } - dst_type_print(use_dst_type); state->type_flags = use_type_flags; state->dst_type = use_dst_type; @@ -834,7 +799,7 @@ static int dst_get_device_id(struct dst_state *state) static int dst_probe(struct dst_state *state) { if ((rdc_8820_reset(state)) < 0) { - dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); return -1; } if (dst_addons & DST_TYPE_HAS_CA) @@ -843,80 +808,69 @@ static int dst_probe(struct dst_state *state) msleep(100); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); return -1; } msleep(100); if (dst_get_device_id(state) < 0) { - dprintk("%s: unknown device.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown device."); return -1; } return 0; } -int dst_command(struct dst_state* state, u8 * data, u8 len) +int dst_command(struct dst_state *state, u8 *data, u8 len) { u8 reply; if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); return -1; } - if (write_dst(state, data, len)) { - if (verbose > 1) - dprintk("%s: Tring to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); return -1; } return -1; } if ((dst_pio_disable(state)) < 0) { - dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); - if (read_dst(state, &reply, GET_ACK)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery Failed."); return -1; } return -1; } - if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); return -1; } if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) return 0; - -// udelay(3000); if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); else udelay(2000); - if (!dst_wait_dst_ready(state, NO_DELAY)) return -1; - if (read_dst(state, state->rxbuffer, FIXED_COMM)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery failed."); return -1; } return -1; } - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: checksum failure\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure"); return -1; } @@ -924,7 +878,7 @@ int dst_command(struct dst_state* state, u8 * data, u8 len) } EXPORT_SYMBOL(dst_command); -static int dst_get_signal(struct dst_state* state) +static int dst_get_signal(struct dst_state *state) { int retval; u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; @@ -955,13 +909,12 @@ static int dst_get_signal(struct dst_state* state) return 0; } -static int dst_tone_power_cmd(struct dst_state* state) +static int dst_tone_power_cmd(struct dst_state *state) { u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; if (state->dst_type == DST_TYPE_IS_TERR) return 0; - paket[4] = state->tx_tuna[4]; paket[2] = state->tx_tuna[2]; paket[3] = state->tx_tuna[3]; @@ -971,61 +924,53 @@ static int dst_tone_power_cmd(struct dst_state* state) return 0; } -static int dst_get_tuna(struct dst_state* state) +static int dst_get_tuna(struct dst_state *state) { int retval; if ((state->diseq_flags & ATTEMPT_TUNE) == 0) return 0; - state->diseq_flags &= ~(HAS_LOCK); if (!dst_wait_dst_ready(state, NO_DELAY)) return 0; - - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { + if (state->type_flags & DST_TYPE_HAS_NEWTUNE) /* how to get variable length reply ???? */ retval = read_dst(state, state->rx_tuna, 10); - } else { + else retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); - } - if (retval < 0) { - dprintk("%s: read not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read not successful"); return 0; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure ? "); return 0; } } else { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure? "); return 0; } } if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) return 0; state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; - state->decode_lock = 1; state->diseq_flags |= HAS_LOCK; return 1; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); -static int dst_write_tuna(struct dvb_frontend* fe) +static int dst_write_tuna(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; int retval; u8 reply; - if (debug > 4) - dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); - + dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); state->decode_freq = 0; state->decode_lock = state->decode_strength = state->decode_snr = 0; if (state->dst_type == DST_TYPE_IS_SAT) { @@ -1035,35 +980,31 @@ static int dst_write_tuna(struct dvb_frontend* fe) state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); return -1; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); retval = write_dst(state, &state->tx_tuna[0], 10); - } else { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); } if (retval < 0) { dst_pio_disable(state); - dprintk("%s: write not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "write not successful"); return retval; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); return -1; } - if ((read_dst(state, &reply, GET_ACK) < 0)) { - dprintk("%s: read verify not successful.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); return -1; } if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); return 0; } state->diseq_flags |= ATTEMPT_TUNE; @@ -1085,14 +1026,13 @@ static int dst_write_tuna(struct dvb_frontend* fe) * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 */ -static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; if (state->dst_type != DST_TYPE_IS_SAT) return 0; - if (cmd->msg_len == 0 || cmd->msg_len > 4) return -EINVAL; memcpy(&paket[3], cmd->msg, cmd->msg_len); @@ -1101,65 +1041,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* return 0; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { int need_cmd; - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->voltage = voltage; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; need_cmd = 0; - switch (voltage) { - case SEC_VOLTAGE_13: - case SEC_VOLTAGE_18: - if ((state->diseq_flags & HAS_POWER) == 0) - need_cmd = 1; - state->diseq_flags |= HAS_POWER; - state->tx_tuna[4] = 0x01; - break; - case SEC_VOLTAGE_OFF: + switch (voltage) { + case SEC_VOLTAGE_13: + case SEC_VOLTAGE_18: + if ((state->diseq_flags & HAS_POWER) == 0) need_cmd = 1; - state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); - state->tx_tuna[4] = 0x00; - break; - - default: - return -EINVAL; + state->diseq_flags |= HAS_POWER; + state->tx_tuna[4] = 0x01; + break; + case SEC_VOLTAGE_OFF: + need_cmd = 1; + state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); + state->tx_tuna[4] = 0x00; + break; + default: + return -EINVAL; } + if (need_cmd) dst_tone_power_cmd(state); return 0; } -static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->tone = tone; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; switch (tone) { - case SEC_TONE_OFF: - if (state->type_flags & DST_TYPE_HAS_OBS_REGS) - state->tx_tuna[2] = 0x00; - else - state->tx_tuna[2] = 0xff; - - break; - - case SEC_TONE_ON: - state->tx_tuna[2] = 0x02; - break; + case SEC_TONE_OFF: + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) + state->tx_tuna[2] = 0x00; + else + state->tx_tuna[2] = 0xff; + break; - default: - return -EINVAL; + case SEC_TONE_ON: + state->tx_tuna[2] = 0x02; + break; + default: + return -EINVAL; } dst_tone_power_cmd(state); @@ -1172,16 +1108,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) if (state->dst_type != DST_TYPE_IS_SAT) return 0; - state->minicmd = minicmd; - switch (minicmd) { - case SEC_MINI_A: - state->tx_tuna[3] = 0x02; - break; - case SEC_MINI_B: - state->tx_tuna[3] = 0xff; - break; + case SEC_MINI_A: + state->tx_tuna[3] = 0x02; + break; + case SEC_MINI_B: + state->tx_tuna[3] = 0xff; + break; } dst_tone_power_cmd(state); @@ -1189,42 +1123,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) } -static int dst_init(struct dvb_frontend* fe) +static int dst_init(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; - static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; - static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; - static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; -// state->inversion = INVERSION_ON; + struct dst_state *state = fe->demodulator_priv; + + static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 }; + static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 }; + static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + state->inversion = INVERSION_OFF; state->voltage = SEC_VOLTAGE_13; state->tone = SEC_TONE_OFF; - state->symbol_rate = 29473000; - state->fec = FEC_AUTO; state->diseq_flags = 0; state->k22 = 0x02; state->bandwidth = BANDWIDTH_7_MHZ; state->cur_jiff = jiffies; - if (state->dst_type == DST_TYPE_IS_SAT) { - state->frequency = 950000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_TERR) { - state->frequency = 137000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { - state->frequency = 51000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna)); - } + if (state->dst_type == DST_TYPE_IS_SAT) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_TERR) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_CABLE) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204)); return 0; } -static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) +static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; *status = 0; if (state->diseq_flags & HAS_LOCK) { @@ -1236,9 +1165,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) return 0; } -static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) +static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *strength = state->decode_strength; @@ -1246,9 +1175,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) return 0; } -static int dst_read_snr(struct dvb_frontend* fe, u16* snr) +static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *snr = state->decode_snr; @@ -1256,28 +1185,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr) return 0; } -static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_set_freq(state, p->frequency); - if (verbose > 4) - dprintk("Set Frequency=[%d]\n", p->frequency); + dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); -// dst_set_inversion(state, p->inversion); if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) dst_set_inversion(state, p->inversion); - dst_set_fec(state, p->u.qpsk.fec_inner); dst_set_symbolrate(state, p->u.qpsk.symbol_rate); dst_set_polarization(state); - if (verbose > 4) - dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate); + dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); - } else if (state->dst_type == DST_TYPE_IS_TERR) { + } else if (state->dst_type == DST_TYPE_IS_TERR) dst_set_bandwidth(state, p->u.ofdm.bandwidth); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { + else if (state->dst_type == DST_TYPE_IS_CABLE) { dst_set_fec(state, p->u.qam.fec_inner); dst_set_symbolrate(state, p->u.qam.symbol_rate); dst_set_modulation(state, p->u.qam.modulation); @@ -1287,16 +1212,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet return 0; } -static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; p->frequency = state->decode_freq; -// p->inversion = state->inversion; if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) p->inversion = state->inversion; - p->u.qpsk.symbol_rate = state->symbol_rate; p->u.qpsk.fec_inner = dst_get_fec(state); } else if (state->dst_type == DST_TYPE_IS_TERR) { @@ -1304,16 +1227,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet } else if (state->dst_type == DST_TYPE_IS_CABLE) { p->u.qam.symbol_rate = state->symbol_rate; p->u.qam.fec_inner = dst_get_fec(state); -// p->u.qam.modulation = QAM_AUTO; p->u.qam.modulation = dst_get_modulation(state); } return 0; } -static void dst_release(struct dvb_frontend* fe) +static void dst_release(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; kfree(state); } @@ -1321,9 +1243,8 @@ static struct dvb_frontend_ops dst_dvbt_ops; static struct dvb_frontend_ops dst_dvbs_ops; static struct dvb_frontend_ops dst_dvbc_ops; -struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) +struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) { - /* check if the ASIC is there */ if (dst_probe(state) < 0) { if (state) @@ -1336,17 +1257,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad case DST_TYPE_IS_TERR: memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_CABLE: memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_SAT: memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); break; - default: - printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); if (state) kfree(state); @@ -1374,12 +1292,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, @@ -1401,16 +1316,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, - .diseqc_send_burst = dst_send_burst, .diseqc_send_master_cmd = dst_set_diseqc, .set_voltage = dst_set_voltage, @@ -1432,18 +1343,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, }; - MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); MODULE_AUTHOR("Jamie Honan, Manu Abraham"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index d2e0b1cb39d..6776a592045 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -18,30 +18,42 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - #include #include #include #include - #include #include "dvbdev.h" #include "dvb_frontend.h" - #include "dst_ca.h" #include "dst_common.h" +#define DST_CA_ERROR 0 +#define DST_CA_NOTICE 1 +#define DST_CA_INFO 2 +#define DST_CA_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_CA_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ## arg); \ + } \ +} while(0) + + static unsigned int verbose = 5; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)"); - -#define dprintk if (debug) printk - /* Need some more work */ static int ca_set_slot_descr(void) { @@ -61,27 +73,20 @@ static int put_checksum(u8 *check_string, int length) { u8 i = 0, checksum = 0; - if (verbose > 3) { - dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__); - dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " ========================= Checksum calculation ==========================="); + dprintk(verbose, DST_CA_DEBUG, 1, " String Length=[0x%02x]", length); + dprintk(verbose, DST_CA_DEBUG, 1, " String=["); - dprintk("%s: String=[", __FUNCTION__); - } while (i < length) { - if (verbose > 3) - dprintk(" %02x", check_string[i]); + dprintk(verbose, DST_CA_DEBUG, 0, " %02x", check_string[i]); checksum += check_string[i]; i++; } - if (verbose > 3) { - dprintk(" ]\n"); - dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum); - } + dprintk(verbose, DST_CA_DEBUG, 0, " ]\n"); + dprintk(verbose, DST_CA_DEBUG, 1, "Sum=[%02x]\n", checksum); check_string[length] = ~checksum + 1; - if (verbose > 3) { - dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]); - dprintk("%s: ==========================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_DEBUG, 1, " Checksum=[%02x]", check_string[length]); + dprintk(verbose, DST_CA_DEBUG, 1, " =========================================================================="); return 0; } @@ -94,30 +99,26 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 msleep(65); if (write_dst(state, data, len)) { - dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover"); dst_error_recovery(state); return -1; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed."); return -1; } - if (read_dst(state, &reply, GET_ACK) < 0) { - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } - if (read) { if (! dst_wait_dst_ready(state, LONG_DELAY)) { - dprintk("%s: 8820 not ready\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready"); return -1; } - if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } @@ -133,8 +134,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, while (dst_ca_comm_err < RETRIES) { dst_comm_init(state); - if (verbose > 2) - dprintk("%s: Put Command\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " Put Command"); if (dst_ci_command(state, data, ca_string, len, read)) { // If error dst_error_recovery(state); dst_ca_comm_err++; // work required here. @@ -153,18 +153,15 @@ static int ca_get_app_info(struct dst_state *state) put_checksum(&command[0], command[0]); if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) { - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); - - dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__); - dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n", - __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9], - (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); - dprintk("%s: ==================================================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); + dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); + dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", + state->messages[7], (state->messages[8] << 8) | state->messages[9], + (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); + dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); return 0; } @@ -177,31 +174,26 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, put_checksum(&slot_command[0], slot_command[0]); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_cap[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); p_ca_caps->slot_num = 1; p_ca_caps->slot_type = 1; p_ca_caps->descr_num = slot_cap[7]; p_ca_caps->descr_type = 1; - - if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) { + if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) return -EFAULT; - } return 0; } @@ -222,39 +214,32 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s put_checksum(&slot_command[0], 7); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_info[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); if (slot_info[4] & 0x80) { p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else if (slot_info[4] & 0x40) { + } else if (slot_info[4] & 0x40) { p_ca_slot_info->flags = CA_CI_MODULE_READY; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else { + } else p_ca_slot_info->flags = 0; - } - if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) { + if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) return -EFAULT; - } return 0; } @@ -268,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; - if (p_ca_message->msg) { - if (verbose > 3) - dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); + dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); for (i = 0; i < 3; i++) { command = command | p_ca_message->msg[i]; if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command); switch (command) { - case CA_APP_INFO: - memcpy(p_ca_message->msg, state->messages, 128); - if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) - return -EFAULT; + case CA_APP_INFO: + memcpy(p_ca_message->msg, state->messages, 128); + if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) + return -EFAULT; break; } } @@ -300,10 +282,9 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ } else { if (length > 247) { - dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); return -1; } - hw_buffer->msg[0] = (length & 0xff) + 7; hw_buffer->msg[1] = 0x40; hw_buffer->msg[2] = 0x03; @@ -324,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) { if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { - dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); - dprintk("%s: Resetting DST.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); + dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); rdc_reset_state(state); return -1; } - if (verbose > 2) - dprintk("%s: DST-CI Command succes.\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes."); return 0; } @@ -341,15 +321,15 @@ u32 asn_1_decode(u8 *asn_1_array) u32 length = 0; length_field = asn_1_array[0]; - dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); + dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field); if (length_field < 0x80) { length = length_field & 0x7f; - dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length); } else { word_count = length_field & 0x7f; for (count = 0; count < word_count; count++) { length = (length | asn_1_array[count + 1]) << 8; - dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length); } } return length; @@ -359,10 +339,10 @@ static int debug_string(u8 *msg, u32 length, u32 offset) { u32 i; - dprintk(" String=[ "); + dprintk(verbose, DST_CA_DEBUG, 0, " String=[ "); for (i = offset; i < length; i++) - dprintk("%02x ", msg[i]); - dprintk("]\n"); + dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]); + dprintk(verbose, DST_CA_DEBUG, 0, "]\n"); return 0; } @@ -373,8 +353,7 @@ static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, stru u8 tag_length = 8; length = asn_1_decode(&p_ca_message->msg[3]); - dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); - dprintk("%s: ASN.1 ", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length); debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ memset(hw_buffer->msg, '\0', length); @@ -396,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message /* Do test board */ /* Not there yet but soon */ - /* CA PMT Reply capable */ if (ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } /* Process CA PMT Reply */ /* will implement soon */ - dprintk("%s: Not there yet\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Not there yet"); } /* CA PMT Reply not capable */ if (!ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } - if (verbose > 3) - dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); /* put a dummy message */ } @@ -431,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer; if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if (verbose > 3) - dprintk("%s\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " "); if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; @@ -450,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); switch (command) { - case CA_PMT: - if (verbose > 3) -// dprintk("Command = SEND_CA_PMT\n"); - dprintk("Command = SEND_CA_PMT\n"); -// if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { - if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started - dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); -// retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0); - - break; - - case CA_PMT_REPLY: - if (verbose > 3) - dprintk("Command = CA_PMT_REPLY\n"); - /* Have to handle the 2 basic types of cards here */ - if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { - dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); - - /* Certain boards do behave different ? */ -// retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1); - - case CA_APP_INFO_ENQUIRY: // only for debugging - if (verbose > 3) - dprintk("%s: Getting Cam Application information\n", __FUNCTION__); - - if ((ca_get_app_info(state)) < 0) { - dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); - - break; + case CA_PMT: + dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); + if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); + break; + case CA_PMT_REPLY: + dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); + /* Have to handle the 2 basic types of cards here */ + if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !"); + break; + case CA_APP_INFO_ENQUIRY: // only for debugging + dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information"); + + if ((ca_get_app_info(state)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !"); + break; } } return 0; @@ -509,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd struct ca_msg *p_ca_message; if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ switch (cmd) { - case CA_SEND_MSG: - if (verbose > 1) - dprintk("%s: Sending message\n", __FUNCTION__); - if ((ca_send_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); - return -1; - } - - break; - - case CA_GET_MSG: - if (verbose > 1) - dprintk("%s: Getting message\n", __FUNCTION__); - if ((ca_get_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); - - break; - - case CA_RESET: - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - dst_error_bailout(state); - msleep(4000); - - break; - - case CA_GET_SLOT_INFO: - if (verbose > 1) - dprintk("%s: Getting Slot info\n", __FUNCTION__); - if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { - dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); - - break; - - case CA_GET_CAP: - if (verbose > 1) - dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); - if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { - dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); - - break; - - case CA_GET_DESCR_INFO: - if (verbose > 1) - dprintk("%s: Getting descrambler description\n", __FUNCTION__); - if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__); - - break; - - case CA_SET_DESCR: - if (verbose > 1) - dprintk("%s: Setting descrambler\n", __FUNCTION__); - if ((ca_set_slot_descr()) < 0) { - dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__); - - break; - - case CA_SET_PID: - if (verbose > 1) - dprintk("%s: Setting PID\n", __FUNCTION__); - if ((ca_set_pid()) < 0) { - dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__); - - default: - return -EOPNOTSUPP; - }; + case CA_SEND_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Sending message"); + if ((ca_send_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); + return -1; + } + break; + case CA_GET_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Getting message"); + if ((ca_get_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); + break; + case CA_RESET: + dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST"); + dst_error_bailout(state); + msleep(4000); + break; + case CA_GET_SLOT_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); + if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !"); + break; + case CA_GET_CAP: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); + if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); + break; + case CA_GET_DESCR_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); + if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); + break; + case CA_SET_DESCR: + dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler"); + if ((ca_set_slot_descr()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !"); + break; + case CA_SET_PID: + dprintk(verbose, DST_CA_INFO, 1, " Setting PID"); + if ((ca_set_pid()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !"); + default: + return -EOPNOTSUPP; + }; return 0; } static int dst_ca_open(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device opened [%p]\n", __FUNCTION__, file); + dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file); try_module_get(THIS_MODULE); return 0; @@ -631,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file) static int dst_ca_release(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device closed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device closed."); module_put(THIS_MODULE); return 0; } -static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) { int bytes_read = 0; - if (verbose > 4) - dprintk("%s:Device read.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device read."); return bytes_read; } -static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) { - if (verbose > 4) - dprintk("%s:Device write.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); return 0; } @@ -676,8 +600,7 @@ static struct dvb_device dvbdev_ca = { int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) { struct dvb_device *dvbdev; - if (verbose > 4) - dprintk("%s:registering DST-CA device\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); return 0; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index ef532a6acea..c0ee0b197bb 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -61,7 +61,6 @@ #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ #define DST_TYPE_HAS_SESSION 128 - #define RDC_8820_PIO_0_DISABLE 0 #define RDC_8820_PIO_0_ENABLE 1 #define RDC_8820_INT 2 @@ -124,15 +123,12 @@ struct dst_types { u32 dst_feature; }; - - struct dst_config { /* the ASIC i2c address */ u8 demod_address; }; - int rdc_reset_state(struct dst_state *state); int rdc_8820_reset(struct dst_state *state); -- cgit v1.2.3 From 62121b1f9e25377ff50121f8c34a4aa92c47f465 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:01 -0700 Subject: [PATCH] dvb: dst: identify boards Identify board properly: Add functions to retrieve MAC Address, FW details, Card type and Vendor Information. Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst.c | 89 ++++++++++++++++++++++++++++++++++-- drivers/media/dvb/bt8xx/dst_common.h | 4 ++ 2 files changed, 90 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 39835edba1d..eef34481d53 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -673,7 +673,7 @@ struct dst_types dst_tlist[] = { .offset = 1, .dst_type = DST_TYPE_IS_CABLE, .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 - | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + | DST_TYPE_HAS_FW_2, .dst_feature = DST_TYPE_HAS_CA }, @@ -681,7 +681,7 @@ struct dst_types dst_tlist[] = { .device_id = "DCTNEW", .offset = 1, .dst_type = DST_TYPE_IS_CABLE, - .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3, + .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD, .dst_feature = 0 }, @@ -689,7 +689,7 @@ struct dst_types dst_tlist[] = { .device_id = "DTT-CI", .offset = 1, .dst_type = DST_TYPE_IS_TERR, - .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2, .dst_feature = 0 }, @@ -729,6 +729,71 @@ struct dst_types dst_tlist[] = { }; +static int dst_get_mac(struct dst_state *state) +{ + u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_mac[7] = dst_check_sum(get_mac, 7); + if (dst_command(state, get_mac, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->mac_address, '\0', 8); + memcpy(&state->mac_address, &state->rxbuffer, 6); + dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", + state->mac_address[0], state->mac_address[1], state->mac_address[2], + state->mac_address[4], state->mac_address[5], state->mac_address[6]); + + return 0; +} + +static int dst_fw_ver(struct dst_state *state) +{ + u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_ver[7] = dst_check_sum(get_ver, 7); + if (dst_command(state, get_ver, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->fw_version, '\0', 8); + memcpy(&state->fw_version, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", + state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, + state->fw_version[1], + state->fw_version[5], state->fw_version[6], + state->fw_version[4], state->fw_version[3], state->fw_version[2]); + + return 0; +} + +static int dst_card_type(struct dst_state *state) +{ + u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_type[7] = dst_check_sum(get_type, 7); + if (dst_command(state, get_type, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->card_info, '\0', 8); + memcpy(&state->card_info, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]); + + return 0; +} + +static int dst_get_vendor(struct dst_state *state) +{ + u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_vendor[7] = dst_check_sum(get_vendor, 7); + if (dst_command(state, get_vendor, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->vendor, '\0', 8); + memcpy(&state->vendor, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]); + + return 0; +} static int dst_get_device_id(struct dst_state *state) { @@ -816,6 +881,24 @@ static int dst_probe(struct dst_state *state) dprintk(verbose, DST_ERROR, 1, "unknown device."); return -1; } + if (dst_get_mac(state) < 0) { + dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command"); + return 0; + } + if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { + if (dst_fw_ver(state) < 0) { + dprintk(verbose, DST_INFO, 1, "FW: Unsupported command"); + return 0; + } + if (dst_card_type(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Card: Unsupported command"); + return 0; + } + if (dst_get_vendor(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command"); + return 0; + } + } return 0; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index c0ee0b197bb..3281a6ca368 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -113,6 +113,10 @@ struct dst_state { fe_sec_mini_cmd_t minicmd; fe_modulation_t modulation; u8 messages[256]; + u8 mac_address[8]; + u8 fw_version[8]; + u8 card_info[8]; + u8 vendor[8]; }; struct dst_types { -- cgit v1.2.3 From 62867429d0d79e47e19ceedc3133efe74993932f Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:02 -0700 Subject: [PATCH] dvb: dst: fix DVB-C tuning Fix BUG in DVB-C frequency setting. Thanks to Peng Cao Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/bt8xx/dst.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index eef34481d53..34a837a1abf 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -359,6 +359,7 @@ static int dst_set_freq(struct dst_state *state, u32 freq) state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; } else if (state->dst_type == DST_TYPE_IS_CABLE) { + freq = freq / 1000; state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; -- cgit v1.2.3 From 6d78933c291bd0b6292e2c631e2f5e346c14d3fa Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:03:05 -0700 Subject: [PATCH] dvb: cinergyT2: remote control fixes IR RC fixes: - EVIOCSKEYCODE is not supported by this driver, fix potential crash when it is used by not setting rc_input_dev->keycodesize - fix key repeat handling (hopefully) - reduce default poll internal to 50msec (necessary for key repeat handling) Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/cinergyT2/Kconfig | 2 +- drivers/media/dvb/cinergyT2/cinergyT2.c | 93 ++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 38 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 226714085f5..7cf4c4a888e 100644 --- a/drivers/media/dvb/cinergyT2/Kconfig +++ b/drivers/media/dvb/cinergyT2/Kconfig @@ -77,7 +77,7 @@ config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE config DVB_CINERGYT2_RC_QUERY_INTERVAL int "Infrared Remote Controller update interval [milliseconds]" depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE - default "100" + default "50" help If you have a very fast-repeating remote control you can try lower values, for normal consumer receivers the default value should be diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index c52e9d5c3d9..6db0929ef53 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -35,7 +35,6 @@ #include "dvb_demux.h" #include "dvb_net.h" - #ifdef CONFIG_DVB_CINERGYT2_TUNING #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT) #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE) @@ -48,7 +47,7 @@ #define STREAM_URB_COUNT (32) #define STREAM_BUF_SIZE (512) /* bytes */ #define ENABLE_RC (1) - #define RC_QUERY_INTERVAL (100) /* milliseconds */ + #define RC_QUERY_INTERVAL (50) /* milliseconds */ #define QUERY_INTERVAL (333) /* milliseconds */ #endif @@ -141,6 +140,8 @@ struct cinergyt2 { struct input_dev rc_input_dev; struct work_struct rc_query_work; int rc_input_event; + u32 rc_last_code; + unsigned long last_event_jiffies; #endif }; @@ -155,7 +156,7 @@ struct cinergyt2_rc_event { uint32_t value; } __attribute__((packed)); -static const uint32_t rc_keys [] = { +static const uint32_t rc_keys[] = { CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2, @@ -684,52 +685,68 @@ static struct dvb_device cinergyt2_fe_template = { #ifdef ENABLE_RC static void cinergyt2_query_rc (void *data) { - struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; - char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS }; + struct cinergyt2 *cinergyt2 = data; + char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; struct cinergyt2_rc_event rc_events[12]; - int n, len; + int n, len, i; if (down_interruptible(&cinergyt2->sem)) return; len = cinergyt2_command(cinergyt2, buf, sizeof(buf), - (char *) rc_events, sizeof(rc_events)); - - for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) { - int i; + (char *) rc_events, sizeof(rc_events)); + if (len < 0) + goto out; + if (len == 0) { + if (time_after(jiffies, cinergyt2->last_event_jiffies + + msecs_to_jiffies(150))) { + /* stop key repeat */ + if (cinergyt2->rc_input_event != KEY_MAX) { + dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + cinergyt2->rc_input_event = KEY_MAX; + } + cinergyt2->rc_last_code = ~0; + } + goto out; + } + cinergyt2->last_event_jiffies = jiffies; -/* dprintk(1,"rc_events[%d].value = %x, type=%x\n",n,le32_to_cpu(rc_events[n].value),rc_events[n].type);*/ + for (n = 0; n < (len / sizeof(rc_events[0])); n++) { + dprintk(1, "rc_events[%d].value = %x, type=%x\n", + n, le32_to_cpu(rc_events[n].value), rc_events[n].type); if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && - rc_events[n].value == ~0) - { - /** - * keyrepeat bit. If we would handle this properly - * we would need to emit down events as long the - * keyrepeat goes, a up event if no further - * repeat bits occur. Would need a timer to implement - * and no other driver does this, so we simply - * emit the last key up/down sequence again. - */ + rc_events[n].value == ~0) { + /* keyrepeat bit -> just repeat last rc_input_event */ } else { cinergyt2->rc_input_event = KEY_MAX; - for (i=0; irc_input_event = rc_keys[i+2]; + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { + if (rc_keys[i + 0] == rc_events[n].type && + rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { + cinergyt2->rc_input_event = rc_keys[i + 2]; break; } } } if (cinergyt2->rc_input_event != KEY_MAX) { - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 1); - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 0); - input_sync(&cinergyt2->rc_input_dev); + if (rc_events[n].value == cinergyt2->rc_last_code && + cinergyt2->rc_last_code != ~0) { + /* emit a key-up so the double event is recognized */ + dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + } + dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 1); + cinergyt2->rc_last_code = rc_events[n].value; } } +out: schedule_delayed_work(&cinergyt2->rc_query_work, msecs_to_jiffies(RC_QUERY_INTERVAL)); @@ -771,7 +788,10 @@ static int cinergyt2_probe (struct usb_interface *intf, const struct usb_device_id *id) { struct cinergyt2 *cinergyt2; - int i, err; + int err; +#ifdef ENABLE_RC + int i; +#endif if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { dprintk(1, "out of memory?!?\n"); @@ -827,19 +847,18 @@ static int cinergyt2_probe (struct usb_interface *intf, DVB_DEVICE_FRONTEND); #ifdef ENABLE_RC - init_input_dev(&cinergyt2->rc_input_dev); - - cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY); - cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char); - cinergyt2->rc_input_dev.keycodemax = KEY_MAX; + cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); + cinergyt2->rc_input_dev.keycodesize = 0; + cinergyt2->rc_input_dev.keycodemax = 0; cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; - for (i=0; irc_input_dev.keybit); + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) + set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit); input_register_device(&cinergyt2->rc_input_dev); cinergyt2->rc_input_event = KEY_MAX; + cinergyt2->rc_last_code = ~0; INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); -- cgit v1.2.3 From f63f5346c943008fe8f6ac66a9026f6c35e24947 Mon Sep 17 00:00:00 2001 From: thomas schorpp Date: Fri, 9 Sep 2005 13:03:06 -0700 Subject: [PATCH] dvb: av7110: Siemens DVB-C analog video input support Add support for analog video inputs (CVBS and Y/C) of the analog module for the Siemens DVB-C card. Signed-off-by: thomas schorpp Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/av7110_v4l.c | 74 ++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e65fc36e2ce..6af74f78b3e 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c @@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) return 0; } -static struct v4l2_input inputs[2] = { +static struct v4l2_input inputs[4] = { { .index = 0, .name = "DVB", @@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = { .tuner = 0, .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, .status = 0, + }, { + .index = 2, + .name = "Video", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, + }, { + .index = 3, + .name = "Y/C", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, } }; @@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) } if (0 != av7110->current_input) { + dprintk(1, "switching to analog TV:\n"); adswitch = 1; source = SAA7146_HPS_SOURCE_PORT_B; sync = SAA7146_HPS_SYNC_PORT_B; memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); - dprintk(1, "switching to analog TV\n"); - msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source - msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source - msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source - msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono - msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone - msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume - if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { - if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) - dprintk(1, "setting band in demodulator failed.\n"); - } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { - saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) - saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + switch (av7110->current_input) { + case 1: + dprintk(1, "switching SAA7113 to Analog Tuner Input.\n"); + msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source + msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source + msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source + msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono + msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone + msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume + + if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { + if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) + dprintk(1, "setting band in demodulator failed.\n"); + } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) + saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + } + if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 2: + dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 3: + dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + default: + dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n"); } } else { adswitch = 0; @@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) // FIXME: standard / stereo detection is still broken msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); - msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); stereo = (s8)(stereo_det >> 8); @@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) t->audmode = V4L2_TUNER_MODE_STEREO; } else if (stereo < -0x10) { - /* bilingual*/ + /* bilingual */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; } @@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) fm_matrix = 0x3000; // mono src = 0x0010; break; - default: /* case V4L2_TUNER_MODE_MONO: {*/ + default: /* case V4L2_TUNER_MODE_MONO: */ dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); fm_matrix = 0x3000; // mono src = 0x0030; @@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); if (av7110->analog_tuner_flags) { - if (i->index < 0 || i->index >= 2) + if (i->index < 0 || i->index >= 4) return -EINVAL; } else { if (i->index != 0) @@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) if (!av7110->analog_tuner_flags) return 0; - if (input < 0 || input >= 2) + if (input < 0 || input >= 4) return -EINVAL; - /* FIXME: switch inputs here */ av7110->current_input = input; return av7110_dvb_c_switch(fh); } -- cgit v1.2.3 From dc27a1696089a9a9d317fc815915e6761e22eeb5 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:07 -0700 Subject: [PATCH] dvb: budget-ci: add support for TT DVB-C CI card Add support for TT DVB-C CI card. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/b2c2/flexcop-fe-tuner.c | 97 ++++++++++++++- drivers/media/dvb/frontends/stv0297.c | 121 +------------------ drivers/media/dvb/frontends/stv0297.h | 8 +- drivers/media/dvb/ttpci/av7110.c | 95 ++++++++++++++- drivers/media/dvb/ttpci/budget-ci.c | 188 +++++++++++++++++++++++++++++- 5 files changed, 387 insertions(+), 122 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index a36bec3a2be..47e28b0ee95 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c @@ -334,8 +334,103 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = { .pll_set = skystar23_samsung_tbdu18132_pll_set, }; + +static u8 alps_tdee4_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0xf8, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; + static struct stv0297_config alps_tdee4_stv0297_config = { .demod_address = 0x1c, + .inittab = alps_tdee4_stv0297_inittab, // .invert = 1, // .pll_set = alps_tdee4_stv0297_pll_set, }; @@ -369,7 +464,7 @@ int flexcop_frontend_init(struct flexcop_device *fc) info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); } else /* try the cable dvb (stv0297) */ - if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap, 0xf8)) != NULL) { + if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { fc->dev_type = FC_CABLE; info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); } else diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 01eb41990e8..8d09afd7545 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -35,7 +35,6 @@ struct stv0297_state { struct dvb_frontend frontend; unsigned long base_freq; - u8 pwm; }; #if 1 @@ -46,94 +45,6 @@ struct stv0297_state { #define STV0297_CLOCK_KHZ 28900 -static u8 init_tab[] = { - 0x00, 0x09, - 0x01, 0x69, - 0x03, 0x00, - 0x04, 0x00, - 0x07, 0x00, - 0x08, 0x00, - 0x20, 0x00, - 0x21, 0x40, - 0x22, 0x00, - 0x23, 0x00, - 0x24, 0x40, - 0x25, 0x88, - 0x30, 0xff, - 0x31, 0x00, - 0x32, 0xff, - 0x33, 0x00, - 0x34, 0x50, - 0x35, 0x7f, - 0x36, 0x00, - 0x37, 0x20, - 0x38, 0x00, - 0x40, 0x1c, - 0x41, 0xff, - 0x42, 0x29, - 0x43, 0x00, - 0x44, 0xff, - 0x45, 0x00, - 0x46, 0x00, - 0x49, 0x04, - 0x4a, 0xff, - 0x4b, 0x7f, - 0x52, 0x30, - 0x55, 0xae, - 0x56, 0x47, - 0x57, 0xe1, - 0x58, 0x3a, - 0x5a, 0x1e, - 0x5b, 0x34, - 0x60, 0x00, - 0x63, 0x00, - 0x64, 0x00, - 0x65, 0x00, - 0x66, 0x00, - 0x67, 0x00, - 0x68, 0x00, - 0x69, 0x00, - 0x6a, 0x02, - 0x6b, 0x00, - 0x70, 0xff, - 0x71, 0x00, - 0x72, 0x00, - 0x73, 0x00, - 0x74, 0x0c, - 0x80, 0x00, - 0x81, 0x00, - 0x82, 0x00, - 0x83, 0x00, - 0x84, 0x04, - 0x85, 0x80, - 0x86, 0x24, - 0x87, 0x78, - 0x88, 0x00, - 0x89, 0x00, - 0x90, 0x01, - 0x91, 0x01, - 0xa0, 0x00, - 0xa1, 0x00, - 0xa2, 0x00, - 0xb0, 0x91, - 0xb1, 0x0b, - 0xc0, 0x53, - 0xc1, 0x70, - 0xc2, 0x12, - 0xd0, 0x00, - 0xd1, 0x00, - 0xd2, 0x00, - 0xd3, 0x00, - 0xd4, 0x00, - 0xd5, 0x00, - 0xde, 0x00, - 0xdf, 0x00, - 0x61, 0x49, - 0x62, 0x0b, - 0x53, 0x08, - 0x59, 0x08, -}; - static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) { @@ -378,34 +289,9 @@ static int stv0297_init(struct dvb_frontend *fe) struct stv0297_state *state = fe->demodulator_priv; int i; - /* soft reset */ - stv0297_writereg_mask(state, 0x80, 1, 1); - stv0297_writereg_mask(state, 0x80, 1, 0); - - /* reset deinterleaver */ - stv0297_writereg_mask(state, 0x81, 1, 1); - stv0297_writereg_mask(state, 0x81, 1, 0); - /* load init table */ - for (i = 0; i < sizeof(init_tab); i += 2) { - stv0297_writereg(state, init_tab[i], init_tab[i + 1]); - } - - /* set a dummy symbol rate */ - stv0297_set_symbolrate(state, 6900); - - /* invert AGC1 polarity */ - stv0297_writereg_mask(state, 0x88, 0x10, 0x10); - - /* setup bit error counting */ - stv0297_writereg_mask(state, 0xA0, 0x80, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x10, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x08, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x07, 0x04); - - /* min + max PWM */ - stv0297_writereg(state, 0x4a, 0x00); - stv0297_writereg(state, 0x4b, state->pwm); + for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) + stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); msleep(200); if (state->config->pll_init) @@ -738,7 +624,7 @@ static void stv0297_release(struct dvb_frontend *fe) static struct dvb_frontend_ops stv0297_ops; struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, - struct i2c_adapter *i2c, int pwm) + struct i2c_adapter *i2c) { struct stv0297_state *state = NULL; @@ -752,7 +638,6 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, state->i2c = i2c; memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); state->base_freq = 0; - state->pwm = pwm; /* check if the demod is there */ if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h index 3be53598930..9e53f019db7 100644 --- a/drivers/media/dvb/frontends/stv0297.h +++ b/drivers/media/dvb/frontends/stv0297.h @@ -29,6 +29,12 @@ struct stv0297_config /* the demodulator's i2c address */ u8 demod_address; + /* inittab - array of pairs of values. + * First of each pair is the register, second is the value. + * List should be terminated with an 0xff, 0xff pair. + */ + u8* inittab; + /* does the "inversion" need inverted? */ u8 invert:1; @@ -38,7 +44,7 @@ struct stv0297_config }; extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, - struct i2c_adapter* i2c, int pwm); + struct i2c_adapter* i2c); extern int stv0297_enable_plli2c(struct dvb_frontend* fe); #endif // STV0297_H diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index c91cf8958b3..48e8097d843 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -1934,6 +1934,98 @@ static struct sp8870_config alps_tdlb7_config = { }; +static u8 nexusca_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { @@ -1982,6 +2074,7 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ static struct stv0297_config nexusca_stv0297_config = { .demod_address = 0x1C, + .inittab = nexusca_stv0297_inittab, .invert = 1, .pll_set = nexusca_stv0297_pll_set, }; @@ -2259,7 +2352,7 @@ static int frontend_init(struct av7110 *av7110) case 0x000A: // Hauppauge/TT Nexus-CA rev1.X - av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b); + av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); if (av7110->fe) { /* set TDA9819 into DVB mode */ saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 88f27a53216..2980db3ef22 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -40,6 +40,7 @@ #include "dvb_ca_en50221.h" #include "stv0299.h" +#include "stv0297.h" #include "tda1004x.h" #define DEBIADDR_IR 0x1234 @@ -847,6 +848,180 @@ static struct tda1004x_config philips_tdm1316l_config = { .request_firmware = philips_tdm1316l_request_firmware, }; +static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +{ + struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; + u8 tuner_buf[5]; + struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, + .flags = 0, + .buf = tuner_buf, + .len = sizeof(tuner_buf) }; + int tuner_frequency = 0; + u8 band, cp, filter; + + // determine charge pump + tuner_frequency = params->frequency + 36125000; + if (tuner_frequency < 87000000) + return -EINVAL; + else if (tuner_frequency < 130000000) { + cp = 3; + band = 1; + } else if (tuner_frequency < 160000000) { + cp = 5; + band = 1; + } else if (tuner_frequency < 200000000) { + cp = 6; + band = 1; + } else if (tuner_frequency < 290000000) { + cp = 3; + band = 2; + } else if (tuner_frequency < 420000000) { + cp = 5; + band = 2; + } else if (tuner_frequency < 480000000) { + cp = 6; + band = 2; + } else if (tuner_frequency < 620000000) { + cp = 3; + band = 4; + } else if (tuner_frequency < 830000000) { + cp = 5; + band = 4; + } else if (tuner_frequency < 895000000) { + cp = 7; + band = 4; + } else + return -EINVAL; + + // assume PLL filter should always be 8MHz for the moment. + filter = 1; + + // calculate divisor + tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500; + + // setup tuner buffer + tuner_buf[0] = tuner_frequency >> 8; + tuner_buf[1] = tuner_frequency & 0xff; + tuner_buf[2] = 0xc8; + tuner_buf[3] = (cp << 5) | (filter << 3) | band; + tuner_buf[4] = 0x80; + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(50); + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(1); + + return 0; +} + +static u8 dvbc_philips_tdm1316l_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x20, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x38, + 0x62, 0x0a, + 0x53, 0x13, + 0x59, 0x08, + 0xff, 0xff, +}; + +static struct stv0297_config dvbc_philips_tdm1316l_config = { + .demod_address = 0x1c, + .inittab = dvbc_philips_tdm1316l_inittab, + .invert = 0, + .pll_set = dvbc_philips_tdm1316l_pll_set, +}; + + static void frontend_init(struct budget_ci *budget_ci) @@ -868,6 +1043,15 @@ static void frontend_init(struct budget_ci *budget_ci) } break; + case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) + budget_ci->tuner_pll_address = 0x61; + budget_ci->budget.dvb_frontend = + stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); + if (budget_ci->budget.dvb_frontend) { + break; + } + break; + case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) budget_ci->tuner_pll_address = 0x63; budget_ci->budget.dvb_frontend = @@ -877,7 +1061,7 @@ static void frontend_init(struct budget_ci *budget_ci) } break; - case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) + case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) budget_ci->tuner_pll_address = 0x60; budget_ci->budget.dvb_frontend = tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); @@ -965,10 +1149,12 @@ static struct saa7146_extension budget_extension; 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); +MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT); static struct pci_device_id pci_tbl[] = { MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), + MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), { -- cgit v1.2.3 From b548747d78f8840024ac3439b7149348a282e086 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:08 -0700 Subject: [PATCH] dvb: budget-av: fixes for CI interface Fixes for CI interface. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/budget-av.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 311be50b2fc..8c2a29007db 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { struct budget_av *budget_av = (struct budget_av *) ca->data; struct saa7146_dev *saa = budget_av->budget.dev; - int timeout = 50; // 5 seconds (4.4.6 Ready) + int timeout = 500; // 5 seconds (4.4.6 Ready) if (slot != 0) return -EINVAL; @@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ return -ETIMEDOUT; } @@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open { printk(KERN_INFO "budget-av: cam ejected\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ budget_av->slot_status = 0; } } -- cgit v1.2.3 From 87b2ecaebceb35c6f6199edd29ae24963d3f9c35 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 9 Sep 2005 13:03:09 -0700 Subject: [PATCH] dvb: budget-av: enable frontend on KNC1 Plus cards Enable frontend on KNC plus cards. Signed-off-by: Andrew de Quincey Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/budget-av.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 8c2a29007db..7692cd23f83 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -743,6 +743,7 @@ static void frontend_init(struct budget_av *budget_av) case SUBID_DVBC_KNC1_PLUS: case SUBID_DVBT_KNC1_PLUS: // Enable / PowerON Frontend + saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); break; } -- cgit v1.2.3 From ce7d3c11aee415c76bcbd5f43cace16132b48a21 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Fri, 9 Sep 2005 13:03:10 -0700 Subject: [PATCH] dvb: av7110: disable superflous firmware handshake Disable superflous firmware handshake. Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/av7110_hw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 1220826696c..456d529cb38 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -41,6 +41,8 @@ #include "av7110.h" #include "av7110_hw.h" +#define _NOHANDSHAKE + /**************************************************************************** * DEBI functions ****************************************************************************/ -- cgit v1.2.3 From 9a7b102e7f5ccb2826a81315abc89f95adaf4421 Mon Sep 17 00:00:00 2001 From: Oliver Endriss Date: Fri, 9 Sep 2005 13:03:11 -0700 Subject: [PATCH] dvb: av7110: conditionally disable workaround for broken firmware Disable COM_IF_LOCK workaround for firmware > 0x261f. Signed-off-by: Oliver Endriss Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/av7110_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 456d529cb38..7442f56a72e 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -366,7 +366,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) msleep(1); } - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); #ifndef _NOHANDSHAKE start = jiffies; @@ -439,7 +440,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); #ifdef COM_DEBUG start = jiffies; -- cgit v1.2.3 From 03388ae30260475650bab24223151397afb72ec9 Mon Sep 17 00:00:00 2001 From: Oliver Endriss Date: Fri, 9 Sep 2005 13:03:12 -0700 Subject: [PATCH] dvb: ttpci: av7110: RC5+ remote control support Improved remote control support for av7110-based cards: o extended rc5 protocol, firmware >= 0x2620 required o key-up timer slightly adjusted o completely moved remote control code to av7110_ir.c o support for multiple ir receivers o for now, all av7110 cards share the same ir configuration and event device Signed-off-by: Oliver Endriss Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/av7110.c | 70 ++---------------- drivers/media/dvb/ttpci/av7110.h | 11 +-- drivers/media/dvb/ttpci/av7110_ir.c | 140 +++++++++++++++++++++++++----------- 3 files changed, 110 insertions(+), 111 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 48e8097d843..b5d40d42436 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -177,9 +177,6 @@ static void init_av7110_av(struct av7110 *av7110) ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); if (ret < 0) printk("dvb-ttpci:cannot set volume :%d\n",ret); - ret = av7110_setup_irc_config(av7110, 0); - if (ret < 0) - printk("dvb-ttpci:cannot setup irc config :%d\n",ret); } static void recover_arm(struct av7110 *av7110) @@ -265,60 +262,6 @@ static int arm_thread(void *data) } -/** - * Hack! we save the last av7110 ptr. This should be ok, since - * you rarely will use more then one IR control. - * - * If we want to support multiple controls we would have to do much more... - */ -int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) -{ - int ret = 0; - static struct av7110 *last; - - dprintk(4, "%p\n", av7110); - - if (!av7110) - av7110 = last; - else - last = av7110; - - if (av7110) { - ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); - av7110->ir_config = ir_config; - } - return ret; -} - -static void (*irc_handler)(u32); - -void av7110_register_irc_handler(void (*func)(u32)) -{ - dprintk(4, "registering %p\n", func); - irc_handler = func; -} - -void av7110_unregister_irc_handler(void (*func)(u32)) -{ - dprintk(4, "unregistering %p\n", func); - irc_handler = NULL; -} - -static void run_handlers(unsigned long ircom) -{ - if (irc_handler != NULL) - (*irc_handler)((u32) ircom); -} - -static DECLARE_TASKLET(irtask, run_handlers, 0); - -static void IR_handle(struct av7110 *av7110, u32 ircom) -{ - dprintk(4, "ircommand = %08x\n", ircom); - irtask.data = (unsigned long) ircom; - tasklet_schedule(&irtask); -} - /**************************************************************************** * IRQ handling ****************************************************************************/ @@ -711,8 +654,9 @@ static void gpioirq(unsigned long data) return; case DATA_IRCOMMAND: - IR_handle(av7110, - swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); + if (av7110->ir_handler) + av7110->ir_handler(av7110, + swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); break; @@ -2783,7 +2727,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d goto err_av7110_exit_v4l_12; #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_init(); + av7110_ir_init(av7110); #endif printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); av7110_num++; @@ -2825,6 +2769,9 @@ static int av7110_detach(struct saa7146_dev* saa) struct av7110 *av7110 = saa->ext_priv; dprintk(4, "%p\n", av7110); +#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) + av7110_ir_exit(av7110); +#endif if (budgetpatch) { /* Disable RPS1 */ saa7146_write(saa, MC1, MASK_29); @@ -2980,9 +2927,6 @@ static int __init av7110_init(void) static void __exit av7110_exit(void) { -#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_exit(); -#endif saa7146_unregister_extension(&av7110_extension); } diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index 508b7739c60..cce00ef293e 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h @@ -228,7 +228,10 @@ struct av7110 { struct dvb_video_events video_events; video_size_t video_size; - u32 ir_config; + u32 ir_config; + u32 ir_command; + void (*ir_handler)(struct av7110 *av7110, u32 ircom); + struct tasklet_struct ir_tasklet; /* firmware stuff */ unsigned char *bin_fw; @@ -257,12 +260,10 @@ struct av7110 { extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, u16 subpid, u16 pcrpid); -extern void av7110_register_irc_handler(void (*func)(u32)); -extern void av7110_unregister_irc_handler(void (*func)(u32)); extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); -extern int av7110_ir_init (void); -extern void av7110_ir_exit (void); +extern int av7110_ir_init(struct av7110 *av7110); +extern void av7110_ir_exit(struct av7110 *av7110); /* msp3400 i2c subaddresses */ #define MSP_WR_DEM 0x10 diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 665cdb8a3f7..357a3728ec6 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c @@ -7,16 +7,16 @@ #include #include "av7110.h" +#include "av7110_hw.h" -#define UP_TIMEOUT (HZ/4) +#define UP_TIMEOUT (HZ*7/25) /* enable ir debugging by or'ing debug with 16 */ -static int ir_initialized; +static int av_cnt; +static struct av7110 *av_list[4]; static struct input_dev input_dev; -static u32 ir_config; - static u16 key_map [256] = { KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, @@ -53,8 +53,11 @@ static void av7110_emit_keyup(unsigned long data) static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; -static void av7110_emit_key(u32 ircom) +static void av7110_emit_key(unsigned long parm) { + struct av7110 *av7110 = (struct av7110 *) parm; + u32 ir_config = av7110->ir_config; + u32 ircom = av7110->ir_command; u8 data; u8 addr; static u16 old_toggle = 0; @@ -62,19 +65,33 @@ static void av7110_emit_key(u32 ircom) u16 keycode; /* extract device address and data */ - if (ir_config & 0x0001) { - /* TODO RCMM: ? bits device address, 8 bits data */ + switch (ir_config & 0x0003) { + case 0: /* RC5: 5 bits device address, 6 bits data */ + data = ircom & 0x3f; + addr = (ircom >> 6) & 0x1f; + break; + + case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */ data = ircom & 0xff; addr = (ircom >> 8) & 0xff; - } else { - /* RC5: 5 bits device address, 6 bits data */ + break; + + case 2: /* extended RC5: 5 bits device address, 7 bits data */ data = ircom & 0x3f; addr = (ircom >> 6) & 0x1f; + /* invert 7th data bit for backward compatibility with RC5 keymaps */ + if (!(ircom & 0x1000)) + data |= 0x40; + break; + + default: + printk("invalid ir_config %x\n", ir_config); + return; } keycode = key_map[data]; - dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n", + dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n", ircom, addr, data, keycode); /* check device address (if selected) */ @@ -87,10 +104,10 @@ static void av7110_emit_key(u32 ircom) return; } - if (ir_config & 0x0001) + if ((ir_config & 0x0003) == 1) new_toggle = 0; /* RCMM */ else - new_toggle = (ircom & 0x800); /* RC5 */ + new_toggle = (ircom & 0x800); /* RC5, extended RC5 */ if (timer_pending(&keyup_timer)) { del_timer(&keyup_timer); @@ -137,6 +154,8 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, { char *page; int size = 4 + 256 * sizeof(u16); + u32 ir_config; + int i; if (count < size) return -EINVAL; @@ -153,60 +172,95 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, memcpy(&ir_config, page, 4); memcpy(&key_map, page + 4, 256 * sizeof(u16)); vfree(page); - av7110_setup_irc_config(NULL, ir_config); + if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001)) + ir_config |= 0x0002; /* enable extended RC5 */ + for (i = 0; i < av_cnt; i++) + av7110_setup_irc_config(av_list[i], ir_config); input_register_keys(); return count; } -int __init av7110_ir_init(void) +int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) { - static struct proc_dir_entry *e; + int ret = 0; - if (ir_initialized) - return 0; + dprintk(4, "%p\n", av7110); + if (av7110) { + ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); + av7110->ir_config = ir_config; + } + return ret; +} - init_timer(&keyup_timer); - keyup_timer.data = 0; - input_dev.name = "DVB on-card IR receiver"; +static void ir_handler(struct av7110 *av7110, u32 ircom) +{ + dprintk(4, "ircommand = %08x\n", ircom); + av7110->ir_command = ircom; + tasklet_schedule(&av7110->ir_tasklet); +} - /** - * enable keys - */ - set_bit(EV_KEY, input_dev.evbit); - set_bit(EV_REP, input_dev.evbit); - input_register_keys(); +int __init av7110_ir_init(struct av7110 *av7110) +{ + static struct proc_dir_entry *e; - input_register_device(&input_dev); - input_dev.timer.function = input_repeat_key; + if (av_cnt >= sizeof av_list/sizeof av_list[0]) + return -ENOSPC; - av7110_setup_irc_config(NULL, 0x0001); - av7110_register_irc_handler(av7110_emit_key); + av7110_setup_irc_config(av7110, 0x0001); + av_list[av_cnt++] = av7110; - e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); - if (e) { - e->write_proc = av7110_ir_write_proc; - e->size = 4 + 256 * sizeof(u16); + if (av_cnt == 1) { + init_timer(&keyup_timer); + keyup_timer.data = 0; + + input_dev.name = "DVB on-card IR receiver"; + set_bit(EV_KEY, input_dev.evbit); + set_bit(EV_REP, input_dev.evbit); + input_register_keys(); + input_register_device(&input_dev); + input_dev.timer.function = input_repeat_key; + + e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); + if (e) { + e->write_proc = av7110_ir_write_proc; + e->size = 4 + 256 * sizeof(u16); + } } - ir_initialized = 1; + tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110); + av7110->ir_handler = ir_handler; + return 0; } -void __exit av7110_ir_exit(void) +void __exit av7110_ir_exit(struct av7110 *av7110) { - if (ir_initialized == 0) + int i; + + if (av_cnt == 0) return; - del_timer_sync(&keyup_timer); - remove_proc_entry("av7110_ir", NULL); - av7110_unregister_irc_handler(av7110_emit_key); - input_unregister_device(&input_dev); - ir_initialized = 0; + + av7110->ir_handler = NULL; + tasklet_kill(&av7110->ir_tasklet); + for (i = 0; i < av_cnt; i++) + if (av_list[i] == av7110) { + av_list[i] = av_list[av_cnt-1]; + av_list[av_cnt-1] = NULL; + break; + } + + if (av_cnt == 1) { + del_timer_sync(&keyup_timer); + remove_proc_entry("av7110_ir", NULL); + input_unregister_device(&input_dev); + } + + av_cnt--; } //MODULE_AUTHOR("Holger Waechtler "); //MODULE_LICENSE("GPL"); - -- cgit v1.2.3 From 6af4ee10f0b2bec2b8c40150298a9f7c1e9e46c6 Mon Sep 17 00:00:00 2001 From: Karl Herz Date: Fri, 9 Sep 2005 13:03:13 -0700 Subject: [PATCH] dvb: ttpci: add PCI ids for old Siemens/TT DVB-C card Add PCI-ids of Siemens-DVB-C card with Technotrend manufacturer id. Signed-off-by: Karl Herz Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttpci/av7110.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index b5d40d42436..22b203f8ff2 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110 *av7110) if (ret < 0) printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); if (rgb_on && - (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { + ((av7110->dev->pci->subsystem_vendor == 0x110a) || + (av7110->dev->pci->subsystem_vendor == 0x13c2)) && + (av7110->dev->pci->subsystem_device == 0x0000)) { saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 } @@ -2868,7 +2870,7 @@ static struct saa7146_pci_extension_data x_var = { \ .ext_priv = x_name, \ .ext = &av7110_extension } -MAKE_AV7110_INFO(tts_1_X, "Technotrend/Hauppauge WinTV DVB-S rev1.X"); +MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); @@ -2880,16 +2882,16 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); static struct pci_device_id pci_tbl[] = { - MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), - MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), - MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), - MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), - MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), - MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), - MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), - MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), - MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), - MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), + MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), + MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000), + MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), + MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), + MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), + MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), + MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), + MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), + MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), + MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 -- cgit v1.2.3 From 1ac2854cbc637de7e958cfa8d153ccf9e6668dda Mon Sep 17 00:00:00 2001 From: Philipp Matthias Hahn Date: Fri, 9 Sep 2005 13:03:13 -0700 Subject: [PATCH] dvb: saa7146: i2c vs. sysfs fix Integrate saa7146_i2c adapter into device model: Moves entries from /sys/device/platform to /sys/device/pci*. Signed-off-by: Philipp Hahn Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/common/saa7146_i2c.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 45f86737699..fec6beab8c2 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -403,6 +403,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c if( NULL != i2c_adapter ) { BUG_ON(!i2c_adapter->class); i2c_set_adapdata(i2c_adapter,dev); + i2c_adapter->dev.parent = &dev->pci->dev; i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; i2c_adapter->id = I2C_HW_SAA7146; -- cgit v1.2.3 From 4da006c63fb4758ee2d688aa65a461337b3ed065 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Fri, 9 Sep 2005 13:03:15 -0700 Subject: [PATCH] dvb: ttusb-budget: use time_after_eq() Use of the time_after_eq() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Domen Puncer Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index c1acd4bb349..d200ab0ad9e 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "dvb_frontend.h" @@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data, int len); #endif -static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid; +static int numpkt = 0, numts, numstuff, numsec, numinvalid; +static unsigned long lastj; static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, int len) @@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs) u8 *data; int len; numpkt++; - if ((jiffies - lastj) >= HZ) { + if (time_after_eq(jiffies, lastj + HZ)) { #if DEBUG > 2 printk ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", -- cgit v1.2.3 From 76fa82fb7156aa7191dfd1fdede1fc0da51d45dd Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 9 Sep 2005 13:03:21 -0700 Subject: [PATCH] pcmcia: reduce ds.c stack footprint This patch reduces the stack footprint of pcmcia_device_query() from 416 bytes to 36 bytes. Signed-off-by: Ingo Molnar Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 43da2e92d50..398146e3823 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -424,9 +424,13 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) { cistpl_manfid_t manf_id; cistpl_funcid_t func_id; - cistpl_vers_1_t vers1; + cistpl_vers_1_t *vers1; unsigned int i; + vers1 = kmalloc(sizeof(*vers1), GFP_KERNEL); + if (!vers1) + return -ENOMEM; + if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_MANFID, &manf_id)) { p_dev->manf_id = manf_id.manf; @@ -443,23 +447,30 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) /* rule of thumb: cards with no FUNCID, but with * common memory device geometry information, are * probably memory cards (from pcmcia-cs) */ - cistpl_device_geo_t devgeo; + cistpl_device_geo_t *devgeo; + + devgeo = kmalloc(sizeof(*devgeo), GFP_KERNEL); + if (!devgeo) { + kfree(vers1); + return -ENOMEM; + } if (!pccard_read_tuple(p_dev->socket, p_dev->func, - CISTPL_DEVICE_GEO, &devgeo)) { + CISTPL_DEVICE_GEO, devgeo)) { ds_dbg(0, "mem device geometry probably means " "FUNCID_MEMORY\n"); p_dev->func_id = CISTPL_FUNCID_MEMORY; p_dev->has_func_id = 1; } + kfree(devgeo); } if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1, - &vers1)) { - for (i=0; i < vers1.ns; i++) { + vers1)) { + for (i=0; i < vers1->ns; i++) { char *tmp; unsigned int length; - tmp = vers1.str + vers1.ofs[i]; + tmp = vers1->str + vers1->ofs[i]; length = strlen(tmp) + 1; if ((length < 3) || (length > 255)) @@ -475,6 +486,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) } } + kfree(vers1); return 0; } -- cgit v1.2.3 From b3743fa4442fc172e950ff0eaf6aa96e7d5ce9be Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:23 -0700 Subject: [PATCH] yenta: share code with PCI core Share code between setup-bus.c and yenta_socket.c: use the write-out code of resources to the bridge also in yenta_socket.c, as it provides useful debug output. In addition, it fixes the bug that the CPU-centric resource view might need to be transferred to the PCI-centric view: setup-bus.c does that, while yenta-socket.c did not. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pci/setup-bus.c | 4 ++-- drivers/pcmcia/yenta_socket.c | 41 ++++++++++++++++++----------------------- 2 files changed, 20 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6b0e6464eb3..657be948baf 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -77,8 +77,7 @@ pbus_assign_resources_sorted(struct pci_bus *bus) } } -static void __devinit -pci_setup_cardbus(struct pci_bus *bus) +void pci_setup_cardbus(struct pci_bus *bus) { struct pci_dev *bridge = bus->self; struct pci_bus_region region; @@ -130,6 +129,7 @@ pci_setup_cardbus(struct pci_bus *bus) region.end); } } +EXPORT_SYMBOL(pci_setup_cardbus); /* Initialize bridges with base/limit values we have collected. PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 0347a29f297..271a52b7c2e 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -667,7 +667,7 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res, return 0; } -static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) +static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) { struct resource *root, *res; struct pci_bus_region region; @@ -676,7 +676,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; /* Already allocated? */ if (res->parent) - return; + return 0; /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */ mask = ~0xfff; @@ -692,7 +692,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ pcibios_bus_to_resource(socket->dev, res, ®ion); root = pci_find_parent_resource(socket->dev, res); if (root && (request_resource(root, res) == 0)) - return; + return 0; printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", pci_name(socket->dev), nr); } @@ -700,35 +700,27 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ if (type & IORESOURCE_IO) { if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) || (yenta_search_res(socket, res, BRIDGE_IO_ACC)) || - (yenta_search_res(socket, res, BRIDGE_IO_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_IO_MIN))) + return 1; } else { if (type & IORESOURCE_PREFETCH) { if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; /* Approximating prefetchable by non-prefetchable */ res->flags = IORESOURCE_MEM; } if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; } printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", pci_name(socket->dev), type); res->start = res->end = res->flags = 0; + return 0; } /* @@ -736,14 +728,17 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ */ static void yenta_allocate_resources(struct yenta_socket *socket) { - yenta_allocate_res(socket, 0, IORESOURCE_IO, + int program = 0; + program += yenta_allocate_res(socket, 0, IORESOURCE_IO, PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0); - yenta_allocate_res(socket, 1, IORESOURCE_IO, + program += yenta_allocate_res(socket, 1, IORESOURCE_IO, PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1); - yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, + program += yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0); - yenta_allocate_res(socket, 3, IORESOURCE_MEM, + program += yenta_allocate_res(socket, 3, IORESOURCE_MEM, PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1); + if (program) + pci_setup_cardbus(socket->dev->subordinate); } @@ -758,7 +753,7 @@ static void yenta_free_resources(struct yenta_socket *socket) res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i; if (res->start != 0 && res->end != 0) release_resource(res); - res->start = res->end = 0; + res->start = res->end = res->flags = 0; } } -- cgit v1.2.3 From bf4de6f2db79f3c396bd884f546cd2ea91a686f2 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:23 -0700 Subject: [PATCH] pcmcia/cs: fix possible missed wakeup - thread_done should only be completed when the wait_queue is installed. - all wake up conditions should be checked before schedule() this fixes a hang of rmmod in the sequence modprobe yenta_socket; rmmod yenta_socket as reported by Andreas Steinmetz. w/o this rmmod yenta_socket can hang on wait_for_completion() in pcmcia_unregister_socket() Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e39178fc59d..fabd3529ceb 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -654,9 +654,10 @@ static int pccardd(void *__skt) skt->thread = NULL; complete_and_exit(&skt->thread_done, 0); } - complete(&skt->thread_done); add_wait_queue(&skt->thread_wait, &wait); + complete(&skt->thread_done); + for (;;) { unsigned long flags; unsigned int events; @@ -682,11 +683,11 @@ static int pccardd(void *__skt) continue; } - schedule(); - try_to_freeze(); - if (!skt->thread) break; + + schedule(); + try_to_freeze(); } remove_wait_queue(&skt->thread_wait, &wait); -- cgit v1.2.3 From c181e0e00ff778623c7fda055fd404a06d2c7845 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:25 -0700 Subject: [PATCH] fix pcmcia_request_irq() for multifunction card multifunction cards need to have the same irq assigned to both functions. the code tries that but fails because ret is still set to CS_IN_USE which results in the function having the CB irq assigned. yenta_set_socket then just changes the irq routing to use the PCI interrupt but the first functions irq handler is registered on an ISA interrupt. boom. Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/pcmcia_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 599b116d974..c0f4eb49177 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -832,7 +832,8 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) } } #endif - if (ret) { + /* only assign PCI irq if no IRQ already assigned */ + if (ret && !s->irq.AssignedIRQ) { if (!s->pci_irq) return ret; irq = s->pci_irq; -- cgit v1.2.3 From c8751e4c0bd32ecb76434240a56a087fa223280c Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 9 Sep 2005 13:03:25 -0700 Subject: [PATCH] pcmcia/yenta: avoid PCI write posting problem extend cb_writel(), exca_writeb(), exca_writel() to do a read[lb]() after the write[lb]() to avoid possible problem with PCI write posting. Seems to fix Bug #5061. Signed-off-by: Daniel Ritz Cc: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/yenta_socket.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 271a52b7c2e..f0997c36c9b 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -72,6 +72,7 @@ static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) { debug("%p %04x %08x\n", socket, reg, val); writel(val, socket->base + reg); + readl(socket->base + reg); /* avoid problems with PCI write posting */ } static inline u8 config_readb(struct yenta_socket *socket, unsigned offset) @@ -136,6 +137,7 @@ static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val { debug("%p %04x %02x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg); /* PCI write posting... */ } static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) @@ -143,6 +145,10 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) debug("%p %04x %04x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); writeb(val >> 8, socket->base + 0x800 + reg + 1); + + /* PCI write posting... */ + readb(socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg + 1); } /* -- cgit v1.2.3 From 76d82ec526b0549cedf332d80929c8c225b653fa Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:26 -0700 Subject: [PATCH] pcmcia: remove unused client_t client_t and CLIENT_MAGIC are unused, so remove them Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs_internal.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 6bbfbd0e02a..4d5ffdcfeca 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -17,9 +17,6 @@ #include -#define CLIENT_MAGIC 0x51E6 -typedef struct client_t client_t; - /* Flags in client state */ #define CLIENT_CONFIG_LOCKED 0x0001 #define CLIENT_IRQ_REQ 0x0002 -- cgit v1.2.3 From 71ed90d89eff51a1137cbef727f11b8f7d5b20f1 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:27 -0700 Subject: [PATCH] pcmcia: remove unused Vpp1, Vpp2 and Vcc config_t->Vpp1, Vpp2 and Vcc are never read, so remove them. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs_internal.h | 1 - drivers/pcmcia/pcmcia_resource.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 4d5ffdcfeca..55867bc7f19 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -42,7 +42,6 @@ typedef struct region_t { typedef struct config_t { u_int state; u_int Attributes; - u_int Vcc, Vpp1, Vpp2; u_int IntType; u_int ConfigBase; u_char Status, Pin, Copy, Option, ExtStatus; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index c0f4eb49177..deb6d00bc2f 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -447,7 +447,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) return CS_BAD_VPP; - c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; + s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || @@ -623,8 +623,6 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; - c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; - /* Pick memory or I/O card, DMA mode, interrupt */ c->IntType = req->IntType; c->Attributes = req->Attributes; -- cgit v1.2.3 From f74e48a51c38f54fa26eb86a7a42f592156eccc2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Fri, 9 Sep 2005 13:03:28 -0700 Subject: [PATCH] pcmcia: OMAP CF controller This adds a socket driver for the OMAP CF controller; it's currently in use on OSK boards. Signed-off-by: David Brownell Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Kconfig | 7 + drivers/pcmcia/Makefile | 1 + drivers/pcmcia/omap_cf.c | 373 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/pcmcia/omap_cf.c (limited to 'drivers') diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 6485f75d2fb..ddc741e6ecb 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -221,6 +221,13 @@ config PCMCIA_VRC4173 tristate "NEC VRC4173 CARDU support" depends on CPU_VR41XX && PCI && PCMCIA +config OMAP_CF + tristate "OMAP CompactFlash Controller" + depends on PCMCIA && ARCH_OMAP16XX + help + Say Y here to support the CompactFlash controller on OMAP. + Note that this doesn't support "True IDE" mode. + config PCCARD_NONSTATIC tristate diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index ef694c74dfb..a41fbb38fdc 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_M32R_CFC) += m32r_cfc.o obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o +obj-$(CONFIG_OMAP_CF) += omap_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c new file mode 100644 index 00000000000..08d1c928826 --- /dev/null +++ b/drivers/pcmcia/omap_cf.c @@ -0,0 +1,373 @@ +/* + * omap_cf.c -- OMAP 16xx CompactFlash controller driver + * + * Copyright (c) 2005 David Brownell + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + + +/* NOTE: don't expect this to support many I/O cards. The 16xx chips have + * hard-wired timings to support Compact Flash memory cards; they won't work + * with various other devices (like WLAN adapters) without some external + * logic to help out. + * + * NOTE: CF controller docs disagree with address space docs as to where + * CF_BASE really lives; this is a doc erratum. + */ +#define CF_BASE 0xfffe2800 + +/* status; read after IRQ */ +#define CF_STATUS_REG __REG16(CF_BASE + 0x00) +# define CF_STATUS_BAD_READ (1 << 2) +# define CF_STATUS_BAD_WRITE (1 << 1) +# define CF_STATUS_CARD_DETECT (1 << 0) + +/* which chipselect (CS0..CS3) is used for CF (active low) */ +#define CF_CFG_REG __REG16(CF_BASE + 0x02) + +/* card reset */ +#define CF_CONTROL_REG __REG16(CF_BASE + 0x04) +# define CF_CONTROL_RESET (1 << 0) + +#define omap_cf_present() (!(CF_STATUS_REG & CF_STATUS_CARD_DETECT)) + +/*--------------------------------------------------------------------------*/ + +static const char driver_name[] = "omap_cf"; + +struct omap_cf_socket { + struct pcmcia_socket socket; + + struct timer_list timer; + unsigned present:1; + unsigned active:1; + + struct platform_device *pdev; + unsigned long phys_cf; + u_int irq; +}; + +#define POLL_INTERVAL (2 * HZ) + +#define SZ_2K (2 * SZ_1K) + +/*--------------------------------------------------------------------------*/ + +static int omap_cf_ss_init(struct pcmcia_socket *s) +{ + return 0; +} + +/* the timer is primarily to kick this socket's pccardd */ +static void omap_cf_timer(unsigned long _cf) +{ + struct omap_cf_socket *cf = (void *) _cf; + unsigned present = omap_cf_present(); + + if (present != cf->present) { + cf->present = present; + pr_debug("%s: card %s\n", driver_name, + present ? "present" : "gone"); + pcmcia_parse_events(&cf->socket, SS_DETECT); + } + + if (cf->active) + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); +} + +/* This irq handler prevents "irqNNN: nobody cared" messages as drivers + * claim the card's IRQ. It may also detect some card insertions, but + * not removals; it can't always eliminate timer irqs. + */ +static irqreturn_t omap_cf_irq(int irq, void *_cf, struct pt_regs *r) +{ + omap_cf_timer((unsigned long)_cf); + return IRQ_HANDLED; +} + +static int omap_cf_get_status(struct pcmcia_socket *s, u_int *sp) +{ + if (!sp) + return -EINVAL; + + /* FIXME power management should probably be board-specific: + * - 3VCARD vs XVCARD (OSK only handles 3VCARD) + * - POWERON (switched on/off by set_socket) + */ + if (omap_cf_present()) { + struct omap_cf_socket *cf; + + *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD; + cf = container_of(s, struct omap_cf_socket, socket); + s->irq.AssignedIRQ = cf->irq; + } else + *sp = 0; + return 0; +} + +static int +omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) +{ + u16 control; + + /* FIXME some non-OSK boards will support power switching */ + switch (s->Vcc) { + case 0: + case 33: + break; + default: + return -EINVAL; + } + + control = CF_CONTROL_REG; + if (s->flags & SS_RESET) + CF_CONTROL_REG = CF_CONTROL_RESET; + else + CF_CONTROL_REG = 0; + + pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", + driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); + + return 0; +} + +static int omap_cf_ss_suspend(struct pcmcia_socket *s) +{ + pr_debug("%s: %s\n", driver_name, __FUNCTION__); + return omap_cf_set_socket(s, &dead_socket); +} + +/* regions are 2K each: mem, attrib, io (and reserved-for-ide) */ + +static int +omap_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) +{ + struct omap_cf_socket *cf; + + cf = container_of(s, struct omap_cf_socket, socket); + io->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + io->start = cf->phys_cf + SZ_4K; + io->stop = io->start + SZ_2K - 1; + return 0; +} + +static int +omap_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map) +{ + struct omap_cf_socket *cf; + + if (map->card_start) + return -EINVAL; + cf = container_of(s, struct omap_cf_socket, socket); + map->static_start = cf->phys_cf; + map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + if (map->flags & MAP_ATTRIB) + map->static_start += SZ_2K; + return 0; +} + +static struct pccard_operations omap_cf_ops = { + .init = omap_cf_ss_init, + .suspend = omap_cf_ss_suspend, + .get_status = omap_cf_get_status, + .set_socket = omap_cf_set_socket, + .set_io_map = omap_cf_set_io_map, + .set_mem_map = omap_cf_set_mem_map, +}; + +/*--------------------------------------------------------------------------*/ + +/* + * NOTE: right now the only board-specific platform_data is + * "what chipselect is used". Boards could want more. + */ + +static int __init omap_cf_probe(struct device *dev) +{ + unsigned seg; + struct omap_cf_socket *cf; + struct platform_device *pdev = to_platform_device(dev); + int irq; + int status; + + seg = (int) dev->platform_data; + if (seg == 0 || seg > 3) + return -ENODEV; + + /* either CFLASH.IREQ (INT_1610_CF) or some GPIO */ + irq = platform_get_irq(pdev, 0); + if (!irq) + return -EINVAL; + + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); + if (!cf) + return -ENOMEM; + init_timer(&cf->timer); + cf->timer.function = omap_cf_timer; + cf->timer.data = (unsigned long) cf; + + cf->pdev = pdev; + dev_set_drvdata(dev, cf); + + /* this primarily just shuts up irq handling noise */ + status = request_irq(irq, omap_cf_irq, SA_SHIRQ, + driver_name, cf); + if (status < 0) + goto fail0; + cf->irq = irq; + cf->socket.pci_irq = irq; + + switch (seg) { + /* NOTE: CS0 could be configured too ... */ + case 1: + cf->phys_cf = OMAP_CS1_PHYS; + break; + case 2: + cf->phys_cf = OMAP_CS2_PHYS; + break; + case 3: + cf->phys_cf = omap_cs3_phys(); + break; + default: + goto fail1; + } + + /* pcmcia layer only remaps "real" memory */ + cf->socket.io_offset = (unsigned long) + ioremap(cf->phys_cf + SZ_4K, SZ_2K); + if (!cf->socket.io_offset) + goto fail1; + + if (!request_mem_region(cf->phys_cf, SZ_8K, driver_name)) + goto fail1; + + /* NOTE: CF conflicts with MMC1 */ + omap_cfg_reg(W11_1610_CF_CD1); + omap_cfg_reg(P11_1610_CF_CD2); + omap_cfg_reg(R11_1610_CF_IOIS16); + omap_cfg_reg(V10_1610_CF_IREQ); + omap_cfg_reg(W10_1610_CF_RESET); + + CF_CFG_REG = ~(1 << seg); + + pr_info("%s: cs%d on irq %d\n", driver_name, seg, irq); + + /* NOTE: better EMIFS setup might support more cards; but the + * TRM only shows how to affect regular flash signals, not their + * CF/PCMCIA variants... + */ + pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", driver_name, + seg, EMIFS_CCS(seg), EMIFS_ACS(seg)); + EMIFS_CCS(seg) = 0x0004a1b3; /* synch mode 4 etc */ + EMIFS_ACS(seg) = 0x00000000; /* OE hold/setup */ + + /* CF uses armxor_ck, which is "always" available */ + + pr_debug("%s: sts %04x cfg %04x control %04x %s\n", driver_name, + CF_STATUS_REG, CF_CFG_REG, CF_CONTROL_REG, + omap_cf_present() ? "present" : "(not present)"); + + cf->socket.owner = THIS_MODULE; + cf->socket.dev.dev = dev; + cf->socket.ops = &omap_cf_ops; + cf->socket.resource_ops = &pccard_static_ops; + cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP + | SS_CAP_MEM_ALIGN; + cf->socket.map_size = SZ_2K; + + status = pcmcia_register_socket(&cf->socket); + if (status < 0) + goto fail2; + + cf->active = 1; + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); + return 0; + +fail2: + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); +fail1: + free_irq(irq, cf); +fail0: + kfree(cf); + return status; +} + +static int __devexit omap_cf_remove(struct device *dev) +{ + struct omap_cf_socket *cf = dev_get_drvdata(dev); + + cf->active = 0; + pcmcia_unregister_socket(&cf->socket); + del_timer_sync(&cf->timer); + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); + free_irq(cf->irq, cf); + kfree(cf); + return 0; +} + +static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level) +{ + if (level != SUSPEND_SAVE_STATE) + return 0; + return pcmcia_socket_dev_suspend(dev, mesg); +} + +static int omap_cf_resume(struct device *dev, u32 level) +{ + if (level != RESUME_RESTORE_STATE) + return 0; + return pcmcia_socket_dev_resume(dev); +} + +static struct device_driver omap_cf_driver = { + .name = (char *) driver_name, + .bus = &platform_bus_type, + .probe = omap_cf_probe, + .remove = __devexit_p(omap_cf_remove), + .suspend = omap_cf_suspend, + .resume = omap_cf_resume, +}; + +static int __init omap_cf_init(void) +{ + if (cpu_is_omap16xx()) + driver_register(&omap_cf_driver); + return 0; +} + +static void __exit omap_cf_exit(void) +{ + if (cpu_is_omap16xx()) + driver_unregister(&omap_cf_driver); +} + +module_init(omap_cf_init); +module_exit(omap_cf_exit); + +MODULE_DESCRIPTION("OMAP CF Driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From d3feb1844ad33911ab1fe9df1ead66082b3bce9b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 9 Sep 2005 13:03:28 -0700 Subject: [PATCH] pcmcia: more IDs for ide_cs (Partly From: David Brownell ) Make ID-CS recognize the CF card manufacturer records for Samsung, Lexar and STI. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/legacy/ide-cs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index f1d1ec4e967..dc0841b2721 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -454,9 +454,12 @@ int ide_event(event_t event, int priority, static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_FUNC_ID(4), PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), + PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), + PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), @@ -481,6 +484,7 @@ static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), + PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), PCMCIA_DEVICE_NULL, }; -- cgit v1.2.3 From bd65a68574b787304a0cd90f22cfd44540ce3695 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Fri, 9 Sep 2005 13:03:29 -0700 Subject: [PATCH] pcmcia: add pcmcia to IRQ information Add a devname parameter to the pcmcia_device structure, fills it with "pcmcia" in pcmcia_device_add, and passes it to request_irq in pcmcia_request_irq. Signed-off-by: Brice Goglin Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 10 +++++++++- drivers/pcmcia/pcmcia_resource.c | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 398146e3823..080608c7381 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -354,6 +354,7 @@ static void pcmcia_release_dev(struct device *dev) struct pcmcia_device *p_dev = to_pcmcia_dev(dev); ds_dbg(1, "releasing dev %p\n", p_dev); pcmcia_put_socket(p_dev->socket); + kfree(p_dev->devname); kfree(p_dev); } @@ -504,6 +505,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f { struct pcmcia_device *p_dev; unsigned long flags; + int bus_id_len; s = pcmcia_get_socket(s); if (!s) @@ -527,7 +529,12 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f p_dev->dev.bus = &pcmcia_bus_type; p_dev->dev.parent = s->dev.dev; p_dev->dev.release = pcmcia_release_dev; - sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + + p_dev->devname = kmalloc(6 + bus_id_len + 1, GFP_KERNEL); + if (!p_dev->devname) + goto err_free; + sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); /* compat */ p_dev->state = CLIENT_UNBOUND; @@ -552,6 +559,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f return p_dev; err_free: + kfree(p_dev->devname); kfree(p_dev); s->device_count--; err_put: diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index deb6d00bc2f..89022ad5b52 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -820,7 +820,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, + p_dev->devname, (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); if (!ret) { if (!(req->Attributes & IRQ_HANDLE_PRESENT)) @@ -842,7 +842,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, req->Instance)) + p_dev->devname, req->Instance)) return CS_IN_USE; } -- cgit v1.2.3 From a1938038dd7e4188a8663e49242fa77dd2adb7ed Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 9 Sep 2005 13:03:34 -0700 Subject: [PATCH] VIDEO_BT848: remove not required part of the help text Things that are already expressed through the dependencies don't have to be mentioned in the help text. Signed-off-by: Adrian Bunk Cc: Mauro Carvalho Chehab Cc: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/Kconfig | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 16c85c081e6..077720c2b64 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -22,9 +22,6 @@ config VIDEO_BT848 the Miro, Hauppauge and STB boards. Please read the material in for more information. - If you say Y or M here, you need to say Y or M to "I2C support" and - "I2C bit-banging interfaces" in the device drivers section. - To compile this driver as a module, choose M here: the module will be called bttv. -- cgit v1.2.3 From 793cf9e6a54c698e109a599c8b8e303658fcaae6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:37 -0700 Subject: [PATCH] v4l: common part Updates and tuner additions - Remove $Id CVS logs for V4L files - Included newer cards. - Added a new NEC protocol for ir based on pulse distance. - Enable ATSC support for DViCO FusionHDTV5 Gold. - Added tuner LG NTSC (TALN mini series). - Fixed tea5767 autodetection. - Resolve more tuner types. - Commented debug function removed from mainstream. - Remove comments from mainstream. Still on development tree. - linux/version dependencies removed. - BTSC Lang1 now is set to auto_stereo mode. - New tuner standby API. - i2c-core.c uses hexadecimal for the i2c address, so it should stay consistent. Signed-off-by: Uli Luckas Signed-off-by: Mac Michaels Signed-off-by: Michael Krufky Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/common/ir-common.c | 68 ++++++++++++++++++++++++++++++- drivers/media/video/btcx-risc.c | 1 - drivers/media/video/btcx-risc.h | 1 - drivers/media/video/ir-kbd-gpio.c | 1 - drivers/media/video/ir-kbd-i2c.c | 1 - drivers/media/video/msp3400.h | 1 - drivers/media/video/mt20xx.c | 2 +- drivers/media/video/tda8290.c | 19 ++++++++- drivers/media/video/tda9887.c | 39 +++++++++++------- drivers/media/video/tea5767.c | 37 ++++++++++------- drivers/media/video/tuner-core.c | 79 +++++++++++++++++++++---------------- drivers/media/video/tuner-simple.c | 5 ++- drivers/media/video/tveeprom.c | 25 ++---------- drivers/media/video/tvmixer.c | 1 - drivers/media/video/v4l1-compat.c | 16 -------- drivers/media/video/v4l2-common.c | 18 --------- drivers/media/video/video-buf-dvb.c | 1 - drivers/media/video/video-buf.c | 1 - 18 files changed, 186 insertions(+), 130 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c index ab7a1fba442..a0e700d7a4a 100644 --- a/drivers/media/common/ir-common.c +++ b/drivers/media/common/ir-common.c @@ -1,5 +1,4 @@ /* - * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -335,6 +334,72 @@ int ir_dump_samples(u32 *samples, int count) 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) { @@ -383,6 +448,7 @@ 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: diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c index 7f2d515d287..a48de3c0e3f 100644 --- a/drivers/media/video/btcx-risc.c +++ b/drivers/media/video/btcx-risc.c @@ -1,5 +1,4 @@ /* - $Id: btcx-risc.c,v 1.6 2005/02/21 13:57:59 kraxel Exp $ btcx-risc.c diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h index 41f60395a52..503e6c6d7b6 100644 --- a/drivers/media/video/btcx-risc.h +++ b/drivers/media/video/btcx-risc.h @@ -1,5 +1,4 @@ /* - * $Id: btcx-risc.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ */ struct btcx_riscmem { unsigned int size; diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index a565823330a..eddadc76e11 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-gpio.c,v 1.13 2005/05/15 19:01:26 mchehab Exp $ * * Copyright (c) 2003 Gerd Knorr * Copyright (c) 2003 Pavel Machek diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 1e273ff3f95..67105b9804a 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-i2c.c,v 1.11 2005/07/07 16:42:11 mchehab Exp $ * * keyboard input driver for i2c IR remote controls * diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 023f33056a4..2d9ff40f0b0 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -1,5 +1,4 @@ /* - * $Id: msp3400.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $ */ #ifndef MSP3400_H diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c index 2fb7c2d1787..972aa5e0aee 100644 --- a/drivers/media/video/mt20xx.c +++ b/drivers/media/video/mt20xx.c @@ -1,5 +1,4 @@ /* - * $Id: mt20xx.c,v 1.5 2005/06/16 08:29:49 nsh Exp $ * * i2c tv tuner chip device driver * controls microtune tuners, mt2032 + mt2050 at the moment. @@ -494,6 +493,7 @@ int microtune_init(struct i2c_client *c) memset(buf,0,sizeof(buf)); t->tv_freq = NULL; t->radio_freq = NULL; + t->standby = NULL; name = "unknown"; i2c_master_send(c,buf,1); diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index a8b6a8df510..c65f0c7680a 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c @@ -1,5 +1,4 @@ /* - * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $ * * i2c tv tuner chip device driver * controls the philips tda8290+75 tuner chip combo. @@ -9,6 +8,9 @@ #include #include +#define I2C_ADDR_TDA8290 0x4b +#define I2C_ADDR_TDA8275 0x61 + /* ---------------------------------------------------------------------- */ struct freq_entry { @@ -75,10 +77,12 @@ static unsigned char i2c_init_tda8275[14] = { 0x00, 0x00, 0x00, 0x00, static unsigned char i2c_set_VS[2] = { 0x30, 0x6F }; static unsigned char i2c_set_GP01_CF[2] = { 0x20, 0x0B }; static unsigned char i2c_tda8290_reset[2] = { 0x00, 0x00 }; +static unsigned char i2c_tda8290_standby[2] = { 0x00, 0x02 }; static unsigned char i2c_gainset_off[2] = { 0x28, 0x14 }; static unsigned char i2c_gainset_on[2] = { 0x28, 0x54 }; static unsigned char i2c_agc3_00[2] = { 0x80, 0x00 }; static unsigned char i2c_agc2_BF[2] = { 0x60, 0xBF }; +static unsigned char i2c_cb1_D0[2] = { 0x30, 0xD0 }; static unsigned char i2c_cb1_D2[2] = { 0x30, 0xD2 }; static unsigned char i2c_cb1_56[2] = { 0x30, 0x56 }; static unsigned char i2c_cb1_52[2] = { 0x30, 0x52 }; @@ -117,6 +121,13 @@ static struct i2c_msg i2c_msg_epilog[] = { { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on }, }; +static struct i2c_msg i2c_msg_standby[] = { + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge }, + { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D0), i2c_cb1_D0 }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_standby), i2c_tda8290_standby }, +}; + static int tda8290_tune(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -205,6 +216,11 @@ static int has_signal(struct i2c_client *c) return (afc & 0x80)? 65535:0; } +static void standby(struct i2c_client *c) +{ + i2c_transfer(c->adapter, i2c_msg_standby, ARRAY_SIZE(i2c_msg_standby)); +} + int tda8290_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -214,6 +230,7 @@ int tda8290_init(struct i2c_client *c) t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = has_signal; + t->standby = standby; i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge)); i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init)); diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index d60fc562aec..79e0bd1aa70 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -49,7 +49,7 @@ MODULE_LICENSE("GPL"); struct tda9887 { struct i2c_client client; v4l2_std_id std; - unsigned int radio; + enum tuner_mode mode; unsigned int config; unsigned int pinnacle_id; unsigned int using_v4l2; @@ -196,7 +196,7 @@ static struct tvnorm tvnorms[] = { .b = ( cNegativeFmTV | cQSS ), .c = ( cDeemphasisON | - cDeemphasis50 ), + cDeemphasis75 ), .e = ( cGating_36 | cAudioIF_4_5 | cVideoIF_45_75 ), @@ -364,7 +364,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) struct tvnorm *norm = NULL; int i; - if (t->radio) { + if (t->mode == T_RADIO) { if (t->radio_mode == V4L2_TUNER_MODE_MONO) norm = &radio_mono; else @@ -378,7 +378,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) } } if (NULL == norm) { - dprintk(PREFIX "Oops: no tvnorm entry found\n"); + dprintk(PREFIX "Unsupported tvnorm entry - audio muted\n"); return -1; } @@ -569,6 +569,10 @@ static int tda9887_configure(struct tda9887 *t) tda9887_set_config(t,buf); tda9887_set_insmod(t,buf); + if (t->mode == T_STANDBY) { + buf[1] |= cForcedMuteAudioON; + } + dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n", buf[1],buf[2],buf[3]); @@ -653,10 +657,17 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) /* --- configuration --- */ case AUDC_SET_RADIO: - t->radio = 1; + { + t->mode = T_RADIO; tda9887_configure(t); break; - + } + case TUNER_SET_STANDBY: + { + t->mode = T_STANDBY; + tda9887_configure(t); + break; + } case AUDC_CONFIG_PINNACLE: { int *i = arg; @@ -689,7 +700,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) struct video_channel *vc = arg; CHECK_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; if (vc->norm < ARRAY_SIZE(map)) t->std = map[vc->norm]; tda9887_fixup_std(t); @@ -701,7 +712,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) v4l2_std_id *id = arg; SWITCH_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; t->std = *id; tda9887_fixup_std(t); tda9887_configure(t); @@ -713,14 +724,14 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) SWITCH_V4L2; if (V4L2_TUNER_ANALOG_TV == f->type) { - if (t->radio == 0) + if (t->mode == T_ANALOG_TV) return 0; - t->radio = 0; + t->mode = T_ANALOG_TV; } if (V4L2_TUNER_RADIO == f->type) { - if (t->radio == 1) + if (t->mode == T_RADIO) return 0; - t->radio = 1; + t->mode = T_RADIO; } tda9887_configure(t); break; @@ -735,7 +746,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) }; struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { __u8 reg = 0; tuner->afc=0; if (1 == i2c_master_recv(&t->client,®,1)) @@ -747,7 +758,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { t->radio_mode = tuner->audmode; tda9887_configure (t); } diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index cebcc1fa68d..38bf5094379 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c @@ -2,7 +2,6 @@ * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview * I2C address is allways 0xC0. * - * $Id: tea5767.c,v 1.27 2005/07/31 12:10:56 mchehab Exp $ * * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) * This code is placed under the terms of the GNU General Public License @@ -205,11 +204,6 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND; buffer[4] = 0; - if (t->mode == T_STANDBY) { - tuner_dbg("TEA5767 set to standby mode\n"); - buffer[3] |= TEA5767_STDBY; - } - if (t->audmode == V4L2_TUNER_MODE_MONO) { tuner_dbg("TEA5767 set to mono\n"); buffer[2] |= TEA5767_MONO; @@ -290,13 +284,31 @@ static int tea5767_stereo(struct i2c_client *c) return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0); } +static void tea5767_standby(struct i2c_client *c) +{ + unsigned char buffer[5]; + struct tuner *t = i2c_get_clientdata(c); + unsigned div, rc; + + div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */ + buffer[0] = (div >> 8) & 0x3f; + buffer[1] = div & 0xff; + buffer[2] = TEA5767_PORT1_HIGH; + buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | + TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY; + buffer[4] = 0; + + if (5 != (rc = i2c_master_send(c, buffer, 5))) + tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); +} + int tea5767_autodetection(struct i2c_client *c) { unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int rc; struct tuner *t = i2c_get_clientdata(c); - if (7 != (rc = i2c_master_recv(c, buffer, 7))) { + if ((rc = i2c_master_recv(c, buffer, 7))< 5) { tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc); return EINVAL; } @@ -313,15 +325,10 @@ int tea5767_autodetection(struct i2c_client *c) * bit 0 : internally set to 0 * Byte 5: bit 7:0 : == 0 */ - if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { + if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); return EINVAL; } - /* It seems that tea5767 returns 0xff after the 5th byte */ - if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { - tuner_warn("Returned more than 5 bytes. It is not a TEA5767\n"); - return EINVAL; - } /* It seems that tea5767 returns 0xff after the 5th byte */ if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { @@ -337,14 +344,14 @@ int tea5767_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); - tuner_info("type set to %d (%s)\n", t->type, - "Philips TEA5767HN FM Radio"); + tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio"); strlcpy(c->name, "tea5767", sizeof(c->name)); t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = tea5767_signal; t->is_stereo = tea5767_stereo; + t->standby = tea5767_standby; return (0); } diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 3b1893c2ae3..afc96bbb1c1 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-core.c,v 1.63 2005/07/28 18:19:55 mchehab Exp $ * * i2c tv tuner chip device driver * core core, i.e. kernel interfaces, registering and so on @@ -182,6 +181,14 @@ static void set_type(struct i2c_client *c, unsigned int type, i2c_master_send(c, buffer, 4); default_tuner_init(c); break; + case TUNER_LG_TDVS_H062F: + /* Set the Auxiliary Byte. */ + buffer[2] &= ~0x20; + buffer[2] |= 0x18; + buffer[3] = 0x20; + i2c_master_send(c, buffer, 4); + default_tuner_init(c); + break; default: default_tuner_init(c); break; @@ -208,31 +215,31 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) { struct tuner *t = i2c_get_clientdata(c); - if (tun_setup->addr == ADDR_UNSET) { - if (t->mode_mask & tun_setup->mode_mask) + if ((tun_setup->addr == ADDR_UNSET && + (t->mode_mask & tun_setup->mode_mask)) || + tun_setup->addr == c->addr) { set_type(c, tun_setup->type, tun_setup->mode_mask); - } else if (tun_setup->addr == c->addr) { - set_type(c, tun_setup->type, tun_setup->mode_mask); } } static inline int check_mode(struct tuner *t, char *cmd) { - if (1 << t->mode & t->mode_mask) { - switch (t->mode) { - case V4L2_TUNER_RADIO: - tuner_dbg("Cmd %s accepted for radio\n", cmd); - break; - case V4L2_TUNER_ANALOG_TV: - tuner_dbg("Cmd %s accepted for analog TV\n", cmd); - break; - case V4L2_TUNER_DIGITAL_TV: - tuner_dbg("Cmd %s accepted for digital TV\n", cmd); - break; - } - return 0; + if ((1 << t->mode & t->mode_mask) == 0) { + return EINVAL; + } + + switch (t->mode) { + case V4L2_TUNER_RADIO: + tuner_dbg("Cmd %s accepted for radio\n", cmd); + break; + case V4L2_TUNER_ANALOG_TV: + tuner_dbg("Cmd %s accepted for analog TV\n", cmd); + break; + case V4L2_TUNER_DIGITAL_TV: + tuner_dbg("Cmd %s accepted for digital TV\n", cmd); + break; } - return EINVAL; + return 0; } static char pal[] = "-"; @@ -406,20 +413,18 @@ static int tuner_detach(struct i2c_client *client) static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) { - if (mode != t->mode) { - - t->mode = mode; - if (check_mode(t, cmd) == EINVAL) { - t->mode = T_STANDBY; - if (V4L2_TUNER_RADIO == mode) { - set_tv_freq(client, 400 * 16); - } else { - set_radio_freq(client, 87.5 * 16000); - } - return EINVAL; - } - } - return 0; + if (mode == t->mode) + return 0; + + t->mode = mode; + + if (check_mode(t, cmd) == EINVAL) { + t->mode = T_STANDBY; + if (t->standby) + t->standby (client); + return EINVAL; + } + return 0; } #define switch_v4l2() if (!t->using_v4l2) \ @@ -453,6 +458,14 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) case AUDC_SET_RADIO: set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO"); break; + case TUNER_SET_STANDBY: + { + if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) + return 0; + if (t->standby) + t->standby (client); + break; + } case AUDC_CONFIG_PINNACLE: if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL) return 0; diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index de0c93aeb75..26034406b37 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-simple.c,v 1.43 2005/07/28 18:41:21 mchehab Exp $ * * i2c tv tuner chip device driver * controls all those simple 4-control-bytes style tuners. @@ -248,9 +247,10 @@ static struct tunertype tuners[] = { { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, - { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, + { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, + 16*150.00,16*425.00,0x01,0x02,0x08,0x8e,732 }, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); @@ -497,6 +497,7 @@ int default_tuner_init(struct i2c_client *c) t->radio_freq = default_set_radio_freq; t->has_signal = tuner_signal; t->is_stereo = tuner_stereo; + t->standby = NULL; return 0; } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3c3356a01cc..d0a00d3a6c4 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -155,10 +155,10 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1216ME MK3"}, { TUNER_ABSENT, "Philips FI1236 MK3"}, { TUNER_PHILIPS_FM1216ME_MK3, "Philips FM1216 ME MK3"}, - { TUNER_ABSENT, "Philips FM1236 MK3"}, + { TUNER_PHILIPS_FM1236_MK3, "Philips FM1236 MK3"}, { TUNER_ABSENT, "Philips FM1216MP MK3"}, /* 60-69 */ - { TUNER_ABSENT, "LG S001D MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "LG S001D MK3"}, { TUNER_ABSENT, "LG M001D MK3"}, { TUNER_ABSENT, "LG S701D MK3"}, { TUNER_ABSENT, "LG M701D MK3"}, @@ -183,8 +183,8 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1216LME MK3"}, { TUNER_ABSENT, "LG TAPC G701D"}, { TUNER_LG_NTSC_NEW_TAPC, "LG TAPC H791F"}, - { TUNER_ABSENT, "TCL 2002MB 3"}, - { TUNER_ABSENT, "TCL 2002MI 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"}, { TUNER_TCL_2002N, "TCL 2002N 6A"}, { TUNER_ABSENT, "Philips FQ1236 MK3"}, { TUNER_ABSENT, "Samsung TCPN 2121P30A"}, @@ -445,23 +445,6 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) } EXPORT_SYMBOL(tveeprom_read); -#if 0 -int tveeprom_dump(unsigned char *eedata, int len) -{ - int i; - - dprintk(1, "%s\n",__FUNCTION__); - for (i = 0; i < len; i++) { - if (0 == (i % 16)) - printk(KERN_INFO "tveeprom: %02x:",i); - printk(" %02x",eedata[i]); - if (15 == (i % 16)) - printk("\n"); - } - return 0; -} -EXPORT_SYMBOL(tveeprom_dump); -#endif /* 0 */ /* ----------------------------------------------------------------------- */ /* needed for ivtv.sf.net at the moment. Should go away in the long */ diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index a43301a154a..d86e08ebddf 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -1,5 +1,4 @@ /* - * $Id: tvmixer.c,v 1.8 2005/06/12 04:19:19 mchehab Exp $ */ #include diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index 70ecbdb8027..59bb71381a1 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c @@ -1,5 +1,4 @@ /* - * $Id: v4l1-compat.c,v 1.9 2005/06/12 04:19:19 mchehab Exp $ * * Video for Linux Two * Backward Compatibility Layer @@ -604,9 +603,6 @@ v4l_compat_translate_ioctl(struct inode *inode, dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n",err); break; } -#if 0 /* FIXME */ - pict->depth = fmt2->fmt.pix.depth; -#endif pict->palette = pixelformat_to_palette( fmt2->fmt.pix.pixelformat); break; @@ -707,13 +703,7 @@ v4l_compat_translate_ioctl(struct inode *inode, } case VIDIOCSTUNER: /* select a tuner input */ { -#if 0 /* FIXME */ - err = drv(inode, file, VIDIOC_S_INPUT, &i); - if (err < 0) - dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n",err); -#else err = 0; -#endif break; } case VIDIOCGFREQ: /* get frequency */ @@ -852,12 +842,6 @@ v4l_compat_translate_ioctl(struct inode *inode, err = 0; break; } -#if 0 - case VIDIOCGMBUF: - /* v4l2 drivers must implement that themself. The - mmap() differences can't be translated fully - transparent, thus there is no point to try that */ -#endif case VIDIOCMCAPTURE: /* capture a frame */ { struct video_mmap *mm = arg; diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index b5e0cf3448f..597b8db35a1 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -84,20 +84,6 @@ MODULE_LICENSE("GPL"); * Video Standard Operations (contributed by Michael Schimek) */ -#if 0 /* seems to have no users */ -/* This is the recommended method to deal with the framerate fields. More - sophisticated drivers will access the fields directly. */ -unsigned int -v4l2_video_std_fps(struct v4l2_standard *vs) -{ - if (vs->frameperiod.numerator > 0) - return (((vs->frameperiod.denominator << 8) / - vs->frameperiod.numerator) + - (1 << 7)) / (1 << 8); - return 0; -} -EXPORT_SYMBOL(v4l2_video_std_fps); -#endif /* Fill in the fields of a v4l2_standard structure according to the 'id' and 'transmission' parameters. Returns negative on error. */ @@ -213,10 +199,6 @@ char *v4l2_ioctl_names[256] = { [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", -#if 0 - [_IOC_NR(VIDIOC_G_COMP)] = "VIDIOC_G_COMP", - [_IOC_NR(VIDIOC_S_COMP)] = "VIDIOC_S_COMP", -#endif [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c index 15f5bb48696..55f129e964e 100644 --- a/drivers/media/video/video-buf-dvb.c +++ b/drivers/media/video/video-buf-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf-dvb.c,v 1.7 2004/12/09 12:51:35 kraxel Exp $ * * some helper function for simple DVB cards which simply DMA the * complete transport stream and let the computer sort everything else diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 5afdc785261..97354f253a8 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf.c,v 1.18 2005/02/24 13:32:30 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. -- cgit v1.2.3 From 24a70fdce872d70171b1f49dcd1a7c3a4e8396b2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:39 -0700 Subject: [PATCH] v4l: BTTV updates and card additions - Remove $Id CVS logs for V4L files - Added DVICO FusionHDTV 5 Lite card. - Added Acorp Y878F. - CodingStyle fixes. - Added tuner_addr to bttv cards structure. - linux/version.h replaced by linux/utsname.h on bttvp.h - kernel module for acquiring RDS data from a SAA6588. - Allow multiple open() and reading calls to /dev/radio on bttv-driver.c - added i2c address for lgdt330x. Signed-off-by: Hans J. Koch Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/bttv-cards.c | 1175 +++++++++++++++++++++---------------- drivers/media/video/bttv-driver.c | 48 +- drivers/media/video/bttv-gpio.c | 1 - drivers/media/video/bttv-i2c.c | 2 +- drivers/media/video/bttv-if.c | 1 - drivers/media/video/bttv-risc.c | 1 - drivers/media/video/bttv-vbi.c | 1 - drivers/media/video/bttv.h | 3 +- drivers/media/video/bttvp.h | 3 +- 9 files changed, 721 insertions(+), 514 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index a97b9b958ed..3cb398b7a02 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -1,5 +1,4 @@ /* - $Id: bttv-cards.c,v 1.54 2005/07/19 18:26:46 mkrufky Exp $ bttv-cards.c @@ -169,10 +168,10 @@ static struct CARD { { 0xd01810fc, BTTV_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" }, { 0x001211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, - // some cards ship with byteswapped IDs ... + /* some cards ship with byteswapped IDs ... */ { 0x1200bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, { 0xff00bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, - // this seems to happen as well ... + /* this seems to happen as well ... */ { 0xff1211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, { 0x3000121a, BTTV_VOODOOTV_FM, "3Dfx VoodooTV FM/ VoodooTV 200" }, @@ -200,12 +199,12 @@ static struct CARD { { 0x1123153b, BTTV_TERRATVRADIO, "Terratec TV Radio+" }, { 0x1127153b, BTTV_TERRATV, "Terratec TV+ (V1.05)" }, - // clashes with FlyVideo - //{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, + /* clashes with FlyVideo + *{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, */ { 0x1134153b, BTTV_TERRATVALUE, "Terratec TValue (LR102)" }, - { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // LR102 - { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, // ?? - { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // ?? + { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* LR102 */ + { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, /* ?? */ + { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* ?? */ { 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, @@ -287,10 +286,12 @@ static struct CARD { { 0x01071805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" }, { 0x01081805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" }, - // likely broken, vendor id doesn't match the other magic views ... - //{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, + { 0x15409511, BTTV_ACORP_Y878F, "Acorp Y878F" }, - // DVB cards (using pci function .1 for mpeg data xfer) + /* likely broken, vendor id doesn't match the other magic views ... + * { 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, */ + + /* DVB cards (using pci function .1 for mpeg data xfer) */ { 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, { 0x07611461, BTTV_AVDVBT_761, "AverMedia AverTV DVB-T 761" }, { 0x001c11bd, BTTV_PINNACLESAT, "Pinnacle PCTV Sat" }, @@ -299,6 +300,7 @@ static struct CARD { { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" }, + { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DVICO FusionHDTV 5 Lite" }, { 0, -1, NULL } }; @@ -316,6 +318,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV", .video_inputs = 4, @@ -327,6 +330,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt848)", .video_inputs = 4, @@ -338,6 +342,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "STB, Gateway P/N 6000699 (bt848)", .video_inputs = 3, @@ -350,6 +355,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -365,6 +371,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Diamond DTV2000", .video_inputs = 4, @@ -376,6 +383,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 0, 1, 3}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVPhone", .video_inputs = 3, @@ -388,6 +396,7 @@ struct tvcard bttv_tvcards[] = { /* 0x04 for some cards ?? */ .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tvphone_audio, .has_remote = 1, },{ @@ -401,6 +410,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x08 ---------------------------------- */ @@ -415,6 +425,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IMS/IXmicro TurboTV", .video_inputs = 3, @@ -427,6 +438,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt878)", .video_inputs = 4, @@ -439,6 +451,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV pro", .video_inputs = 3, @@ -450,6 +463,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20001,0x10001, 0, 0,10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x0c ---------------------------------- */ @@ -463,6 +477,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 13, 14, 11, 7, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVCapture 98", .video_inputs = 3, @@ -476,6 +491,7 @@ struct tvcard bttv_tvcards[] = { .msp34xx_alt = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tv_stereo_audio, },{ .name = "Aimslab Video Highway Xtreme (VHX)", @@ -489,6 +505,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix TV-Max", .video_inputs = 3, @@ -500,6 +517,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 , 0, 1 , 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x10 ---------------------------------- */ @@ -510,7 +528,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .gpiomask = 0x01fe00, .muxsel = { 2, 3, 1, 1}, - // 2003-10-20 by "Anton A. Arapov" + /* 2003-10-20 by "Anton A. Arapov" */ .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, .needs_tvaudio = 1, .pll = PLL_28, @@ -526,6 +544,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = winview_audio, .has_radio = 1, },{ @@ -539,6 +558,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {1, 0, 0, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)", .video_inputs = 4, @@ -550,6 +570,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x14 ---------------------------------- */ @@ -560,10 +581,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = {2, 3, 1, 1}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50", .video_inputs = 4, - .audio_inputs = 2, // tuner, line in + .audio_inputs = 2, /* tuner, line in */ .tuner = 0, .svhs = 2, .gpiomask = 0x1800, @@ -571,6 +593,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH050/ Phoebe Tv Master + FM", .video_inputs = 3, @@ -583,6 +606,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878", .video_inputs = 3, @@ -591,11 +615,12 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 7, .muxsel = { 2, 3, -1 }, - .digital_mode = DIGITAL_MODE_CAMERA, + .digital_mode = DIGITAL_MODE_CAMERA, .audiomux = { 0, 0, 0, 0, 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSBB5_PAL_I, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x18 ---------------------------------- */ @@ -610,6 +635,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", @@ -622,6 +648,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, },{ .name = "Hauppauge WinCam newer (bt878)", @@ -634,6 +661,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50", .video_inputs = 4, @@ -645,6 +673,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_SECAM, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x1c ---------------------------------- */ @@ -658,37 +687,38 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, /* GPIO wiring: - External 20 pin connector (for Active Radio Upgrade board) - gpio00: i2c-sda - gpio01: i2c-scl - gpio02: om5610-data - gpio03: om5610-clk - gpio04: om5610-wre - gpio05: om5610-stereo - gpio06: rds6588-davn - gpio07: Pin 7 n.c. - gpio08: nIOW - gpio09+10: nIOR, nSEL ?? (bt878) - gpio09: nIOR (bt848) - gpio10: nSEL (bt848) - Sound Routing: - gpio16: u2-A0 (1st 4052bt) - gpio17: u2-A1 - gpio18: u2-nEN - gpio19: u4-A0 (2nd 4052) - gpio20: u4-A1 - u4-nEN - GND - Btspy: - 00000 : Cdrom (internal audio input) + External 20 pin connector (for Active Radio Upgrade board) + gpio00: i2c-sda + gpio01: i2c-scl + gpio02: om5610-data + gpio03: om5610-clk + gpio04: om5610-wre + gpio05: om5610-stereo + gpio06: rds6588-davn + gpio07: Pin 7 n.c. + gpio08: nIOW + gpio09+10: nIOR, nSEL ?? (bt878) + gpio09: nIOR (bt848) + gpio10: nSEL (bt848) + Sound Routing: + gpio16: u2-A0 (1st 4052bt) + gpio17: u2-A1 + gpio18: u2-nEN + gpio19: u4-A0 (2nd 4052) + gpio20: u4-A1 + u4-nEN - GND + Btspy: + 00000 : Cdrom (internal audio input) 10000 : ext. Video audio input 20000 : TV Mono a0000 : TV Mono/2 - 1a0000 : TV Stereo + 1a0000 : TV Stereo 30000 : Radio 40000 : Mute - */ +*/ },{ /* Jannik Fritsch */ @@ -702,6 +732,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = PXC200_muxsel, },{ @@ -710,11 +741,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x1800, //0x8dfe00 + .gpiomask = 0x1800, /* 0x8dfe00 */ .muxsel = { 2, 3, 1, 1}, .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Formac iProTV, Formac ProTV I (bt848)", .video_inputs = 4, @@ -726,6 +758,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 0, 0, 0, 0 }, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x20 ---------------------------------- */ @@ -739,6 +772,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TerraTValue Version Bt878", .video_inputs = 3, @@ -751,31 +785,33 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Leadtek WinFast 2000/ WinFast 2000 XP", .video_inputs = 4, .audio_inputs = 1, .tuner = 0, .svhs = 2, - .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector + .muxsel = { 2, 3, 1, 1, 0}, /* TV, CVid, SVid, CVid over SVid connector */ /* Alexander Varakin [stereo version] */ .gpiomask = 0xb33000, .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 }, /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) gpio23 -- hef4052:nEnable (0x800000) gpio12 -- hef4052:A1 - gpio13 -- hef4052:A0 - 0x0000: external audio - 0x1000: FM - 0x2000: TV - 0x3000: n.c. - Note: There exists another variant "Winfast 2000" with tv stereo !? - Note: eeprom only contains FF and pci subsystem id 107d:6606 - */ + gpio13 -- hef4052:A0 + 0x0000: external audio + 0x1000: FM + 0x2000: TV + 0x3000: n.c. + Note: There exists another variant "Winfast 2000" with tv stereo !? + Note: eeprom only contains FF and pci subsystem id 107d:6606 + */ .needs_tvaudio = 0, .pll = PLL_28, .has_radio = 1, - .tuner_type = 5, // default for now, gpio reads BFFF06 for Pal bg+dk + .tuner_type = 5, /* default for now, gpio reads BFFF06 for Pal bg+dk */ + .tuner_addr = ADDR_UNSET, .audio_hook = winfast2000_audio, .has_remote = 1, },{ @@ -789,6 +825,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x24 ---------------------------------- */ @@ -802,6 +839,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ .name = "Prolink PixelView PlayTV pro", @@ -815,6 +853,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH06X TView99", .video_inputs = 4, @@ -827,6 +866,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Pinnacle PCTV Studio/Rave", @@ -840,6 +880,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x28 ---------------------------------- */ @@ -854,6 +895,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -868,6 +910,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, .audio_hook = avermedia_tvphone_audio, },{ @@ -883,6 +926,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, },{ .name = "Little OnAir TV", .video_inputs = 3, @@ -894,6 +938,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc}, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x2c ---------------------------------- */ @@ -908,6 +953,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_NONE, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MATRIX-Vision MV-Delta 2", .video_inputs = 5, @@ -920,6 +966,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix Genie TV/FM", .video_inputs = 3, @@ -932,6 +979,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 21, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TV/Radio+", .video_inputs = 3, @@ -945,6 +993,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ @@ -960,6 +1009,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IODATA GV-BCTV3/PCI", .video_inputs = 3, @@ -972,6 +1022,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSHC6_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ .name = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP", @@ -986,6 +1037,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: (different from Rev.4C !) GPIO17: U4.A0 (first hef4052bt) @@ -994,8 +1046,8 @@ struct tvcard bttv_tvcards[] = { GPIO21: U4.nEN GPIO22: BT832 Reset Line GPIO23: A5,A0, U5,nEN - Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 - */ + Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 + */ },{ .name = "Eagle Wireless Capricorn2 (bt878A)", .video_inputs = 4, @@ -1007,6 +1059,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .pll = PLL_28, .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x34 ---------------------------------- */ @@ -1020,20 +1073,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1, 1}, .audiomux = { 1, 0xd0001, 0, 0, 10}, /* sound path (5 sources): - MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) + MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) 0= ext. Audio IN 1= from MUX2 2= Mono TV sound from Tuner 3= not connected - MUX2 (mask 0x30000): + MUX2 (mask 0x30000): 0,2,3= from MSP34xx 1= FM stereo Radio from Tuner */ .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Claas Langbehn , - Sven Grothklags */ + Sven Grothklags */ .name = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS", .video_inputs = 4, .audio_inputs = 3, @@ -1045,10 +1099,11 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ /* Tim Röstermundt - in de.comp.os.unix.linux.hardware: + in de.comp.os.unix.linux.hardware: options bttv card=0 pll=1 radio=1 gpiomask=0x18e0 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff options tuner type=5 */ @@ -1060,15 +1115,16 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x18e0, .muxsel = { 2, 3, 1, 1}, .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 }, - /* For cards with tda9820/tda9821: - 0x0000: Tuner normal stereo - 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) - 0x0880: Tuner A2 stereo */ + /* For cards with tda9820/tda9821: + 0x0000: Tuner normal stereo + 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) + 0x0880: Tuner A2 stereo */ .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Angel Alvarez - old Easy TV BT848 version (model CPH031) */ + old Easy TV BT848 version (model CPH031) */ .name = "Askey CPH031/ BESTBUY Easy TV", .video_inputs = 4, .audio_inputs = 1, @@ -1080,6 +1136,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x38 ---------------------------------- */ @@ -1094,10 +1151,11 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = 5, + .tuner_addr = ADDR_UNSET, },{ /* This is the ultimate cheapo capture card - * just a BT848A on a small PCB! - * Steve Hosgood */ + * just a BT848A on a small PCB! + * Steve Hosgood */ .name = "GrandTec 'Grand Video Capture' (Bt848)", .video_inputs = 2, .audio_inputs = 0, @@ -1110,19 +1168,21 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* Daniel Herrington */ - .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0xe00, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + /* Daniel Herrington */ + .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0xe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + .tuner_addr = ADDR_UNSET, },{ /* Matti Mottus */ .name = "Askey CPH03x TV Capturer", @@ -1130,11 +1190,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x03000F, + .gpiomask = 0x03000F, .muxsel = { 2, 3, 1, 0}, - .audiomux = { 2,0,0,0,1 }, + .audiomux = { 2,0,0,0,1 }, .pll = PLL_28, .tuner_type = 0, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x3c ---------------------------------- */ @@ -1149,7 +1210,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 1, 8}, .pll = PLL_35, .tuner_type = TUNER_TEMIC_PAL, - + .tuner_addr = ADDR_UNSET, },{ /* Adrian Cox - new Easy TV BT878 version (model CPH061) - special thanks to Informatica Mieres for providing the card */ + new Easy TV BT878 version (model CPH061) + special thanks to Informatica Mieres for providing the card */ .name = "Askey CPH061/ BESTBUY Easy TV (bt878)", .video_inputs = 3, .audio_inputs = 2, @@ -1179,6 +1241,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* Lukas Gebauer */ .name = "ATI TV-Wonder", @@ -1191,6 +1254,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe}, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x40 ---------------------------------- */ @@ -1206,6 +1270,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* DeeJay */ @@ -1251,25 +1318,27 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ /* ---- card 0x44 ---------------------------------- */ - .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", - // try "insmod msp3400 simple=0" if you have - // sound problems with this card. - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 0x4f8a00, - // 0x100000: 1=MSP enabled (0=disable again) - // 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) - .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, - // tvtuner, radio, external,internal, mute, stereo - /* tuner, Composit, SVid, Composit-on-Svid-adapter*/ - .muxsel = { 2, 3 ,0 ,1}, - .tuner_type = TUNER_MT2032, + .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", + /* try "insmod msp3400 simple=0" if you have + * sound problems with this card. */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 0x4f8a00, + /* 0x100000: 1=MSP enabled (0=disable again) + * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ + .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, + /* tvtuner, radio, external,internal, mute, stereo + * tuner, Composit, SVid, Composit-on-Svid-adapter */ + .muxsel = { 2, 3 ,0 ,1}, + .tuner_type = TUNER_MT2032, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -1279,22 +1348,24 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .muxsel = { 2 }, .gpiomask = 0 },{ - /* Tomasz Pyra */ - .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", - .video_inputs = 3, - .audio_inputs = 4, - .tuner = 0, - .svhs = 2, - .gpiomask = 15, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO ! - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = 25, + /* Tomasz Pyra */ + .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", + .video_inputs = 3, + .audio_inputs = 4, + .tuner = 0, + .svhs = 2, + .gpiomask = 15, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 0, 11, 7, 13, 0}, /* TV and Radio with same GPIO ! */ + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = 25, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: GPIO0: U4.A0 (hef4052bt) @@ -1302,16 +1373,18 @@ struct tvcard bttv_tvcards[] = { GPIO2: U4.A1 (second hef4052bt) GPIO3: U4.nEN, U5.A0, A5.nEN GPIO8-15: vrd866b ? - */ + */ },{ .name = "Lifeview FlyVideo 98EZ (capture only) LR51", .video_inputs = 4, .audio_inputs = 0, .tuner = -1, .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS + .muxsel = { 2, 3, 1, 1}, /* AV1, AV2, SVHS, CVid adapter on SVHS */ .pll = PLL_28, .no_msp34xx = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x48 ---------------------------------- */ @@ -1329,8 +1402,9 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .pll = PLL_28, .tuner_type = 5, - .audio_hook = pvbt878p9b_audio, // Note: not all cards have stereo - .has_radio = 1, // Note: not all cards have radio + .tuner_addr = ADDR_UNSET, + .audio_hook = pvbt878p9b_audio, /* Note: not all cards have stereo */ + .has_radio = 1, /* Note: not all cards have radio */ .has_remote = 1, /* GPIO wiring: GPIO0: A0 hef4052 @@ -1338,7 +1412,7 @@ struct tvcard bttv_tvcards[] = { GPIO3: nEN hef4052 GPIO8-15: vrd866b GPIO20,22,23: R30,R29,R28 - */ + */ },{ /* Clay Kunz */ /* you must jumper JP5 for the card to work */ @@ -1352,6 +1426,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Freitas */ .name = "RemoteVision MX (RV605)", @@ -1362,71 +1437,78 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x00, .gpiomask2 = 0x07ff, .muxsel = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03, - 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, + 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, .no_msp34xx = 1, .no_tda9875 = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = rv605_muxsel, },{ - .name = "Powercolor MTV878/ MTV878R/ MTV878F", - .video_inputs = 3, - .audio_inputs = 2, + .name = "Powercolor MTV878/ MTV878R/ MTV878F", + .video_inputs = 3, + .audio_inputs = 2, .tuner = 0, - .svhs = 2, - .gpiomask = 0x1C800F, // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset - .muxsel = { 2, 1, 1, }, - .audiomux = { 0, 1, 2, 2, 4 }, - .needs_tvaudio = 0, - .tuner_type = TUNER_PHILIPS_PAL, + .svhs = 2, + .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */ + .muxsel = { 2, 1, 1, }, + .audiomux = { 0, 1, 2, 2, 4 }, + .needs_tvaudio = 0, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ /* ---- card 0x4c ---------------------------------- */ - /* Masaki Suzuki */ - .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x140007, - .muxsel = { 2, 3, 1, 1 }, - .audiomux = { 0, 1, 2, 3, 4, 0 }, - .tuner_type = TUNER_PHILIPS_NTSC, - .audio_hook = windvr_audio, -},{ - .name = "GrandTec Multi Capture Card (Bt878)", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, -},{ - .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", - .video_inputs = 4, - .audio_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1 }, // Tuner, SVid, SVHS, SVid to SVHS connector - .audiomux = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio! - // This card lacks external Audio In, so we mute it on Ext. & Int. - // The PCB can take a sbx1637/sbx1673, wiring unknown. - // This card lacks PCI subsystem ID, sigh. - // audiomux=1: lower volume, 2+3: mute - // btwincap uses 0x80000/0x80003 - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and - // radio signal strength indicators work fine. - .has_radio = 1, + /* Masaki Suzuki */ + .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x140007, + .muxsel = { 2, 3, 1, 1 }, + .audiomux = { 0, 1, 2, 3, 4, 0 }, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .audio_hook = windvr_audio, +},{ + .name = "GrandTec Multi Capture Card (Bt878)", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, +},{ + .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", + .video_inputs = 4, + .audio_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */ + .audiomux = { 0 ,0 ,4, 4,4,4},/* Yes, this tuner uses the same audio output for TV and FM radio! + * This card lacks external Audio In, so we mute it on Ext. & Int. + * The PCB can take a sbx1637/sbx1673, wiring unknown. + * This card lacks PCI subsystem ID, sigh. + * audiomux=1: lower volume, 2+3: mute + * btwincap uses 0x80000/0x80003 + */ + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, + /* Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and + radio signal strength indicators work fine. */ + .has_radio = 1, /* GPIO Info: GPIO0,1: HEF4052 A0,A1 GPIO2: HEF4052 nENABLE @@ -1437,25 +1519,27 @@ struct tvcard bttv_tvcards[] = { GPIO22,23: ?? ?? : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/ },{ - /* Arthur Tetzlaff-Deas, DSP Design Ltd */ - .name = "DSP Design TCVIDEO", - .video_inputs = 4, - .svhs = -1, - .muxsel = { 2, 3, 1, 0}, - .pll = PLL_28, - .tuner_type = -1, + /* Arthur Tetzlaff-Deas, DSP Design Ltd */ + .name = "DSP Design TCVIDEO", + .video_inputs = 4, + .svhs = -1, + .muxsel = { 2, 3, 1, 0}, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* ---- card 0x50 ---------------------------------- */ + /* ---- card 0x50 ---------------------------------- */ .name = "Hauppauge WinTV PVR", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 0, 1, 1}, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 0, 1, 1}, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .gpiomask = 7, .audiomux = {7}, @@ -1471,6 +1555,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv5pci_audio, .has_radio = 1, },{ @@ -1482,9 +1567,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 2, 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */ .video_inputs = 3, @@ -1494,9 +1580,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x54 ---------------------------------- */ @@ -1508,9 +1595,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151", /* 0x1(4|5)-0004-C4 */ .video_inputs = 1, @@ -1520,9 +1608,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151 w/ svid", /* 0x(16|17|20)-00C4-C1 */ .video_inputs = 2, @@ -1532,9 +1621,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 200/201/250/251", /* 0x1(8|9|E|F)-0004-C4 */ .video_inputs = 1, @@ -1543,10 +1633,11 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .muxsel = { 0 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x58 ---------------------------------- */ @@ -1557,10 +1648,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 0, 1 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 210/220", /* 0x1(A|B)-04C0-C1 */ .video_inputs = 2, @@ -1569,10 +1661,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 500", /* 500 */ .video_inputs = 2, @@ -1582,19 +1675,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ - .name = "Osprey 540", /* 540 */ - .video_inputs = 4, - .audio_inputs = 1, - .tuner = -1, - .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .name = "Osprey 540", /* 540 */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = -1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x5C ---------------------------------- */ @@ -1605,10 +1700,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ },{ /* M G Berberich */ .name = "IDS Eagle", @@ -1616,6 +1712,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0, .muxsel = { 0, 1, 2, 3 }, @@ -1630,6 +1727,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, .no_tda7432 = 1, @@ -1641,38 +1739,40 @@ struct tvcard bttv_tvcards[] = { .no_gpioirq = 1, .has_dvb = 1, },{ - .name = "Formac ProTV II (bt878)", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 3, - .gpiomask = 2, - // TV, Comp1, Composite over SVID con, SVID - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 2, 2, 0, 0, 0 }, - .pll = PLL_28, + .name = "Formac ProTV II (bt878)", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 3, + .gpiomask = 2, + /* TV, Comp1, Composite over SVID con, SVID */ + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 2, 2, 0, 0, 0 }, + .pll = PLL_28, .has_radio = 1, - .tuner_type = TUNER_PHILIPS_PAL, - /* sound routing: - GPIO=0x00,0x01,0x03: mute (?) - 0x02: both TV and radio (tuner: FM1216/I) - The card has onboard audio connectors labeled "cdrom" and "board", - not soldered here, though unknown wiring. - Card lacks: external audio in, pci subsystem id. - */ + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, +/* sound routing: + GPIO=0x00,0x01,0x03: mute (?) + 0x02: both TV and radio (tuner: FM1216/I) + The card has onboard audio connectors labeled "cdrom" and "board", + not soldered here, though unknown wiring. + Card lacks: external audio in, pci subsystem id. +*/ },{ /* ---- card 0x60 ---------------------------------- */ .name = "MachTV", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 1, 2, 3, 4}, - .needs_tvaudio = 1, - .tuner_type = 5, + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 1, 2, 3, 4}, + .needs_tvaudio = 1, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, .pll = 1, },{ .name = "Euresys Picolo", @@ -1686,6 +1786,8 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .muxsel = { 2, 0, 1}, .pll = PLL_28, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Luc Van Hoeylandt */ .name = "ProVideo PV150", /* 0x4f */ @@ -1699,7 +1801,8 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .no_msp34xx = 1, .pll = PLL_28, - .tuner_type = -1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Hiroshi Takekawa */ /* This card lacks subsystem ID */ @@ -1716,78 +1819,85 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 2, + .tuner_addr = ADDR_UNSET, .audio_hook = adtvk503_audio, },{ /* ---- card 0x64 ---------------------------------- */ - .name = "Hercules Smart TV Stereo", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x00, - .muxsel = { 2, 3, 1, 1 }, - .needs_tvaudio = 1, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, + .name = "Hercules Smart TV Stereo", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x00, + .muxsel = { 2, 3, 1, 1 }, + .needs_tvaudio = 1, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, /* Notes: - - card lacks subsystem ID - - stereo variant w/ daughter board with tda9874a @0xb0 - - Audio Routing: + - card lacks subsystem ID + - stereo variant w/ daughter board with tda9874a @0xb0 + - Audio Routing: always from tda9874 independent of GPIO (?) external line in: unknown - - Other chips: em78p156elp @ 0x96 (probably IR remote control) - hef4053 (instead 4052) for unknown function + - Other chips: em78p156elp @ 0x96 (probably IR remote control) + hef4053 (instead 4052) for unknown function */ },{ - .name = "Pace TV & Radio Card", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector - .gpiomask = 0, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = 1, - .has_radio = 1, - .pll = PLL_28, - /* Bt878, Bt832, FI1246 tuner; no pci subsystem id - only internal line out: (4pin header) RGGL - Radio must be decoded by msp3410d (not routed through)*/ - // .digital_mode = DIGITAL_MODE_CAMERA, // todo! -},{ - /* Chris Willing */ - .name = "IVC-200", - .video_inputs = 1, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2 }, - .pll = PLL_28, + .name = "Pace TV & Radio Card", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 1}, /* Tuner, CVid, SVid, CVid over SVid connector */ + .gpiomask = 0, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = 1, + .tuner_addr = ADDR_UNSET, + .has_radio = 1, + .pll = PLL_28, + /* Bt878, Bt832, FI1246 tuner; no pci subsystem id + only internal line out: (4pin header) RGGL + Radio must be decoded by msp3410d (not routed through)*/ + /* + .digital_mode = DIGITAL_MODE_CAMERA, todo! + */ +},{ + /* Chris Willing */ + .name = "IVC-200", + .video_inputs = 1, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2 }, + .pll = PLL_28, },{ .name = "Grand X-Guard / Trust 814PCI", .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, .tuner_type = 4, - .gpiomask2 = 0xff, + .tuner_addr = ADDR_UNSET, + .gpiomask2 = 0xff, .muxsel = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 }, .muxsel_hook = xguard_muxsel, .no_msp34xx = 1, .no_tda9875 = 1, - .no_tda7432 = 1, + .no_tda7432 = 1, .pll = PLL_28, },{ /* ---- card 0x68 ---------------------------------- */ .name = "Nebula Electronics DigiTV", .video_inputs = 1, - .tuner = -1, + .tuner = -1, .svhs = -1, .muxsel = { 2, 3, 1, 0}, .no_msp34xx = 1, @@ -1795,22 +1905,24 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, },{ /* Jorge Boncompte - DTI2 */ .name = "ProVideo PV143", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* M.Klahr@phytec.de */ .name = "PHYTEC VD-009-X1 MiniDIN (bt878)", @@ -1824,6 +1936,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009-X1 Combi (bt878)", .video_inputs = 4, @@ -1836,6 +1949,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x6c ---------------------------------- */ @@ -1846,13 +1960,14 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009 Combi (bt878)", .video_inputs = 10, @@ -1861,23 +1976,25 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - .name = "IVC-100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2, 3, 1, 0 }, - .pll = PLL_28, + .name = "IVC-100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2, 3, 1, 0 }, + .pll = PLL_28, },{ /* IVC-120G - Alan Garfield */ .name = "IVC-120G", @@ -1885,6 +2002,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, /* card has no audio */ .tuner = -1, /* card has no tuner */ .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* card has no svhs */ .needs_tvaudio = 0, .no_msp34xx = 1, @@ -1892,7 +2010,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .gpiomask = 0x00, .muxsel = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, .muxsel_hook = ivc120_muxsel, .pll = PLL_28, },{ @@ -1905,6 +2023,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = TUNER_PHILIPS_ATSC, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, },{ .name = "Twinhan DST + clones", @@ -1912,19 +2031,21 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .no_tda7432 = 1, .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .no_video = 1, .has_dvb = 1, },{ - .name = "Winfast VC100", + .name = "Winfast VC100", .video_inputs = 3, .audio_inputs = 0, .svhs = 1, - .tuner = -1, // no tuner - .muxsel = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = TUNER_ABSENT, + .tuner = -1, + .muxsel = { 3, 1, 1, 3}, /* Vid In, SVid In, Vid over SVid in connector */ + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, },{ .name = "Teppro TEV-560/InterVision IV-560", @@ -1937,44 +2058,49 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 1, 1, 1, 0}, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_35, },{ /* ---- card 0x74 ---------------------------------- */ - .name = "SIMUS GVC1100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .tuner_type = -1, - .pll = PLL_28, - .muxsel = { 2, 2, 2, 2}, - .gpiomask = 0x3F, + .name = "SIMUS GVC1100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, + .muxsel = { 2, 2, 2, 2}, + .gpiomask = 0x3F, .muxsel_hook = gvc1100_muxsel, },{ - /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ - .name = "NGS NGSTV+", - .video_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x008007, - .muxsel = {2, 3, 0, 0}, - .audiomux = {0, 0, 0, 0, 0x000003, 0}, - .pll = PLL_28, - .tuner_type = TUNER_PHILIPS_PAL, - .has_remote = 1, -},{ - /* http://linuxmedialabs.com */ - .name = "LMLBT4", - .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 3, 1, 0 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .needs_tvaudio = 0, + /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ + .name = "NGS NGSTV+", + .video_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x008007, + .muxsel = {2, 3, 0, 0}, + .audiomux = {0, 0, 0, 0, 0x000003, 0}, + .pll = PLL_28, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, + .has_remote = 1, +},{ + /* http://linuxmedialabs.com */ + .name = "LMLBT4", + .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 3, 1, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .needs_tvaudio = 0, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Helmroos Harri */ .name = "Tekram M205 PRO", @@ -1982,6 +2108,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .svhs = 2, .needs_tvaudio = 0, .gpiomask = 0x68, @@ -2004,6 +2131,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, .has_radio = 1, },{ @@ -2026,6 +2154,8 @@ struct tvcard bttv_tvcards[] = { .pll = PLL_28, .needs_tvaudio = 0, .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/ + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Spirit TV Tuner from http://spiritmodems.com.au */ /* Stafford Goodsell */ @@ -2038,23 +2168,25 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 1, 1 }, .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00}, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, },{ /* Wolfram Joost */ - .name = "AVerMedia AVerTV DVB-T 771", - .video_inputs = 2, - .svhs = 1, - .tuner = -1, - .tuner_type = TUNER_ABSENT, - .muxsel = { 3 , 3 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .pll = PLL_28, - .has_dvb = 1, - .no_gpioirq = 1, - .has_remote = 1, + .name = "AVerMedia AVerTV DVB-T 771", + .video_inputs = 2, + .svhs = 1, + .tuner = -1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, + .muxsel = { 3 , 3 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .pll = PLL_28, + .has_dvb = 1, + .no_gpioirq = 1, + .has_remote = 1, },{ /* ---- card 0x7c ---------------------------------- */ /* Matt Jesson */ @@ -2069,6 +2201,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, .has_remote = 1, @@ -2081,12 +2214,13 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 0x0, .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3 }, + 3, 3, 3, 3, 3, 3, 3, 3 }, .muxsel_hook = sigmaSQ_muxsel, .audiomux = { 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* andre.schwarz@matrix-vision.de */ .name = "MATRIX Vision Sigma-SLC", @@ -2101,6 +2235,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* BTTV_APAC_VIEWCOMP */ /* Attila Kondoros */ @@ -2116,6 +2251,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* miniremote works, see ir-kbd-gpio.c */ .has_radio = 1, /* not every card has radio */ },{ @@ -2131,6 +2267,7 @@ struct tvcard bttv_tvcards[] = { .no_video = 1, .has_dvb = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Steven */ .name = "V-Gear MyVCD", @@ -2144,62 +2281,65 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .has_radio = 0, - // .has_remote = 1, },{ /* Rick C */ - .name = "Super TV Tuner", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = TUNER_PHILIPS_NTSC, - .gpiomask = 0x008007, - .audiomux = { 0, 0x000001,0,0, 0}, - .needs_tvaudio = 1, - .has_radio = 1, -},{ - /* Chris Fanning */ - .name = "Tibet Systems 'Progress DVR' CS16", - .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, - .pll = PLL_28, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = -1, - .muxsel_hook = tibetCS16_muxsel, + .name = "Super TV Tuner", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .gpiomask = 0x008007, + .audiomux = { 0, 0x000001,0,0, 0}, + .needs_tvaudio = 1, + .has_radio = 1, +},{ + /* Chris Fanning */ + .name = "Tibet Systems 'Progress DVR' CS16", + .video_inputs = 16, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + .pll = PLL_28, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .muxsel_hook = tibetCS16_muxsel, }, { /* Bill Brack */ /* - * Note that, because of the card's wiring, the "master" - * BT878A chip (i.e. the one which controls the analog switch - * and must use this card type) is the 2nd one detected. The - * other 3 chips should use card type 0x85, whose description - * follows this one. There is a EEPROM on the card (which is - * connected to the I2C of one of those other chips), but is - * not currently handled. There is also a facility for a - * "monitor", which is also not currently implemented. - */ - .name = "Kodicom 4400R (master)", + * Note that, because of the card's wiring, the "master" + * BT878A chip (i.e. the one which controls the analog switch + * and must use this card type) is the 2nd one detected. The + * other 3 chips should use card type 0x85, whose description + * follows this one. There is a EEPROM on the card (which is + * connected to the I2C of one of those other chips), but is + * not currently handled. There is also a facility for a + * "monitor", which is also not currently implemented. + */ + .name = "Kodicom 4400R (master)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* GPIO bits 0-9 used for analog switch: - * 00 - 03: camera selector - * 04 - 06: channel (controller) selector - * 07: data (1->on, 0->off) - * 08: strobe - * 09: reset - * bit 16 is input from sync separator for the channel - */ + * 00 - 03: camera selector + * 04 - 06: channel (controller) selector + * 07: data (1->on, 0->off) + * 08: strobe + * 09: reset + * bit 16 is input from sync separator for the channel + */ .gpiomask = 0x0003ff, .no_gpioirq = 1, .muxsel = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, @@ -2212,15 +2352,16 @@ struct tvcard bttv_tvcards[] = { { /* Bill Brack */ /* Note that, for reasons unknown, the "master" BT878A chip (i.e. the - * one which controls the analog switch, and must use the card type) - * is the 2nd one detected. The other 3 chips should use this card - * type - */ + * one which controls the analog switch, and must use the card type) + * is the 2nd one detected. The other 3 chips should use this card + * type + */ .name = "Kodicom 4400R (slave)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0x010000, .no_gpioirq = 1, @@ -2232,18 +2373,51 @@ struct tvcard bttv_tvcards[] = { .muxsel_hook = kodicom4400r_muxsel, }, { - /* ---- card 0x85---------------------------------- */ - /* Michael Henson */ - /* Adlink RTV24 with special unlock codes */ - .name = "Adlink RTV24", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = -1, - .pll = PLL_28, - + /* ---- card 0x86---------------------------------- */ + /* Michael Henson */ + /* Adlink RTV24 with special unlock codes */ + .name = "Adlink RTV24", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, +}, +{ + /* ---- card 0x87---------------------------------- */ + /* Michael Krufky */ + .name = "DVICO FusionHDTV 5 Lite", + .tuner = 0, + .tuner_type = TUNER_LG_TDVS_H062F, + .tuner_addr = ADDR_UNSET, + .video_inputs = 2, + .audio_inputs = 1, + .svhs = 2, + .muxsel = { 2, 3 }, + .gpiomask = 0x00e00007, + .audiomux = { 0x00400005, 0, 0, 0, 0, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, +},{ + /* ---- card 0x88---------------------------------- */ + /* Mauro Carvalho Chehab */ + .name = "Acorp Y878F", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x01fe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_YMEC_TVF66T5_B_DFF, + .tuner_addr = 0xc1 >>1, + .has_radio = 1, }}; static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); @@ -2355,32 +2529,32 @@ static void flyvideo_gpio(struct bttv *btv) int tuner=-1,ttype; gpio_inout(0xffffff, 0); - udelay(8); // without this we would see the 0x1800 mask + udelay(8); /* without this we would see the 0x1800 mask */ gpio = gpio_read(); /* FIXME: must restore OUR_EN ??? */ - // all cards provide GPIO info, some have an additional eeprom - // LR50: GPIO coding can be found lower right CP1 .. CP9 - // CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. - // GPIO14-12: n.c. - // LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) - - // lowest 3 bytes are remote control codes (no handshake needed) - // xxxFFF: No remote control chip soldered - // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered - // Note: Some bits are Audio_Mask ! + /* all cards provide GPIO info, some have an additional eeprom + * LR50: GPIO coding can be found lower right CP1 .. CP9 + * CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. + * GPIO14-12: n.c. + * LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) + * lowest 3 bytes are remote control codes (no handshake needed) + * xxxFFF: No remote control chip soldered + * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered + * Note: Some bits are Audio_Mask ! + */ ttype=(gpio&0x0f0000)>>16; switch(ttype) { - case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P + case 0x0: tuner=2; /* NTSC, e.g. TPI8NSR11P */ break; - case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P + case 0x2: tuner=39;/* LG NTSC (newer TAPC series) TAPC-H701P */ break; - case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 + case 0x4: tuner=5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ break; - case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P + case 0x6: tuner=37;/* LG PAL (newer TAPC series) TAPC-G702P */ break; - case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF + case 0xC: tuner=3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ break; default: printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr); @@ -2388,15 +2562,16 @@ static void flyvideo_gpio(struct bttv *btv) has_remote = gpio & 0x800000; has_radio = gpio & 0x400000; - // unknown 0x200000; - // unknown2 0x100000; - is_capture_only = !(gpio & 0x008000); //GPIO15 + /* unknown 0x200000; + * unknown2 0x100000; */ + is_capture_only = !(gpio & 0x008000); /* GPIO15 */ has_tda9820_tda9821 = !(gpio & 0x004000); - is_lr90 = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only) - // gpio & 0x001000 // output bit for audio routing + is_lr90 = !(gpio & 0x002000); /* else LR26/LR50 (LR38/LR51 f. capture only) */ + /* + * gpio & 0x001000 output bit for audio routing */ if(is_capture_only) - tuner=4; // No tuner present + tuner=4; /* No tuner present */ printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); @@ -2404,15 +2579,15 @@ static void flyvideo_gpio(struct bttv *btv) btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", is_capture_only?"yes":"no "); - if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through + if(tuner!= -1) /* only set if known tuner autodetected, else let insmod option through */ btv->tuner_type = tuner; btv->has_radio = has_radio; - // LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 - // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 - // Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute + /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 + * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 + * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio; - //todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; + /* todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; */ } static int miro_tunermap[] = { 0,6,2,3, 4,5,6,0, 3,0,4,5, 5,2,16,1, @@ -2633,6 +2808,8 @@ void __devinit bttv_init_card1(struct bttv *btv) void __devinit bttv_init_card2(struct bttv *btv) { int tda9887; + int addr=ADDR_UNSET; + btv->tuner_type = -1; if (BTTV_UNKNOWN == btv->c.type) { @@ -2773,9 +2950,12 @@ void __devinit bttv_init_card2(struct bttv *btv) btv->pll.pll_current = -1; /* tuner configuration (from card list / autodetect / insmod option) */ - if (UNSET != bttv_tvcards[btv->c.type].tuner_type) + if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr) + addr = bttv_tvcards[btv->c.type].tuner_addr; + + if (UNSET != bttv_tvcards[btv->c.type].tuner_type) if(UNSET == btv->tuner_type) - btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; + btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; if (UNSET != tuner[btv->c.nr]) btv->tuner_type = tuner[btv->c.nr]; printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type); @@ -2787,7 +2967,7 @@ void __devinit bttv_init_card2(struct bttv *btv) tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; tun_setup.type = btv->tuner_type; - tun_setup.addr = ADDR_UNSET; + tun_setup.addr = addr; bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); } @@ -2902,7 +3082,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv) btv->mbox_csel = 1 << 10; freq=88000/62.5; - tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8 + tea5757_write(btv, 5 * freq + 0x358); /* write 0x1ed8 */ if (0x1ed8 == tea5757_read(btv)) { printk("bttv%d: Terratec Active Radio Upgrade found.\n", btv->c.nr); @@ -3073,7 +3253,7 @@ static void __devinit osprey_eeprom(struct bttv *btv) case 0x0060: case 0x0070: btv->c.type = BTTV_OSPREY2x0; - //enable output on select control lines + /* enable output on select control lines */ gpio_inout(0xffffff,0x000303); break; default: @@ -3105,7 +3285,7 @@ static int tuner_1_table[] = { TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, - TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM + TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, /* TUNER_TEMIC_SECAM */ TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL}; static void __devinit avermedia_eeprom(struct bttv *btv) @@ -3126,7 +3306,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) if (tuner_make == 4) if(tuner_format == 0x09) - tuner = TUNER_LG_NTSC_NEW_TAPC; // TAPC-G702P + tuner = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=", btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]); @@ -3143,7 +3323,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */ void bttv_tda9880_setnorm(struct bttv *btv, int norm) { - // fix up our card entry + /* fix up our card entry */ if(norm==VIDEO_MODE_NTSC) { bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff; bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff; @@ -3154,7 +3334,7 @@ void bttv_tda9880_setnorm(struct bttv *btv, int norm) bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff; dprintk("bttv_tda9880_setnorm to PAL\n"); } - // set GPIO according + /* set GPIO according */ gpio_bits(bttv_tvcards[btv->c.type].gpiomask, bttv_tvcards[btv->c.type].audiomux[btv->audio]); } @@ -3447,7 +3627,7 @@ static int tea5757_read(struct bttv *btv) udelay(10); timeout= jiffies + HZ; - // wait for DATA line to go low; error if it doesn't + /* wait for DATA line to go low; error if it doesn't */ while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout)) schedule(); if (bus_in(btv,btv->mbox_data)) { @@ -3574,8 +3754,8 @@ gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set) con = 0x300; if (v->mode & VIDEO_SOUND_STEREO) con = 0x200; -// if (v->mode & VIDEO_SOUND_MONO) -// con = 0x100; +/* if (v->mode & VIDEO_SOUND_MONO) + * con = 0x100; */ gpio_bits(0x300, con); } else { v->mode = VIDEO_SOUND_STEREO | @@ -3718,7 +3898,7 @@ lt9415_audio(struct bttv *btv, struct video_audio *v, int set) } } -// TDA9821 on TerraTV+ Bt848, Bt878 +/* TDA9821 on TerraTV+ Bt848, Bt878 */ static void terratv_audio(struct bttv *btv, struct video_audio *v, int set) { @@ -3818,7 +3998,7 @@ fv2000s_audio(struct bttv *btv, struct video_audio *v, int set) } if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) || (v->mode & VIDEO_SOUND_STEREO)) { - val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ... + val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ } if (val != 0xffff) { gpio_bits(0x1800, val); @@ -3869,10 +4049,10 @@ adtvk503_audio(struct bttv *btv, struct video_audio *v, int set) { unsigned int con = 0xffffff; - //btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); + /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ if (set) { - //btor(***, BT848_GPIO_OUT_EN); + /* btor(***, BT848_GPIO_OUT_EN); */ if (v->mode & VIDEO_SOUND_LANG1) con = 0x00000000; if (v->mode & VIDEO_SOUND_LANG2) @@ -4079,14 +4259,14 @@ static void kodicom4400r_init(struct bttv *btv) master[btv->c.nr+2] = btv; } -// The Grandtec X-Guard framegrabber card uses two Dual 4-channel -// video multiplexers to provide up to 16 video inputs. These -// multiplexers are controlled by the lower 8 GPIO pins of the -// bt878. The multiplexers probably Pericom PI5V331Q or similar. - -// xxx0 is pin xxx of multiplexer U5, -// yyy1 is pin yyy of multiplexer U2 +/* The Grandtec X-Guard framegrabber card uses two Dual 4-channel + * video multiplexers to provide up to 16 video inputs. These + * multiplexers are controlled by the lower 8 GPIO pins of the + * bt878. The multiplexers probably Pericom PI5V331Q or similar. + * xxx0 is pin xxx of multiplexer U5, + * yyy1 is pin yyy of multiplexer U2 + */ #define ENA0 0x01 #define ENB0 0x02 #define ENA1 0x04 @@ -4157,14 +4337,14 @@ static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) static void ivc120_muxsel(struct bttv *btv, unsigned int input) { - // Simple maths + /* Simple maths */ int key = input % 4; int matrix = input / 4; dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n", btv->c.nr, input, matrix, key); - // Handles the input selection on the TDA8540's + /* Handles the input selection on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00, ((matrix == 3) ? (key | key << 2) : 0x00), 1); bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00, @@ -4174,17 +4354,17 @@ static void ivc120_muxsel(struct bttv *btv, unsigned int input) bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00, ((matrix == 2) ? (key | key << 2) : 0x00), 1); - // Handles the output enables on the TDA8540's + /* Handles the output enables on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02, - ((matrix == 3) ? 0x03 : 0x00), 1); // 13 - 16 + ((matrix == 3) ? 0x03 : 0x00), 1); /* 13 - 16 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02, - ((matrix == 0) ? 0x03 : 0x00), 1); // 1-4 + ((matrix == 0) ? 0x03 : 0x00), 1); /* 1-4 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02, - ((matrix == 1) ? 0x03 : 0x00), 1); // 5-8 + ((matrix == 1) ? 0x03 : 0x00), 1); /* 5-8 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02, - ((matrix == 2) ? 0x03 : 0x00), 1); // 9-12 + ((matrix == 2) ? 0x03 : 0x00), 1); /* 9-12 */ - // Selects MUX0 for input on the 878 + /* Selects MUX0 for input on the 878 */ btaor((0)<<5, ~(3<<5), BT848_IFORM); } @@ -4305,7 +4485,6 @@ void __devinit bttv_check_chipset(void) } if (UNSET != latency) printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency); - while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, dev))) { unsigned char b; diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 087efb4dea0..53ecdbf4622 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -1,5 +1,4 @@ /* - $Id: bttv-driver.c,v 1.52 2005/08/04 00:55:16 mchehab Exp $ bttv - Bt848 frame grabber driver @@ -42,6 +41,9 @@ #include "bttvp.h" +#include "rds.h" + + unsigned int bttv_num; /* number of Bt848s in use */ struct bttv bttvs[BTTV_MAX]; @@ -3128,15 +3130,12 @@ static int radio_open(struct inode *inode, struct file *file) dprintk("bttv%d: open called (radio)\n",btv->c.nr); down(&btv->lock); - if (btv->radio_user) { - up(&btv->lock); - return -EBUSY; - } + btv->radio_user++; + file->private_data = btv; - i2c_vidiocschan(btv); - bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); + bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); audio_mux(btv,AUDIO_RADIO); up(&btv->lock); @@ -3145,9 +3144,13 @@ static int radio_open(struct inode *inode, struct file *file) static int radio_release(struct inode *inode, struct file *file) { - struct bttv *btv = file->private_data; + struct bttv *btv = file->private_data; + struct rds_command cmd; btv->radio_user--; + + bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); + return 0; } @@ -3203,13 +3206,42 @@ static int radio_ioctl(struct inode *inode, struct file *file, return video_usercopy(inode, file, cmd, arg, radio_do_ioctl); } +static ssize_t radio_read(struct file *file, char __user *data, + size_t count, loff_t *ppos) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.block_count = count/3; + cmd.buffer = data; + cmd.instance = file; + cmd.result = -ENODEV; + + bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); + + return cmd.result; +} + +static unsigned int radio_poll(struct file *file, poll_table *wait) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.instance = file; + cmd.event_list = wait; + cmd.result = -ENODEV; + bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); + + return cmd.result; +} + static struct file_operations radio_fops = { .owner = THIS_MODULE, .open = radio_open, + .read = radio_read, .release = radio_release, .ioctl = radio_ioctl, .llseek = no_llseek, + .poll = radio_poll, }; static struct video_device radio_template = diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c index 77320cdf205..6b280c03e39 100644 --- a/drivers/media/video/bttv-gpio.c +++ b/drivers/media/video/bttv-gpio.c @@ -1,5 +1,4 @@ /* - $Id: bttv-gpio.c,v 1.7 2005/02/16 12:14:10 kraxel Exp $ bttv-gpio.c -- gpio sub drivers diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 706dc48df96..e684df37eb0 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -1,5 +1,4 @@ /* - $Id: bttv-i2c.c,v 1.25 2005/07/05 17:37:35 nsh Exp $ bttv-i2c.c -- all the i2c code is here @@ -381,6 +380,7 @@ void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) } static char *i2c_devs[128] = { + [ 0x1c >> 1 ] = "lgdt330x", [ 0x30 >> 1 ] = "IR (hauppauge)", [ 0x80 >> 1 ] = "msp34xx", [ 0x86 >> 1 ] = "tda9887", diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index f7b5543a96a..e8aada772b8 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -1,5 +1,4 @@ /* - $Id: bttv-if.c,v 1.4 2004/11/17 18:47:47 kraxel Exp $ bttv-if.c -- old gpio interface to other kernel modules don't use in new code, will go away in 2.7 diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c index 9ed21fd190c..a5ed99b8944 100644 --- a/drivers/media/video/bttv-risc.c +++ b/drivers/media/video/bttv-risc.c @@ -1,5 +1,4 @@ /* - $Id: bttv-risc.c,v 1.10 2004/11/19 18:07:12 kraxel Exp $ bttv-risc.c -- interfaces to other kernel modules diff --git a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c index 06f3e62b3e8..f4f58c60f15 100644 --- a/drivers/media/video/bttv-vbi.c +++ b/drivers/media/video/bttv-vbi.c @@ -1,5 +1,4 @@ /* - $Id: bttv-vbi.c,v 1.9 2005/01/13 17:22:33 kraxel Exp $ bttv - Bt848 frame grabber driver vbi interface diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h index f2af9e1454f..d254e90e3bb 100644 --- a/drivers/media/video/bttv.h +++ b/drivers/media/video/bttv.h @@ -1,5 +1,4 @@ /* - * $Id: bttv.h,v 1.22 2005/07/28 18:41:21 mchehab Exp $ * * bttv - Bt848 frame grabber driver * @@ -218,6 +217,8 @@ struct tvcard #define PLL_35 2 unsigned int tuner_type; + unsigned int tuner_addr; + unsigned int has_radio; void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); void (*muxsel_hook)(struct bttv *btv, unsigned int input); diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index aab094bc243..a0eb0ce1aa9 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h @@ -1,5 +1,4 @@ /* - $Id: bttvp.h,v 1.21 2005/07/15 21:44:14 mchehab Exp $ bttv - Bt848 frame grabber driver @@ -26,7 +25,7 @@ #ifndef _BTTVP_H_ #define _BTTVP_H_ -#include +#include #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,16) #include -- cgit v1.2.3 From e52e98a7eccfb0e7e91630d01690fb11d77db77d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:41 -0700 Subject: [PATCH] v4l: CX88 updates and card additions - Remove $Id CVS logs for V4L files - add ioctl indirection via cx88_ioctl_hook and cx88_ioctl_translator to cx88-blackbird.c. - declare the indirection hooks from cx88-blackbird.c. - dcprintk macro which uses core instead of dev->core on cx88-video.c. - replace dev->core occurances with core on cx88-video.c. - CodingStyle fixes. - MaxInput replaced by a define. - cx8801 structures moved from cx88.h. - The output_mode needs to be set for the Hauppauge Nova-T DVB-T for versions after 2.6.12. - Corrected GPIO values for cx88 cards #28 & #31 for s-video and composite. - Updated DViCO FusionHDTV5 Gold & added DVB support. - Fixed DViCO FusionHDTV 3 Gold-Q GPIO. - Some clean up in cx88-tvaudio.c - replaced hex values when writing to AUD_CTL to EN_xx for better reading. - Allow select by hand between Mono, Lang1, Lang2 and Stereo for BTSC. - Support for stereo NICAM and BTSC improved. - Broken stereo check removed. - Added support for remote control to Cinergy DVBT-1400. - local var renamed from rc5 to a better name (ircode). - LGDT330X QAM lock bug fixes. - Some reorg: move some bits to struct cx88_core, factor out common ioctl's to cx88_do_ioctl. - Get rid of '//' comments, replace them with #if 0 and /**/. - Minor clean-ups: remove dcprintk and replace all instances of "dev->core" with "core". - Added some registers to control PCI controller at CX2388x chips. - New tuner standby API. - Small mpeg fixes and cleanups for blackbird. - fix mpeg packet size & count - add VIDIOC_QUERYCAP ioctl for the mpeg stream - return more information in struct v4l2_format - fix default window height - small cleanups Signed-off-by: Uli Luckas Signed-off-by: Torsten Seeboth Signed-off-by: Nickolay V. Shmyrev Signed-off-by: Michael Krufky Signed-off-by: Patrick Boettcher Signed-off-by: Catalin Climov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/cx88/cx88-blackbird.c | 73 ++- drivers/media/video/cx88/cx88-cards.c | 24 +- drivers/media/video/cx88/cx88-core.c | 21 +- drivers/media/video/cx88/cx88-dvb.c | 47 +- drivers/media/video/cx88/cx88-i2c.c | 1 - drivers/media/video/cx88/cx88-input.c | 96 +++- drivers/media/video/cx88/cx88-mpeg.c | 17 +- drivers/media/video/cx88/cx88-reg.h | 24 +- drivers/media/video/cx88/cx88-tvaudio.c | 742 ++++++++++++++++-------------- drivers/media/video/cx88/cx88-vbi.c | 1 - drivers/media/video/cx88/cx88-video.c | 388 +++++++++------- drivers/media/video/cx88/cx88.h | 39 +- 12 files changed, 874 insertions(+), 599 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 4f39688f780..0c0c59e9477 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-blackbird.c,v 1.27 2005/06/03 13:31:50 mchehab Exp $ * * Support for a cx23416 mpeg encoder via cx2388x host port. * "blackbird" reference design. @@ -62,7 +61,6 @@ static LIST_HEAD(cx8802_devlist); #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF /* Firmware API commands */ -/* #define IVTV_API_STD_TIMEOUT 0x00010000 // 65536, units?? */ #define IVTV_API_STD_TIMEOUT 500 #define BLACKBIRD_API_PING 0x80 @@ -696,7 +694,6 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) /* assign stream type */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); - /* blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_TRANSPORT); */ /* assign output port */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */ @@ -824,7 +821,8 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); /* initialize the video input */ + /* initialize the video input */ + blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); msleep(1); @@ -833,11 +831,12 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) blackbird_api_cmd(dev, BLACKBIRD_API_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE); msleep(1); - /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); // start capturing to the host interface */ + /* start capturing to the host interface */ + /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); */ blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE - ); /* start capturing to the host interface */ + ); msleep(10); blackbird_api_cmd(dev, BLACKBIRD_API_REFRESH_INPUT, 0,0); @@ -851,8 +850,8 @@ static int bb_buf_setup(struct videobuf_queue *q, { struct cx8802_fh *fh = q->priv_data; - fh->dev->ts_packet_size = 512; - fh->dev->ts_packet_count = 100; + fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ + fh->dev->ts_packet_count = 32; /* was: 100 */ *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; if (0 == *count) @@ -900,12 +899,36 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, { struct cx8802_fh *fh = file->private_data; struct cx8802_dev *dev = fh->dev; + struct cx88_core *core = dev->core; if (debug > 1) - cx88_print_ioctl(dev->core->name,cmd); + cx88_print_ioctl(core->name,cmd); switch (cmd) { + /* --- capabilities ------------------------------------------ */ + case VIDIOC_QUERYCAP: + { + struct v4l2_capability *cap = arg; + + memset(cap,0,sizeof(*cap)); + strcpy(cap->driver, "cx88_blackbird"); + strlcpy(cap->card, cx88_boards[core->board].name,sizeof(cap->card)); + sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); + cap->version = CX88_VERSION_CODE; + cap->capabilities = + V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_READWRITE | + V4L2_CAP_STREAMING | + V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | + 0; + if (UNSET != core->tuner_type) + cap->capabilities |= V4L2_CAP_TUNER; + + return 0; + } + /* --- capture ioctls ---------------------------------------- */ case VIDIOC_ENUM_FMT: { @@ -935,7 +958,11 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; - f->fmt.pix.sizeimage = 1024 * 512 /* FIXME: BUFFER_SIZE */; + f->fmt.pix.field = V4L2_FIELD_NONE; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.sizeimage = 188 * 4 * 1024; /* 1024 * 512 */ /* FIXME: BUFFER_SIZE */; + f->fmt.pix.colorspace = 0; + return 0; } /* --- streaming capture ------------------------------------- */ @@ -959,15 +986,25 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, return videobuf_streamoff(&fh->mpegq); default: - return -EINVAL; + return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook ); } return 0; } +int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + +static unsigned int mpeg_translate_ioctl(unsigned int cmd) +{ + return cmd; +} + static int mpeg_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); + cmd = cx88_ioctl_translator( cmd ); + return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook); } static int mpeg_open(struct inode *inode, struct file *file) @@ -1135,7 +1172,7 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, dev->pci = pci_dev; dev->core = core; dev->width = 720; - dev->height = 480; + dev->height = 576; err = cx8802_init_common(dev); if (0 != err) @@ -1148,6 +1185,9 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, list_add_tail(&dev->devlist,&cx8802_devlist); blackbird_register_video(dev); + + /* initial device configuration: needed ? */ + return 0; fail_free: @@ -1202,6 +1242,8 @@ static int blackbird_init(void) printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); #endif + cx88_ioctl_hook = mpeg_do_ioctl; + cx88_ioctl_translator = mpeg_translate_ioctl; return pci_register_driver(&blackbird_pci_driver); } @@ -1213,6 +1255,9 @@ static void blackbird_fini(void) module_init(blackbird_init); module_exit(blackbird_fini); +EXPORT_SYMBOL(cx88_ioctl_hook); +EXPORT_SYMBOL(cx88_ioctl_translator); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index ebf02a7f81e..92623231db7 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-cards.c,v 1.90 2005/07/28 02:47:42 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * card-specific stuff. @@ -499,9 +498,6 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, - },{ - .type = CX88_VMUX_SVIDEO, - .vmux = 2, }}, .dvb = 1, }, @@ -614,12 +610,12 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0xed12, // internal decoder + .gpio0 = 0xed12, /* internal decoder */ .gpio2 = 0x00ff, },{ .type = CX88_VMUX_DEBUG, .vmux = 0, - .gpio0 = 0xff01, // mono from tuner chip + .gpio0 = 0xff01, /* mono from tuner chip */ },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -715,19 +711,18 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x97ed, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, }}, .dvb = 1, }, @@ -765,20 +760,21 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ + .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x87fd, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, }}, + .dvb = 1, }, }; const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 5e868f5cd0c..dc5c5c1f346 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * driver core @@ -876,7 +875,7 @@ static int set_tvaudio(struct cx88_core *core) cx_andor(MO_AFECFG_IO, 0x1f, 0x0); cx88_set_tvaudio(core); - // cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); + /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ @@ -1087,10 +1086,17 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->pci_bus = pci->bus->number; core->pci_slot = PCI_SLOT(pci->devfn); core->pci_irqmask = 0x00fc00; + init_MUTEX(&core->lock); core->nr = cx88_devcount++; sprintf(core->name,"cx88[%d]",core->nr); if (0 != get_ressources(core,pci)) { + printk(KERN_ERR "CORE %s No more PCI ressources for " + "subsystem: %04x:%04x, board: %s\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device, + cx88_boards[core->board].name); + cx88_devcount--; goto fail_free; } @@ -1114,11 +1120,11 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->board = CX88_BOARD_UNKNOWN; cx88_card_list(core,pci); } - printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", - core->name,pci->subsystem_vendor, - pci->subsystem_device,cx88_boards[core->board].name, - core->board, card[core->nr] == core->board ? - "insmod option" : "autodetected"); + printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device,cx88_boards[core->board].name, + core->board, card[core->nr] == core->board ? + "insmod option" : "autodetected"); core->tuner_type = tuner[core->nr]; core->radio_type = radio[core->nr]; @@ -1202,4 +1208,5 @@ EXPORT_SYMBOL(cx88_core_put); * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 78d223257a6..cc71cafc2cb 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-dvb.c,v 1.58 2005/08/07 09:24:08 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * MPEG Transport Stream (DVB) routines @@ -31,6 +30,7 @@ #include #include + #include "cx88.h" #include "dvb-pll.h" @@ -210,16 +210,26 @@ static struct or51132_config pchdtv_hd3000 = { static int lgdt330x_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { + /* FIXME make this routine use the tuner-simple code. + * It could probably be shared with a number of ATSC + * frontends. Many share the same tuner with analog TV. */ + struct cx8802_dev *dev= fe->dvb->priv; + struct cx88_core *core = dev->core; u8 buf[4]; struct i2c_msg msg = { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; int err; - dvb_pll_configure(dev->core->pll_desc, buf, params->frequency, 0); + /* Put the analog decoder in standby to keep it quiet */ + if (core->tda9887_conf) { + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + } + + dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); - if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { + if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { printk(KERN_WARNING "cx88-dvb: %s error " "(addr %02x <- %02x, err = %i)\n", __FUNCTION__, buf[0], buf[1], err); @@ -228,6 +238,13 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe, else return -EREMOTEIO; } + if (core->tuner_type == TUNER_LG_TDVS_H062F) { + /* Set the Auxiliary Byte. */ + buf[2] &= ~0x20; + buf[2] |= 0x18; + buf[3] = 0x50; + i2c_transfer(&core->i2c_adap, &msg, 1); + } return 0; } @@ -261,6 +278,14 @@ static struct lgdt330x_config fusionhdtv_3_gold = { .pll_set = lgdt330x_pll_set, .set_ts_params = lgdt330x_set_ts_param, }; + +static struct lgdt330x_config fusionhdtv_5_gold = { + .demod_address = 0x0e, + .demod_chip = LGDT3303, + .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ + .pll_set = lgdt330x_pll_set, + .set_ts_params = lgdt330x_set_ts_param, +}; #endif static int dvb_register(struct cx8802_dev *dev) @@ -346,6 +371,22 @@ static int dvb_register(struct cx8802_dev *dev) &dev->core->i2c_adap); } break; + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: + dev->ts_gen_cntrl = 0x08; + { + /* Do a hardware reset of chip before using it. */ + struct cx88_core *core = dev->core; + + cx_clear(MO_GP0_IO, 1); + mdelay(100); + cx_set(MO_GP0_IO, 1); + mdelay(200); + dev->core->pll_addr = 0x61; + dev->core->pll_desc = &dvb_pll_tdvs_tua6034; + dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, + &dev->core->i2c_adap); + } + break; #endif default: printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 7f598039e02..761cebd40db 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c @@ -1,5 +1,4 @@ /* - $Id: cx88-i2c.c,v 1.30 2005/07/25 05:10:13 mkrufky Exp $ cx88-i2c.c -- all the i2c code is here diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index 21488779819..d7980c51478 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $ * * Device driver for GPIO attached remote control interfaces * on Conexant 2388x based TV/DVB cards. @@ -212,6 +211,53 @@ static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { /* ---------------------------------------------------------------------- */ +/* Cinergy 1400 DVB-T */ +static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { + [0x01] = KEY_POWER, + [0x02] = KEY_1, + [0x03] = KEY_2, + [0x04] = KEY_3, + [0x05] = KEY_4, + [0x06] = KEY_5, + [0x07] = KEY_6, + [0x08] = KEY_7, + [0x09] = KEY_8, + [0x0a] = KEY_9, + [0x0c] = KEY_0, + + [0x0b] = KEY_VIDEO, + [0x0d] = KEY_REFRESH, + [0x0e] = KEY_SELECT, + [0x0f] = KEY_EPG, + [0x10] = KEY_UP, + [0x11] = KEY_LEFT, + [0x12] = KEY_OK, + [0x13] = KEY_RIGHT, + [0x14] = KEY_DOWN, + [0x15] = KEY_TEXT, + [0x16] = KEY_INFO, + + [0x17] = KEY_RED, + [0x18] = KEY_GREEN, + [0x19] = KEY_YELLOW, + [0x1a] = KEY_BLUE, + + [0x1b] = KEY_CHANNELUP, + [0x1c] = KEY_VOLUMEUP, + [0x1d] = KEY_MUTE, + [0x1e] = KEY_VOLUMEDOWN, + [0x1f] = KEY_CHANNELDOWN, + + [0x40] = KEY_PAUSE, + [0x4c] = KEY_PLAY, + [0x58] = KEY_RECORD, + [0x54] = KEY_PREVIOUS, + [0x48] = KEY_STOP, + [0x5c] = KEY_NEXT, +}; + +/* ---------------------------------------------------------------------- */ + struct cx88_IR { struct cx88_core *core; struct input_dev input; @@ -241,7 +287,7 @@ module_param(ir_debug, int, 0644); /* debug level [IR] */ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); #define ir_dprintk(fmt, arg...) if (ir_debug) \ - printk(KERN_DEBUG "%s IR: " fmt , ir->core->name, ## arg) + printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) /* ---------------------------------------------------------------------- */ @@ -329,6 +375,11 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->mask_keyup = 0x60; ir->polling = 50; /* ms */ break; + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ir_codes = ir_codes_cinergy_1400; + ir_type = IR_TYPE_PD; + ir->sampling = 1; + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: ir_codes = ir_codes_hauppauge_new; @@ -445,7 +496,7 @@ int cx88_ir_fini(struct cx88_core *core) void cx88_ir_irq(struct cx88_core *core) { struct cx88_IR *ir = core->ir; - u32 samples, rc5; + u32 samples, ircode; int i; if (NULL == ir) @@ -477,13 +528,44 @@ void cx88_ir_irq(struct cx88_core *core) /* decode it */ switch (core->board) { + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); + + if (ircode == 0xffffffff) { /* decoding error */ + ir_dprintk("pulse distance decoding error\n"); + break; + } + + ir_dprintk("pulse distance decoded: %x\n", ircode); + + if (ircode == 0) { /* key still pressed */ + ir_dprintk("pulse distance decoded repeat code\n"); + ir->release = jiffies + msecs_to_jiffies(120); + break; + } + + if ((ircode & 0xffff) != 0xeb04) { /* wrong address */ + ir_dprintk("pulse distance decoded wrong address\n"); + break; + } + + if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */ + ir_dprintk("pulse distance decoded wrong check sum\n"); + break; + } + + ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); + + ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); + ir->release = jiffies + msecs_to_jiffies(120); + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: - rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7); - ir_dprintk("biphase decoded: %x\n", rc5); - if ((rc5 & 0xfffff000) != 0x3000) + ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); + ir_dprintk("biphase decoded: %x\n", ircode); + if ((ircode & 0xfffff000) != 0x3000) break; - ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5); + ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); ir->release = jiffies + msecs_to_jiffies(120); break; } diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index fe2767c0ff9..6d0d15c3a1c 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $ * * Support for the mpeg transport stream transfers * PCI function #2 of the cx2388x. @@ -73,11 +72,15 @@ static int cx8802_start_dma(struct cx8802_dev *dev, udelay(100); cx_write(MO_PINMUX_IO, 0x00); cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01); - if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) || - (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) { + switch (core->board) { + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: cx_write(TS_SOP_STAT, 1<<13); - } else { + break; + default: cx_write(TS_SOP_STAT, 0x00); + break; } cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); udelay(100); @@ -86,12 +89,10 @@ static int cx8802_start_dma(struct cx8802_dev *dev, if (cx88_boards[core->board].blackbird) { cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ - // cx_write(TS_F2_CMD_STAT_MM, 0x2900106); /* F2_CMD_STAT_MM defaults + master + memory space */ cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ udelay(100); cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */ - //cx_write(TS_HW_SOP_CNTRL, 0x2F0BC0); /* mpeg start byte ts: 0x2F0BC0 ? */ cx_write(TS_VALERR_CNTRL, 0x2000); cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ @@ -106,7 +107,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev, dprintk( 0, "setting the interrupt mask\n" ); cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04); cx_set(MO_TS_INTMSK, 0x1f0011); - //cx_write(MO_TS_INTMSK, 0x0f0011); /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); @@ -206,7 +206,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); dprintk(0,"[%p/%d] %s - first active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } else { dprintk( 1, "queue is not empty - append to active\n" ); @@ -217,7 +216,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); dprintk( 1, "[%p/%d] %s - append to active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } } @@ -387,7 +385,6 @@ int cx8802_init_common(struct cx8802_dev *dev) dev->pci_lat,pci_resource_start(dev->pci,0)); /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); /* init dma queue */ diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h index 37f82662d26..0a3a62fc9bb 100644 --- a/drivers/media/video/cx88/cx88-reg.h +++ b/drivers/media/video/cx88/cx88-reg.h @@ -1,5 +1,4 @@ /* - $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $ cx88x-hw.h - CX2388x register offsets @@ -40,6 +39,29 @@ #define CX88X_EN_TBFX 0x02 #define CX88X_EN_VSFX 0x04 +/* ---------------------------------------------------------------------- */ +/* PCI controller registers */ + +/* Command and Status Register */ +#define F0_CMD_STAT_MM 0x2f0004 +#define F1_CMD_STAT_MM 0x2f0104 +#define F2_CMD_STAT_MM 0x2f0204 +#define F3_CMD_STAT_MM 0x2f0304 +#define F4_CMD_STAT_MM 0x2f0404 + +/* Device Control #1 */ +#define F0_DEV_CNTRL1_MM 0x2f0040 +#define F1_DEV_CNTRL1_MM 0x2f0140 +#define F2_DEV_CNTRL1_MM 0x2f0240 +#define F3_DEV_CNTRL1_MM 0x2f0340 +#define F4_DEV_CNTRL1_MM 0x2f0440 + +/* Device Control #1 */ +#define F0_BAR0_MM 0x2f0010 +#define F1_BAR0_MM 0x2f0110 +#define F2_BAR0_MM 0x2f0210 +#define F3_BAR0_MM 0x2f0310 +#define F4_BAR0_MM 0x2f0410 /* ---------------------------------------------------------------------- */ /* DMA Controller registers */ diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 91207f10bae..2765acee028 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c @@ -1,5 +1,4 @@ /* - $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $ cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver @@ -121,25 +120,19 @@ static void set_audio_registers(struct cx88_core *core, } static void set_audio_start(struct cx88_core *core, - u32 mode, u32 ctl) + u32 mode) { // mute cx_write(AUD_VOL_CTL, (1 << 6)); - // increase level of input by 12dB -// cx_write(AUD_AFE_12DB_EN, 0x0001); - cx_write(AUD_AFE_12DB_EN, 0x0000); - // start programming cx_write(AUD_CTL, 0x0000); cx_write(AUD_INIT, mode); cx_write(AUD_INIT_LD, 0x0001); cx_write(AUD_SOFT_RESET, 0x0001); - - cx_write(AUD_CTL, ctl); } -static void set_audio_finish(struct cx88_core *core) +static void set_audio_finish(struct cx88_core *core, u32 ctl) { u32 volume; @@ -154,25 +147,25 @@ static void set_audio_finish(struct cx88_core *core) cx_write(AUD_I2SOUTPUTCNTL, 1); cx_write(AUD_I2SCNTL, 0); //cx_write(AUD_APB_IN_RATE_ADJ, 0); + } else { + ctl |= EN_DAC_ENABLE; + cx_write(AUD_CTL, ctl); } - // finish programming + /* finish programming */ cx_write(AUD_SOFT_RESET, 0x0000); - // start audio processing - cx_set(AUD_CTL, EN_DAC_ENABLE); - - // unmute + /* unmute */ volume = cx_sread(SHADOW_AUD_VOL_CTL); cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, volume); } /* ----------------------------------------------------------- */ -static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) +static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap, u32 mode) { static const struct rlist btsc[] = { - /* from dscaler */ + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_OUT1_SEL, 0x00000013 }, { AUD_OUT1_SHIFT, 0x00000000 }, { AUD_POLY0_DDS_CONSTANT, 0x0012010c }, @@ -206,9 +199,10 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; static const struct rlist btsc_sap[] = { + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_DBX_IN_GAIN, 0x00007200 }, { AUD_DBX_WBE_GAIN, 0x00006200 }, { AUD_DBX_SE_GAIN, 0x00006200 }, @@ -259,371 +253,400 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; - // dscaler: exactly taken from driver, - // dscaler: don't know why to set EN_FMRADIO_EN_RDS + mode |= EN_FMRADIO_EN_RDS; + if (sap) { dprintk("%s SAP (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_FORCE_SAP); + set_audio_start(core, SEL_SAP); set_audio_registers(core, btsc_sap); + set_audio_finish(core, mode); } else { dprintk("%s (status: known-good)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_AUTO_STEREO); + set_audio_start(core, SEL_BTSC); set_audio_registers(core, btsc); + set_audio_finish(core, mode); } - set_audio_finish(core); } static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo) { - /* This is probably weird.. - * Let's operate and find out. */ - - static const struct rlist nicam_l_mono[] = { - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - - { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, - { AUD_QAM_MODE, 0x00 }, - { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x4a }, - - { AUD_DEEMPHGAIN_R, 0x6680 }, - { AUD_DEEMPHNUMER1_R, 0x353DE }, - { AUD_DEEMPHNUMER2_R, 0x1B1 }, - { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x0 }, - { AUD_FM_MODE_ENABLE, 0x7 }, - { AUD_POLYPH80SCALEFAC, 0x3 }, - { AUD_AFE_12DB_EN, 0x1 }, - { AAGC_GAIN, 0x0 }, - { AAGC_HYST, 0x18 }, - { AAGC_DEF, 0x20 }, - { AUD_DN0_FREQ, 0x0 }, - { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, - { AUD_DCOC_0_SRC, 0x21 }, - { AUD_IIR1_0_SEL, 0x0 }, - { AUD_IIR1_0_SHIFT, 0x7 }, - { AUD_IIR1_1_SEL, 0x2 }, - { AUD_IIR1_1_SHIFT, 0x0 }, - { AUD_DCOC_1_SRC, 0x3 }, - { AUD_DCOC1_SHIFT, 0x0 }, - { AUD_DCOC_PASS_IN, 0x0 }, - { AUD_IIR1_2_SEL, 0x23 }, - { AUD_IIR1_2_SHIFT, 0x0 }, - { AUD_IIR1_3_SEL, 0x4 }, - { AUD_IIR1_3_SHIFT, 0x7 }, - { AUD_IIR1_4_SEL, 0x5 }, - { AUD_IIR1_4_SHIFT, 0x7 }, - { AUD_IIR3_0_SEL, 0x7 }, - { AUD_IIR3_0_SHIFT, 0x0 }, - { AUD_DEEMPH0_SRC_SEL, 0x11 }, - { AUD_DEEMPH0_SHIFT, 0x0 }, - { AUD_DEEMPH0_G0, 0x7000 }, - { AUD_DEEMPH0_A0, 0x0 }, - { AUD_DEEMPH0_B0, 0x0 }, - { AUD_DEEMPH0_A1, 0x0 }, - { AUD_DEEMPH0_B1, 0x0 }, - { AUD_DEEMPH1_SRC_SEL, 0x11 }, - { AUD_DEEMPH1_SHIFT, 0x0 }, - { AUD_DEEMPH1_G0, 0x7000 }, - { AUD_DEEMPH1_A0, 0x0 }, - { AUD_DEEMPH1_B0, 0x0 }, - { AUD_DEEMPH1_A1, 0x0 }, - { AUD_DEEMPH1_B1, 0x0 }, - { AUD_OUT0_SEL, 0x3F }, - { AUD_OUT1_SEL, 0x3F }, - { AUD_DMD_RA_DDS, 0x0F5C285 }, - { AUD_PLL_INT, 0x1E }, - { AUD_PLL_DDS, 0x0 }, - { AUD_PLL_FRAC, 0x0E542 }, - - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000100 }, - { AUD_RATE_ADJ2, 0x00000200 }, - { AUD_RATE_ADJ3, 0x00000300 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00000500 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - }; - - static const struct rlist nicam_l[] = { - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000060 }, - { AUD_RATE_ADJ2, 0x000000F9 }, - { AUD_RATE_ADJ3, 0x000001CC }, - { AUD_RATE_ADJ4, 0x000002B3 }, - { AUD_RATE_ADJ5, 0x00000726 }, - { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_DMD_RA_DDS, 0x00C00000 }, - { AUD_PLL_INT, 0x0000001E }, - { AUD_PLL_DDS, 0x00000000 }, - { AUD_PLL_FRAC, 0x0000E542 }, - { AUD_START_TIMER, 0x00000000 }, - { AUD_DEEMPHNUMER1_R, 0x000353DE }, - { AUD_DEEMPHNUMER2_R, 0x000001B1 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4C }, - { AUD_DEEMPHGAIN_R, 0x00006680 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - } ; - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - /* AM mono sound */ - set_audio_start(core, 0x0004, - 0x100c /* FIXME again */); - set_audio_registers(core, nicam_l_mono); - } else { - set_audio_start(core, 0x0010, - 0x1924 /* FIXME again */); - set_audio_registers(core, nicam_l); - } - set_audio_finish(core); + /* This is probably weird.. + * Let's operate and find out. */ + + static const struct rlist nicam_l_mono[] = { + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + + { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, + { AUD_QAM_MODE, 0x00 }, + { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x4a }, + + { AUD_DEEMPHGAIN_R, 0x6680 }, + { AUD_DEEMPHNUMER1_R, 0x353DE }, + { AUD_DEEMPHNUMER2_R, 0x1B1 }, + { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x0 }, + { AUD_FM_MODE_ENABLE, 0x7 }, + { AUD_POLYPH80SCALEFAC, 0x3 }, + { AUD_AFE_12DB_EN, 0x1 }, + { AAGC_GAIN, 0x0 }, + { AAGC_HYST, 0x18 }, + { AAGC_DEF, 0x20 }, + { AUD_DN0_FREQ, 0x0 }, + { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, + { AUD_DCOC_0_SRC, 0x21 }, + { AUD_IIR1_0_SEL, 0x0 }, + { AUD_IIR1_0_SHIFT, 0x7 }, + { AUD_IIR1_1_SEL, 0x2 }, + { AUD_IIR1_1_SHIFT, 0x0 }, + { AUD_DCOC_1_SRC, 0x3 }, + { AUD_DCOC1_SHIFT, 0x0 }, + { AUD_DCOC_PASS_IN, 0x0 }, + { AUD_IIR1_2_SEL, 0x23 }, + { AUD_IIR1_2_SHIFT, 0x0 }, + { AUD_IIR1_3_SEL, 0x4 }, + { AUD_IIR1_3_SHIFT, 0x7 }, + { AUD_IIR1_4_SEL, 0x5 }, + { AUD_IIR1_4_SHIFT, 0x7 }, + { AUD_IIR3_0_SEL, 0x7 }, + { AUD_IIR3_0_SHIFT, 0x0 }, + { AUD_DEEMPH0_SRC_SEL, 0x11 }, + { AUD_DEEMPH0_SHIFT, 0x0 }, + { AUD_DEEMPH0_G0, 0x7000 }, + { AUD_DEEMPH0_A0, 0x0 }, + { AUD_DEEMPH0_B0, 0x0 }, + { AUD_DEEMPH0_A1, 0x0 }, + { AUD_DEEMPH0_B1, 0x0 }, + { AUD_DEEMPH1_SRC_SEL, 0x11 }, + { AUD_DEEMPH1_SHIFT, 0x0 }, + { AUD_DEEMPH1_G0, 0x7000 }, + { AUD_DEEMPH1_A0, 0x0 }, + { AUD_DEEMPH1_B0, 0x0 }, + { AUD_DEEMPH1_A1, 0x0 }, + { AUD_DEEMPH1_B1, 0x0 }, + { AUD_OUT0_SEL, 0x3F }, + { AUD_OUT1_SEL, 0x3F }, + { AUD_DMD_RA_DDS, 0x0F5C285 }, + { AUD_PLL_INT, 0x1E }, + { AUD_PLL_DDS, 0x0 }, + { AUD_PLL_FRAC, 0x0E542 }, + + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000100 }, + { AUD_RATE_ADJ2, 0x00000200 }, + { AUD_RATE_ADJ3, 0x00000300 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00000500 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + }; + static const struct rlist nicam_l[] = { + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000060 }, + { AUD_RATE_ADJ2, 0x000000F9 }, + { AUD_RATE_ADJ3, 0x000001CC }, + { AUD_RATE_ADJ4, 0x000002B3 }, + { AUD_RATE_ADJ5, 0x00000726 }, + { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_DMD_RA_DDS, 0x00C00000 }, + { AUD_PLL_INT, 0x0000001E }, + { AUD_PLL_DDS, 0x00000000 }, + { AUD_PLL_FRAC, 0x0000E542 }, + { AUD_START_TIMER, 0x00000000 }, + { AUD_DEEMPHNUMER1_R, 0x000353DE }, + { AUD_DEEMPHNUMER2_R, 0x000001B1 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x34 }, + { AUD_PHACC_FREQ_8LSB, 0x4C }, + { AUD_DEEMPHGAIN_R, 0x00006680 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + } ; + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* AM Mono */ + set_audio_start(core, SEL_A2); + set_audio_registers(core, nicam_l_mono); + set_audio_finish(core, EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); + set_audio_registers(core, nicam_l); + set_audio_finish(core, 0x1924); /* FIXME */ + } } static void set_audio_standard_PAL_I(struct cx88_core *core, int stereo) { static const struct rlist pal_i_fm_mono[] = { - {AUD_ERRLOGPERIOD_R, 0x00000064}, - {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, - {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, - {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, - {AUD_PDF_DDS_CNST_BYTE2, 0x06}, - {AUD_PDF_DDS_CNST_BYTE1, 0x82}, - {AUD_PDF_DDS_CNST_BYTE0, 0x12}, - {AUD_QAM_MODE, 0x05}, - {AUD_PHACC_FREQ_8MSB, 0x3a}, - {AUD_PHACC_FREQ_8LSB, 0x93}, - {AUD_DMD_RA_DDS, 0x002a4f2f}, - {AUD_PLL_INT, 0x0000001e}, - {AUD_PLL_DDS, 0x00000004}, - {AUD_PLL_FRAC, 0x0000e542}, - {AUD_RATE_ADJ1, 0x00000100}, - {AUD_RATE_ADJ2, 0x00000200}, - {AUD_RATE_ADJ3, 0x00000300}, - {AUD_RATE_ADJ4, 0x00000400}, - {AUD_RATE_ADJ5, 0x00000500}, - {AUD_THR_FR, 0x00000000}, - {AUD_PILOT_BQD_1_K0, 0x0000755b}, - {AUD_PILOT_BQD_1_K1, 0x00551340}, - {AUD_PILOT_BQD_1_K2, 0x006d30be}, - {AUD_PILOT_BQD_1_K3, 0xffd394af}, - {AUD_PILOT_BQD_1_K4, 0x00400000}, - {AUD_PILOT_BQD_2_K0, 0x00040000}, - {AUD_PILOT_BQD_2_K1, 0x002a4841}, - {AUD_PILOT_BQD_2_K2, 0x00400000}, - {AUD_PILOT_BQD_2_K3, 0x00000000}, - {AUD_PILOT_BQD_2_K4, 0x00000000}, - {AUD_MODE_CHG_TIMER, 0x00000060}, - {AUD_AFE_12DB_EN, 0x00000001}, - {AAGC_HYST, 0x0000000a}, - {AUD_CORDIC_SHIFT_0, 0x00000007}, - {AUD_CORDIC_SHIFT_1, 0x00000007}, - {AUD_C1_UP_THR, 0x00007000}, - {AUD_C1_LO_THR, 0x00005400}, - {AUD_C2_UP_THR, 0x00005400}, - {AUD_C2_LO_THR, 0x00003000}, - {AUD_DCOC_0_SRC, 0x0000001a}, - {AUD_DCOC0_SHIFT, 0x00000000}, - {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, - {AUD_DCOC_PASS_IN, 0x00000003}, - {AUD_IIR3_0_SEL, 0x00000021}, - {AUD_DN2_AFC, 0x00000002}, - {AUD_DCOC_1_SRC, 0x0000001b}, - {AUD_DCOC1_SHIFT, 0x00000000}, - {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, - {AUD_IIR3_1_SEL, 0x00000023}, - {AUD_DN0_FREQ, 0x000035a3}, - {AUD_DN2_FREQ, 0x000029c7}, - {AUD_CRDC0_SRC_SEL, 0x00000511}, - {AUD_IIR1_0_SEL, 0x00000001}, - {AUD_IIR1_1_SEL, 0x00000000}, - {AUD_IIR3_2_SEL, 0x00000003}, - {AUD_IIR3_2_SHIFT, 0x00000000}, - {AUD_IIR3_0_SEL, 0x00000002}, - {AUD_IIR2_0_SEL, 0x00000021}, - {AUD_IIR2_0_SHIFT, 0x00000002}, - {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, - {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, - {AUD_POLYPH80SCALEFAC, 0x00000001}, - {AUD_START_TIMER, 0x00000000}, - { /* end of list */ }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x3a}, + {AUD_PHACC_FREQ_8LSB, 0x93}, + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000004}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000060}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AAGC_HYST, 0x0000000a}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_DN0_FREQ, 0x000035a3}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_CRDC0_SRC_SEL, 0x00000511}, + {AUD_IIR1_0_SEL, 0x00000001}, + {AUD_IIR1_1_SEL, 0x00000000}, + {AUD_IIR3_2_SEL, 0x00000003}, + {AUD_IIR3_2_SHIFT, 0x00000000}, + {AUD_IIR3_0_SEL, 0x00000002}, + {AUD_IIR2_0_SEL, 0x00000021}, + {AUD_IIR2_0_SHIFT, 0x00000002}, + {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, + {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, }; static const struct rlist pal_i_nicam[] = { - { AUD_RATE_ADJ1, 0x00000010 }, - { AUD_RATE_ADJ2, 0x00000040 }, - { AUD_RATE_ADJ3, 0x00000100 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00001000 }, - // { AUD_DMD_RA_DDS, 0x00c0d5ce }, - { AUD_DEEMPHGAIN_R, 0x000023c2 }, - { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, - { AUD_DEEMPHNUMER2_R, 0x0003023e }, - { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000fff }, - { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, - { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x93 }, - { /* end of list */ }, - }; - - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - // FM mono - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + { AUD_RATE_ADJ1, 0x00000010 }, + { AUD_RATE_ADJ2, 0x00000040 }, + { AUD_RATE_ADJ3, 0x00000100 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00001000 }, + // { AUD_DMD_RA_DDS, 0x00c0d5ce }, + { AUD_DEEMPHGAIN_R, 0x000023c2 }, + { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, + { AUD_DEEMPHNUMER2_R, 0x0003023e }, + { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000fff }, + { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, + { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x93 }, + { /* end of list */ }, + }; + + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* FM Mono */ + set_audio_start(core, SEL_A2); set_audio_registers(core, pal_i_fm_mono); - } else { - // Nicam Stereo - set_audio_start(core, 0x0010, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + set_audio_finish(core, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); set_audio_registers(core, pal_i_nicam); - } - set_audio_finish(core); + set_audio_finish(core, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + } } -static void set_audio_standard_A2(struct cx88_core *core) +static void set_audio_standard_A2(struct cx88_core *core, u32 mode) { - /* from dscaler cvs */ static const struct rlist a2_common[] = { - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4c }, - - { AUD_RATE_ADJ1, 0x00001000 }, - { AUD_RATE_ADJ2, 0x00002000 }, - { AUD_RATE_ADJ3, 0x00003000 }, - { AUD_RATE_ADJ4, 0x00004000 }, - { AUD_RATE_ADJ5, 0x00005000 }, - { AUD_THR_FR, 0x00000000 }, - { AAGC_HYST, 0x0000001a }, - { AUD_PILOT_BQD_1_K0, 0x0000755b }, - { AUD_PILOT_BQD_1_K1, 0x00551340 }, - { AUD_PILOT_BQD_1_K2, 0x006d30be }, - { AUD_PILOT_BQD_1_K3, 0xffd394af }, - { AUD_PILOT_BQD_1_K4, 0x00400000 }, - { AUD_PILOT_BQD_2_K0, 0x00040000 }, - { AUD_PILOT_BQD_2_K1, 0x002a4841 }, - { AUD_PILOT_BQD_2_K2, 0x00400000 }, - { AUD_PILOT_BQD_2_K3, 0x00000000 }, - { AUD_PILOT_BQD_2_K4, 0x00000000 }, - { AUD_MODE_CHG_TIMER, 0x00000040 }, - { AUD_START_TIMER, 0x00000200 }, - { AUD_AFE_12DB_EN, 0x00000000 }, - { AUD_CORDIC_SHIFT_0, 0x00000007 }, - { AUD_CORDIC_SHIFT_1, 0x00000007 }, - { AUD_DEEMPH0_G0, 0x00000380 }, - { AUD_DEEMPH1_G0, 0x00000380 }, - { AUD_DCOC_0_SRC, 0x0000001a }, - { AUD_DCOC0_SHIFT, 0x00000000 }, - { AUD_DCOC_0_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_0_SHIFT_IN1, 0x00000008 }, - { AUD_DCOC_PASS_IN, 0x00000003 }, - { AUD_IIR3_0_SEL, 0x00000021 }, - { AUD_DN2_AFC, 0x00000002 }, - { AUD_DCOC_1_SRC, 0x0000001b }, - { AUD_DCOC1_SHIFT, 0x00000000 }, - { AUD_DCOC_1_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_1_SHIFT_IN1, 0x00000008 }, - { AUD_IIR3_1_SEL, 0x00000023 }, - { AUD_RDSI_SEL, 0x00000017 }, - { AUD_RDSI_SHIFT, 0x00000000 }, - { AUD_RDSQ_SEL, 0x00000017 }, - { AUD_RDSQ_SHIFT, 0x00000000 }, - { AUD_POLYPH80SCALEFAC, 0x00000001 }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x34}, + {AUD_PHACC_FREQ_8LSB, 0x4c}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AAGC_HYST, 0x0000001a}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000040}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_RDSI_SEL, 0x00000017}, + {AUD_RDSI_SHIFT, 0x00000000}, + {AUD_RDSQ_SEL, 0x00000017}, + {AUD_RDSQ_SHIFT, 0x00000000}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000000}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, + }; + static const struct rlist a2_bg[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, { /* end of list */ }, }; - static const struct rlist a2_table1[] = { - // PAL-BG - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, + static const struct rlist a2_dk[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DN0_FREQ, 0x00003a1c}, + {AUD_DN2_FREQ, 0x0000d2e0}, { /* end of list */ }, }; - static const struct rlist a2_table2[] = { - // PAL-DK - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, - { AUD_DN0_FREQ, 0x00003a1c }, - { AUD_DN2_FREQ, 0x0000d2e0 }, +/* unknown, probably NTSC-M */ + static const struct rlist a2_m[] = { + {AUD_DMD_RA_DDS, 0x002a0425}, + {AUD_C1_UP_THR, 0x00003c00}, + {AUD_C1_LO_THR, 0x00003000}, + {AUD_C2_UP_THR, 0x00006000}, + {AUD_C2_LO_THR, 0x00003c00}, + {AUD_DEEMPH0_A0, 0x00007a80}, + {AUD_DEEMPH1_A0, 0x00007a80}, + {AUD_DEEMPH0_G0, 0x00001200}, + {AUD_DEEMPH1_G0, 0x00001200}, + {AUD_DN0_FREQ, 0x0000283b}, + {AUD_DN1_FREQ, 0x00003418}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_POLY0_DDS_CONSTANT, 0x000a7540}, { /* end of list */ }, }; - static const struct rlist a2_table3[] = { - // unknown, probably NTSC-M - { AUD_DMD_RA_DDS, 0x002a2873 }, - { AUD_C1_UP_THR, 0x00003c00 }, - { AUD_C1_LO_THR, 0x00003000 }, - { AUD_C2_UP_THR, 0x00006000 }, - { AUD_C2_LO_THR, 0x00003c00 }, - { AUD_DN0_FREQ, 0x00002836 }, - { AUD_DN1_FREQ, 0x00003418 }, - { AUD_DN2_FREQ, 0x000029c7 }, - { AUD_POLY0_DDS_CONSTANT, 0x000a7540 }, + + static const struct rlist a2_deemph50[] = { + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DEEMPHGAIN_R, 0x000011e1}, + {AUD_DEEMPHNUMER1_R, 0x0002a7bc}, + {AUD_DEEMPHNUMER2_R, 0x0003023c}, + { /* end of list */ }, + }; + + static const struct rlist a2_deemph75[] = { + {AUD_DEEMPH0_G0, 0x00000480}, + {AUD_DEEMPH1_G0, 0x00000480}, + {AUD_DEEMPHGAIN_R, 0x00009000}, + {AUD_DEEMPHNUMER1_R, 0x000353de}, + {AUD_DEEMPHNUMER2_R, 0x000001b1}, { /* end of list */ }, }; - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO); + set_audio_start(core, SEL_A2); set_audio_registers(core, a2_common); switch (core->tvaudio) { case WW_A2_BG: dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table1); + set_audio_registers(core, a2_bg); + set_audio_registers(core, a2_deemph50); break; case WW_A2_DK: dprintk("%s PAL-DK A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table2); + set_audio_registers(core, a2_dk); + set_audio_registers(core, a2_deemph50); break; case WW_A2_M: dprintk("%s NTSC-M A2 (status: unknown)\n",__FUNCTION__); - set_audio_registers(core, a2_table3); + set_audio_registers(core, a2_m); + set_audio_registers(core, a2_deemph75); break; }; - set_audio_finish(core); + + mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; + set_audio_finish(core, mode); } static void set_audio_standard_EIAJ(struct cx88_core *core) @@ -635,9 +658,9 @@ static void set_audio_standard_EIAJ(struct cx88_core *core) }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0002, EN_EIAJ_AUTO_STEREO); + set_audio_start(core, SEL_EIAJ); set_audio_registers(core, eiaj); - set_audio_finish(core); + set_audio_finish(core, EN_EIAJ_AUTO_STEREO); } static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type deemph) @@ -683,7 +706,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0020, EN_FMRADIO_AUTO_STEREO); + set_audio_start(core, SEL_FMRADIO); switch (deemph) { @@ -700,7 +723,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type break; } - set_audio_finish(core); + set_audio_finish(core, EN_FMRADIO_AUTO_STEREO); } /* ----------------------------------------------------------- */ @@ -709,7 +732,7 @@ void cx88_set_tvaudio(struct cx88_core *core) { switch (core->tvaudio) { case WW_BTSC: - set_audio_standard_BTSC(core,0); + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); break; case WW_NICAM_BGDKL: set_audio_standard_NICAM_L(core,0); @@ -720,7 +743,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - set_audio_standard_A2(core); + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case WW_EIAJ: set_audio_standard_EIAJ(core); @@ -734,7 +757,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_NONE: default: printk("%s/0: unknown tv audio mode [%d]\n", - core->name, core->tvaudio); + core->name, core->tvaudio); break; } return; @@ -769,6 +792,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) aud_ctl_names[cx_read(AUD_CTL) & 63]); core->astat = reg; +/* TODO + Reading from AUD_STATUS is not enough + for auto-detecting sap/dual-fm/nicam. + Add some code here later. +*/ + +# if 0 t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; t->rxsubchans = V4L2_TUNER_SUB_MONO; @@ -779,7 +809,7 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP; t->rxsubchans = V4L2_TUNER_SUB_STEREO; - if (1 == pilot) { + if (1 == pilot) { /* SAP */ t->rxsubchans |= V4L2_TUNER_SUB_SAP; } @@ -787,13 +817,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - if (1 == pilot) { + if (1 == pilot) { /* stereo */ t->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; if (0 == mode) t->audmode = V4L2_TUNER_MODE_STEREO; } - if (2 == pilot) { + if (2 == pilot) { /* dual language -- FIXME */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; @@ -805,16 +835,17 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } break; - case WW_SYSTEM_L_AM: - if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { - t->audmode = V4L2_TUNER_MODE_STEREO; + case WW_SYSTEM_L_AM: + if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { + t->audmode = V4L2_TUNER_MODE_STEREO; t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } - break ; + break ; default: /* nothing */ break; } +# endif return; } @@ -835,16 +866,16 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) case WW_BTSC: switch (mode) { case V4L2_TUNER_MODE_MONO: - ctl = EN_BTSC_FORCE_MONO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_MONO); break; - case V4L2_TUNER_MODE_SAP: - ctl = EN_BTSC_FORCE_SAP; - mask = 0x3f; + case V4L2_TUNER_MODE_LANG1: + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); + break; + case V4L2_TUNER_MODE_LANG2: + set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_BTSC_AUTO_STEREO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); break; } break; @@ -854,16 +885,13 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) switch (mode) { case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1: - ctl = EN_A2_FORCE_MONO1; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case V4L2_TUNER_MODE_LANG2: - ctl = EN_A2_AUTO_MONO2; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO2); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_A2_AUTO_STEREO | EN_DMTRX_SUMR; - mask = 0x8bf; + set_audio_standard_A2(core, EN_A2_FORCE_STEREO); break; } break; diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c index 320d57888bb..9bc6c899558 100644 --- a/drivers/media/video/cx88/cx88-vbi.c +++ b/drivers/media/video/cx88/cx88-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-vbi.c,v 1.17 2005/06/12 04:19:19 mchehab Exp $ */ #include #include diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 5f58c103198..61d4b29ec30 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-video.c,v 1.82 2005/07/22 05:13:34 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * video4linux video interface @@ -66,7 +65,7 @@ module_param(vid_limit,int,0644); MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); #define dprintk(level,fmt, arg...) if (video_debug >= level) \ - printk(KERN_DEBUG "%s/0: " fmt, dev->core->name , ## arg) + printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) /* ------------------------------------------------------------------ */ @@ -326,22 +325,23 @@ static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit) { + struct cx88_core *core = dev->core; if (fh->resources & bit) /* have it already allocated */ return 1; /* is it free? */ - down(&dev->lock); + down(&core->lock); if (dev->resources & bit) { /* no, someone else uses it */ - up(&dev->lock); + up(&core->lock); return 0; } /* it's free, grab it */ fh->resources |= bit; dev->resources |= bit; dprintk(1,"res: get %d\n",bit); - up(&dev->lock); + up(&core->lock); return 1; } @@ -360,27 +360,29 @@ int res_locked(struct cx8800_dev *dev, unsigned int bit) static void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) { + struct cx88_core *core = dev->core; if ((fh->resources & bits) != bits) BUG(); - down(&dev->lock); + down(&core->lock); fh->resources &= ~bits; dev->resources &= ~bits; dprintk(1,"res: put %d\n",bits); - up(&dev->lock); + up(&core->lock); } /* ------------------------------------------------------------------ */ -static int video_mux(struct cx8800_dev *dev, unsigned int input) +/* static int video_mux(struct cx8800_dev *dev, unsigned int input) */ +static int video_mux(struct cx88_core *core, unsigned int input) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", input, INPUT(input)->vmux, INPUT(input)->gpio0,INPUT(input)->gpio1, INPUT(input)->gpio2,INPUT(input)->gpio3); - dev->core->input = input; + core->input = input; cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14); cx_write(MO_GP3_IO, INPUT(input)->gpio3); cx_write(MO_GP0_IO, INPUT(input)->gpio0); @@ -413,9 +415,9 @@ static int start_video_dma(struct cx8800_dev *dev, struct cx88_core *core = dev->core; /* setup fifo + format */ - cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH21], + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], buf->bpl, buf->risc.dma); - cx88_set_scale(dev->core, buf->vb.width, buf->vb.height, buf->vb.field); + cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field); cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma); /* reset counter */ @@ -424,6 +426,14 @@ static int start_video_dma(struct cx8800_dev *dev, /* enable irqs */ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01); + + /* Enables corresponding bits at PCI_INT_STAT: + bits 0 to 4: video, audio, transport stream, VIP, Host + bit 7: timer + bits 8 and 9: DMA complete for: SRC, DST + bits 10 and 11: BERR signal asserted for RISC: RD, WR + bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB + */ cx_set(MO_VID_INTMSK, 0x0f0011); /* enable capture */ @@ -431,7 +441,7 @@ static int start_video_dma(struct cx8800_dev *dev, /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); - cx_set(MO_VID_DMACNTRL, 0x11); + cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ return 0; } @@ -455,6 +465,7 @@ static int stop_video_dma(struct cx8800_dev *dev) static int restart_video_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q) { + struct cx88_core *core = dev->core; struct cx88_buffer *buf, *prev; struct list_head *item; @@ -524,12 +535,13 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, { struct cx8800_fh *fh = q->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); int rc, init_buffer = 0; BUG_ON(NULL == fh->fmt); - if (fh->width < 48 || fh->width > norm_maxw(dev->core->tvnorm) || - fh->height < 32 || fh->height > norm_maxh(dev->core->tvnorm)) + if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) || + fh->height < 32 || fh->height > norm_maxh(core->tvnorm)) return -EINVAL; buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) @@ -609,6 +621,7 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) struct cx88_buffer *prev; struct cx8800_fh *fh = vq->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_dmaqueue *q = &dev->vidq; /* add jump to stopper */ @@ -701,6 +714,7 @@ static int video_open(struct inode *inode, struct file *file) { int minor = iminor(inode); struct cx8800_dev *h,*dev = NULL; + struct cx88_core *core; struct cx8800_fh *fh; struct list_head *list; enum v4l2_buf_type type = 0; @@ -725,6 +739,8 @@ static int video_open(struct inode *inode, struct file *file) if (NULL == dev) return -ENODEV; + core = dev->core; + dprintk(1,"open minor=%d radio=%d type=%s\n", minor,radio,v4l2_type_names[type]); @@ -755,17 +771,16 @@ static int video_open(struct inode *inode, struct file *file) fh); if (fh->radio) { - struct cx88_core *core = dev->core; int board = core->board; dprintk(1,"video_open: setting radio device\n"); cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3); cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0); cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1); cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2); - dev->core->tvaudio = WW_FM; + core->tvaudio = WW_FM; cx88_set_tvaudio(core); cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); - cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL); + cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); } return 0; @@ -857,6 +872,9 @@ static int video_release(struct inode *inode, struct file *file) videobuf_mmap_free(&fh->vbiq); file->private_data = NULL; kfree(fh); + + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + return 0; } @@ -870,9 +888,10 @@ video_mmap(struct file *file, struct vm_area_struct * vma) /* ------------------------------------------------------------------ */ -static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int get_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 value; int i; @@ -898,9 +917,10 @@ static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int set_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 v_sat_value; u32 value; @@ -913,9 +933,9 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return -EINVAL; if (ctl->value < c->v.minimum) - return -ERANGE; + ctl->value = c->v.minimum; if (ctl->value > c->v.maximum) - return -ERANGE; + ctl->value = c->v.maximum; switch (ctl->id) { case V4L2_CID_AUDIO_BALANCE: value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; @@ -946,7 +966,8 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static void init_controls(struct cx8800_dev *dev) +/* static void init_controls(struct cx8800_dev *dev) */ +static void init_controls(struct cx88_core *core) { static struct v4l2_control mute = { .id = V4L2_CID_AUDIO_MUTE, @@ -969,11 +990,11 @@ static void init_controls(struct cx8800_dev *dev) .value = 0x80, }; - set_control(dev,&mute); - set_control(dev,&volume); - set_control(dev,&hue); - set_control(dev,&contrast); - set_control(dev,&brightness); + set_control(core,&mute); + set_control(core,&volume); + set_control(core,&hue); + set_control(core,&contrast); + set_control(core,&brightness); } /* ------------------------------------------------------------------ */ @@ -1004,6 +1025,8 @@ static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, struct v4l2_format *f) { + struct cx88_core *core = dev->core; + switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: { @@ -1016,8 +1039,8 @@ static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, return -EINVAL; field = f->fmt.pix.field; - maxw = norm_maxw(dev->core->tvnorm); - maxh = norm_maxh(dev->core->tvnorm); + maxw = norm_maxw(core->tvnorm); + maxh = norm_maxh(core->tvnorm); if (V4L2_FIELD_ANY == field) { field = (f->fmt.pix.height > maxh/2) @@ -1101,12 +1124,14 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (video_debug > 1) cx88_print_ioctl(core->name,cmd); switch (cmd) { + + /* --- capabilities ------------------------------------------ */ case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); - strcpy(cap->driver, "cx8800"); + strcpy(cap->driver, "cx8800"); strlcpy(cap->card, cx88_boards[core->board].name, sizeof(cap->card)); sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); @@ -1116,12 +1141,128 @@ static int video_do_ioctl(struct inode *inode, struct file *file, V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | 0; if (UNSET != core->tuner_type) cap->capabilities |= V4L2_CAP_TUNER; return 0; } + /* --- capture ioctls ---------------------------------------- */ + case VIDIOC_ENUM_FMT: + { + struct v4l2_fmtdesc *f = arg; + enum v4l2_buf_type type; + unsigned int index; + + index = f->index; + type = f->type; + switch (type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + if (index >= ARRAY_SIZE(formats)) + return -EINVAL; + memset(f,0,sizeof(*f)); + f->index = index; + f->type = type; + strlcpy(f->description,formats[index].name,sizeof(f->description)); + f->pixelformat = formats[index].fourcc; + break; + default: + return -EINVAL; + } + return 0; + } + case VIDIOC_G_FMT: + { + struct v4l2_format *f = arg; + return cx8800_g_fmt(dev,fh,f); + } + case VIDIOC_S_FMT: + { + struct v4l2_format *f = arg; + return cx8800_s_fmt(dev,fh,f); + } + case VIDIOC_TRY_FMT: + { + struct v4l2_format *f = arg; + return cx8800_try_fmt(dev,fh,f); + } + + /* --- streaming capture ------------------------------------- */ + case VIDIOCGMBUF: + { + struct video_mbuf *mbuf = arg; + struct videobuf_queue *q; + struct v4l2_requestbuffers req; + unsigned int i; + + q = get_queue(fh); + memset(&req,0,sizeof(req)); + req.type = q->type; + req.count = 8; + req.memory = V4L2_MEMORY_MMAP; + err = videobuf_reqbufs(q,&req); + if (err < 0) + return err; + memset(mbuf,0,sizeof(*mbuf)); + mbuf->frames = req.count; + mbuf->size = 0; + for (i = 0; i < mbuf->frames; i++) { + mbuf->offsets[i] = q->bufs[i]->boff; + mbuf->size += q->bufs[i]->bsize; + } + return 0; + } + case VIDIOC_REQBUFS: + return videobuf_reqbufs(get_queue(fh), arg); + + case VIDIOC_QUERYBUF: + return videobuf_querybuf(get_queue(fh), arg); + + case VIDIOC_QBUF: + return videobuf_qbuf(get_queue(fh), arg); + + case VIDIOC_DQBUF: + return videobuf_dqbuf(get_queue(fh), arg, + file->f_flags & O_NONBLOCK); + + case VIDIOC_STREAMON: + { + int res = get_ressource(fh); + + if (!res_get(dev,fh,res)) + return -EBUSY; + return videobuf_streamon(get_queue(fh)); + } + case VIDIOC_STREAMOFF: + { + int res = get_ressource(fh); + + err = videobuf_streamoff(get_queue(fh)); + if (err < 0) + return err; + res_free(dev,fh,res); + return 0; + } + + default: + return cx88_do_ioctl( inode, file, fh->radio, core, cmd, arg, video_do_ioctl ); + } + return 0; +} + +int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl) +{ + int err; + + if (video_debug > 1) + cx88_print_ioctl(core->name,cmd); + printk( KERN_INFO "CORE IOCTL: 0x%x\n", cmd ); + cx88_print_ioctl(core->name,cmd); + dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); + + switch (cmd) { /* ---------- tv norms ---------- */ case VIDIOC_ENUMSTD: { @@ -1156,9 +1297,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (i == ARRAY_SIZE(tvnorms)) return -EINVAL; - down(&dev->lock); - cx88_set_tvnorm(dev->core,&tvnorms[i]); - up(&dev->lock); + down(&core->lock); + cx88_set_tvnorm(core,&tvnorms[i]); + up(&core->lock); return 0; } @@ -1199,7 +1340,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, { unsigned int *i = arg; - *i = dev->core->input; + *i = core->input; return 0; } case VIDIOC_S_INPUT: @@ -1208,55 +1349,15 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (*i >= 4) return -EINVAL; - down(&dev->lock); + down(&core->lock); cx88_newstation(core); - video_mux(dev,*i); - up(&dev->lock); + video_mux(core,*i); + up(&core->lock); return 0; } - /* --- capture ioctls ---------------------------------------- */ - case VIDIOC_ENUM_FMT: - { - struct v4l2_fmtdesc *f = arg; - enum v4l2_buf_type type; - unsigned int index; - - index = f->index; - type = f->type; - switch (type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (index >= ARRAY_SIZE(formats)) - return -EINVAL; - memset(f,0,sizeof(*f)); - f->index = index; - f->type = type; - strlcpy(f->description,formats[index].name,sizeof(f->description)); - f->pixelformat = formats[index].fourcc; - break; - default: - return -EINVAL; - } - return 0; - } - case VIDIOC_G_FMT: - { - struct v4l2_format *f = arg; - return cx8800_g_fmt(dev,fh,f); - } - case VIDIOC_S_FMT: - { - struct v4l2_format *f = arg; - return cx8800_s_fmt(dev,fh,f); - } - case VIDIOC_TRY_FMT: - { - struct v4l2_format *f = arg; - return cx8800_try_fmt(dev,fh,f); - } - /* --- controls ---------------------------------------------- */ case VIDIOC_QUERYCTRL: { @@ -1277,9 +1378,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOC_G_CTRL: - return get_control(dev,arg); + return get_control(core,arg); case VIDIOC_S_CTRL: - return set_control(dev,arg); + return set_control(core,arg); /* --- tuner ioctls ------------------------------------------ */ case VIDIOC_G_TUNER: @@ -1323,10 +1424,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (UNSET == core->tuner_type) return -EINVAL; - f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; - f->frequency = dev->freq; + /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ + f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + f->frequency = core->freq; - cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); return 0; } @@ -1338,83 +1440,26 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return -EINVAL; if (f->tuner != 0) return -EINVAL; - if (0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV) + if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV) return -EINVAL; - if (1 == fh->radio && f->type != V4L2_TUNER_RADIO) + if (1 == radio && f->type != V4L2_TUNER_RADIO) return -EINVAL; - down(&dev->lock); - dev->freq = f->frequency; + down(&core->lock); + core->freq = f->frequency; cx88_newstation(core); - cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); /* When changing channels it is required to reset TVAUDIO */ msleep (10); cx88_set_tvaudio(core); - up(&dev->lock); - return 0; - } - - /* --- streaming capture ------------------------------------- */ - case VIDIOCGMBUF: - { - struct video_mbuf *mbuf = arg; - struct videobuf_queue *q; - struct v4l2_requestbuffers req; - unsigned int i; - - q = get_queue(fh); - memset(&req,0,sizeof(req)); - req.type = q->type; - req.count = 8; - req.memory = V4L2_MEMORY_MMAP; - err = videobuf_reqbufs(q,&req); - if (err < 0) - return err; - memset(mbuf,0,sizeof(*mbuf)); - mbuf->frames = req.count; - mbuf->size = 0; - for (i = 0; i < mbuf->frames; i++) { - mbuf->offsets[i] = q->bufs[i]->boff; - mbuf->size += q->bufs[i]->bsize; - } - return 0; - } - case VIDIOC_REQBUFS: - return videobuf_reqbufs(get_queue(fh), arg); - - case VIDIOC_QUERYBUF: - return videobuf_querybuf(get_queue(fh), arg); - - case VIDIOC_QBUF: - return videobuf_qbuf(get_queue(fh), arg); - - case VIDIOC_DQBUF: - return videobuf_dqbuf(get_queue(fh), arg, - file->f_flags & O_NONBLOCK); - - case VIDIOC_STREAMON: - { - int res = get_ressource(fh); - - if (!res_get(dev,fh,res)) - return -EBUSY; - return videobuf_streamon(get_queue(fh)); - } - case VIDIOC_STREAMOFF: - { - int res = get_ressource(fh); - - err = videobuf_streamoff(get_queue(fh)); - if (err < 0) - return err; - res_free(dev,fh,res); + up(&core->lock); return 0; } default: return v4l_compat_translate_ioctl(inode,file,cmd,arg, - video_do_ioctl); + driver_ioctl); } return 0; } @@ -1461,7 +1506,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, memset(t,0,sizeof(*t)); strcpy(t->name, "Radio"); - cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t); return 0; } case VIDIOC_ENUMINPUT: @@ -1501,8 +1546,8 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (v->tuner) /* Only tuner 0 */ return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOCSTUNER,v); - return 0; + cx88_call_i2c_clients(core,VIDIOCSTUNER,v); + return 0; } case VIDIOC_S_TUNER: { @@ -1511,7 +1556,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (0 != t->index) return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOC_S_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t); return 0; } @@ -1569,7 +1614,7 @@ static void cx8800_vid_timeout(unsigned long data) struct cx88_buffer *buf; unsigned long flags; - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); @@ -1614,14 +1659,14 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) printk(KERN_WARNING "%s/0: video risc op code error\n",core->name); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); } /* risc1 y */ if (status & 0x01) { spin_lock(&dev->slock); count = cx_read(MO_VIDY_GPCNT); - cx88_wakeup(dev->core, &dev->vidq, count); + cx88_wakeup(core, &dev->vidq, count); spin_unlock(&dev->slock); } @@ -1629,7 +1674,7 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) if (status & 0x08) { spin_lock(&dev->slock); count = cx_read(MO_VBI_GPCNT); - cx88_wakeup(dev->core, &dev->vbiq, count); + cx88_wakeup(core, &dev->vbiq, count); spin_unlock(&dev->slock); } @@ -1798,7 +1843,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, } /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); core->tvnorm = tvnorms; @@ -1835,6 +1879,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, request_module("tuner"); if (core->tda9887_conf) request_module("tda9887"); + /* register v4l devices */ dev->video_dev = cx88_vdev_init(core,dev->pci, &cx8800_video_template,"video"); @@ -1878,11 +1923,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, pci_set_drvdata(pci_dev,dev); /* initial device configuration */ - down(&dev->lock); - init_controls(dev); - cx88_set_tvnorm(dev->core,tvnorms); - video_mux(dev,0); - up(&dev->lock); + down(&core->lock); + init_controls(core); + cx88_set_tvnorm(core,tvnorms); + video_mux(core,0); + up(&core->lock); /* start tvaudio thread */ if (core->tuner_type != TUNER_ABSENT) @@ -1902,14 +1947,15 @@ fail_free: static void __devexit cx8800_finidev(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); + struct cx88_core *core = dev->core; /* stop thread */ - if (dev->core->kthread) { - kthread_stop(dev->core->kthread); - dev->core->kthread = NULL; + if (core->kthread) { + kthread_stop(core->kthread); + core->kthread = NULL; } - cx88_shutdown(dev->core); /* FIXME */ + cx88_shutdown(core); /* FIXME */ pci_disable_device(pci_dev); /* unregister stuff */ @@ -1921,7 +1967,7 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) /* free memory */ btcx_riscmem_free(dev->pci,&dev->vidq.stopper); list_del(&dev->devlist); - cx88_core_put(dev->core,dev->pci); + cx88_core_put(core,dev->pci); kfree(dev); } @@ -1945,7 +1991,7 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) spin_unlock(&dev->slock); /* FIXME -- shutdown device */ - cx88_shutdown(dev->core); + cx88_shutdown(core); pci_save_state(pci_dev); if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { @@ -1968,7 +2014,7 @@ static int cx8800_resume(struct pci_dev *pci_dev) pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ - cx88_reset(dev->core); + cx88_reset(core); /* restart video+vbi capture */ spin_lock(&dev->slock); @@ -2030,6 +2076,8 @@ static void cx8800_fini(void) module_init(cx8800_init); module_exit(cx8800_fini); +EXPORT_SYMBOL(cx88_do_ioctl); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index da65dc92787..13b8fb7e921 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -1,5 +1,4 @@ /* - * $Id: cx88.h,v 1.70 2005/07/24 17:44:09 mkrufky Exp $ * * v4l2 device driver for cx2388x based TV cards * @@ -48,6 +47,9 @@ #define CX88_MAXBOARDS 8 +/* Max number of inputs by card */ +#define MAX_CX88_INPUT 8 + /* ----------------------------------------------------------- */ /* defines and enums */ @@ -199,7 +201,7 @@ struct cx88_board { unsigned char tuner_addr; unsigned char radio_addr; int tda9887_conf; - struct cx88_input input[8]; + struct cx88_input input[MAX_CX88_INPUT]; struct cx88_input radio; int blackbird:1; int dvb:1; @@ -288,6 +290,11 @@ struct cx88_core { /* IR remote control state */ struct cx88_IR *ir; + + struct semaphore lock; + + /* various v4l controls */ + u32 freq; }; struct cx8800_dev; @@ -323,8 +330,7 @@ struct cx8800_suspend_state { struct cx8800_dev { struct cx88_core *core; struct list_head devlist; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* various device info */ unsigned int resources; @@ -342,7 +348,6 @@ struct cx8800_dev { struct cx88_dmaqueue vbiq; /* various v4l controls */ - u32 freq; /* other global state info */ struct cx8800_suspend_state state; @@ -350,14 +355,8 @@ struct cx8800_dev { /* ----------------------------------------------------------- */ /* function 1: audio/alsa stuff */ +/* =============> moved to cx88-alsa.c <====================== */ -struct cx8801_dev { - struct cx88_core *core; - - /* pci i/o */ - struct pci_dev *pci; - unsigned char pci_rev,pci_lat; -}; /* ----------------------------------------------------------- */ /* function 2: mpeg stuff */ @@ -373,8 +372,7 @@ struct cx8802_suspend_state { struct cx8802_dev { struct cx88_core *core; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* pci i/o */ struct pci_dev *pci; @@ -553,8 +551,21 @@ void cx8802_fini_common(struct cx8802_dev *dev); int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state); int cx8802_resume_common(struct pci_dev *pci_dev); +/* ----------------------------------------------------------- */ +/* cx88-video.c */ +extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, + void *arg, v4l2_kioctl driver_ioctl); + +/* ----------------------------------------------------------- */ +/* cx88-blackbird.c */ +extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + /* * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ -- cgit v1.2.3 From 2f1807102a3a5c9b9782b6e8d271fc8ccef91f0a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:46 -0700 Subject: [PATCH] v4l: SAA7134 updates and board additions - Remove $Id CVS logs for V4L files - linux/version.h replaced by linux/utsname.h - Add new Digimatrix card and LG TAPC Mini tuner for it Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/saa7134/saa7134-cards.c | 48 ++++++++++++++++++++++++++- drivers/media/video/saa7134/saa7134-core.c | 1 - drivers/media/video/saa7134/saa7134-dvb.c | 1 - drivers/media/video/saa7134/saa7134-empress.c | 1 - drivers/media/video/saa7134/saa7134-i2c.c | 1 - drivers/media/video/saa7134/saa7134-input.c | 1 - drivers/media/video/saa7134/saa7134-oss.c | 1 - drivers/media/video/saa7134/saa7134-reg.h | 1 - drivers/media/video/saa7134/saa7134-ts.c | 1 - drivers/media/video/saa7134/saa7134-tvaudio.c | 1 - drivers/media/video/saa7134/saa7134-vbi.c | 1 - drivers/media/video/saa7134/saa7134-video.c | 25 +------------- drivers/media/video/saa7134/saa7134.h | 4 +-- 13 files changed, 50 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 88b71a20b60..c277b3b4651 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-cards.c,v 1.80 2005/07/07 01:49:30 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * card-specific stuff. @@ -2001,6 +2000,41 @@ struct saa7134_board saa7134_boards[] = { .gpio = 0x000, }, }, + [SAA7134_BOARD_FLYTV_DIGIMATRIX] = { + .name = "FlyTV mini Asus Digimatrix", + .audio_clock = 0x00200000, + .tuner_type = TUNER_LG_NTSC_TALN_MINI, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + },{ + .name = name_tv_mono, + .vmux = 1, + .amux = LINE2, + .tv = 1, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + },{ + .name = name_comp2, + .vmux = 3, + .amux = LINE2, + },{ + .name = name_svideo, + .vmux = 8, + .amux = LINE2, + }}, + .radio = { + .name = name_radio, /* radio unconfirmed */ + .amux = LINE2, + }, + }, }; @@ -2346,6 +2380,18 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x4e42, .subdevice = 0x0502, .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci NTSC version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7134, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci PAL/SECAM version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, },{ /* --- boards without eeprom + subsystem ID --- */ diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 1dbe61755e9..e5e36f3c625 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-core.c,v 1.39 2005/07/05 17:37:35 nsh Exp $ * * device driver for philips saa7134 based TV cards * driver core diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 8be6a90358c..fa29dd5f7f0 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-dvb.c,v 1.23 2005/07/24 22:12:47 mkrufky Exp $ * * (c) 2004 Gerd Knorr [SuSE Labs] * diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index c85348d0239..77b627eb648 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-empress.c,v 1.11 2005/05/22 19:23:39 nsh Exp $ * * (c) 2004 Gerd Knorr [SuSE Labs] * diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index eae6b529713..711aa8e85fa 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-i2c.c,v 1.22 2005/07/22 04:09:41 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * i2c interface support diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 213740122fe..0e97b1eec20 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-input.c,v 1.21 2005/06/22 23:37:34 nsh Exp $ * * handle saa7134 IR remotes via linux kernel input layer. * diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c index b5bede95dbf..c20630c82f1 100644 --- a/drivers/media/video/saa7134/saa7134-oss.c +++ b/drivers/media/video/saa7134/saa7134-oss.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-oss.c,v 1.17 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * oss dsp interface diff --git a/drivers/media/video/saa7134/saa7134-reg.h b/drivers/media/video/saa7134/saa7134-reg.h index 87734f22af7..ae0c7a16539 100644 --- a/drivers/media/video/saa7134/saa7134-reg.h +++ b/drivers/media/video/saa7134/saa7134-reg.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134-reg.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ * * philips saa7134 registers */ diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c index 4dd9f1b2392..463885601ab 100644 --- a/drivers/media/video/saa7134/saa7134-ts.c +++ b/drivers/media/video/saa7134/saa7134-ts.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-ts.c,v 1.15 2005/06/14 22:48:18 hhackmann Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index eeafa5a71d2..badf2f9e307 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * tv audio decoder (fm stereo, nicam, ...) diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c index 29e51cad2aa..f4aee0af80e 100644 --- a/drivers/media/video/saa7134/saa7134-vbi.c +++ b/drivers/media/video/saa7134/saa7134-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-vbi.c,v 1.7 2005/05/24 23:13:06 nsh Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index a4c2f751d09..35e5e85f669 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-video.c,v 1.36 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -1368,29 +1367,7 @@ static int video_release(struct inode *inode, struct file *file) saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); - if (dev->tuner_type == TUNER_PHILIPS_TDA8290) { - u8 data[2]; - int ret; - struct i2c_msg msg = {.addr=I2C_ADDR_TDA8290, .flags=0, .buf=data, .len = 2}; - data[0] = 0x21; - data[1] = 0xc0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8290 access failure\n"); - msg.addr = I2C_ADDR_TDA8275; - data[0] = 0x30; - data[1] = 0xd0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8275 access failure\n"); - msg.addr = I2C_ADDR_TDA8290; - data[0] = 0x21; - data[1] = 0x80; - i2c_transfer(&dev->i2c_adap, &msg, 1); - data[0] = 0x00; - data[1] = 0x02; - i2c_transfer(&dev->i2c_adap, &msg, 1); - } + saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); /* free stuff */ videobuf_mmap_free(&fh->cap); diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 2af0cb2a731..7a7fa42e1d2 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134.h,v 1.49 2005/07/13 17:25:25 mchehab Exp $ * * v4l2 device driver for philips saa7134 based TV cards * @@ -20,7 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14) #include @@ -185,6 +184,7 @@ struct saa7134_format { #define SAA7134_BOARD_PHILIPS_TOUGH 61 #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 #define SAA7134_BOARD_KWORLD_XPERT 63 +#define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v1.2.3 From c0e9eae60e8f1a18e2e6502b3e738dd2886d18ff Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:47 -0700 Subject: [PATCH] v4l: change the prefix of msp34xx and error while reading chip version - Changes the prefix to 'msp34xx' instead of 'msp3400'. - Changes the message 'error while reading chip version' to a debug printk at msp3400.c Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/msp3400.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index ca02f6f14b0..01d567cf5c6 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1452,7 +1452,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) client_template.addr = addr; if (-1 == msp3400c_reset(&client_template)) { - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1478,7 +1478,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if (-1 == msp3400c_reset(c)) { kfree(msp); kfree(c); - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1488,7 +1488,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { kfree(msp); kfree(c); - printk("msp3400: error while reading chip version\n"); + dprintk("msp34xx: error while reading chip version\n"); return -1; } -- cgit v1.2.3 From 272435dc44f7254c7174d69b41eb430a50583d1a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:47 -0700 Subject: [PATCH] v4l: syncs tveeprom tuners list with the list from ivtv - Syncs tveeprom tuners list with the list from ivtv. - Fixes the incorrect reporting of the radio presence. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tveeprom.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index d0a00d3a6c4..367401449e3 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -152,7 +152,7 @@ hauppauge_tuner[] = { TUNER_MICROTUNE_4049FM5, "Microtune 4049 FM5"}, { TUNER_ABSENT, "LG TPI8NSR11F"}, { TUNER_ABSENT, "Microtune 4049 FM5 Alt I2C"}, - { TUNER_ABSENT, "Philips FQ1216ME MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "Philips FQ1216ME MK3"}, { TUNER_ABSENT, "Philips FI1236 MK3"}, { TUNER_PHILIPS_FM1216ME_MK3, "Philips FM1216 ME MK3"}, { TUNER_PHILIPS_FM1236_MK3, "Philips FM1236 MK3"}, @@ -167,7 +167,7 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Temic 4106FH5"}, { TUNER_ABSENT, "Philips FQ1216LMP MK3"}, { TUNER_LG_NTSC_TAPE, "LG TAPE H001F MK3"}, - { TUNER_ABSENT, "LG TAPE H701F MK3"}, + { TUNER_LG_NTSC_TAPE, "LG TAPE H701F MK3"}, /* 70-79 */ { TUNER_ABSENT, "LG TALN H200T"}, { TUNER_ABSENT, "LG TALN H250T"}, @@ -199,6 +199,13 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1236 MK5"}, { TUNER_ABSENT, "Unspecified"}, { TUNER_LG_PAL_TAPE, "LG PAL (TAPE Series)"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_TCL_2002N, "TCL 2002N 5H"}, + /* 100-103 */ + { TUNER_ABSENT, "Unspecified"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, }; static char *sndtype[] = { @@ -484,6 +491,7 @@ tveeprom_command(struct i2c_client *client, eeprom_props[1] = eeprom.tuner_formats; eeprom_props[2] = eeprom.model; eeprom_props[3] = eeprom.revision; + eeprom_props[4] = eeprom.has_radio; break; default: return -EINVAL; -- cgit v1.2.3 From 5adc1c306b1ce5b297bd8ee010a62f39cd32b9e4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:48 -0700 Subject: [PATCH] v4l: correct LG NTSC TALN mini tuner takeover - correct LG NTSC TALN mini tuner takeover as far we can empirically determine for now. Signed-off-by: Hermann Pitton Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tuner-simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 26034406b37..6f153ca9749 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -250,7 +250,7 @@ static struct tunertype tuners[] = { { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, - 16*150.00,16*425.00,0x01,0x02,0x08,0x8e,732 }, + 16*137.25,16*373.25,0x01,0x02,0x08,0x8e,732 }, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); -- cgit v1.2.3 From 260784dcca44b5a526cece1f275cb81ccd186a3e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:49 -0700 Subject: [PATCH] v4l: add saa713x card #65 Kworld V-Stream Studio TV Terminator - Add saa713x card #65 Kworld V-Stream Studio TV Terminator Signed-off-by: James R Webb Signed-off-by: Peter Missel Signed-off-by: Nickolay V. Shmyrev Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/saa7134/saa7134-cards.c | 33 +++++++++++++++++++++++++++++ drivers/media/video/saa7134/saa7134.h | 1 + 2 files changed, 34 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index c277b3b4651..ea0237a0b56 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2035,6 +2035,39 @@ struct saa7134_board saa7134_boards[] = { .amux = LINE2, }, }, + [SAA7134_BOARD_KWORLD_TERMINATOR] = { + /* Kworld V-Stream Studio TV Terminator */ + /* "James Webb */ + .name = "V-Stream Studio TV Terminator", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .gpiomask = 1 << 21, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .gpio = 0x0000000, + .tv = 1, + },{ + .name = name_comp1, /* Composite input */ + .vmux = 3, + .amux = LINE2, + .gpio = 0x0000000, + },{ + .name = name_svideo, /* S-Video input */ + .vmux = 8, + .amux = LINE2, + .gpio = 0x0000000, + }}, + .radio = { + .name = name_radio, + .amux = TV, + .gpio = 0x0200000, + }, + }, }; diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 7a7fa42e1d2..26ec9446dff 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -185,6 +185,7 @@ struct saa7134_format { #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 #define SAA7134_BOARD_KWORLD_XPERT 63 #define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 +#define SAA7134_BOARD_KWORLD_TERMINATOR 65 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v1.2.3 From 4279f02478c2c4f106ec9efb80ca152e8d406844 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:51 -0700 Subject: [PATCH] v4l: add saa713x card #66: Yuan TUN-900 (saa7135) - Add saa713x card #66: Yuan TUN-900 (saa7135) Signed-off-by: De Greef Sebastien Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/saa7134/saa7134-cards.c | 41 +++++++++++++++++++++++++++++ drivers/media/video/saa7134/saa7134.h | 1 + 2 files changed, 42 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index ea0237a0b56..f991f232534 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2068,6 +2068,47 @@ struct saa7134_board saa7134_boards[] = { .gpio = 0x0200000, }, }, + [SAA7134_BOARD_YUAN_TUN900] = { + /* FIXME: + * S-Video and composite sources untested. + * Radio not working. + * Remote control not yet implemented. + * From : codemaster@webgeeks.be */ + .name = "Yuan TUN-900 (saa7135)", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr= ADDR_UNSET, + .radio_addr= ADDR_UNSET, + .gpiomask = 0x00010003, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + .gpio = 0x01, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + .gpio = 0x02, + },{ + .name = name_svideo, + .vmux = 6, + .amux = LINE2, + .gpio = 0x02, + }}, + .radio = { + .name = name_radio, + .amux = LINE1, + .gpio = 0x00010003, + }, + .mute = { + .name = name_mute, + .amux = TV, + .gpio = 0x01, + }, + }, }; diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 26ec9446dff..1d70f3415e9 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -186,6 +186,7 @@ struct saa7134_format { #define SAA7134_BOARD_KWORLD_XPERT 63 #define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 #define SAA7134_BOARD_KWORLD_TERMINATOR 65 +#define SAA7134_BOARD_YUAN_TUN900 66 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 -- cgit v1.2.3 From 10c35cf8fd89e166d13bc93175f2b05d9cb85e07 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:52 -0700 Subject: [PATCH] v4l: cx88-dvb incorrect reporting fixed and remove bad PCI ID for Sabrent - cx88-dvb has been incorrectly reporting the card name instead of frontend name - Removes a bad PCI subsystem ID for saa713x Sabrent card - Renames DVICO --> DViCO for bttv. - #include no longer needed. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/bttv-cards.c | 4 ++-- drivers/media/video/cx88/cx88-dvb.c | 6 ------ drivers/media/video/saa7134/saa7134-cards.c | 6 ------ 3 files changed, 2 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 3cb398b7a02..64785d3fe83 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -2258,7 +2258,7 @@ struct tvcard bttv_tvcards[] = { /* ---- card 0x80 ---------------------------------- */ /* Chris Pascoe */ - .name = "DVICO FusionHDTV DVB-T Lite", + .name = "DViCO FusionHDTV DVB-T Lite", .tuner = -1, .no_msp34xx = 1, .no_tda9875 = 1, @@ -2389,7 +2389,7 @@ struct tvcard bttv_tvcards[] = { { /* ---- card 0x87---------------------------------- */ /* Michael Krufky */ - .name = "DVICO FusionHDTV 5 Lite", + .name = "DViCO FusionHDTV 5 Lite", .tuner = 0, .tuner_type = TUNER_LG_TDVS_H062F, .tuner_addr = ADDR_UNSET, diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index cc71cafc2cb..c9106b1d79d 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "cx88.h" @@ -403,11 +402,6 @@ static int dvb_register(struct cx8802_dev *dev) dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; } - /* Copy the board name into the DVB structure */ - strlcpy(dev->dvb.frontend->ops->info.name, - cx88_boards[dev->core->board].name, - sizeof(dev->dvb.frontend->ops->info.name)); - /* register everything */ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); } diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index f991f232534..07d3ee0ada7 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2378,12 +2378,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x185b, .subdevice = 0xc100, .driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR, - },{ - .vendor = PCI_VENDOR_ID_PHILIPS, - .device = PCI_DEVICE_ID_PHILIPS_SAA7130, - .subvendor = 0x1131, - .subdevice = 0, - .driver_data = SAA7134_BOARD_SABRENT_SBTTVFM, },{ .vendor = PCI_VENDOR_ID_PHILIPS, .device = PCI_DEVICE_ID_PHILIPS_SAA7134, -- cgit v1.2.3 From 1c94aeecd3fd2aed66d9a1135f5329df622e6137 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:52 -0700 Subject: [PATCH] v4l: normalize whitespace and comments in tuner lists - normalize whitespace and comments in tuner lists Signed-off-by: Philip Rowlands Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tuner-simple.c | 43 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 6f153ca9749..5e99b242a28 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -101,6 +101,7 @@ struct tunertype * "no float in kernel" rule. */ static struct tunertype tuners[] = { + /* 0-9 */ { "Temic PAL (4002 FH5)", TEMIC, PAL, 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623}, { "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I, @@ -109,7 +110,6 @@ static struct tunertype tuners[] = { 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732}, { "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM, 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623}, - { "NoTuner", NoTuner, NOTUNER, 0,0,0x00,0x00,0x00,0x00,0x00}, { "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL, @@ -118,34 +118,34 @@ static struct tunertype tuners[] = { 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732}, { "Temic PAL_I (4062 FY5)", TEMIC, PAL_I, 16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4036 FY5)", TEMIC, NTSC, 16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732}, { "Alps HSBH1", TEMIC, NTSC, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, - { "Alps TSBE1",TEMIC,PAL, + + /* 10-19 */ + { "Alps TSBE1", TEMIC, PAL, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632}, - { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622}, { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608}, { "Temic PAL_BG (4006FH5)", TEMIC, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Alps TSCH6",Alps,NTSC, + { "Alps TSCH6", Alps, NTSC, 16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732}, - - { "Temic PAL_DK (4016 FY5)",TEMIC,PAL, + { "Temic PAL_DK (4016 FY5)", TEMIC, PAL, 16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623}, - { "Philips NTSC_M (MK2)",Philips,NTSC, + { "Philips NTSC_M (MK2)", Philips, NTSC, 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL* auto (4006 FN5)", TEMIC, PAL, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, + /* 20-29 */ { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic NTSC (4039 FR5)", TEMIC, NTSC, @@ -154,7 +154,6 @@ static struct tunertype tuners[] = { 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I, @@ -163,25 +162,24 @@ static struct tunertype tuners[] = { 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC, 16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732}, - { "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, + + /* 30-39 */ { "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */ 16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 }, - - { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ + { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ 16*169,16*464,0xA0,0x90,0x30,0x8e,623}, - { "MT20xx universal", Microtune,PAL|NTSC, + { "MT20xx universal", Microtune, PAL|NTSC, /* see mt20xx.c for details */ }, { "Temic PAL_BG (4106 FH5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL, 16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4136 FY5)", TEMIC, NTSC, 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732}, { "LG PAL (newer TAPC series)", LGINNOTEK, PAL, @@ -191,42 +189,41 @@ static struct tunertype tuners[] = { { "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732}, + /* 40-49 */ { "HITACHI V7-J180AT", HITACHI, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 }, { "Philips PAL_MK (FI1216 MK)", Philips, PAL, 16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623}, - { "Philips 1236D ATSC/NTSC daul in",Philips,ATSC, + { "Philips 1236D ATSC/NTSC daul in", Philips, ATSC, 16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Microtune 4049 FM5",Microtune,PAL, + { "Microtune 4049 FM5", Microtune, PAL, 16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623}, { "Panasonic VP27s/ENGE4324D", Panasonic, NTSC, 16*160.00,16*454.00,0x01,0x02,0x08,0xce,940}, { "LG NTSC (TAPE series)", LGINNOTEK, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, - { "Tenna TNF 8831 BGFF)", Philips, PAL, 16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623}, { "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC, 16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732}, + + /* 50-59 */ { "TCL 2002N", TCL, NTSC, 16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732}, { "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 }, - { "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Philips FQ1286", Philips, NTSC, - 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested - { "tda8290+75", Philips,PAL|NTSC, + 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, /* UHF band untested */ + { "tda8290+75", Philips, PAL|NTSC, /* see tda8290.c for details */ }, { "LG PAL (TAPE series)", LGINNOTEK, PAL, 16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623}, - { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, { "Philips FQ1236A MK4", Philips, NTSC, @@ -236,6 +233,7 @@ static struct tunertype tuners[] = { { "Ymec TVision TVF-5533MF", Philips, NTSC, 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, + /* 60-66 */ { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, @@ -244,7 +242,6 @@ static struct tunertype tuners[] = { /* see tea5767.c for details */}, { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, - { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, { "Ymec TVF66T5-B/DFF", Philips, PAL, -- cgit v1.2.3 From 4c93b07a48039cee1d845f38294abec0f803e05e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:54 -0700 Subject: [PATCH] v4l: change LG TDVS H062F from NTSC to ATSC - Change LG TDVS H062F from NTSC to ATSC. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tuner-simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 5e99b242a28..61dee53d328 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -242,7 +242,7 @@ static struct tunertype tuners[] = { /* see tea5767.c for details */}, { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, - { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, + { "LG TDVS-H062F/TUA6034", LGINNOTEK, ATSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, -- cgit v1.2.3 From 08adb9e20be83bb4c5322bf15b966c537038f6d9 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:55 -0700 Subject: [PATCH] v4l: some error treatment implemented at resume functions. - Some error treatment implemented at resume functions. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/bttv-driver.c | 18 ++++++++++++++++-- drivers/media/video/cx88/cx88-mpeg.c | 20 +++++++++++++++++--- drivers/media/video/cx88/cx88-video.c | 20 ++++++++++++++++++-- 3 files changed, 51 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 53ecdbf4622..b35c586a225 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -4111,15 +4111,29 @@ static int bttv_resume(struct pci_dev *pci_dev) { struct bttv *btv = pci_get_drvdata(pci_dev); unsigned long flags; + int err; dprintk("bttv%d: resume\n", btv->c.nr); /* restore pci state */ if (btv->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + return err; + } btv->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + pci_disable_device(pci_dev); + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + btv->state.disabled = 1; + return err; + } + pci_restore_state(pci_dev); /* restore bt878 state */ diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 6d0d15c3a1c..ee2300e1ae0 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -455,14 +455,28 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) int cx8802_resume_common(struct pci_dev *pci_dev) { - struct cx8802_dev *dev = pci_get_drvdata(pci_dev); + struct cx8802_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + return err; + } dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 61d4b29ec30..3dbc074fb51 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -2005,12 +2005,28 @@ static int cx8800_resume(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + return err; + } + dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err= pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ -- cgit v1.2.3 From 33ac6b52679743c3dbb7c7245f1df90588ee1097 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:56 -0700 Subject: [PATCH] v4l: the Microtune 4049FM5 uses an IF frequency of 33.3 MHz for FM radio. - The Microtune 4049FM5 uses an IF frequency of 33.3 MHz for FM radio. Signed-off-by: Hans Verkuil Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/bttv-cards.c | 4 ++-- drivers/media/video/tuner-simple.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 64785d3fe83..10ab12ba4c6 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -299,8 +299,8 @@ static struct CARD { { 0x00011822, BTTV_TWINHAN_DST, "Twinhan VisionPlus DVB" }, { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, - { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" }, - { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DVICO FusionHDTV 5 Lite" }, + { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" }, + { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, { 0, -1, NULL } }; diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 61dee53d328..8edd73abe1d 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -468,6 +468,10 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) case TUNER_LG_PAL_FM: buffer[3] = 0xa5; break; + case TUNER_MICROTUNE_4049FM5: + div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */ + buffer[3] = 0xa4; + break; default: buffer[3] = 0xa4; break; -- cgit v1.2.3 From fccdf1bd362452d5e2bc0a1874b2b504b481e367 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:57 -0700 Subject: [PATCH] v4l: #include no longer needed. - #include no longer needed. Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/saa7134/saa7134-dvb.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index fa29dd5f7f0..639ae51a052 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "saa7134-reg.h" -- cgit v1.2.3 From 6a989d7328aa4a0b4793ea05b13871bf1b500b1e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:57 -0700 Subject: [PATCH] v4l: correct the amux for composite and s-video inputs on the Sabrent SBT-TVFM card. - correct the amux for composite and s-video inputs on the Sabrent SBT-TVFM card. Signed-off-by: Michael Rodriquez-Torrent Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/saa7134/saa7134-cards.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 07d3ee0ada7..acc7a4335e2 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -1372,7 +1372,7 @@ struct saa7134_board saa7134_boards[] = { .inputs = {{ .name = name_comp1, .vmux = 1, - .amux = LINE2, + .amux = LINE1, },{ .name = name_tv, .vmux = 3, @@ -1381,7 +1381,7 @@ struct saa7134_board saa7134_boards[] = { },{ .name = name_svideo, .vmux = 8, - .amux = LINE2, + .amux = LINE1, }}, .radio = { .name = name_radio, -- cgit v1.2.3 From 21d4df375be2c9e5f1002800036fbfb793cf031f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:03:59 -0700 Subject: [PATCH] v4l: print warning if pal= or secam= argument is unrecognized - print warning if pal= or secam= argument is unrecognized Signed-off-by: Philip Rowlands Signed-off-by: Michael Krufky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tda9887.c | 13 +++++++++++++ drivers/media/video/tuner-core.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 79e0bd1aa70..0456dda2624 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -23,6 +23,7 @@ TDA9887 (world), TDA9885 (USA) Note: OP2 of tda988x must be set to 1, else MT2032 is disabled! - KNC One TV-Station RDS (saa7134) + - Hauppauge PVR-150/500 (possibly more) */ @@ -519,6 +520,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: PAL => PAL-DK\n"); t->std = V4L2_STD_PAL_DK; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -535,6 +542,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "secam= argument not recognised\n"); + break; } } return 0; diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index afc96bbb1c1..05572020af4 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -281,6 +281,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: PAL => PAL-N\n"); t->std = V4L2_STD_PAL_N; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -297,6 +303,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("secam= argument not recognised\n"); + break; } } -- cgit v1.2.3 From 5129b1589883d6eaa54886f3e0c5d918dafe329e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:00 -0700 Subject: [PATCH] v4l: add some missing parameter descriptions in msp3400.c - added some missing parameter descriptions at msp3400.c Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/msp3400.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 01d567cf5c6..f0d43fc2632 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -124,10 +124,14 @@ module_param(standard, int, 0644); module_param(amsound, int, 0644); module_param(dolby, int, 0644); +MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Simple, 2=Simpler"); MODULE_PARM_DESC(once, "No continuous stereo monitoring"); MODULE_PARM_DESC(debug, "Enable debug messages"); +MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo"); MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect"); MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan"); +MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); + MODULE_DESCRIPTION("device driver for msp34xx TV sound processor"); MODULE_AUTHOR("Gerd Knorr"); -- cgit v1.2.3 From 67e49a1abe3e9458c7ffba66775b350b5ceffae0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:00 -0700 Subject: [PATCH] v4l: make the input event device for IR matchable by udev rules. - Makes the input event device created by the V4L drivers for the infrared remote matchable by udev rules. Signed-off-by: Rudo Thomas Signed-off-by: Michael Fair Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/cx88/cx88-input.c | 1 + drivers/media/video/ir-kbd-gpio.c | 1 + drivers/media/video/saa7134/saa7134-input.c | 1 + 3 files changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index d7980c51478..d81b21d6e05 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c @@ -445,6 +445,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->input.id.vendor = pci->vendor; ir->input.id.product = pci->device; } + ir->input.dev = &pci->dev; /* record handles to ourself */ ir->core = core; diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index eddadc76e11..cf292da8fdd 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c @@ -353,6 +353,7 @@ static int ir_probe(struct device *dev) ir->input.id.vendor = sub->core->pci->vendor; ir->input.id.product = sub->core->pci->device; } + ir->input.dev = &sub->core->pci->dev; if (ir->polling) { INIT_WORK(&ir->work, ir_work, ir); diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 0e97b1eec20..1f456c4d76f 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c @@ -564,6 +564,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) ir->dev.id.vendor = dev->pci->vendor; ir->dev.id.product = dev->pci->device; } + ir->dev.dev = &dev->pci->dev; /* all done */ dev->remote = ir; -- cgit v1.2.3 From 10b89ee387fd6cc38532a881f64b3d35f338ea0b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:03 -0700 Subject: [PATCH] v4l: include saa6588 compiler option and files / fixes comments on tuner.h - Include saa6588 compiler option and files. - Fix comment on tuner.h - linux/utsname.h replaced by linux/version.h to compile on vanilla 2.6.13 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/Kconfig | 12 + drivers/media/video/Makefile | 2 + drivers/media/video/bttvp.h | 2 +- drivers/media/video/cx88/cx88.h | 2 +- drivers/media/video/rds.h | 48 +++ drivers/media/video/saa6588.c | 534 ++++++++++++++++++++++++++++++++++ drivers/media/video/saa7134/saa7134.h | 2 +- 7 files changed, 599 insertions(+), 3 deletions(-) create mode 100644 drivers/media/video/rds.h create mode 100644 drivers/media/video/saa6588.c (limited to 'drivers') diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 077720c2b64..93570355819 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -25,6 +25,18 @@ config VIDEO_BT848 To compile this driver as a module, choose M here: the module will be called bttv. +config VIDEO_SAA6588 + tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" + depends on VIDEO_DEV && I2C && VIDEO_BT848 + + help + Support for Radio Data System (RDS) decoder. This allows seeing + radio station identification transmitted using this standard. + Currentlly, it works only with bt8x8 chips. + + To compile this driver as a module, choose M here: the + module will be called saa6588. + config VIDEO_PMS tristate "Mediavision Pro Movie Studio Video For Linux" depends on VIDEO_DEV && ISA diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 3e6f5347da2..046b82de928 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -5,6 +5,7 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o +rds-objs := saa6588.o zr36067-objs := zoran_procfs.o zoran_device.o \ zoran_driver.o zoran_card.o tuner-objs := tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o @@ -15,6 +16,7 @@ obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \ obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o obj-$(CONFIG_VIDEO_ZR36120) += zoran.o +obj-$(CONFIG_VIDEO_SAA6588) += rds.o obj-$(CONFIG_VIDEO_SAA5246A) += saa5246a.o obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index a0eb0ce1aa9..9b0b7ca035f 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h @@ -25,7 +25,7 @@ #ifndef _BTTVP_H_ #define _BTTVP_H_ -#include +#include #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,16) #include diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 13b8fb7e921..f48dd435356 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -34,7 +34,7 @@ #include "btcx-risc.h" #include "cx88-reg.h" -#include +#include #define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) #ifndef TRUE diff --git a/drivers/media/video/rds.h b/drivers/media/video/rds.h new file mode 100644 index 00000000000..30337d0f1a8 --- /dev/null +++ b/drivers/media/video/rds.h @@ -0,0 +1,48 @@ +/* + + Types and defines needed for RDS. This is included by + saa6588.c and every driver (e.g. bttv-driver.c) that wants + to use the saa6588 module. + + Instead of having a seperate rds.h, I'd prefer to include + this stuff in one of the already existing files like tuner.h + + (c) 2005 by Hans J. Koch + + 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 _RDS_H +#define _RDS_H + +struct rds_command { + unsigned int block_count; + int result; + unsigned char *buffer; + struct file *instance; + poll_table *event_list; +}; + +#define RDS_CMD_OPEN _IOW('R',1,int) +#define RDS_CMD_CLOSE _IOW('R',2,int) +#define RDS_CMD_READ _IOR('R',3,int) +#define RDS_CMD_POLL _IOR('R',4,int) + +#endif + + + + diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c new file mode 100644 index 00000000000..1a657a70ff4 --- /dev/null +++ b/drivers/media/video/saa6588.c @@ -0,0 +1,534 @@ +/* + Driver for SAA6588 RDS decoder + + (c) 2005 Hans J. Koch + + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "rds.h" + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { + 0x20 >> 1, + 0x22 >> 1, + I2C_CLIENT_END, +}; + +I2C_CLIENT_INSMOD; + +/* insmod options */ +static unsigned int debug = 0; +static unsigned int xtal = 0; +static unsigned int rbds = 0; +static unsigned int plvl = 0; +static unsigned int bufblocks = 100; + +MODULE_PARM(debug, "i"); +MODULE_PARM_DESC(debug, "enable debug messages"); +MODULE_PARM(xtal, "i"); +MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0"); +MODULE_PARM(rbds, "i"); +MODULE_PARM_DESC(rbds, "select mode, 0=RDS, 1=RBDS, default 0"); +MODULE_PARM(plvl, "i"); +MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0"); +MODULE_PARM(bufblocks, "i"); +MODULE_PARM_DESC(bufblocks, "number of buffered blocks, default 100"); + +MODULE_DESCRIPTION("v4l2 driver module for SAA6588 RDS decoder"); +MODULE_AUTHOR("Hans J. Koch "); + +MODULE_LICENSE("GPL"); + +/* ---------------------------------------------------------------------- */ + +#define UNSET (-1U) +#define PREFIX "saa6588: " +#define dprintk if (debug) printk + +struct saa6588 { + struct i2c_client client; + struct work_struct work; + struct timer_list timer; + spinlock_t lock; + unsigned char *buffer; + unsigned int buf_size; + unsigned int rd_index; + unsigned int wr_index; + unsigned int block_count; + unsigned char last_blocknum; + wait_queue_head_t read_queue; + int data_available_for_read; +}; + +static struct i2c_driver driver; +static struct i2c_client client_template; + +/* ---------------------------------------------------------------------- */ + +/* + * SAA6588 defines + */ + +/* Initialization and mode control byte (0w) */ + +/* bit 0+1 (DAC0/DAC1) */ +#define cModeStandard 0x00 +#define cModeFastPI 0x01 +#define cModeReducedRequest 0x02 +#define cModeInvalid 0x03 + +/* bit 2 (RBDS) */ +#define cProcessingModeRDS 0x00 +#define cProcessingModeRBDS 0x04 + +/* bit 3+4 (SYM0/SYM1) */ +#define cErrCorrectionNone 0x00 +#define cErrCorrection2Bits 0x08 +#define cErrCorrection5Bits 0x10 +#define cErrCorrectionNoneRBDS 0x18 + +/* bit 5 (NWSY) */ +#define cSyncNormal 0x00 +#define cSyncRestart 0x20 + +/* bit 6 (TSQD) */ +#define cSigQualityDetectOFF 0x00 +#define cSigQualityDetectON 0x40 + +/* bit 7 (SQCM) */ +#define cSigQualityTriggered 0x00 +#define cSigQualityContinous 0x80 + +/* Pause level and flywheel control byte (1w) */ + +/* bits 0..5 (FEB0..FEB5) */ +#define cFlywheelMaxBlocksMask 0x3F +#define cFlywheelDefault 0x20 + +/* bits 6+7 (PL0/PL1) */ +#define cPauseLevel_11mV 0x00 +#define cPauseLevel_17mV 0x40 +#define cPauseLevel_27mV 0x80 +#define cPauseLevel_43mV 0xC0 + +/* Pause time/oscillator frequency/quality detector control byte (1w) */ + +/* bits 0..4 (SQS0..SQS4) */ +#define cQualityDetectSensMask 0x1F +#define cQualityDetectDefault 0x0F + +/* bit 5 (SOSC) */ +#define cSelectOscFreqOFF 0x00 +#define cSelectOscFreqON 0x20 + +/* bit 6+7 (PTF0/PTF1) */ +#define cOscFreq_4332kHz 0x00 +#define cOscFreq_8664kHz 0x40 +#define cOscFreq_12996kHz 0x80 +#define cOscFreq_17328kHz 0xC0 + +/* ---------------------------------------------------------------------- */ + +static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) +{ + int i; + + if (s->rd_index == s->wr_index) { + if (debug > 2) + dprintk(PREFIX "Read: buffer empty.\n"); + return 0; + } + + if (debug > 2) { + dprintk(PREFIX "Read: "); + for (i = s->rd_index; i < s->rd_index + 3; i++) + dprintk("0x%02x ", s->buffer[i]); + } + + if (copy_to_user(user_buf, &s->buffer[s->rd_index], 3)) + return -EFAULT; + + s->rd_index += 3; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + s->block_count--; + + if (debug > 2) + dprintk("%d blocks total.\n", s->block_count); + + return 1; +} + +static void read_from_buf(struct saa6588 *s, struct rds_command *a) +{ + unsigned long flags; + + unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ + unsigned int i; + unsigned int rd_blocks; + + a->result = 0; + if (!a->buffer) + return; + + while (!s->data_available_for_read) { + int ret = wait_event_interruptible(s->read_queue, + s->data_available_for_read); + if (ret == -ERESTARTSYS) { + a->result = -EINTR; + return; + } + } + + spin_lock_irqsave(&s->lock, flags); + rd_blocks = a->block_count; + if (rd_blocks > s->block_count) + rd_blocks = s->block_count; + + if (!rd_blocks) + return; + + for (i = 0; i < rd_blocks; i++) { + if (block_to_user_buf(s, buf_ptr)) { + buf_ptr += 3; + a->result++; + } else + break; + } + a->result *= 3; + s->data_available_for_read = (s->block_count > 0); + spin_unlock_irqrestore(&s->lock, flags); +} + +static void block_to_buf(struct saa6588 *s, unsigned char *blockbuf) +{ + unsigned int i; + + if (debug > 3) + dprintk(PREFIX "New block: "); + + for (i = 0; i < 3; ++i) { + if (debug > 3) + dprintk("0x%02x ", blockbuf[i]); + s->buffer[s->wr_index] = blockbuf[i]; + s->wr_index++; + } + + if (s->wr_index >= s->buf_size) + s->wr_index = 0; + + if (s->wr_index == s->rd_index) { + s->rd_index++; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + } else + s->block_count++; + + if (debug > 3) + dprintk("%d blocks total.\n", s->block_count); +} + +static void saa6588_i2c_poll(struct saa6588 *s) +{ + unsigned long flags; + unsigned char tmpbuf[6]; + unsigned char blocknum; + unsigned char tmp; + + /* Although we only need 3 bytes, we have to read at least 6. + SAA6588 returns garbage otherwise */ + if (6 != i2c_master_recv(&s->client, &tmpbuf[0], 6)) { + if (debug > 1) + dprintk(PREFIX "read error!\n"); + return; + } + + blocknum = tmpbuf[0] >> 5; + if (blocknum == s->last_blocknum) { + if (debug > 3) + dprintk("Saw block %d again.\n", blocknum); + return; + } + + s->last_blocknum = blocknum; + + /* + Byte order according to v4l2 specification: + + Byte 0: Least Significant Byte of RDS Block + Byte 1: Most Significant Byte of RDS Block + Byte 2 Bit 7: Error bit. Indicates that an uncorrectable error + occurred during reception of this block. + Bit 6: Corrected bit. Indicates that an error was + corrected for this data block. + Bits 5-3: Received Offset. Indicates the offset received + by the sync system. + Bits 2-0: Offset Name. Indicates the offset applied to this data. + + SAA6588 byte order is Status-MSB-LSB, so we have to swap the + first and the last of the 3 bytes block. + */ + + tmp = tmpbuf[2]; + tmpbuf[2] = tmpbuf[0]; + tmpbuf[0] = tmp; + + tmp = blocknum; + tmp |= blocknum << 3; /* Received offset == Offset Name (OK ?) */ + if ((tmpbuf[2] & 0x03) == 0x03) + tmp |= 0x80; /* uncorrectable error */ + else if ((tmpbuf[2] & 0x03) != 0x00) + tmp |= 0x40; /* corrected error */ + tmpbuf[2] = tmp; /* Is this enough ? Should we also check other bits ? */ + + spin_lock_irqsave(&s->lock, flags); + block_to_buf(s, tmpbuf); + spin_unlock_irqrestore(&s->lock, flags); + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); +} + +static void saa6588_timer(unsigned long data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + schedule_work(&s->work); +} + +static void saa6588_work(void *data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + saa6588_i2c_poll(s); + mod_timer(&s->timer, jiffies + HZ / 50); /* 20 msec */ +} + +static int saa6588_configure(struct saa6588 *s) +{ + unsigned char buf[3]; + int rc; + + buf[0] = cSyncRestart; + if (rbds) + buf[0] |= cProcessingModeRBDS; + + buf[1] = cFlywheelDefault; + switch (plvl) { + case 0: + buf[1] |= cPauseLevel_11mV; + break; + case 1: + buf[1] |= cPauseLevel_17mV; + break; + case 2: + buf[1] |= cPauseLevel_27mV; + break; + case 3: + buf[1] |= cPauseLevel_43mV; + break; + default: /* nothing */ + break; + } + + buf[2] = cQualityDetectDefault | cSelectOscFreqON; + + switch (xtal) { + case 0: + buf[2] |= cOscFreq_4332kHz; + break; + case 1: + buf[2] |= cOscFreq_8664kHz; + break; + case 2: + buf[2] |= cOscFreq_12996kHz; + break; + case 3: + buf[2] |= cOscFreq_17328kHz; + break; + default: /* nothing */ + break; + } + + dprintk(PREFIX "writing: 0w=0x%02x 1w=0x%02x 2w=0x%02x\n", + buf[0], buf[1], buf[2]); + + if (3 != (rc = i2c_master_send(&s->client, buf, 3))) + printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc); + + return 0; +} + +/* ---------------------------------------------------------------------- */ + +static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) +{ + struct saa6588 *s; + client_template.adapter = adap; + client_template.addr = addr; + + printk(PREFIX "chip found @ 0x%x\n", addr << 1); + + if (NULL == (s = kmalloc(sizeof(*s), GFP_KERNEL))) + return -ENOMEM; + + s->buf_size = bufblocks * 3; + + if (NULL == (s->buffer = kmalloc(s->buf_size, GFP_KERNEL))) { + kfree(s); + return -ENOMEM; + } + s->client = client_template; + s->block_count = 0; + s->wr_index = 0; + s->rd_index = 0; + s->last_blocknum = 0xff; + init_waitqueue_head(&s->read_queue); + s->data_available_for_read = 0; + i2c_set_clientdata(&s->client, s); + i2c_attach_client(&s->client); + + saa6588_configure(s); + + /* start polling via eventd */ + INIT_WORK(&s->work, saa6588_work, s); + init_timer(&s->timer); + s->timer.function = saa6588_timer; + s->timer.data = (unsigned long)s; + schedule_work(&s->work); + + return 0; +} + +static int saa6588_probe(struct i2c_adapter *adap) +{ +#ifdef I2C_CLASS_TV_ANALOG + if (adap->class & I2C_CLASS_TV_ANALOG) + return i2c_probe(adap, &addr_data, saa6588_attach); +#else + switch (adap->id) { + case I2C_ALGO_BIT | I2C_HW_B_BT848: + case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_ALGO_SAA7134: + return i2c_probe(adap, &addr_data, saa6588_attach); + break; + } +#endif + return 0; +} + +static int saa6588_detach(struct i2c_client *client) +{ + struct saa6588 *s = i2c_get_clientdata(client); + + del_timer_sync(&s->timer); + flush_scheduled_work(); + + i2c_detach_client(client); + kfree(s->buffer); + kfree(s); + return 0; +} + +static int saa6588_command(struct i2c_client *client, unsigned int cmd, + void *arg) +{ + struct saa6588 *s = i2c_get_clientdata(client); + struct rds_command *a = (struct rds_command *)arg; + + switch (cmd) { + /* --- open() for /dev/radio --- */ + case RDS_CMD_OPEN: + a->result = 0; /* return error if chip doesn't work ??? */ + break; + /* --- close() for /dev/radio --- */ + case RDS_CMD_CLOSE: + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); + a->result = 0; + break; + /* --- read() for /dev/radio --- */ + case RDS_CMD_READ: + read_from_buf(s, a); + break; + /* --- poll() for /dev/radio --- */ + case RDS_CMD_POLL: + a->result = 0; + if (s->data_available_for_read) { + a->result |= POLLIN | POLLRDNORM; + } + poll_wait(a->instance, &s->read_queue, a->event_list); + break; + + default: + /* nothing */ + break; + } + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static struct i2c_driver driver = { + .owner = THIS_MODULE, + .name = "i2c saa6588 driver", + .id = -1, /* FIXME */ + .flags = I2C_DF_NOTIFY, + .attach_adapter = saa6588_probe, + .detach_client = saa6588_detach, + .command = saa6588_command, +}; + +static struct i2c_client client_template = { + .name = "saa6588", + .flags = I2C_CLIENT_ALLOW_USE, + .driver = &driver, +}; + +static int __init saa6588_init_module(void) +{ + return i2c_add_driver(&driver); +} + +static void __exit saa6588_cleanup_module(void) +{ + i2c_del_driver(&driver); +} + +module_init(saa6588_init_module); +module_exit(saa6588_cleanup_module); + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * --------------------------------------------------------------------------- + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 1d70f3415e9..3ea09142ec9 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -19,7 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14) #include -- cgit v1.2.3 From 18fc59e230bbda9725736f8f526ef88aab212348 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:05 -0700 Subject: [PATCH] v4l: TVaudio cleanup and better debug messages - adds the adapter number + i2c address to printk msgs. - Some CodingStyle cleanups. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/tvaudio.c | 206 +++++++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 94 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 258724b2d6d..1c31ef52f86 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr"); MODULE_LICENSE("GPL"); #define UNSET (-1U) -#define dprintk if (debug) printk + +#define tvaudio_info(fmt, arg...) do {\ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) /* ---------------------------------------------------------------------- */ /* our structs */ @@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) unsigned char buffer[2]; if (-1 == subaddr) { - dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); + tvaudio_dbg("%s: chip_write: 0x%x\n", + chip->c.name, val); chip->shadow.bytes[1] = val; buffer[0] = val; if (1 != i2c_master_send(&chip->c,buffer,1)) { - printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", - chip->c.name, val); + tvaudio_warn("%s: I/O error (write 0x%x)\n", + chip->c.name, val); return -1; } } else { - dprintk("%s: chip_write: reg%d=0x%x\n", + tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", chip->c.name, subaddr, val); chip->shadow.bytes[subaddr+1] = val; buffer[0] = subaddr; buffer[1] = val; if (2 != i2c_master_send(&chip->c,buffer,2)) { - printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", - chip->c.name, subaddr, val); + tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", + chip->c.name, subaddr, val); return -1; } } @@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip) unsigned char buffer; if (1 != i2c_master_recv(&chip->c,&buffer,1)) { - printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read)\n", + chip->c.name); return -1; } - dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); + tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer); return buffer; } static int chip_read2(struct CHIPSTATE *chip, int subaddr) { - unsigned char write[1]; - unsigned char read[1]; - struct i2c_msg msgs[2] = { - { chip->c.addr, 0, 1, write }, - { chip->c.addr, I2C_M_RD, 1, read } - }; - write[0] = subaddr; + unsigned char write[1]; + unsigned char read[1]; + struct i2c_msg msgs[2] = { + { chip->c.addr, 0, 1, write }, + { chip->c.addr, I2C_M_RD, 1, read } + }; + write[0] = subaddr; if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { - printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read2)\n", chip->c.name); return -1; } - dprintk("%s: chip_read2: reg%d=0x%x\n", - chip->c.name, subaddr, read[0]); + tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", + chip->c.name,subaddr,read[0]); return read[0]; } @@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) return 0; /* update our shadow register set; print bytes if (debug > 0) */ - dprintk("%s: chip_cmd(%s): reg=%d, data:", - chip->c.name, name, cmd->bytes[0]); + tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", + chip->c.name,name,cmd->bytes[0]); for (i = 1; i < cmd->count; i++) { - dprintk(" 0x%x",cmd->bytes[i]); + if (debug) + printk(" 0x%x",cmd->bytes[i]); chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; } - dprintk("\n"); + if (debug) + printk("\n"); /* send data to the chip */ if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { - printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); + tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name); return -1; } return 0; @@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) static void chip_thread_wake(unsigned long data) { - struct CHIPSTATE *chip = (struct CHIPSTATE*)data; + struct CHIPSTATE *chip = (struct CHIPSTATE*)data; wake_up_interruptible(&chip->wq); } static int chip_thread(void *data) { DECLARE_WAITQUEUE(wait, current); - struct CHIPSTATE *chip = data; + struct CHIPSTATE *chip = data; struct CHIPDESC *desc = chiplist + chip->type; daemonize("%s", chip->c.name); allow_signal(SIGTERM); - dprintk("%s: thread started\n", chip->c.name); + tvaudio_dbg("%s: thread started\n", chip->c.name); for (;;) { add_wait_queue(&chip->wq, &wait); @@ -285,7 +299,7 @@ static int chip_thread(void *data) try_to_freeze(); if (chip->done || signal_pending(current)) break; - dprintk("%s: thread wakeup\n", chip->c.name); + tvaudio_dbg("%s: thread wakeup\n", chip->c.name); /* don't do anything for radio or if mode != auto */ if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) @@ -298,8 +312,8 @@ static int chip_thread(void *data) mod_timer(&chip->wt, jiffies+2*HZ); } - dprintk("%s: thread exiting\n", chip->c.name); - complete_and_exit(&chip->texit, 0); + tvaudio_dbg("%s: thread exiting\n", chip->c.name); + complete_and_exit(&chip->texit, 0); return 0; } @@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip) int mode = desc->getmode(chip); if (mode == chip->prevmode) - return; + return; - dprintk("%s: thread checkmode\n", chip->c.name); + tvaudio_dbg("%s: thread checkmode\n", chip->c.name); chip->prevmode = mode; if (mode & VIDEO_SOUND_STEREO) @@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip) if (val & TDA9840_ST_STEREO) mode |= VIDEO_SOUND_STEREO; - dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_STEREO; if (val & TDA9873_DUAL) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; - dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { - dprintk("tda9873_setmode(): external input\n"); + tvaudio_dbg("tda9873_setmode(): external input\n"); return; } - dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); - dprintk("tda9873_setmode(): sw_data = %d\n", sw_data); + tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); + tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); switch (mode) { case VIDEO_SOUND_MONO: @@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) } chip_write(chip, TDA9873_SW, sw_data); - dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", + tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n", mode, sw_data); } @@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip) } else { /* dic == 0x07 */ chip_write(chip, TDA9874A_AMCONR, 0xfb); chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); - chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10 + chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ } - dprintk("tda9874a_setup(): %s [0x%02X].\n", + tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); return 1; } @@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; } - dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", + tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", dsr, nsr, necr, mode); return mode; } @@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_AOSR, aosr); chip_write(chip, TDA9874A_MDACOSR, mdacosr); - dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", mode, aosr, mdacosr); } else { /* dic == 0x07 */ @@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_FMMR, fmmr); chip_write(chip, TDA9874A_AOSR, aosr); - dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", mode, fmmr, aosr); } } @@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) return 0; - dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); + tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); if((dic == 0x11)||(dic == 0x07)) { - printk("tvaudio: found tda9874%s.\n", (dic == 0x11) ? "a":"h"); + tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); tda9874a_dic = dic; /* remember device id. */ return 1; } @@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) /* ---------------------------------------------------------------------- */ /* audio chip descriptions - defines+functions for TA8874Z */ -// write 1st byte +/* write 1st byte */ #define TA8874Z_LED_STE 0x80 #define TA8874Z_LED_BIL 0x40 #define TA8874Z_LED_EXT 0x20 @@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) #define TA8874Z_MODE_SUB 0x02 #define TA8874Z_MODE_MAIN 0x01 -// write 2nd byte -//#define TA8874Z_TI 0x80 // test mode +/* write 2nd byte */ +/*#define TA8874Z_TI 0x80 */ /* test mode */ #define TA8874Z_SEPARATION 0x3f #define TA8874Z_SEPARATION_DEFAULT 0x10 -// read +/* read */ #define TA8874Z_B1 0x80 #define TA8874Z_B0 0x40 #define TA8874Z_CHAG_FLAG 0x20 -// B1 B0 -// mono L H -// stereo L L -// BIL H L - +/* + * B1 B0 + * mono L H + * stereo L L + * BIL H L + */ static int ta8874z_getmode(struct CHIPSTATE *chip) { int val, mode; @@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) }else if (!(val & TA8874Z_B0)){ mode |= VIDEO_SOUND_STEREO; } - //dprintk ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); + /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ return mode; } @@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) { int update = 1; audiocmd *t = NULL; - dprintk("ta8874z_setmode(): mode: 0x%02x\n", mode); + tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); switch(mode){ case VIDEO_SOUND_MONO: @@ -1235,11 +1250,11 @@ static int tda9850 = 1; static int tda9855 = 1; static int tda9873 = 1; static int tda9874a = 1; -static int tea6300 = 0; // address clash with msp34xx -static int tea6320 = 0; // address clash with msp34xx +static int tea6300 = 0; /* address clash with msp34xx */ +static int tea6320 = 0; /* address clash with msp34xx */ static int tea6420 = 1; static int pic16c54 = 1; -static int ta8874z = 0; // address clash with tda9840 +static int ta8874z = 0; /* address clash with tda9840 */ module_param(tda8425, int, 0444); module_param(tda9840, int, 0444); @@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = { { .name = "ta8874z", .id = -1, - //.id = I2C_DRIVERID_TA8874Z, + /*.id = I2C_DRIVERID_TA8874Z, */ .checkit = ta8874z_checkit, .insmodopt = &ta8874z, .addr_lo = I2C_TDA9840 >> 1, @@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) i2c_set_clientdata(&chip->c, chip); /* find description for the chip */ - dprintk("tvaudio: chip found @ i2c-addr=0x%x\n", addr<<1); + tvaudio_dbg("chip found @ 0x%x\n", addr<<1); for (desc = chiplist; desc->name != NULL; desc++) { if (0 == *(desc->insmodopt)) continue; @@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) break; } if (desc->name == NULL) { - dprintk("tvaudio: no matching chip description found\n"); + tvaudio_dbg("no matching chip description found\n"); return -EIO; } - printk("tvaudio: found %s @ 0x%x\n", desc->name, addr<<1); - dprintk("tvaudio: matches:%s%s%s.\n", - (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", - (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", - (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); + if (desc->flags) { + tvaudio_dbg("matches:%s%s%s.\n", + (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", + (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", + (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + } /* fill required data structures */ - strcpy(chip->c.name, desc->name); + strcpy(chip->c.name,desc->name); chip->type = desc-chiplist; chip->shadow.count = desc->registers+1; chip->prevmode = -1; @@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) init_completion(&chip->texit); chip->tpid = kernel_thread(chip_thread,(void *)chip,0); if (chip->tpid < 0) - printk(KERN_WARNING "%s: kernel_thread() failed\n", + tvaudio_warn("%s: kernel_thread() failed\n", chip->c.name); wake_up_interruptible(&chip->wq); } @@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap) { /* don't attach on saa7146 based cards, because dedicated drivers are used */ - if (adap->id == I2C_HW_SAA7146) + if ((adap->id == I2C_HW_SAA7146)) return 0; #ifdef I2C_CLASS_TV_ANALOG if (adap->class & I2C_CLASS_TV_ANALOG) @@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client) static int chip_command(struct i2c_client *client, unsigned int cmd, void *arg) { - __u16 *sarg = arg; + __u16 *sarg = arg; struct CHIPSTATE *chip = i2c_get_clientdata(client); struct CHIPDESC *desc = chiplist + chip->type; - dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); + tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd); switch (cmd) { case AUDC_SET_INPUT: @@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client, break; case AUDC_SET_RADIO: - dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n"); chip->norm = VIDEO_MODE_RADIO; chip->watch_stereo = 0; /* del_timer(&chip->wt); */ @@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client, /* --- v4l ioctls --- */ /* take care: bttv does userspace copying, we'll get a - kernel pointer here... */ + kernel pointer here... */ case VIDIOCGAUDIO: { struct video_audio *va = arg; @@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client, if (desc->flags & CHIP_HAS_VOLUME) { chip->left = (min(65536 - va->balance,32768) * - va->volume) / 32768; + va->volume) / 32768; chip->right = (min(va->balance,(__u16)32768) * - va->volume) / 32768; + va->volume) / 32768; chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); } @@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client, { struct video_channel *vc = arg; - dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n"); chip->norm = vc->norm; break; } case VIDIOCSFREQ: { - chip->mode = 0; /* automatic */ + chip->mode = 0; /* automatic */ if (desc->checkmode) { desc->setmode(chip,VIDEO_SOUND_MONO); - if (chip->prevmode != VIDEO_SOUND_MONO) - chip->prevmode = -1; /* reset previous mode */ + if (chip->prevmode != VIDEO_SOUND_MONO) + chip->prevmode = -1; /* reset previous mode */ mod_timer(&chip->wt, jiffies+2*HZ); /* the thread will call checkmode() later */ } @@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client, static struct i2c_driver driver = { .owner = THIS_MODULE, - .name = "generic i2c audio driver", - .id = I2C_DRIVERID_TVAUDIO, - .flags = I2C_DF_NOTIFY, - .attach_adapter = chip_probe, - .detach_client = chip_detach, - .command = chip_command, + .name = "generic i2c audio driver", + .id = I2C_DRIVERID_TVAUDIO, + .flags = I2C_DF_NOTIFY, + .attach_adapter = chip_probe, + .detach_client = chip_detach, + .command = chip_command, }; static struct i2c_client client_template = { .name = "(unset)", .flags = I2C_CLIENT_ALLOW_USE, - .driver = &driver, + .driver = &driver, }; static int __init audiochip_init_module(void) { struct CHIPDESC *desc; - printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); - printk(KERN_INFO "tvaudio: known chips: "); - for (desc = chiplist; desc->name != NULL; desc++) - printk("%s%s", (desc == chiplist) ? "" : ",",desc->name); - printk("\n"); + + if (debug) { + printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); + printk(KERN_INFO "tvaudio: known chips: "); + for (desc = chiplist; desc->name != NULL; desc++) + printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name); + printk("\n"); + } return i2c_add_driver(&driver); } -- cgit v1.2.3 From 0f97a931b337e4662e736ca67f1fab0a187f5852 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:05 -0700 Subject: [PATCH] v4l: tveeprom improved to support newer Hauppage cards - tveeprom improved and updated to reflect newer Hauppage cards. - CodingStyle fixes. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/bttv-cards.c | 3 +- drivers/media/video/bttv-driver.c | 1 + drivers/media/video/cx88/cx88-cards.c | 2 +- drivers/media/video/tveeprom.c | 327 ++++++++++++++++++++++++---------- 4 files changed, 232 insertions(+), 101 deletions(-) (limited to 'drivers') diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 10ab12ba4c6..190977a1e54 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -3060,7 +3060,7 @@ static void __devinit hauppauge_eeprom(struct bttv *btv) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&btv->i2c_client, &tv, eeprom_data); btv->tuner_type = tv.tuner_type; btv->has_radio = tv.has_radio; } @@ -4485,6 +4485,7 @@ void __devinit bttv_check_chipset(void) } if (UNSET != latency) printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency); + while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, dev))) { unsigned char b; diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index b35c586a225..a564321db2f 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -4079,6 +4079,7 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) struct bttv_buffer_set idle; unsigned long flags; + dprintk("bttv%d: suspend %d\n", btv->c.nr, state.event); /* stop dma + irqs */ spin_lock_irqsave(&btv->s_lock,flags); diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 92623231db7..4da91d535a5 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c @@ -945,7 +945,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); core->tuner_type = tv.tuner_type; core->has_radio = tv.has_radio; } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 367401449e3..5344d559219 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -47,18 +47,21 @@ MODULE_LICENSE("GPL"); static int debug = 0; module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug level (0-2)"); +MODULE_PARM_DESC(debug, "Debug level (0-1)"); #define STRM(array,i) (i < sizeof(array)/sizeof(char*) ? array[i] : "unknown") -#define dprintk(num, args...) \ - do { \ - if (debug >= num) \ - printk(KERN_INFO "tveeprom: " args); \ - } while (0) +#define tveeprom_info(fmt, arg...) do {\ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) -#define TVEEPROM_KERN_ERR(args...) printk(KERN_ERR "tveeprom: " args); -#define TVEEPROM_KERN_INFO(args...) printk(KERN_INFO "tveeprom: " args); /* ----------------------------------------------------------------------- */ /* some hauppauge specific stuff */ @@ -70,14 +73,14 @@ static struct HAUPPAUGE_TUNER_FMT } hauppauge_tuner_fmt[] = { - { 0x00000000, "unknown1" }, - { 0x00000000, "unknown2" }, - { 0x00000007, "PAL(B/G)" }, - { 0x00001000, "NTSC(M)" }, - { 0x00000010, "PAL(I)" }, - { 0x00400000, "SECAM(L/L´)" }, - { 0x00000e00, "PAL(D/K)" }, - { 0x03000000, "ATSC Digital" }, + { 0x00000000, " unknown1" }, + { 0x00000000, " unknown2" }, + { 0x00000007, " PAL(B/G)" }, + { 0x00001000, " NTSC(M)" }, + { 0x00000010, " PAL(I)" }, + { 0x00400000, " SECAM(L/L')" }, + { 0x00000e00, " PAL(D/K)" }, + { 0x03000000, " ATSC Digital" }, }; /* This is the full list of possible tuners. Many thanks to Hauppauge for @@ -203,20 +206,47 @@ hauppauge_tuner[] = { TUNER_TCL_2002N, "TCL 2002N 5H"}, /* 100-103 */ { TUNER_ABSENT, "Unspecified"}, - { TUNER_ABSENT, "Unspecified"}, + { TUNER_TEA5767, "Philips TEA5767HN FM Radio"}, { TUNER_ABSENT, "Unspecified"}, { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, }; -static char *sndtype[] = { - "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", "MSP3410D", - "MSP3415", "MSP3430", "MSP3438", "CS5331", "MSP3435", "MSP3440", - "MSP3445", "MSP3411", "MSP3416", "MSP3425", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *audioIC[] = { + /* 0-4 */ + "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", + /* 5-9 */ + "MSP3410D", "MSP3415", "MSP3430", "MSP3438", "CS5331", + /* 10-14 */ + "MSP3435", "MSP3440", "MSP3445", "MSP3411", "MSP3416", + /* 15-19 */ + "MSP3425", "MSP3451", "MSP3418", "Type 0x12", "OKI7716", + /* 20-24 */ + "MSP4410", "MSP4420", "MSP4440", "MSP4450", "MSP4408", + /* 25-29 */ + "MSP4418", "MSP4428", "MSP4448", "MSP4458", "Type 0x1d", + /* 30-34 */ + "CX880", "CX881", "CX883", "CX882", "CX25840", + /* 35-38 */ + "CX25841", "CX25842", "CX25843", "CX23418", +}; - "Type 0x10","Type 0x11","Type 0x12","Type 0x13", - "Type 0x14","Type 0x15","Type 0x16","Type 0x17", - "Type 0x18","MSP4418","Type 0x1a","MSP4448", - "Type 0x1c","Type 0x1d","Type 0x1e","Type 0x1f", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *decoderIC[] = { + /* 0-4 */ + "None", "BT815", "BT817", "BT819", "BT815A", + /* 5-9 */ + "BT817A", "BT819A", "BT827", "BT829", "BT848", + /* 10-14 */ + "BT848A", "BT849A", "BT829A", "BT827A", "BT878", + /* 15-19 */ + "BT879", "BT880", "VPX3226E", "SAA7114", "SAA7115", + /* 20-24 */ + "CX880", "CX881", "CX883", "SAA7111", "SAA7113", + /* 25-29 */ + "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", + /* 30-31 */ + "CX25843", "CX23418", }; static int hasRadioTuner(int tunerType) @@ -257,7 +287,8 @@ static int hasRadioTuner(int tunerType) return 0; } -void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data) +void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, + unsigned char *eeprom_data) { /* ---------------------------------------------- ** The hauppauge eeprom format is tagged @@ -267,10 +298,11 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** if packet[0] & f8 == f8, then EOD and packet[1] == checksum ** ** In our (ivtv) case we're interested in the following: - ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) - ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) - ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) - ** audio proc: tag [02].01 or [05].00 (lower nibble indexes lut?) + ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) + ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) + ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) + ** audio proc: tag [02].01 or [05].00 (mask with 0x7f) + ** decoder proc: tag [09].01) ** Fun info: ** model: tag [00].07-08 or [06].00-01 @@ -280,20 +312,24 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** # of inputs/outputs ??? */ - int i, j, len, done, beenhere, tag, tuner = 0, t_format = 0; - char *t_name = NULL, *t_fmt_name = NULL; + int i, j, len, done, beenhere, tag; - dprintk(1, "%s\n",__FUNCTION__); - tvee->revision = done = len = beenhere = 0; - for (i = 0; !done && i < 256; i += len) { - dprintk(2, "processing pos = %02x (%02x, %02x)\n", - i, eeprom_data[i], eeprom_data[i + 1]); + int tuner1 = 0, t_format1 = 0; + char *t_name1 = NULL; + const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" }; + int tuner2 = 0, t_format2 = 0; + char *t_name2 = NULL; + const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; + + memset(tvee, 0, sizeof(*tvee)); + done = len = beenhere = 0; + for (i = 0; !done && i < 256; i += len) { if (eeprom_data[i] == 0x84) { len = eeprom_data[i + 1] + (eeprom_data[i + 2] << 8); - i+=3; + i += 3; } else if ((eeprom_data[i] & 0xf0) == 0x70) { - if ((eeprom_data[i] & 0x08)) { + if (eeprom_data[i] & 0x08) { /* verify checksum! */ done = 1; break; @@ -301,24 +337,30 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data len = eeprom_data[i] & 0x07; ++i; } else { - TVEEPROM_KERN_ERR("Encountered bad packet header [%02x]. " + tveeprom_warn("Encountered bad packet header [%02x]. " "Corrupt or not a Hauppauge eeprom.\n", eeprom_data[i]); return; } - dprintk(1, "%3d [%02x] ", len, eeprom_data[i]); - for(j = 1; j < len; j++) { - dprintk(1, "%02x ", eeprom_data[i + j]); - } - dprintk(1, "\n"); + if (debug) { + tveeprom_info("Tag [%02x] + %d bytes:", eeprom_data[i], len - 1); + for(j = 1; j < len; j++) { + printk(" %02x", eeprom_data[i + j]); + } + printk("\n"); + } /* process by tag */ tag = eeprom_data[i]; switch (tag) { case 0x00: - tuner = eeprom_data[i+6]; - t_format = eeprom_data[i+5]; + /* tag: 'Comprehensive' */ + tuner1 = eeprom_data[i+6]; + t_format1 = eeprom_data[i+5]; tvee->has_radio = eeprom_data[i+len-1]; + /* old style tag, don't know how to detect + IR presence, mark as unknown. */ + tvee->has_ir = 2; tvee->model = eeprom_data[i+8] + (eeprom_data[i+9] << 8); @@ -326,25 +368,43 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+11] << 8) + (eeprom_data[i+12] << 16); break; + case 0x01: + /* tag: 'SerialID' */ tvee->serial_number = eeprom_data[i+6] + (eeprom_data[i+7] << 8) + (eeprom_data[i+8] << 16); break; + case 0x02: - tvee->audio_processor = eeprom_data[i+2] & 0x0f; + /* tag 'AudioInfo' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+2] & 0x7f; break; + + /* case 0x03: tag 'EEInfo' */ + case 0x04: + /* tag 'SerialID2' */ tvee->serial_number = eeprom_data[i+5] + (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + case 0x05: - tvee->audio_processor = eeprom_data[i+1] & 0x0f; + /* tag 'Audio2' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+1] & 0x7f; break; + case 0x06: + /* tag 'ModelRev' */ tvee->model = eeprom_data[i+1] + (eeprom_data[i+2] << 8); @@ -352,27 +412,66 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + + case 0x07: + /* tag 'Details': according to Hauppauge not interesting + on any PCI-era or later boards. */ + break; + + /* there is no tag 0x08 defined */ + + case 0x09: + /* tag 'Video' */ + tvee->decoder_processor = eeprom_data[i + 1]; + break; + case 0x0a: - if(beenhere == 0) { - tuner = eeprom_data[i+2]; - t_format = eeprom_data[i+1]; + /* tag 'Tuner' */ + if (beenhere == 0) { + tuner1 = eeprom_data[i+2]; + t_format1 = eeprom_data[i+1]; beenhere = 1; - break; } else { - break; - } + /* a second (radio) tuner may be present */ + tuner2 = eeprom_data[i+2]; + t_format2 = eeprom_data[i+1]; + if (t_format2 == 0) { /* not a TV tuner? */ + tvee->has_radio = 1; /* must be radio */ + } + } + break; + + case 0x0b: + /* tag 'Inputs': according to Hauppauge this is specific + to each driver family, so no good assumptions can be + made. */ + break; + + /* case 0x0c: tag 'Balun' */ + /* case 0x0d: tag 'Teletext' */ + case 0x0e: + /* tag: 'Radio' */ tvee->has_radio = eeprom_data[i+1]; break; + + case 0x0f: + /* tag 'IRInfo' */ + tvee->has_ir = eeprom_data[i+1]; + break; + + /* case 0x10: tag 'VBIInfo' */ + /* case 0x11: tag 'QCInfo' */ + /* case 0x12: tag 'InfoBits' */ + default: - dprintk(1, "Not sure what to do with tag [%02x]\n", tag); + tveeprom_dbg("Not sure what to do with tag [%02x]\n", tag); /* dump the rest of the packet? */ } - } if (!done) { - TVEEPROM_KERN_ERR("Ran out of data!\n"); + tveeprom_warn("Ran out of data!\n"); return; } @@ -384,47 +483,72 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data tvee->rev_str[4] = 0; } - if (hasRadioTuner(tuner) && !tvee->has_radio) { - TVEEPROM_KERN_INFO("The eeprom says no radio is present, but the tuner type\n"); - TVEEPROM_KERN_INFO("indicates otherwise. I will assume that radio is present.\n"); + if (hasRadioTuner(tuner1) && !tvee->has_radio) { + tveeprom_info("The eeprom says no radio is present, but the tuner type\n"); + tveeprom_info("indicates otherwise. I will assume that radio is present.\n"); tvee->has_radio = 1; } - if (tuner < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { - tvee->tuner_type = hauppauge_tuner[tuner].id; - t_name = hauppauge_tuner[tuner].name; + if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner_type = hauppauge_tuner[tuner1].id; + t_name1 = hauppauge_tuner[tuner1].name; } else { - t_name = ""; + t_name1 = "unknown"; + } + + if (tuner2 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner2_type = hauppauge_tuner[tuner2].id; + t_name2 = hauppauge_tuner[tuner2].name; + } else { + t_name2 = "unknown"; } tvee->tuner_formats = 0; - t_fmt_name = ""; - for (i = 0; i < 8; i++) { - if (t_format & (1<tuner2_formats = 0; + for (i = j = 0; i < 8; i++) { + if (t_format1 & (1 << i)) { tvee->tuner_formats |= hauppauge_tuner_fmt[i].id; - /* yuck */ - t_fmt_name = hauppauge_tuner_fmt[i].name; + t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name; } + if (t_format2 & (1 << i)) { + tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id; + t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name; + } } - - TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n", - tvee->model, - tvee->rev_str, - tvee->serial_number); - TVEEPROM_KERN_INFO("tuner = %s (idx = %d, type = %d)\n", - t_name, - tuner, - tvee->tuner_type); - TVEEPROM_KERN_INFO("tuner fmt = %s (eeprom = 0x%02x, v4l2 = 0x%08x)\n", - t_fmt_name, - t_format, - tvee->tuner_formats); - - TVEEPROM_KERN_INFO("audio_processor = %s (type = %d)\n", - STRM(sndtype,tvee->audio_processor), + tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", + tvee->model, tvee->rev_str, tvee->serial_number); + tveeprom_info("tuner model is %s (idx %d, type %d)\n", + t_name1, tuner1, tvee->tuner_type); + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], t_fmt_name1[3], + t_fmt_name1[4], t_fmt_name1[5], t_fmt_name1[6], t_fmt_name1[7], + t_format1); + if (tuner2) { + tveeprom_info("second tuner model is %s (idx %d, type %d)\n", + t_name2, tuner2, tvee->tuner2_type); + } + if (t_format2) { + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], t_fmt_name2[3], + t_fmt_name2[4], t_fmt_name2[5], t_fmt_name2[6], t_fmt_name2[7], + t_format2); + } + tveeprom_info("audio processor is %s (idx %d)\n", + STRM(audioIC, tvee->audio_processor), tvee->audio_processor); - + if (tvee->decoder_processor) { + tveeprom_info("decoder processor is %s (idx %d)\n", + STRM(decoderIC, tvee->decoder_processor), + tvee->decoder_processor); + } + if (tvee->has_ir == 2) + tveeprom_info("has %sradio\n", + tvee->has_radio ? "" : "no "); + else + tveeprom_info("has %sradio, has %sIR remote\n", + tvee->has_radio ? "" : "no ", + tvee->has_ir ? "" : "no "); } EXPORT_SYMBOL(tveeprom_hauppauge_analog); @@ -436,23 +560,31 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) unsigned char buf; int err; - dprintk(1, "%s\n",__FUNCTION__); buf = 0; - if (1 != (err = i2c_master_send(c,&buf,1))) { - printk(KERN_INFO "tveeprom(%s): Huh, no eeprom present (err=%d)?\n", - c->name,err); + if (1 != (err = i2c_master_send(c, &buf, 1))) { + tveeprom_info("Huh, no eeprom present (err=%d)?\n", err); return -1; } - if (len != (err = i2c_master_recv(c,eedata,len))) { - printk(KERN_WARNING "tveeprom(%s): i2c eeprom read error (err=%d)\n", - c->name,err); + if (len != (err = i2c_master_recv(c, eedata, len))) { + tveeprom_warn("i2c eeprom read error (err=%d)\n", err); return -1; } + if (debug) { + int i; + + tveeprom_info("full 256-byte eeprom dump:\n"); + for (i = 0; i < len; i++) { + if (0 == (i % 16)) + tveeprom_info("%02x:", i); + printk(" %02x", eedata[i]); + if (15 == (i % 16)) + printk("\n"); + } + } return 0; } EXPORT_SYMBOL(tveeprom_read); - /* ----------------------------------------------------------------------- */ /* needed for ivtv.sf.net at the moment. Should go away in the long */ /* run, just call the exported tveeprom_* directly, there is no point in */ @@ -485,7 +617,7 @@ tveeprom_command(struct i2c_client *client, buf = kmalloc(256,GFP_KERNEL); memset(buf,0,256); tveeprom_read(client,buf,256); - tveeprom_hauppauge_analog(&eeprom,buf); + tveeprom_hauppauge_analog(client, &eeprom,buf); kfree(buf); eeprom_props[0] = eeprom.tuner_type; eeprom_props[1] = eeprom.tuner_formats; @@ -506,8 +638,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, { struct i2c_client *client; - dprintk(1,"%s: id 0x%x @ 0x%x\n",__FUNCTION__, - adapter->id, address << 1); client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (NULL == client) return -ENOMEM; @@ -524,7 +654,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, static int tveeprom_attach_adapter (struct i2c_adapter *adapter) { - dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id); if (adapter->id != I2C_HW_B_BT848) return 0; return i2c_probe(adapter, &addr_data, tveeprom_detect_client); -- cgit v1.2.3 From badf16621c1f9d1ac753be056fce11b43d6e0be5 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:10 -0700 Subject: [PATCH] files: break up files struct In order for the RCU to work, the file table array, sets and their sizes must be updated atomically. Instead of ensuring this through too many memory barriers, we put the arrays and their sizes in a separate structure. This patch takes the first step of putting the file table elements in a separate structure fdtable that is embedded withing files_struct. It also changes all the users to refer to the file table using files_fdtable() macro. Subsequent applciation of RCU becomes easier after this. Signed-off-by: Dipankar Sarma Signed-Off-By: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tty_io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 6a56ae4f772..0bfc7af6891 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2454,6 +2454,7 @@ static void __do_SAK(void *arg) int i; struct file *filp; struct tty_ldisc *disc; + struct fdtable *fdt; if (!tty) return; @@ -2480,7 +2481,8 @@ static void __do_SAK(void *arg) task_lock(p); if (p->files) { spin_lock(&p->files->file_lock); - for (i=0; i < p->files->max_fds; i++) { + fdt = files_fdtable(p->files); + for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); if (!filp) continue; -- cgit v1.2.3 From b835996f628eadb55c5fb222ba46fe9395bf73c7 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:14 -0700 Subject: [PATCH] files: lock-free fd look-up With the use of RCU in files structure, the look-up of files using fds can now be lock-free. The lookup is protected by rcu_read_lock()/rcu_read_unlock(). This patch changes the readers to use lock-free lookup. Signed-off-by: Maneesh Soni Signed-off-by: Ravikiran Thirumalai Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/tty_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 0bfc7af6891..e5953f3433f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2480,7 +2480,7 @@ static void __do_SAK(void *arg) } task_lock(p); if (p->files) { - spin_lock(&p->files->file_lock); + rcu_read_lock(); fdt = files_fdtable(p->files); for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); @@ -2495,7 +2495,7 @@ static void __do_SAK(void *arg) break; } } - spin_unlock(&p->files->file_lock); + rcu_read_unlock(); } task_unlock(p); } while_each_task_pid(session, PIDTYPE_SID, p); -- cgit v1.2.3 From 7726e9e10fc6e026ed2dc00e48f4a3ffc1254ad2 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Fri, 9 Sep 2005 13:04:29 -0700 Subject: [PATCH] fbdev: Add fbset -a support Add capability to fbdev to listen to the FB_ACTIVATE_ALL flag. If set, it notifies fbcon that all consoles must be set to the current var. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/console/fbcon.c | 48 +++++++++++++++++++++++++++++++++++++++++++ drivers/video/fbmem.c | 6 ++++-- 2 files changed, 52 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 35c88bd7ba5..751890a5f5f 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -2593,6 +2593,51 @@ static void fbcon_modechanged(struct fb_info *info) } } +static void fbcon_set_all_vcs(struct fb_info *info) +{ + struct fbcon_ops *ops = info->fbcon_par; + struct vc_data *vc; + struct display *p; + int i, rows, cols; + + if (!ops || ops->currcon < 0) + return; + + for (i = 0; i < MAX_NR_CONSOLES; i++) { + vc = vc_cons[i].d; + if (!vc || vc->vc_mode != KD_TEXT || + registered_fb[con2fb_map[i]] != info) + continue; + + p = &fb_display[vc->vc_num]; + + info->var.xoffset = info->var.yoffset = p->yscroll = 0; + var_to_display(p, &info->var, info); + cols = info->var.xres / vc->vc_font.width; + rows = info->var.yres / vc->vc_font.height; + vc_resize(vc, cols, rows); + + if (CON_IS_VISIBLE(vc)) { + updatescrollmode(p, info, vc); + scrollback_max = 0; + scrollback_current = 0; + update_var(vc->vc_num, info); + fbcon_set_palette(vc, color_table); + update_screen(vc); + if (softback_buf) { + int l = fbcon_softback_size / vc->vc_size_row; + if (l > 5) + softback_end = softback_buf + l * vc->vc_size_row; + else { + /* Smaller scrollback makes no sense, and 0 + would screw the operation totally */ + softback_top = 0; + } + } + } + } +} + static int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { @@ -2708,6 +2753,9 @@ static int fbcon_event_notify(struct notifier_block *self, case FB_EVENT_MODE_CHANGE: fbcon_modechanged(info); break; + case FB_EVENT_MODE_CHANGE_ALL: + fbcon_set_all_vcs(info); + break; case FB_EVENT_MODE_DELETE: mode = event->data; ret = fbcon_mode_deleted(info, mode); diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 4ff853fbe0b..a8eee79e117 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -684,11 +684,13 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (!err && (flags & FBINFO_MISC_USEREVENT)) { struct fb_event event; + int evnt = (var->activate & FB_ACTIVATE_ALL) ? + FB_EVENT_MODE_CHANGE_ALL : + FB_EVENT_MODE_CHANGE; info->flags &= ~FBINFO_MISC_USEREVENT; event.info = info; - notifier_call_chain(&fb_notifier_list, - FB_EVENT_MODE_CHANGE, + notifier_call_chain(&fb_notifier_list, evnt, &event); } } -- cgit v1.2.3 From d2d58384fc5d4c0fe2d8e34bc2d15a90a9bb372a Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Fri, 9 Sep 2005 13:04:31 -0700 Subject: [PATCH] vesafb: Add blanking support Add rudimentary support by manipulating the VGA registers. However, not all vesa modes are VGA compatible, so VGA compatiblity is checked first. Only 2 levels are supported, powerup and powerdown. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/vesafb.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'drivers') diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index a272592b037..1ca80264c7b 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c @@ -19,6 +19,7 @@ #include #include #include +#include