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 diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index c4909b4..82b330b 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 2bb2fe7..b350827 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" @@ -520,6 +521,12 @@ static int psmouse_extensions(struct psmouse *psmouse, 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. */ @@ -600,6 +607,12 @@ static struct psmouse_protocol psmouse_protocols[] = { .init = lifebook_init, }, { + .type = PSMOUSE_TRACKPOINT, + .name = "TPPS/2", + .alias = "trackpoint", + .detect = trackpoint_detect, + }, + { .type = PSMOUSE_AUTO, .name = "auto", .alias = "any", @@ -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 86691cf..e312a6b 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 0000000..aee3b24 --- /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 0000000..9857d8b --- /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 v0.10.2 From b1b5d7f9b7ac6a8e3452ac43a53eebf69fdf5a77 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Tue, 30 Aug 2005 14:28:56 -0500 Subject: JFS: jfs_delete_inode should always call clear_inode. Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 767c7ec..37da3e3 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -128,21 +128,21 @@ void jfs_delete_inode(struct inode *inode) { jfs_info("In jfs_delete_inode, inode = 0x%p", inode); - if (is_bad_inode(inode) || - (JFS_IP(inode)->fileset != cpu_to_le32(FILESYSTEM_I))) - return; + if (!is_bad_inode(inode) && + (JFS_IP(inode)->fileset == cpu_to_le32(FILESYSTEM_I))) { - if (test_cflag(COMMIT_Freewmap, inode)) - jfs_free_zero_link(inode); + if (test_cflag(COMMIT_Freewmap, inode)) + jfs_free_zero_link(inode); - diFree(inode); + diFree(inode); - /* - * Free the inode from the quota allocation. - */ - DQUOT_INIT(inode); - DQUOT_FREE_INODE(inode); - DQUOT_DROP(inode); + /* + * Free the inode from the quota allocation. + */ + DQUOT_INIT(inode); + DQUOT_FREE_INODE(inode); + DQUOT_DROP(inode); + } clear_inode(inode); } -- cgit v0.10.2 From dc90e95f310f4f821c905b2aec8e9449bb3270fa Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Wed, 24 Aug 2005 17:13:00 -0700 Subject: [IA64] Add PAL_VM_SUMMARY/PAL_MEM_ATTRIB to bootloader for SKI This patch implements PAL_VM_SUMMARY (and PAL_MEM_ATTRIB for good measure) and pretends that the simulated machine is a McKinley. Some extra comments and clean-up by Tony Luck. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/hp/sim/boot/boot_head.S b/arch/ia64/hp/sim/boot/boot_head.S index 1c8c7e6..a9bd71a 100644 --- a/arch/ia64/hp/sim/boot/boot_head.S +++ b/arch/ia64/hp/sim/boot/boot_head.S @@ -4,6 +4,7 @@ */ #include +#include .bss .align 16 @@ -49,7 +50,11 @@ GLOBAL_ENTRY(jmp_to_kernel) br.sptk.few b7 END(jmp_to_kernel) - +/* + * r28 contains the index of the PAL function + * r29--31 the args + * Return values in ret0--3 (r8--11) + */ GLOBAL_ENTRY(pal_emulator_static) mov r8=-1 mov r9=256 @@ -62,7 +67,7 @@ GLOBAL_ENTRY(pal_emulator_static) cmp.gtu p6,p7=r9,r28 (p6) br.cond.sptk.few stacked ;; -static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ +static: cmp.eq p6,p7=PAL_PTCE_INFO,r28 (p7) br.cond.sptk.few 1f ;; mov r8=0 /* status = 0 */ @@ -70,21 +75,21 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ movl r10=0x0000000200000003 /* count[0], count[1] */ movl r11=0x1000000000002000 /* stride[0], stride[1] */ br.cond.sptk.few rp -1: cmp.eq p6,p7=14,r28 /* PAL_FREQ_RATIOS */ +1: cmp.eq p6,p7=PAL_FREQ_RATIOS,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ movl r9 =0x100000064 /* proc_ratio (1/100) */ movl r10=0x100000100 /* bus_ratio<<32 (1/256) */ movl r11=0x100000064 /* itc_ratio<<32 (1/100) */ ;; -1: cmp.eq p6,p7=19,r28 /* PAL_RSE_INFO */ +1: cmp.eq p6,p7=PAL_RSE_INFO,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ mov r9=96 /* num phys stacked */ mov r10=0 /* hints */ mov r11=0 br.cond.sptk.few rp -1: cmp.eq p6,p7=1,r28 /* PAL_CACHE_FLUSH */ +1: cmp.eq p6,p7=PAL_CACHE_FLUSH,r28 /* PAL_CACHE_FLUSH */ (p7) br.cond.sptk.few 1f mov r9=ar.lc movl r8=524288 /* flush 512k million cache lines (16MB) */ @@ -102,7 +107,7 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ mov ar.lc=r9 mov r8=r0 ;; -1: cmp.eq p6,p7=15,r28 /* PAL_PERF_MON_INFO */ +1: cmp.eq p6,p7=PAL_PERF_MON_INFO,r28 (p7) br.cond.sptk.few 1f mov r8=0 /* status = 0 */ movl r9 =0x08122f04 /* generic=4 width=47 retired=8 cycles=18 */ @@ -138,6 +143,20 @@ static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */ st8 [r29]=r0,16 /* clear remaining bits */ st8 [r18]=r0,16 /* clear remaining bits */ ;; +1: cmp.eq p6,p7=PAL_VM_SUMMARY,r28 +(p7) br.cond.sptk.few 1f + mov r8=0 /* status = 0 */ + movl r9=0x2044040020F1865 /* num_tc_levels=2, num_unique_tcs=4 */ + /* max_itr_entry=64, max_dtr_entry=64 */ + /* hash_tag_id=2, max_pkr=15 */ + /* key_size=24, phys_add_size=50, vw=1 */ + movl r10=0x183C /* rid_size=24, impl_va_msb=60 */ + ;; +1: cmp.eq p6,p7=PAL_MEM_ATTRIB,r28 +(p7) br.cond.sptk.few 1f + mov r8=0 /* status = 0 */ + mov r9=0x80|0x01 /* NatPage|WB */ + ;; 1: br.cond.sptk.few rp stacked: br.ret.sptk.few rp -- cgit v0.10.2 From 714d2dc14914f0f7bb008effe830c99eb47c75df Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Thu, 25 Aug 2005 17:39:00 -0700 Subject: [IA64] Allow /proc/pal/cpu0/vm_info under the simulator Not all of the PAL VM calls are implemented for the SKI simulator. Don't just give up if one fails, print information from the calls that succeed. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c index 25e7c83..89faa60 100644 --- a/arch/ia64/kernel/palinfo.c +++ b/arch/ia64/kernel/palinfo.c @@ -307,11 +307,9 @@ vm_info(char *page) if ((status = ia64_pal_vm_summary(&vm_info_1, &vm_info_2)) !=0) { printk(KERN_ERR "ia64_pal_vm_summary=%ld\n", status); - return 0; - } + } else { - - p += sprintf(p, + p += sprintf(p, "Physical Address Space : %d bits\n" "Virtual Address Space : %d bits\n" "Protection Key Registers(PKR) : %d\n" @@ -319,92 +317,99 @@ vm_info(char *page) "Hash Tag ID : 0x%x\n" "Size of RR.rid : %d\n", vm_info_1.pal_vm_info_1_s.phys_add_size, - vm_info_2.pal_vm_info_2_s.impl_va_msb+1, vm_info_1.pal_vm_info_1_s.max_pkr+1, - vm_info_1.pal_vm_info_1_s.key_size, vm_info_1.pal_vm_info_1_s.hash_tag_id, + vm_info_2.pal_vm_info_2_s.impl_va_msb+1, + vm_info_1.pal_vm_info_1_s.max_pkr+1, + vm_info_1.pal_vm_info_1_s.key_size, + vm_info_1.pal_vm_info_1_s.hash_tag_id, vm_info_2.pal_vm_info_2_s.rid_size); + } - if (ia64_pal_mem_attrib(&attrib) != 0) - return 0; - - p += sprintf(p, "Supported memory attributes : "); - sep = ""; - for (i = 0; i < 8; i++) { - if (attrib & (1 << i)) { - p += sprintf(p, "%s%s", sep, mem_attrib[i]); - sep = ", "; + if (ia64_pal_mem_attrib(&attrib) == 0) { + p += sprintf(p, "Supported memory attributes : "); + sep = ""; + for (i = 0; i < 8; i++) { + if (attrib & (1 << i)) { + p += sprintf(p, "%s%s", sep, mem_attrib[i]); + sep = ", "; + } } + p += sprintf(p, "\n"); } - p += sprintf(p, "\n"); if ((status = ia64_pal_vm_page_size(&tr_pages, &vw_pages)) !=0) { printk(KERN_ERR "ia64_pal_vm_page_size=%ld\n", status); - return 0; - } - - p += sprintf(p, - "\nTLB walker : %simplemented\n" - "Number of DTR : %d\n" - "Number of ITR : %d\n" - "TLB insertable page sizes : ", - vm_info_1.pal_vm_info_1_s.vw ? "" : "not ", - vm_info_1.pal_vm_info_1_s.max_dtr_entry+1, - vm_info_1.pal_vm_info_1_s.max_itr_entry+1); + } else { + p += sprintf(p, + "\nTLB walker : %simplemented\n" + "Number of DTR : %d\n" + "Number of ITR : %d\n" + "TLB insertable page sizes : ", + vm_info_1.pal_vm_info_1_s.vw ? "" : "not ", + vm_info_1.pal_vm_info_1_s.max_dtr_entry+1, + vm_info_1.pal_vm_info_1_s.max_itr_entry+1); - p = bitvector_process(p, tr_pages); - p += sprintf(p, "\nTLB purgeable page sizes : "); + p = bitvector_process(p, tr_pages); - p = bitvector_process(p, vw_pages); + p += sprintf(p, "\nTLB purgeable page sizes : "); + p = bitvector_process(p, vw_pages); + } if ((status=ia64_get_ptce(&ptce)) != 0) { printk(KERN_ERR "ia64_get_ptce=%ld\n", status); - return 0; - } - - p += sprintf(p, + } else { + p += sprintf(p, "\nPurge base address : 0x%016lx\n" "Purge outer loop count : %d\n" "Purge inner loop count : %d\n" "Purge outer loop stride : %d\n" "Purge inner loop stride : %d\n", - ptce.base, ptce.count[0], ptce.count[1], ptce.stride[0], ptce.stride[1]); + ptce.base, ptce.count[0], ptce.count[1], + ptce.stride[0], ptce.stride[1]); - p += sprintf(p, + p += sprintf(p, "TC Levels : %d\n" "Unique TC(s) : %d\n", vm_info_1.pal_vm_info_1_s.num_tc_levels, vm_info_1.pal_vm_info_1_s.max_unique_tcs); - for(i=0; i < vm_info_1.pal_vm_info_1_s.num_tc_levels; i++) { - for (j=2; j>0 ; j--) { - tc_pages = 0; /* just in case */ + for(i=0; i < vm_info_1.pal_vm_info_1_s.num_tc_levels; i++) { + for (j=2; j>0 ; j--) { + tc_pages = 0; /* just in case */ - /* even without unification, some levels may not be present */ - if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0) { - continue; - } + /* even without unification, some levels may not be present */ + if ((status=ia64_pal_vm_info(i,j, &tc_info, &tc_pages)) != 0) { + continue; + } - p += sprintf(p, + p += sprintf(p, "\n%s Translation Cache Level %d:\n" "\tHash sets : %d\n" "\tAssociativity : %d\n" "\tNumber of entries : %d\n" "\tFlags : ", - cache_types[j+tc_info.tc_unified], i+1, tc_info.tc_num_sets, - tc_info.tc_associativity, tc_info.tc_num_entries); + cache_types[j+tc_info.tc_unified], i+1, + tc_info.tc_num_sets, + tc_info.tc_associativity, + tc_info.tc_num_entries); - if (tc_info.tc_pf) p += sprintf(p, "PreferredPageSizeOptimized "); - if (tc_info.tc_unified) p += sprintf(p, "Unified "); - if (tc_info.tc_reduce_tr) p += sprintf(p, "TCReduction"); + if (tc_info.tc_pf) + p += sprintf(p, "PreferredPageSizeOptimized "); + if (tc_info.tc_unified) + p += sprintf(p, "Unified "); + if (tc_info.tc_reduce_tr) + p += sprintf(p, "TCReduction"); - p += sprintf(p, "\n\tSupported page sizes: "); + p += sprintf(p, "\n\tSupported page sizes: "); - p = bitvector_process(p, tc_pages); + p = bitvector_process(p, tc_pages); - /* when unified date (j=2) is enough */ - if (tc_info.tc_unified) break; + /* when unified date (j=2) is enough */ + if (tc_info.tc_unified) + break; + } } } p += sprintf(p, "\n"); @@ -440,14 +445,14 @@ register_info(char *page) p += sprintf(p, "\n"); } - if (ia64_pal_rse_info(&phys_stacked, &hints) != 0) return 0; + if (ia64_pal_rse_info(&phys_stacked, &hints) == 0) { p += sprintf(p, "RSE stacked physical registers : %ld\n" "RSE load/store hints : %ld (%s)\n", phys_stacked, hints.ph_data, hints.ph_data < RSE_HINTS_COUNT ? rse_hints[hints.ph_data]: "(??)"); - + } if (ia64_pal_debug_info(&iregs, &dregs)) return 0; -- cgit v0.10.2 From 6cf07a8cc86a0b471466c7fe45892f7ef434015b Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Tue, 23 Aug 2005 20:07:00 -0700 Subject: [IA64] Fix nasty VMLPT problem... I've solved the problem I was having with the simulator and not booting Debian. The problem is that the number of bits for the virtual linear array short-format VHPT (Virtually mapped linear page table, VMLPT for short) is being tested incorrectly. There are two problems: 1. The PAL call that should tell the kernel the size of the virtual address space isn't implemented for the simulator, so the kernel uses the default 50. This is addressed separately in dc90e95f310f4f821c905b2aec8e9449bb3270fa 2. In arch/ia64/mm/init.c there's code to calcualte the size of the VMLPT based on the number of implemented virtual address bits and the page size. It checks to see if the VMLPT base address overlaps the top of the mapped region, but this check doesn't allow for the address space hole, and in fact will never trigger. Here's an alternative test and panic, that I think is more accurate. Signed-off-by: Peter Chubb Signed-off-by: Tony Luck diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 65f9958..1281c60 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -382,13 +382,22 @@ ia64_mmu_init (void *my_cpu_data) if (impl_va_bits < 51 || impl_va_bits > 61) panic("CPU has bogus IMPL_VA_MSB value of %lu!\n", impl_va_bits - 1); + /* + * mapped_space_bits - PAGE_SHIFT is the total number of ptes we need, + * which must fit into "vmlpt_bits - pte_bits" slots. Second half of + * the test makes sure that our mapped space doesn't overlap the + * unimplemented hole in the middle of the region. + */ + if ((mapped_space_bits - PAGE_SHIFT > vmlpt_bits - pte_bits) || + (mapped_space_bits > impl_va_bits - 1)) + panic("Cannot build a big enough virtual-linear page table" + " to cover mapped address space.\n" + " Try using a smaller page size.\n"); + /* place the VMLPT at the end of each page-table mapped region: */ pta = POW2(61) - POW2(vmlpt_bits); - if (POW2(mapped_space_bits) >= pta) - panic("mm/init: overlap between virtually mapped linear page table and " - "mapped kernel space!"); /* * Set the (virtually mapped linear) page table address. Bit * 8 selects between the short and long format, bits 2-7 the -- cgit v0.10.2 From a1cddb88920b915eaba10712ecfd0fc698b00a22 Mon Sep 17 00:00:00 2001 From: Jack Steiner Date: Wed, 31 Aug 2005 08:05:00 -0700 Subject: [IA64-SGI] Add new vendor-specific SAL calls for: - notifying the PROM of specific features that are supported by the OS. This is used to enable PROM feature if and only if the corresponding feature is implemented in the OS - fetch feature sets that are supported by the current PROM. This allows the OS to selectively enable features when the PROM support is available. Signed-off-by: Jack Steiner Signed-off-by: Tony Luck diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c index 7c7fe44..981928f 100644 --- a/arch/ia64/sn/kernel/setup.c +++ b/arch/ia64/sn/kernel/setup.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "xtalk/xwidgetdev.h" #include "xtalk/hubdev.h" #include @@ -99,6 +100,7 @@ EXPORT_SYMBOL(sn_region_size); int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */ short physical_node_map[MAX_PHYSNODE_ID]; +static unsigned long sn_prom_features[MAX_PROM_FEATURE_SETS]; EXPORT_SYMBOL(physical_node_map); @@ -273,7 +275,10 @@ void __init sn_setup(char **cmdline_p) u32 version = sn_sal_rev(); extern void sn_cpu_init(void); - ia64_sn_plat_set_error_handling_features(); + ia64_sn_plat_set_error_handling_features(); // obsolete + ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV); + ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES); + #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) /* @@ -316,16 +321,6 @@ void __init sn_setup(char **cmdline_p) printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); - /* - * Confirm the SAL we're running on is recent enough... - */ - if (version < SN_SAL_MIN_VERSION) { - printk(KERN_ERR "This kernel needs SGI SAL version >= " - "%x.%02x\n", SN_SAL_MIN_VERSION >> 8, - SN_SAL_MIN_VERSION & 0x00FF); - panic("PROM version too old\n"); - } - master_nasid = boot_get_nasid(); status = @@ -481,6 +476,10 @@ void __init sn_cpu_init(void) if (nodepdaindr[0] == NULL) return; + for (i = 0; i < MAX_PROM_FEATURE_SETS; i++) + if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0) + break; + cpuid = smp_processor_id(); cpuphyid = get_sapicid(); @@ -652,3 +651,12 @@ nasid_slice_to_cpuid(int nasid, int slice) return -1; } + +int sn_prom_feature_available(int id) +{ + if (id >= BITS_PER_LONG * MAX_PROM_FEATURE_SETS) + return 0; + return test_bit(id, sn_prom_features); +} +EXPORT_SYMBOL(sn_prom_feature_available); + diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h new file mode 100644 index 0000000..e68a808 --- /dev/null +++ b/include/asm-ia64/sn/sn_feature_sets.h @@ -0,0 +1,57 @@ +#ifndef _ASM_IA64_SN_FEATURE_SETS_H +#define _ASM_IA64_SN_FEATURE_SETS_H + +/* + * SN PROM Features + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved. + */ + + +#include +#include + +/* --------------------- PROM Features -----------------------------*/ +extern int sn_prom_feature_available(int id); + +#define MAX_PROM_FEATURE_SETS 2 + +/* + * The following defines features that may or may not be supported by the + * current PROM. The OS uses sn_prom_feature_available(feature) to test for + * the presence of a PROM feature. Down rev (old) PROMs will always test + * "false" for new features. + * + * Use: + * if (sn_prom_feature_available(PRF_FEATURE_XXX)) + * ... + */ + +/* + * Example: feature XXX + */ +#define PRF_FEATURE_XXX 0 + + + +/* --------------------- OS Features -------------------------------*/ + +/* + * The following defines OS features that are optionally present in + * the operating system. + * During boot, PROM is notified of these features via a series of calls: + * + * ia64_sn_set_os_feature(feature1); + * + * Once enabled, a feature cannot be disabled. + * + * By default, features are disabled unless explicitly enabled. + */ +#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 +#define OSF_FEAT_LOG_SBES 1 + +#endif /* _ASM_IA64_SN_FEATURE_SETS_H */ diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h index 27976d2..231d0d0 100644 --- a/include/asm-ia64/sn/sn_sal.h +++ b/include/asm-ia64/sn/sn_sal.h @@ -80,6 +80,9 @@ #define SN_SAL_BTE_RECOVER 0x02000061 #define SN_SAL_IOIF_GET_PCI_TOPOLOGY 0x02000062 +#define SN_SAL_GET_PROM_FEATURE_SET 0x02000065 +#define SN_SAL_SET_OS_FEATURE_SET 0x02000066 + /* * Service-specific constants */ @@ -118,8 +121,8 @@ /* * Error Handling Features */ -#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 -#define SAL_ERR_FEAT_LOG_SBES 0x2 +#define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 // obsolete +#define SAL_ERR_FEAT_LOG_SBES 0x2 // obsolete #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4 #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000 @@ -152,12 +155,6 @@ sn_sal_rev(void) } /* - * Specify the minimum PROM revsion required for this kernel. - * Note that they're stored in hex format... - */ -#define SN_SAL_MIN_VERSION 0x0404 - -/* * Returns the master console nasid, if the call fails, return an illegal * value. */ @@ -336,7 +333,7 @@ ia64_sn_plat_cpei_handler(void) } /* - * Set Error Handling Features + * Set Error Handling Features (Obsolete) */ static inline u64 ia64_sn_plat_set_error_handling_features(void) @@ -1100,4 +1097,25 @@ ia64_sn_is_fake_prom(void) return (rv.status == 0); } +static inline int +ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set) +{ + struct ia64_sal_retval rv; + + SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0); + if (rv.status != 0) + return rv.status; + *feature_set = rv.v0; + return 0; +} + +static inline int +ia64_sn_set_os_feature(int feature) +{ + struct ia64_sal_retval rv; + + SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0); + return rv.status; +} + #endif /* _ASM_IA64_SN_SN_SAL_H */ -- cgit v0.10.2 From 4f4b401bfaa97edbea41a1fcab794148e7ac0421 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Thu, 1 Sep 2005 09:02:43 -0500 Subject: JFS: allow extended attributes to be set within a existing transaction Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index e892dab..461e493 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c @@ -23,6 +23,7 @@ #include #include #include "jfs_incore.h" +#include "jfs_txnmgr.h" #include "jfs_xattr.h" #include "jfs_acl.h" @@ -75,7 +76,8 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type) return acl; } -static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) +static int jfs_set_acl(tid_t tid, struct inode *inode, int type, + struct posix_acl *acl) { char *ea_name; struct jfs_inode_info *ji = JFS_IP(inode); @@ -110,7 +112,7 @@ static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) if (rc < 0) goto out; } - rc = __jfs_setxattr(inode, ea_name, value, size, 0); + rc = __jfs_setxattr(tid, inode, ea_name, value, size, 0); out: kfree(value); @@ -143,7 +145,7 @@ int jfs_permission(struct inode *inode, int mask, struct nameidata *nd) return generic_permission(inode, mask, jfs_check_acl); } -int jfs_init_acl(struct inode *inode, struct inode *dir) +int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) { struct posix_acl *acl = NULL; struct posix_acl *clone; @@ -159,7 +161,7 @@ int jfs_init_acl(struct inode *inode, struct inode *dir) if (acl) { if (S_ISDIR(inode->i_mode)) { - rc = jfs_set_acl(inode, ACL_TYPE_DEFAULT, acl); + rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); if (rc) goto cleanup; } @@ -173,7 +175,8 @@ int jfs_init_acl(struct inode *inode, struct inode *dir) if (rc >= 0) { inode->i_mode = mode; if (rc > 0) - rc = jfs_set_acl(inode, ACL_TYPE_ACCESS, clone); + rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, + clone); } posix_acl_release(clone); cleanup: @@ -202,8 +205,15 @@ static int jfs_acl_chmod(struct inode *inode) return -ENOMEM; rc = posix_acl_chmod_masq(clone, inode->i_mode); - if (!rc) - rc = jfs_set_acl(inode, ACL_TYPE_ACCESS, clone); + if (!rc) { + tid_t tid = txBegin(inode->i_sb, 0); + down(&JFS_IP(inode)->commit_sem); + rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, clone); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&JFS_IP(inode)->commit_sem); + } posix_acl_release(clone); return rc; diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h index a3acd3e..a7629376 100644 --- a/fs/jfs/jfs_acl.h +++ b/fs/jfs/jfs_acl.h @@ -21,8 +21,16 @@ #ifdef CONFIG_JFS_POSIX_ACL int jfs_permission(struct inode *, int, struct nameidata *); -int jfs_init_acl(struct inode *, struct inode *); +int jfs_init_acl(tid_t, struct inode *, struct inode *); int jfs_setattr(struct dentry *, struct iattr *); -#endif /* CONFIG_JFS_POSIX_ACL */ +#else + +static inline int jfs_init_acl(tid_t tid, struct inode *inode, + struct inode *dir) +{ + return 0; +} + +#endif #endif /* _H_JFS_ACL */ diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index a1052f3..116a73c 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h @@ -52,8 +52,8 @@ struct jfs_ea_list { #define END_EALIST(ealist) \ ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist))) -extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t, - int); +extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *, + size_t, int); extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t, int); extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t); diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 49ccde3..f23f9c2 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -39,6 +39,24 @@ struct dentry_operations jfs_ci_dentry_operations; static s64 commitZeroLink(tid_t, struct inode *); /* + * NAME: free_ea_wmap(inode) + * + * FUNCTION: free uncommitted extended attributes from working map + * + */ +static inline void free_ea_wmap(struct inode *inode) +{ + dxd_t *ea = &JFS_IP(inode)->ea; + + if (ea->flag & DXD_EXTENT) { + /* free EA pages from cache */ + invalidate_dxd_metapages(inode, *ea); + dbFree(inode, addressDXD(ea), lengthDXD(ea)); + } + ea->flag = 0; +} + +/* * NAME: jfs_create(dip, dentry, mode) * * FUNCTION: create a regular file in the parent directory @@ -89,8 +107,13 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_acl(tid, ip, dip); + if (rc) + goto out3; + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_create: dtSearch returned %d", rc); + txAbort(tid, 0); goto out3; } @@ -139,6 +162,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -147,11 +171,6 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif - out1: jfs_info("jfs_create: rc:%d", rc); @@ -216,8 +235,13 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_acl(tid, ip, dip); + if (rc) + goto out3; + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_mkdir: dtSearch returned %d", rc); + txAbort(tid, 0); goto out3; } @@ -267,6 +291,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -275,10 +300,6 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif out1: @@ -1000,6 +1021,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, up(&JFS_IP(dip)->commit_sem); up(&JFS_IP(ip)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -1008,11 +1030,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, out2: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dip); -#endif - out1: jfs_info("jfs_symlink: rc:%d", rc); return rc; @@ -1328,17 +1345,25 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, down(&JFS_IP(dir)->commit_sem); down(&JFS_IP(ip)->commit_sem); - if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) + rc = jfs_init_acl(tid, ip, dir); + if (rc) goto out3; + if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { + txAbort(tid, 0); + goto out3; + } + tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; tblk->u.ixpxd = JFS_IP(ip)->ixpxd; ino = ip->i_ino; - if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) + if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) { + txAbort(tid, 0); goto out3; + } ip->i_op = &jfs_file_inode_operations; jfs_ip->dev = new_encode_dev(rdev); @@ -1360,6 +1385,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, up(&JFS_IP(ip)->commit_sem); up(&JFS_IP(dir)->commit_sem); if (rc) { + free_ea_wmap(ip); ip->i_nlink = 0; iput(ip); } else @@ -1368,11 +1394,6 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, out1: free_UCSname(&dname); -#ifdef CONFIG_JFS_POSIX_ACL - if (rc == 0) - jfs_init_acl(ip, dir); -#endif - out: jfs_info("jfs_mknod: returning %d", rc); return rc; diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 554ec73..35674b2 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c @@ -633,12 +633,12 @@ static void ea_release(struct inode *inode, struct ea_buffer *ea_buf) } } -static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) +static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf, + int new_size) { struct jfs_inode_info *ji = JFS_IP(inode); unsigned long old_blocks, new_blocks; int rc = 0; - tid_t tid; if (new_size == 0) { ea_release(inode, ea_buf); @@ -664,9 +664,6 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) if (rc) return rc; - tid = txBegin(inode->i_sb, 0); - down(&ji->commit_sem); - old_blocks = new_blocks = 0; if (ji->ea.flag & DXD_EXTENT) { @@ -695,11 +692,8 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) DQUOT_FREE_BLOCK(inode, old_blocks); inode->i_ctime = CURRENT_TIME; - rc = txCommit(tid, 1, &inode, 0); - txEnd(tid); - up(&ji->commit_sem); - return rc; + return 0; } /* @@ -810,8 +804,8 @@ static int can_set_xattr(struct inode *inode, const char *name, return permission(inode, MAY_WRITE, NULL); } -int __jfs_setxattr(struct inode *inode, const char *name, const void *value, - size_t value_len, int flags) +int __jfs_setxattr(tid_t tid, struct inode *inode, const char *name, + const void *value, size_t value_len, int flags) { struct jfs_ea_list *ealist; struct jfs_ea *ea, *old_ea = NULL, *next_ea = NULL; @@ -825,9 +819,6 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, int rc; int length; - if ((rc = can_set_xattr(inode, name, value, value_len))) - return rc; - if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { os2name = kmalloc(namelen - XATTR_OS2_PREFIX_LEN + 1, GFP_KERNEL); @@ -939,7 +930,7 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, ealist->size = cpu_to_le32(new_size); - rc = ea_put(inode, &ea_buf, new_size); + rc = ea_put(tid, inode, &ea_buf, new_size); goto out; release: @@ -955,12 +946,29 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value, int jfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t value_len, int flags) { + struct inode *inode = dentry->d_inode; + struct jfs_inode_info *ji = JFS_IP(inode); + int rc; + tid_t tid; + + if ((rc = can_set_xattr(inode, name, value, value_len))) + return rc; + if (value == NULL) { /* empty EA, do not remove */ value = ""; value_len = 0; } - return __jfs_setxattr(dentry->d_inode, name, value, value_len, flags); + tid = txBegin(inode->i_sb, 0); + down(&ji->commit_sem); + rc = __jfs_setxattr(tid, dentry->d_inode, name, value, value_len, + flags); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&ji->commit_sem); + + return rc; } static int can_get_xattr(struct inode *inode, const char *name) @@ -1122,5 +1130,21 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size) int jfs_removexattr(struct dentry *dentry, const char *name) { - return __jfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); + struct inode *inode = dentry->d_inode; + struct jfs_inode_info *ji = JFS_IP(inode); + int rc; + tid_t tid; + + if ((rc = can_set_xattr(inode, name, NULL, 0))) + return rc; + + tid = txBegin(inode->i_sb, 0); + down(&ji->commit_sem); + rc = __jfs_setxattr(tid, dentry->d_inode, name, NULL, 0, XATTR_REPLACE); + if (!rc) + rc = txCommit(tid, 1, &inode, 0); + txEnd(tid); + up(&ji->commit_sem); + + return rc; } -- cgit v0.10.2 From 1d15b10f95d4c4295a0f2288c7be7b6a005490da Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Thu, 1 Sep 2005 09:05:39 -0500 Subject: JFS: Implement jfs_init_security This atomically initializes the security xattr when an object is created Signed-off-by: Dave Kleikamp diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index 116a73c..25e9990 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h @@ -61,4 +61,14 @@ extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t); extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); extern int jfs_removexattr(struct dentry *, const char *); +#ifdef CONFIG_JFS_SECURITY +extern int jfs_init_security(tid_t, struct inode *, struct inode *); +#else +static inline int jfs_init_security(tid_t tid, struct inode *inode, + struct inode *dir) +{ + return 0; +} +#endif + #endif /* H_JFS_XATTR */ diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index f23f9c2..1abe734 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -111,6 +111,12 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, if (rc) goto out3; + rc = jfs_init_security(tid, ip, dip); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_create: dtSearch returned %d", rc); txAbort(tid, 0); @@ -239,6 +245,12 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) if (rc) goto out3; + rc = jfs_init_security(tid, ip, dip); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { jfs_err("jfs_mkdir: dtSearch returned %d", rc); txAbort(tid, 0); @@ -906,6 +918,10 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, down(&JFS_IP(dip)->commit_sem); down(&JFS_IP(ip)->commit_sem); + rc = jfs_init_security(tid, ip, dip); + if (rc) + goto out3; + tblk = tid_to_tblock(tid); tblk->xflag |= COMMIT_CREATE; tblk->ino = ip->i_ino; @@ -1349,6 +1365,12 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, if (rc) goto out3; + rc = jfs_init_security(tid, ip, dir); + if (rc) { + txAbort(tid, 0); + goto out3; + } + if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { txAbort(tid, 0); goto out3; diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 35674b2..23aa506 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "jfs_incore.h" #include "jfs_superblock.h" #include "jfs_dmap.h" @@ -1148,3 +1149,38 @@ int jfs_removexattr(struct dentry *dentry, const char *name) return rc; } + +#ifdef CONFIG_JFS_SECURITY +int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir) +{ + int rc; + size_t len; + void *value; + char *suffix; + char *name; + + rc = security_inode_init_security(inode, dir, &suffix, &value, &len); + if (rc) { + if (rc == -EOPNOTSUPP) + return 0; + return rc; + } + name = kmalloc(XATTR_SECURITY_PREFIX_LEN + 1 + strlen(suffix), + GFP_NOFS); + if (!name) { + rc = -ENOMEM; + goto kmalloc_failed; + } + strcpy(name, XATTR_SECURITY_PREFIX); + strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); + + rc = __jfs_setxattr(tid, inode, name, value, len, 0); + + kfree(name); +kmalloc_failed: + kfree(suffix); + kfree(value); + + return rc; +} +#endif -- cgit v0.10.2 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 diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 48d2b20..e65c279 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 b350827..0830c6e 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 e312a6b..45d2bd7 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 aee3b24..b4898d8 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 v0.10.2 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 diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0d68e5e..b20783f 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 v0.10.2 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 diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index e65c279..7df9652 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 v0.10.2 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 diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 523fd3c..1ddaabe 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 20e3a16..3a8314b 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 v0.10.2 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 diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 708a1d3..f0d9c5f 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 v0.10.2 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 diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h index c9e633d..9a92216 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 863b9c9..ee1ad27 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 5c20ab1..13fd710 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 da2a198..ed9446f 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 03877c8..02bc231 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 f0d9c5f..2a76d08 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 v0.10.2 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 diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 02bc231..84a73bc 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 v0.10.2 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 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3d5cd7a..111e980 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -549,6 +549,7 @@ running once the system is up. keyboard and can not control its state (Don't attempt to blink the leds) i8042.noaux [HW] Don't check for auxiliary (== mouse) port + i8042.nokbd [HW] Don't check/create keyboard port i8042.nomux [HW] Don't check presence of an active multiplexing controller i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 84a73bc..d5ea3cf 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 2a76d08..19ef35d 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 v0.10.2 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 diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index d5ea3cf..273bb3b 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -138,6 +138,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { }, }, { + .ident = "Fujitsu-Siemens Lifebook E4010", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"), + }, + }, + { .ident = "Toshiba P10", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), -- cgit v0.10.2 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 diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 63a4db7..3b162a1 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 c1b6b69..f3b85a0 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 52437e5..789df80 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 3b162a1..fa4f79d 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 f3b85a0..cea5cf3 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 789df80..ceebab9 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 fa4f79d..b28cf85 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 cea5cf3..ca3e170 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 diff --git a/include/linux/input.h b/include/linux/input.h index bdc53c6..227a497 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -287,6 +287,8 @@ struct input_absinfo { #define KEY_SCROLLDOWN 178 #define KEY_KPLEFTPAREN 179 #define KEY_KPRIGHTPAREN 180 +#define KEY_NEW 181 +#define KEY_REDO 182 #define KEY_F13 183 #define KEY_F14 184 @@ -333,6 +335,12 @@ struct input_absinfo { #define KEY_KBDILLUMDOWN 229 #define KEY_KBDILLUMUP 230 +#define KEY_SEND 231 +#define KEY_REPLY 232 +#define KEY_FORWARDMAIL 233 +#define KEY_SAVE 234 +#define KEY_DOCUMENTS 235 + #define KEY_UNKNOWN 240 #define BTN_MISC 0x100 -- cgit v0.10.2 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 diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 4d4985b..1ad8c2e 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b2cb2b3..376b604 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 ca3e170..d76bbc8 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index b28cf85..22f9d91 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 v0.10.2 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 diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 58728eb..e5a31e5 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 6369a24..58600f9 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 v0.10.2 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 diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 596964c..4bae5d8 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 376b604..7d5eb4d 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 7d5eb4d..661709a 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 22f9d91..14acfc5 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 d76bbc8..47f75a4 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 661709a..485575a 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 14acfc5..0b64522 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 47f75a4..ec2412c 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 v0.10.2 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 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 485575a..a721299 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 v0.10.2 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 diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 4c13331..d324278 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 v0.10.2 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 diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0e8ac13..49d120d 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 v0.10.2 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 diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 126ac80..9191793 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 v0.10.2 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 diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 7959582..d0f0b0a 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 c8819b9..f46f37b 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 */ diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h index 72182d1..e4d1654 100644 --- a/include/rdma/ib_user_cm.h +++ b/include/rdma/ib_user_cm.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 @@ -37,7 +38,7 @@ #include -#define IB_USER_CM_ABI_VERSION 1 +#define IB_USER_CM_ABI_VERSION 2 enum { IB_USER_CM_CMD_CREATE_ID, @@ -60,6 +61,7 @@ enum { IB_USER_CM_CMD_SEND_SIDR_REP, IB_USER_CM_CMD_EVENT, + IB_USER_CM_CMD_INIT_QP_ATTR, }; /* * command ABI structures. @@ -71,6 +73,7 @@ struct ib_ucm_cmd_hdr { }; struct ib_ucm_create_id { + __u64 uid; __u64 response; }; @@ -79,9 +82,14 @@ struct ib_ucm_create_id_resp { }; struct ib_ucm_destroy_id { + __u64 response; __u32 id; }; +struct ib_ucm_destroy_id_resp { + __u32 events_reported; +}; + struct ib_ucm_attr_id { __u64 response; __u32 id; @@ -94,6 +102,64 @@ struct ib_ucm_attr_id_resp { __be32 remote_id; }; +struct ib_ucm_init_qp_attr { + __u64 response; + __u32 id; + __u32 qp_state; +}; + +struct ib_ucm_ah_attr { + __u8 grh_dgid[16]; + __u32 grh_flow_label; + __u16 dlid; + __u16 reserved; + __u8 grh_sgid_index; + __u8 grh_hop_limit; + __u8 grh_traffic_class; + __u8 sl; + __u8 src_path_bits; + __u8 static_rate; + __u8 is_global; + __u8 port_num; +}; + +struct ib_ucm_init_qp_attr_resp { + __u32 qp_attr_mask; + __u32 qp_state; + __u32 cur_qp_state; + __u32 path_mtu; + __u32 path_mig_state; + __u32 qkey; + __u32 rq_psn; + __u32 sq_psn; + __u32 dest_qp_num; + __u32 qp_access_flags; + + struct ib_ucm_ah_attr ah_attr; + struct ib_ucm_ah_attr alt_ah_attr; + + /* ib_qp_cap */ + __u32 max_send_wr; + __u32 max_recv_wr; + __u32 max_send_sge; + __u32 max_recv_sge; + __u32 max_inline_data; + + __u16 pkey_index; + __u16 alt_pkey_index; + __u8 en_sqd_async_notify; + __u8 sq_draining; + __u8 max_rd_atomic; + __u8 max_dest_rd_atomic; + __u8 min_rnr_timer; + __u8 port_num; + __u8 timeout; + __u8 retry_cnt; + __u8 rnr_retry; + __u8 alt_port_num; + __u8 alt_timeout; +}; + struct ib_ucm_listen { __be64 service_id; __be64 service_mask; @@ -157,6 +223,7 @@ struct ib_ucm_req { }; struct ib_ucm_rep { + __u64 uid; __u64 data; __u32 id; __u32 qpn; @@ -232,7 +299,6 @@ struct ib_ucm_event_get { }; struct ib_ucm_req_event_resp { - __u32 listen_id; /* device */ /* port */ struct ib_ucm_path_rec primary_path; @@ -287,7 +353,6 @@ struct ib_ucm_apr_event_resp { }; struct ib_ucm_sidr_req_event_resp { - __u32 listen_id; /* device */ /* port */ __u16 pkey; @@ -307,6 +372,7 @@ struct ib_ucm_sidr_rep_event_resp { #define IB_UCM_PRES_ALTERNATE 0x08 struct ib_ucm_event_resp { + __u64 uid; __u32 id; __u32 event; __u32 present; -- cgit v0.10.2 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 diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 0164b84..c753f73 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 v0.10.2 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 diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index c753f73..bcef06b 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 v0.10.2 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 diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 43fd805..2bd8b1c 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 v0.10.2 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 diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 32cdfb3..325d502 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 678a7e0..ec3353f 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 v0.10.2 From 0ba7a3ba6608de6e0c0bfe3009a63d7e0b7ab0ce Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:28:47 -0300 Subject: [CCID3] Avoid unsigned integer overflows in usecs_div Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 7bf3b3a..ae0500c 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -43,12 +43,22 @@ #include "ccid3.h" /* - * Reason for maths with 10 here is to avoid 32 bit overflow when a is big. + * Reason for maths here is to avoid 32 bit overflow when a is big. + * With this we get close to the limit. */ static inline u32 usecs_div(const u32 a, const u32 b) { - const u32 tmp = a * (USEC_PER_SEC / 10); - return b > 20 ? tmp / (b / 10) : tmp; + const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 : + a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 : + a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 : + a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 : + a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 : + a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 : + a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 : + a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 : + 100000; + const u32 tmp = a * (USEC_PER_SEC / div); + return (b >= 2 * div) ? tmp / (b / div) : tmp; } static int ccid3_debug; -- cgit v0.10.2 From 507d37cf269ebbd1b32bcc435fe577e411f73151 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:30:07 -0300 Subject: [CCID] Only call the HC insert_options methods when requested Signed-off-by: Arnaldo Carvalho de Melo diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 007c290..5e0af0d 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -433,6 +433,8 @@ struct dccp_sock { struct ccid *dccps_hc_tx_ccid; struct dccp_options_received dccps_options_received; enum dccp_role dccps_role:2; + __u8 dccps_hc_rx_insert_options:1; + __u8 dccps_hc_tx_insert_options:1; }; static inline struct dccp_sock *dccp_sk(const struct sock *sk) diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index ae0500c..37fd9eb 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -358,10 +358,12 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, } /* Can we send? if so add options and add to packet history */ - if (rc == 0) + if (rc == 0) { + dp->dccps_hc_tx_insert_options = 1; new_packet->dccphtx_ccval = DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; + } out: return rc; } @@ -811,6 +813,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) hcrx->ccid3hcrx_pinv = ~0; else hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; + dp->dccps_hc_rx_insert_options = 1; dccp_send_ack(sk); } diff --git a/net/dccp/options.c b/net/dccp/options.c index 382c589..7ad2f42 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -505,13 +505,18 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb) (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1)) dccp_insert_option_ack_vector(sk, skb); - if (dp->dccps_timestamp_echo != 0) dccp_insert_option_timestamp_echo(sk, skb); } - ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); - ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); + if (dp->dccps_hc_rx_insert_options) { + ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb); + dp->dccps_hc_rx_insert_options = 0; + } + if (dp->dccps_hc_tx_insert_options) { + ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb); + dp->dccps_hc_tx_insert_options = 0; + } /* XXX: insert other options when appropriate */ -- cgit v0.10.2 From 27ae543e6f116df66e2b19ff0a3aa1053e4784d8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:31:07 -0300 Subject: [CCID3] Calculate ccid3hcrx_x_recv using usecs_div Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 37fd9eb..63f8973 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -779,11 +779,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) case TFRC_RSTATE_DATA: { const u32 delta = timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_feedback); - - hcrx->ccid3hcrx_x_recv = (hcrx->ccid3hcrx_bytes_recv * - USEC_PER_SEC); - if (likely(delta > 1)) - hcrx->ccid3hcrx_x_recv /= delta; + hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, + delta); } break; default: -- cgit v0.10.2 From 1c14ac0ae8eb62cbb40af1e31b156994c7d7d3d5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:32:01 -0300 Subject: [DCCP] Give precedence to the biggest ELAPSED_TIME We can get this value in an TIMESTAMP_ECHO and/or in an ELAPSED_TIME option, if receiving both give precendence to the biggest one. In my tests they are very close if not equal at all times, so we may well think about removing the code in CCID3 that inserts this option and leaving this to the core, and perhaps even use just TIMESTAMP_ECHO including the elapsed time. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/options.c b/net/dccp/options.c index 7ad2f42..34b230a 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -72,6 +72,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) struct dccp_options_received *opt_recv = &dp->dccps_options_received; unsigned char opt, len; unsigned char *value; + u32 elapsed_time; memset(opt_recv, 0, sizeof(*opt_recv)); @@ -159,18 +160,18 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq); - if (len > 4) { - if (len == 6) - opt_recv->dccpor_elapsed_time = - ntohs(*(u16 *)(value + 4)); - else - opt_recv->dccpor_elapsed_time = - ntohl(*(u32 *)(value + 4)); - dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", - debug_prefix, - opt_recv->dccpor_elapsed_time); - } + if (len == 4) + break; + + if (len == 6) + elapsed_time = ntohs(*(u16 *)(value + 4)); + else + elapsed_time = ntohl(*(u32 *)(value + 4)); + + /* Give precedence to the biggest ELAPSED_TIME */ + if (elapsed_time > opt_recv->dccpor_elapsed_time) + opt_recv->dccpor_elapsed_time = elapsed_time; break; case DCCPO_ELAPSED_TIME: if (len != 2 && len != 4) @@ -180,14 +181,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) continue; if (len == 2) - opt_recv->dccpor_elapsed_time = - ntohs(*(u16 *)value); + elapsed_time = ntohs(*(u16 *)value); else - opt_recv->dccpor_elapsed_time = - ntohl(*(u32 *)value); + elapsed_time = ntohl(*(u32 *)value); + + if (elapsed_time > opt_recv->dccpor_elapsed_time) + opt_recv->dccpor_elapsed_time = elapsed_time; dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, - opt_recv->dccpor_elapsed_time); + elapsed_time); break; /* * From draft-ietf-dccp-spec-11.txt: -- cgit v0.10.2 From 1a28599a2c2781dd6af72f4f84175e2db74d3bb1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:32:56 -0300 Subject: [CCID3] Use ELAPSED_TIME in the HC TX RTT estimation Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 63f8973..86c109e 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -483,7 +483,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) opt_recv = &hctx->ccid3hctx_options_received; - t_elapsed = dp->dccps_options_received.dccpor_elapsed_time; + t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; x_recv = opt_recv->ccid3or_receive_rate; pinv = opt_recv->ccid3or_loss_event_rate; @@ -509,8 +509,12 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) /* Update RTT */ r_sample = timeval_now_delta(&packet->dccphtx_tstamp); - /* FIXME: */ - // r_sample -= usecs_to_jiffies(t_elapsed * 10); + if (unlikely(r_sample <= t_elapsed)) + LIMIT_NETDEBUG(KERN_WARNING + "%s: r_sample=%uus, t_elapsed=%uus\n", + __FUNCTION__, r_sample, t_elapsed); + else + r_sample -= t_elapsed; /* Update RTT estimate by * If (No feedback recv) -- cgit v0.10.2 From b3a3077d963fc54a25be26e2e84fe9f4327c1e12 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:34:10 -0300 Subject: [CCID3] Make the ccid3hcrx_rtt calc look more like the ccid3hctx_rtt one Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 86c109e..0804b3e 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -962,7 +962,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) struct dccp_rx_hist_entry *packet; struct timeval now; u8 win_count; - u32 p_prev; + u32 p_prev, r_sample, t_elapsed; int ins; if (hcrx == NULL) @@ -982,9 +982,23 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) break; p_prev = hcrx->ccid3hcrx_rtt; do_gettimeofday(&now); - hcrx->ccid3hcrx_rtt = timeval_usecs(&now) - - (opt_recv->dccpor_timestamp_echo - - opt_recv->dccpor_elapsed_time) * 10; + timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); + r_sample = timeval_usecs(&now); + t_elapsed = opt_recv->dccpor_elapsed_time * 10; + + if (unlikely(r_sample <= t_elapsed)) + LIMIT_NETDEBUG(KERN_WARNING + "%s: r_sample=%uus, t_elapsed=%uus\n", + __FUNCTION__, r_sample, t_elapsed); + else + r_sample -= t_elapsed; + + if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) + hcrx->ccid3hcrx_rtt = r_sample; + else + hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 + + r_sample / 10; + if (p_prev != hcrx->ccid3hcrx_rtt) ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", dccp_role(sk), hcrx->ccid3hcrx_rtt, -- cgit v0.10.2 From 954ee31f366fabe53fb450482789258fe552f40b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:37:05 -0300 Subject: [CCID3] Initialize more fields in ccid3_hc_rx_init The initialization of ccid3hcrx_rtt to 5ms is just a bandaid, I'll continue auditing the CCID3 HC rx codebase to fix this properly, probably I'll add a feedback timer as suggested in the CCID3 draft. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 0804b3e..145aafa 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -1100,11 +1100,9 @@ static int ccid3_hc_rx_init(struct sock *sk) hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); - /* - * XXX this seems to be paranoid, need to think more about this, for - * now start with something different than zero. -acme - */ - hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5; + do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); + hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; + hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ return 0; } -- cgit v0.10.2 From b0e567806d16586629468c824dfb2e71155df7da Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:38:35 -0300 Subject: [DCCP] Introduce dccp_timestamp To start the timestamps with 0.0ms, easing the integer maths in the CCIDs, this probably will be reworked to use the to be introduced struct timeval_offset infrastructure out of skb_get_timestamp, etc. Signed-off-by: Arnaldo Carvalho de Melo diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 5e0af0d..8bf4bac 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -432,6 +432,7 @@ struct dccp_sock { struct ccid *dccps_hc_rx_ccid; struct ccid *dccps_hc_tx_ccid; struct dccp_options_received dccps_options_received; + struct timeval dccps_epoch; enum dccp_role dccps_role:2; __u8 dccps_hc_rx_insert_options:1; __u8 dccps_hc_tx_insert_options:1; diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 145aafa..348e6fb 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -169,7 +169,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) } else { struct timeval now; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= hctx->ccid3hctx_rtt) { hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, @@ -317,7 +317,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); } - do_gettimeofday(&now); + dccp_timestamp(sk, &now); switch (hctx->ccid3hctx_state) { case TFRC_SSTATE_NO_SENT: @@ -382,7 +382,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) return; } - do_gettimeofday(&now); + dccp_timestamp(sk, &now); /* check if we have sent a data packet */ if (len > 0) { @@ -461,6 +461,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; struct ccid3_options_received *opt_recv; struct dccp_tx_hist_entry *packet; + struct timeval now; unsigned long next_tmout; u32 t_elapsed; u32 pinv; @@ -508,7 +509,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) } /* Update RTT */ - r_sample = timeval_now_delta(&packet->dccphtx_tstamp); + dccp_timestamp(sk, &now); + r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); if (unlikely(r_sample <= t_elapsed)) LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, t_elapsed=%uus\n", @@ -774,7 +776,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - do_gettimeofday(&now); + dccp_timestamp(sk, &now); switch (hcrx->ccid3hcrx_state) { case TFRC_RSTATE_NO_DATA: @@ -903,10 +905,9 @@ found: if (rtt == 0) rtt = 1; - delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); - x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; - if (likely(delta > 1)) - x_recv /= delta; + dccp_timestamp(sk, &tstamp); + delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); + x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); tmp1 = (u64)x_recv * (u64)rtt; do_div(tmp1,10000000); @@ -981,7 +982,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) if (opt_recv->dccpor_timestamp_echo == 0) break; p_prev = hcrx->ccid3hcrx_rtt; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); r_sample = timeval_usecs(&now); t_elapsed = opt_recv->dccpor_elapsed_time * 10; @@ -1013,7 +1014,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) return; } - packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, + packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, skb, SLAB_ATOMIC); if (packet == NULL) { ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " @@ -1045,7 +1046,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) if (ins != 0) break; - do_gettimeofday(&now); + dccp_timestamp(sk, &now); if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= hcrx->ccid3hcrx_rtt) { hcrx->ccid3hcrx_tstamp_last_ack = now; @@ -1100,7 +1101,7 @@ static int ccid3_hc_rx_init(struct sock *sk) hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); - do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); + dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ return 0; diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbac..58be612 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h @@ -115,7 +115,7 @@ struct ccid3_hc_rx_sock { u64 ccid3hcrx_seqno_last_counter:48, ccid3hcrx_state:8, ccid3hcrx_last_counter:4; - unsigned long ccid3hcrx_rtt; + u32 ccid3hcrx_rtt; u32 ccid3hcrx_p; u32 ccid3hcrx_bytes_recv; struct timeval ccid3hcrx_tstamp_last_feedback; diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index fb90a91..b375ebd 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h @@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry * static inline struct dccp_rx_hist_entry * dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, + const struct sock *sk, const u32 ndp, const struct sk_buff *skb, const unsigned int __nocast prio) @@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry * entry->dccphrx_ccval = dh->dccph_ccval; entry->dccphrx_type = dh->dccph_type; entry->dccphrx_ndp = ndp; - do_gettimeofday(&(entry->dccphrx_tstamp)); + dccp_timestamp(sk, &entry->dccphrx_tstamp); } return entry; diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 33456c0..95c4630 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -426,10 +426,13 @@ extern struct dccp_ackpkts * dccp_ackpkts_alloc(unsigned int len, const unsigned int __nocast priority); extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); -extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); +extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, + u64 ackno, u8 state); extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk, u64 ackno); +extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); + static inline suseconds_t timeval_usecs(const struct timeval *tv) { return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; @@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv, } } -/* - * Returns the difference in usecs between timeval - * passed in and current time - */ -static inline suseconds_t timeval_now_delta(const struct timeval *tv) -{ - struct timeval now; - do_gettimeofday(&now); - return timeval_delta(&now, tv); -} - #ifdef CONFIG_IP_DCCP_DEBUG extern void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len); diff --git a/net/dccp/input.c b/net/dccp/input.c index ef29cef..c60bc34 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -170,7 +170,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, if (dp->dccps_options.dccpo_send_ack_vector) { struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; - if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, + if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_ACKPKTS_STATE_RECEIVED)) { LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " @@ -498,7 +498,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, * DCCP_ACKPKTS_STATE_ECN_MARKED */ if (dp->dccps_options.dccpo_send_ack_vector) { - if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, + if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_ACKPKTS_STATE_RECEIVED)) goto discard; diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3fc75db..fee9a8c 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -1243,6 +1243,7 @@ static int dccp_v4_init_sock(struct sock *sk) static int dccp_ctl_socket_init = 1; dccp_options_init(&dp->dccps_options); + do_gettimeofday(&dp->dccps_epoch); if (dp->dccps_options.dccpo_send_ack_vector) { dp->dccps_hc_rx_ackpkts = diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index ce5dff4..18461bc 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -96,6 +96,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, newdp->dccps_hc_rx_ackpkts = NULL; newdp->dccps_role = DCCP_ROLE_SERVER; newicsk->icsk_rto = DCCP_TIMEOUT_INIT; + do_gettimeofday(&newdp->dccps_epoch); if (newdp->dccps_options.dccpo_send_ack_vector) { newdp->dccps_hc_rx_ackpkts = diff --git a/net/dccp/options.c b/net/dccp/options.c index 34b230a..d4c4242 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c @@ -140,7 +140,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; - do_gettimeofday(&dp->dccps_timestamp_time); + dccp_timestamp(sk, &dp->dccps_timestamp_time); dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", debug_prefix, opt_recv->dccpor_timestamp, @@ -361,9 +361,13 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) #endif struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; int len = ap->dccpap_buf_vector_len + 2; - const u32 elapsed_time = timeval_now_delta(&ap->dccpap_time) / 10; + struct timeval now; + u32 elapsed_time; unsigned char *to, *from; + dccp_timestamp(sk, &now); + elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10; + if (elapsed_time != 0) dccp_insert_option_elapsed_time(sk, skb, elapsed_time); @@ -428,13 +432,29 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) (unsigned long long) ap->dccpap_ack_ackno); } +void dccp_timestamp(const struct sock *sk, struct timeval *tv) +{ + const struct dccp_sock *dp = dccp_sk(sk); + + do_gettimeofday(tv); + tv->tv_sec -= dp->dccps_epoch.tv_sec; + tv->tv_usec -= dp->dccps_epoch.tv_usec; + + while (tv->tv_usec < 0) { + tv->tv_sec--; + tv->tv_usec += USEC_PER_SEC; + } +} + +EXPORT_SYMBOL_GPL(dccp_timestamp); + void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) { struct timeval tv; u32 now; - do_gettimeofday(&tv); - now = (tv.tv_sec * USEC_PER_SEC + tv.tv_usec) / 10; + dccp_timestamp(sk, &tv); + now = timeval_usecs(&tv) / 10; /* yes this will overflow but that is the point as we want a * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ @@ -452,13 +472,17 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk, const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : "server TX opt: "; #endif + struct timeval now; u32 tstamp_echo; - const u32 elapsed_time = - timeval_now_delta(&dp->dccps_timestamp_time) / 10; - const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); - const int len = 6 + elapsed_time_len; + u32 elapsed_time; + int len, elapsed_time_len; unsigned char *to; + dccp_timestamp(sk, &now); + elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10; + elapsed_time_len = dccp_elapsed_time_len(elapsed_time); + len = 6 + elapsed_time_len; + if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " "timestamp echo!\n"); @@ -623,7 +647,8 @@ static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap, /* * Implements the draft-ietf-dccp-spec-11.txt Appendix A */ -int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) +int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, + u64 ackno, u8 state) { /* * Check at the right places if the buffer is full, if it is, tell the @@ -704,7 +729,7 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) } ap->dccpap_buf_ackno = ackno; - do_gettimeofday(&ap->dccpap_time); + dccp_timestamp(sk, &ap->dccpap_time); out: dccp_pr_debug(""); dccp_ackpkts_print(ap); -- cgit v0.10.2 From 59725dc2a2e86a03bbf97976ede3bdc6f95bba92 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 9 Sep 2005 02:40:58 -0300 Subject: [CCID3] Introduce ccid3_hc_[rt]x_sk() for overal consistency Signed-off-by: Arnaldo Carvalho de Melo diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 348e6fb..ea30012d 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -112,8 +112,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) static inline void ccid3_hc_tx_set_state(struct sock *sk, enum ccid3_hc_tx_states state) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", @@ -154,8 +153,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) */ static void ccid3_hc_tx_update_x(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); /* To avoid large error in calcX */ if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { @@ -184,9 +182,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk) static void ccid3_hc_tx_no_feedback_timer(unsigned long data) { struct sock *sk = (struct sock *)data; - struct dccp_sock *dp = dccp_sk(sk); unsigned long next_tmout = 0; - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); bh_lock_sock(sk); if (sock_owned_by_user(sk)) { @@ -284,7 +281,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb, int len) { struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct dccp_tx_hist_entry *new_packet; struct timeval now; long delay; @@ -370,8 +367,8 @@ out: static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct timeval now; BUG_ON(hctx == NULL); @@ -457,8 +454,8 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_options_received *opt_recv; struct dccp_tx_hist_entry *packet; struct timeval now; @@ -609,8 +606,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) { - const struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) @@ -624,8 +620,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, unsigned char *value) { int rc = 0; - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_options_received *opt_recv; if (hctx == NULL) @@ -688,11 +684,11 @@ static int ccid3_hc_tx_init(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), - gfp_any()); - if (hctx == NULL) + dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any()); + if (dp->dccps_hc_tx_ccid_private == NULL) return -ENOMEM; + hctx = ccid3_hc_tx_sk(sk); memset(hctx, 0, sizeof(*hctx)); if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && @@ -714,7 +710,7 @@ static int ccid3_hc_tx_init(struct sock *sk) static void ccid3_hc_tx_exit(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); BUG_ON(hctx == NULL); @@ -756,8 +752,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) static inline void ccid3_hc_rx_set_state(struct sock *sk, enum ccid3_hc_rx_states state) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", @@ -769,8 +764,8 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk, static void ccid3_hc_rx_send_feedback(struct sock *sk) { + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; struct dccp_rx_hist_entry *packet; struct timeval now; @@ -822,9 +817,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) { - const struct dccp_sock *dp = dccp_sk(sk); + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); u32 x_recv, pinv; - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) @@ -853,8 +847,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_rx_hist_entry *entry, *next, *tail = NULL; u32 rtt, delta, x_recv, fval, p, tmp2; struct timeval tstamp = { 0, }; @@ -926,8 +919,7 @@ found: static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); if (seq_loss != DCCP_MAX_SEQNO + 1 && list_empty(&hcrx->ccid3hcrx_li_hist)) { @@ -945,8 +937,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) static void ccid3_hc_rx_detect_loss(struct sock *sk) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); u8 win_loss; const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, &hcrx->ccid3hcrx_li_hist, @@ -957,8 +948,7 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk) static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) { - struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); const struct dccp_options_received *opt_recv; struct dccp_rx_hist_entry *packet; struct timeval now; @@ -972,7 +962,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); - opt_recv = &dp->dccps_options_received; + opt_recv = &dccp_sk(sk)->dccps_options_received; switch (DCCP_SKB_CB(skb)->dccpd_type) { case DCCP_PKT_ACK: @@ -1085,11 +1075,11 @@ static int ccid3_hc_rx_init(struct sock *sk) ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); - hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), - gfp_any()); - if (hcrx == NULL) + dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any()); + if (dp->dccps_hc_rx_ccid_private == NULL) return -ENOMEM; + hcrx = ccid3_hc_rx_sk(sk); memset(hcrx, 0, sizeof(*hcrx)); if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && @@ -1109,8 +1099,8 @@ static int ccid3_hc_rx_init(struct sock *sk) static void ccid3_hc_rx_exit(struct sock *sk) { + struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); struct dccp_sock *dp = dccp_sk(sk); - struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); @@ -1131,8 +1121,7 @@ static void ccid3_hc_rx_exit(struct sock *sk) static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) { - const struct dccp_sock *dp = dccp_sk(sk); - const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; + const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); if (hcrx == NULL) return; @@ -1144,8 +1133,7 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) { - const struct dccp_sock *dp = dccp_sk(sk); - const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; + const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); if (hctx == NULL) return; diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index 58be612..d16f00d 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h @@ -128,10 +128,14 @@ struct ccid3_hc_rx_sock { u32 ccid3hcrx_x_recv; }; -#define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ - ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) +static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) +{ + return dccp_sk(sk)->dccps_hc_tx_ccid_private; +} -#define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ - ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) +static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) +{ + return dccp_sk(sk)->dccps_hc_rx_ccid_private; +} #endif /* _DCCP_CCID3_H_ */ -- cgit v0.10.2 From 9c2c389307c03a35672c80725ccf7968656d87ef Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 11:12:51 +0100 Subject: [ARM] Add memory type based allocation syscalls Add syscall numbers and syscall table entries for mbind, set_mempolicy and get_mempolicy. Signed-off-by: Russell King diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index db07ce4..cc89a73 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -10,7 +10,7 @@ * This file is included twice in entry-common.S */ #ifndef NR_syscalls -#define NR_syscalls 320 +#define NR_syscalls 328 #else __syscall_start: @@ -333,6 +333,9 @@ __syscall_start: .long sys_inotify_init .long sys_inotify_add_watch .long sys_inotify_rm_watch + .long sys_mbind +/* 320 */ .long sys_get_mempolicy + .long sys_set_mempolicy __syscall_end: .rept NR_syscalls - (__syscall_end - __syscall_start) / 4 diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h index 278de61..c49df63 100644 --- a/include/asm-arm/unistd.h +++ b/include/asm-arm/unistd.h @@ -355,6 +355,9 @@ #define __NR_inotify_init (__NR_SYSCALL_BASE+316) #define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317) #define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318) +#define __NR_mbind (__NR_SYSCALL_BASE+319) +#define __NR_get_mempolicy (__NR_SYSCALL_BASE+320) +#define __NR_set_mempolicy (__NR_SYSCALL_BASE+321) /* * The following SWIs are ARM private. -- cgit v0.10.2 From 35efb606e544403835df48cd240441a8e089c80b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 15:57:17 +0100 Subject: [ARM] Fix typo in arch/arm/Kconfig.debug It's called printch, not printchar Signed-off-by: Russell King diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 45a5709..5d3acff 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -53,7 +53,7 @@ config DEBUG_LL bool "Kernel low-level debugging functions" depends on DEBUG_KERNEL help - Say Y here to include definitions of printascii, printchar, printhex + Say Y here to include definitions of printascii, printch, printhex in the kernel. This is helpful if you are debugging code that executes before the console is initialized. -- cgit v0.10.2 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 diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 5b65e20..4d75cdf 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 v0.10.2 From 86feeaa8120bb1b0ab21efed49e9754039395ef1 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 19:28:28 +0200 Subject: kbuild: full dependency check on asm-offsets.h Building asm-offsets.h has been moved to a seperate Kbuild file located in the top-level directory. This allow us to share the functionality across the architectures. The old rules in architecture specific Makefiles will die in subsequent patches. Furhtermore the usual kbuild dependency tracking is now used when deciding to rebuild asm-offsets.s. So we no longer risk to fail a rebuild caused by asm-offsets.c dependencies being touched. With this common rule-set we now force the same name across all architectures. Following patches will fix the rest. Signed-off-by: Sam Ravnborg diff --git a/Kbuild b/Kbuild new file mode 100644 index 0000000..197ece8 --- /dev/null +++ b/Kbuild @@ -0,0 +1,41 @@ +# +# Kbuild for top-level directory of the kernel +# This file takes care of the following: +# 1) Generate asm-offsets.h + +##### +# 1) Generate asm-offsets.h +# + +offsets-file := include/asm-$(ARCH)/asm-offsets.h + +always := $(offsets-file) +targets := $(offsets-file) +targets += arch/$(ARCH)/kernel/asm-offsets.s + +quiet_cmd_offsets = GEN $@ +define cmd_offsets + cat $< | \ + (set -e; \ + echo "#ifndef __ASM_OFFSETS_H__"; \ + echo "#define __ASM_OFFSETS_H__"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by $(srctree)/Kbuild"; \ + echo " *"; \ + echo " */"; \ + echo ""; \ + sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + echo ""; \ + echo "#endif" ) > $@ +endef + +# We use internal kbuild rules to avoid the "is up to date" message from make +arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE + $(Q)mkdir -p $(dir $@) + $(call if_changed_dep,cc_s_c) + +$(srctree)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild + $(call cmd,offsets) + diff --git a/Makefile b/Makefile index 63e5c9f..2402430 100644 --- a/Makefile +++ b/Makefile @@ -776,14 +776,14 @@ $(vmlinux-dirs): prepare-all scripts # A multi level approach is used. prepare1 is updated first, then prepare0. # prepare-all is the collection point for the prepare targets. -.PHONY: prepare-all prepare prepare0 prepare1 prepare2 +.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3 -# prepare2 is used to check if we are building in a separate output directory, +# prepare3 is used to check if we are building in a separate output directory, # and if so do: # 1) Check that make has not been executed in the kernel src $(srctree) # 2) Create the include2 directory, used for the second asm symlink -prepare2: +prepare3: ifneq ($(KBUILD_SRC),) @echo ' Using $(srctree) as source for kernel' $(Q)if [ -f $(srctree)/.config ]; then \ @@ -795,18 +795,21 @@ ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm endif -# prepare1 creates a makefile if using a separate output directory -prepare1: prepare2 outputmakefile +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile -prepare0: prepare1 include/linux/version.h include/asm \ +prepare1: prepare2 include/linux/version.h include/asm \ include/config/MARKER ifneq ($(KBUILD_MODULES),) $(Q)rm -rf $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR) endif +prepare0: prepare prepare1 FORCE + $(Q)$(MAKE) $(build)=$(srctree) + # All the preparing.. -prepare-all: prepare0 prepare +prepare-all: prepare0 # Leave this as default for preprocessing vmlinux.lds.S, which is now # done in arch/$(ARCH)/kernel/Makefile @@ -949,26 +952,6 @@ modules modules_install: FORCE endif # CONFIG_MODULES -# Generate asm-offsets.h -# --------------------------------------------------------------------------- - -define filechk_gen-asm-offsets - (set -e; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by arch/$(ARCH)/Makefile"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ - echo ""; \ - echo "#endif" ) -endef - - ### # Cleaning is done on three levels. # make clean Delete most generated files @@ -991,7 +974,7 @@ MRPROPER_FILES += .config .config.old include/asm .version \ # clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES) -clean-dirs := $(addprefix _clean_,$(vmlinux-alldirs)) +clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) .PHONY: $(clean-dirs) clean archclean $(clean-dirs): diff --git a/arch/i386/Makefile b/arch/i386/Makefile index bf7c9ba..0995199 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -156,15 +156,6 @@ install: vmlinux install kernel_install: $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install -prepare: include/asm-$(ARCH)/asm_offsets.h -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: $(Q)$(MAKE) $(clean)=arch/i386/boot diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 0480ca9..e437fb3 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include /* diff --git a/arch/i386/kernel/vsyscall-sigreturn.S b/arch/i386/kernel/vsyscall-sigreturn.S index 68afa50..fadb5bc 100644 --- a/arch/i386/kernel/vsyscall-sigreturn.S +++ b/arch/i386/kernel/vsyscall-sigreturn.S @@ -7,7 +7,7 @@ */ #include -#include +#include /* XXX diff --git a/arch/i386/kernel/vsyscall.lds.S b/arch/i386/kernel/vsyscall.lds.S index a797770..98699ca 100644 --- a/arch/i386/kernel/vsyscall.lds.S +++ b/arch/i386/kernel/vsyscall.lds.S @@ -3,7 +3,7 @@ * object prelinked to its virtual address, and with only one read-only * segment (that fits in one page). This script controls its layout. */ -#include +#include SECTIONS { diff --git a/arch/i386/power/swsusp.S b/arch/i386/power/swsusp.S index c410528..c893b89 100644 --- a/arch/i386/power/swsusp.S +++ b/arch/i386/power/swsusp.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include .text diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h index e2cb9fa..8fbf791 100644 --- a/include/asm-i386/thread_info.h +++ b/include/asm-i386/thread_info.h @@ -48,7 +48,7 @@ struct thread_info { #else /* !__ASSEMBLY__ */ -#include +#include #endif -- cgit v0.10.2 From 9b9eb8c06177f07657ad35440b56cbf68e1d253b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Sep 2005 18:35:12 +0100 Subject: [ARM] sys_mbind needs wrapping sys_mbind is a 6-arg syscall, hence needs wrapping to save the sixth argument. Signed-off-by: Russell King diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index cc89a73..949ec44 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -333,7 +333,7 @@ __syscall_start: .long sys_inotify_init .long sys_inotify_add_watch .long sys_inotify_rm_watch - .long sys_mbind + .long sys_mbind_wrapper /* 320 */ .long sys_get_mempolicy .long sys_set_mempolicy __syscall_end: diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 6281d48..db302c6 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -269,6 +269,10 @@ sys_arm_fadvise64_64_wrapper: str r5, [sp, #4] @ push r5 to stack b sys_arm_fadvise64_64 +sys_mbind_wrapper: + str r5, [sp, #4] + b sys_mbind + /* * Note: off_4k (r5) is always units of 4K. If we can't do the requested * offset, we return EINVAL. -- cgit v0.10.2 From aa6c2e794f7e1f54dc52c84471c750327fa21ccd Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 9 Sep 2005 18:54:03 +0100 Subject: [ARM] 2893/1: [MMC] Update corgi to use the new mmc delayed detection function Patch from Richard Purdie We can remove this timer and its associated code from the corgi platform code now mmc_detect_change() and the pxamci code support an optional delay. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 29185ac..07b5dd4 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -131,27 +131,12 @@ static struct platform_device corgits_device = { /* * MMC/SD Device * - * The card detect interrupt isn't debounced so we delay it by HZ/4 + * The card detect interrupt isn't debounced so we delay it by 250ms * to give the card a chance to fully insert/eject. */ -static struct mmc_detect { - struct timer_list detect_timer; - void *devid; -} mmc_detect; +static struct pxamci_platform_data corgi_mci_platform_data; -static void mmc_detect_callback(unsigned long data) -{ - mmc_detect_change(mmc_detect.devid); -} - -static irqreturn_t corgi_mmc_detect_int(int irq, void *devid, struct pt_regs *regs) -{ - mmc_detect.devid=devid; - mod_timer(&mmc_detect.detect_timer, jiffies + HZ/4); - return IRQ_HANDLED; -} - -static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(int, void *, struct pt_regs *), void *data) +static int corgi_mci_init(struct device *dev, irqreturn_t (*corgi_detect_int)(int, void *, struct pt_regs *), void *data) { int err; @@ -161,11 +146,9 @@ static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(i pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN); pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT); - init_timer(&mmc_detect.detect_timer); - mmc_detect.detect_timer.function = mmc_detect_callback; - mmc_detect.detect_timer.data = (unsigned long) &mmc_detect; + corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250); - err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_mmc_detect_int, SA_INTERRUPT, + err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, SA_INTERRUPT, "MMC card detect", data); if (err) { printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); @@ -198,7 +181,6 @@ static int corgi_mci_get_ro(struct device *dev) static void corgi_mci_exit(struct device *dev, void *data) { free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data); - del_timer(&mmc_detect.detect_timer); } static struct pxamci_platform_data corgi_mci_platform_data = { -- cgit v0.10.2 From daad56661d56cc382948fc95b74e17d3326b901b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 9 Sep 2005 18:54:04 +0100 Subject: [ARM] 2894/1: Sharp Scoop driver pm_message_t type fix Patch from Richard Purdie Fix a pm_message_t type warning in the Sharp scoop driver Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 688a595..d3a04c2 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -91,7 +91,7 @@ EXPORT_SYMBOL(read_scoop_reg); EXPORT_SYMBOL(write_scoop_reg); #ifdef CONFIG_PM -static int scoop_suspend(struct device *dev, uint32_t state, uint32_t level) +static int scoop_suspend(struct device *dev, pm_message_t state, uint32_t level) { if (level == SUSPEND_POWER_DOWN) { struct scoop_dev *sdev = dev_get_drvdata(dev); -- cgit v0.10.2 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 diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index b844bc9..1044498 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 v0.10.2 From 144a50ea5e1487b8b8e722289b4177713354448a Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 9 Aug 2005 00:20:10 -0400 Subject: [PATCH] must_check attributes for PCI layer. Self explanatory really. Some newer gcc's print a warning if a function is used and we don't check its result. We do this for a bunch of things in the kernel already, this extends that to the PCI layer. Based on a patch originally from Arjan van de Ven. Signed-off-by: Dave Jones Signed-off-by: Arjan van de Ven Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/pci.h b/include/linux/pci.h index 6caaba0..6094993 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -376,32 +376,32 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); } -int pci_enable_device(struct pci_dev *dev); -int pci_enable_device_bars(struct pci_dev *dev, int mask); +int __must_check pci_enable_device(struct pci_dev *dev); +int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); void pci_disable_device(struct pci_dev *dev); void pci_set_master(struct pci_dev *dev); #define HAVE_PCI_SET_MWI -int pci_set_mwi(struct pci_dev *dev); +int __must_check pci_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); void pci_intx(struct pci_dev *dev, int enable); -int pci_set_dma_mask(struct pci_dev *dev, u64 mask); -int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); +int __must_check pci_set_dma_mask(struct pci_dev *dev, u64 mask); +int __must_check pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); int pci_assign_resource(struct pci_dev *dev, int i); void pci_restore_bars(struct pci_dev *dev); /* ROM control related routines */ -void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size); -void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); +void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); +void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size); void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); void pci_remove_rom(struct pci_dev *pdev); /* Power management related routines */ int pci_save_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev); -int pci_set_power_state(struct pci_dev *dev, pci_power_t state); -pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); -int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); +int __must_check pci_set_power_state(struct pci_dev *dev, pci_power_t state); +pci_power_t __must_check pci_choose_state(struct pci_dev *dev, pm_message_t state); +int __must_check pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources(struct pci_bus *bus); -- cgit v0.10.2 From cca6e6f5f473ec63e85c87dfc77279ce1ca114e6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:28:49 +0200 Subject: kbuild: h8300,m68knommu,sh,sh64 use generic asm-offsets.h support h8300, m68knommu, sh and sh64 all used the name asm-offsets.h so minimal changes required. Signed-off-by: Sam Ravnborg diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile index c9b80cf..40b3f56 100644 --- a/arch/h8300/Makefile +++ b/arch/h8300/Makefile @@ -61,12 +61,6 @@ archmrproper: archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm-offsets.h - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h - $(call filechk,gen-asm-offsets) - vmlinux.srec vmlinux.bin: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ @@ -74,5 +68,3 @@ define archhelp echo 'vmlinux.bin - Create raw binary' echo 'vmlinux.srec - Create srec binary' endef - -CLEAN_FILES += include/asm-$(ARCH)/asm-offsets.h diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile index 7ce5e55..b8fdf19 100644 --- a/arch/m68knommu/Makefile +++ b/arch/m68knommu/Makefile @@ -102,21 +102,11 @@ CFLAGS += -DUTS_SYSNAME=\"uClinux\" head-y := arch/m68knommu/platform/$(cpuclass-y)/head.o -CLEAN_FILES := include/asm-$(ARCH)/asm-offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s - core-y += arch/m68knommu/kernel/ \ arch/m68knommu/mm/ \ $(CLASSDIR) \ arch/m68knommu/platform/$(PLATFORM)/ libs-y += arch/m68knommu/lib/ -prepare: include/asm-$(ARCH)/asm-offsets.h - archclean: $(Q)$(MAKE) $(clean)=arch/m68knommu/boot - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h \ - include/config/MARKER - $(call filechk,gen-asm-offsets) diff --git a/arch/sh/Makefile b/arch/sh/Makefile index b563563..19f00d5 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -155,7 +155,7 @@ endif prepare: maketools include/asm-sh/.cpu include/asm-sh/.mach .PHONY: maketools FORCE -maketools: include/asm-sh/asm-offsets.h include/linux/version.h FORCE +maketools: include/linux/version.h FORCE $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h all: zImage @@ -168,14 +168,7 @@ compressed: zImage archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-sh/machtypes.h include/asm-sh/asm-offsets.h - -arch/sh/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/asm-sh/.cpu include/asm-sh/.mach - -include/asm-sh/asm-offsets.h: arch/sh/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - +CLEAN_FILES += include/asm-sh/machtypes.h define archhelp @echo ' zImage - Compressed kernel image (arch/sh/boot/zImage)' diff --git a/arch/sh64/Makefile b/arch/sh64/Makefile index b4fd8e1..3907373 100644 --- a/arch/sh64/Makefile +++ b/arch/sh64/Makefile @@ -73,11 +73,7 @@ compressed: zImage archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm-offsets.h arch/$(ARCH)/lib/syscalltab.h - -include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \ - include/asm include/linux/version.h - $(call filechk,gen-asm-offsets) +prepare: arch/$(ARCH)/lib/syscalltab.h define filechk_gen-syscalltab (set -e; \ @@ -108,7 +104,7 @@ endef arch/$(ARCH)/lib/syscalltab.h: arch/sh64/kernel/syscalls.S $(call filechk,gen-syscalltab) -CLEAN_FILES += include/asm-$(ARCH)/asm-offsets.h arch/$(ARCH)/lib/syscalltab.h +CLEAN_FILES += arch/$(ARCH)/lib/syscalltab.h define archhelp @echo ' zImage - Compressed kernel image (arch/sh64/boot/zImage)' -- cgit v0.10.2 From 47003497dd819b10874a2291e54df7dc5cf8be57 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:35:55 +0200 Subject: kbuild: arm26,sparc use generic asm-offset support Rename all includes to use asm-offsets.h to match generic name Signed-off-by: Sam Ravnborg diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile index e9cb8ef..844a9e4 100644 --- a/arch/arm26/Makefile +++ b/arch/arm26/Makefile @@ -49,10 +49,6 @@ all: zImage boot := arch/arm26/boot -prepare: include/asm-$(ARCH)/asm_offsets.h -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - - .PHONY: maketools FORCE maketools: FORCE @@ -94,12 +90,6 @@ zi:; $(Q)$(MAKE) $(build)=$(boot) zinstall fi; \ ) -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - define archhelp echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' diff --git a/arch/arm26/kernel/entry.S b/arch/arm26/kernel/entry.S index a231dd8..6d910ea 100644 --- a/arch/arm26/kernel/entry.S +++ b/arch/arm26/kernel/entry.S @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/arm26/lib/copy_page.S b/arch/arm26/lib/copy_page.S index 2d79ee1..c7511a2 100644 --- a/arch/arm26/lib/copy_page.S +++ b/arch/arm26/lib/copy_page.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm26/lib/csumpartialcopyuser.S b/arch/arm26/lib/csumpartialcopyuser.S index 5b82118..261dd15 100644 --- a/arch/arm26/lib/csumpartialcopyuser.S +++ b/arch/arm26/lib/csumpartialcopyuser.S @@ -11,7 +11,7 @@ #include #include #include -#include +#include .text diff --git a/arch/arm26/lib/getuser.S b/arch/arm26/lib/getuser.S index e6d59b33..2b1de7f 100644 --- a/arch/arm26/lib/getuser.S +++ b/arch/arm26/lib/getuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000. * Note also that it is intended that __get_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm26/lib/putuser.S b/arch/arm26/lib/putuser.S index 87588cb..46c7f15 100644 --- a/arch/arm26/lib/putuser.S +++ b/arch/arm26/lib/putuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000 * Note also that it is intended that __put_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm26/mm/proc-funcs.S b/arch/arm26/mm/proc-funcs.S index c3d4cd3..f9fca52 100644 --- a/arch/arm26/mm/proc-funcs.S +++ b/arch/arm26/mm/proc-funcs.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include diff --git a/arch/arm26/nwfpe/entry.S b/arch/arm26/nwfpe/entry.S index 7d6dfaa..e631200 100644 --- a/arch/arm26/nwfpe/entry.S +++ b/arch/arm26/nwfpe/entry.S @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include /* This is the kernel's entry point into the floating point emulator. It is called from the kernel with code similar to this: diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index 7b3bbaf..dea48f6 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -59,17 +59,7 @@ image tftpboot.img: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s \ - arch/$(ARCH)/boot/System.map +CLEAN_FILES += arch/$(ARCH)/boot/System.map # Don't use tabs in echo arguments. define archhelp diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index b448166..03ecb4e 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/sparc/kernel/sclow.S b/arch/sparc/kernel/sclow.S index 3a867fc..136e37c 100644 --- a/arch/sparc/kernel/sclow.S +++ b/arch/sparc/kernel/sclow.S @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/hypersparc.S b/arch/sparc/mm/hypersparc.S index 54b8e76..a231cca 100644 --- a/arch/sparc/mm/hypersparc.S +++ b/arch/sparc/mm/hypersparc.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/swift.S b/arch/sparc/mm/swift.S index 2dcaa5a..cd90f3f 100644 --- a/arch/sparc/mm/swift.S +++ b/arch/sparc/mm/swift.S @@ -9,7 +9,7 @@ #include #include #include -#include +#include .text .align 4 diff --git a/arch/sparc/mm/tsunami.S b/arch/sparc/mm/tsunami.S index 8acd178..697af61 100644 --- a/arch/sparc/mm/tsunami.S +++ b/arch/sparc/mm/tsunami.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/sparc/mm/viking.S b/arch/sparc/mm/viking.S index f58712d..3cbd6de 100644 --- a/arch/sparc/mm/viking.S +++ b/arch/sparc/mm/viking.S @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/asm-sparc/ptrace.h b/include/asm-sparc/ptrace.h index dd9d94d..a8ecb2d 100644 --- a/include/asm-sparc/ptrace.h +++ b/include/asm-sparc/ptrace.h @@ -73,11 +73,11 @@ extern void show_regs(struct pt_regs *); #endif /* - * The asm_offsets.h is a generated file, so we cannot include it. + * The asm-offsets.h is a generated file, so we cannot include it. * It may be OK for glibc headers, but it's utterly pointless for C code. * The assembly code using those offsets has to include it explicitly. */ -/* #include */ +/* #include */ /* These are for pt_regs. */ #define PT_PSR 0x0 -- cgit v0.10.2 From 0013a85454c281faaf064ccb576e373a2881aac8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 20:57:26 +0200 Subject: kbuild: m68k,parisc,ppc,ppc64,s390,xtensa use generic asm-offsets.h support Delete obsoleted parts form arch makefiles and rename to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index 466e740..34d826d 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -113,14 +113,5 @@ else bzip2 -1c vmlinux >vmlinux.bz2 endif -prepare: include/asm-$(ARCH)/offsets.h -CLEAN_FILES += include/asm-$(ARCH)/offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: rm -f vmlinux.gz vmlinux.bz2 diff --git a/arch/m68k/fpsp040/skeleton.S b/arch/m68k/fpsp040/skeleton.S index dbc1255..9571a21 100644 --- a/arch/m68k/fpsp040/skeleton.S +++ b/arch/m68k/fpsp040/skeleton.S @@ -40,7 +40,7 @@ #include #include -#include +#include |SKELETON idnt 2,1 | Motorola 040 Floating Point Software Package diff --git a/arch/m68k/ifpsp060/iskeleton.S b/arch/m68k/ifpsp060/iskeleton.S index 803a6ec..4ba2c74 100644 --- a/arch/m68k/ifpsp060/iskeleton.S +++ b/arch/m68k/ifpsp060/iskeleton.S @@ -36,7 +36,7 @@ #include #include -#include +#include |################################ diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S index e964015..23ca60a 100644 --- a/arch/m68k/kernel/entry.S +++ b/arch/m68k/kernel/entry.S @@ -42,7 +42,7 @@ #include #include -#include +#include .globl system_call, buserr, trap .globl resume, ret_from_exception diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S index 7cd6de1..d4336d8 100644 --- a/arch/m68k/kernel/head.S +++ b/arch/m68k/kernel/head.S @@ -263,7 +263,7 @@ #include #include #include -#include +#include #ifdef CONFIG_MAC diff --git a/arch/m68k/math-emu/fp_emu.h b/arch/m68k/math-emu/fp_emu.h index 1d6edc9..c1ecfef 100644 --- a/arch/m68k/math-emu/fp_emu.h +++ b/arch/m68k/math-emu/fp_emu.h @@ -39,7 +39,7 @@ #define _FP_EMU_H #ifdef __ASSEMBLY__ -#include +#include #endif #include diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile index 0403d2f..3b339b1 100644 --- a/arch/parisc/Makefile +++ b/arch/parisc/Makefile @@ -100,15 +100,7 @@ kernel_install: vmlinux install: kernel_install modules_install -prepare: include/asm-parisc/offsets.h - -arch/parisc/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-parisc/offsets.h: arch/parisc/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += lifimage include/asm-parisc/offsets.h +CLEAN_FILES += lifimage MRPROPER_FILES += palo.conf define archhelp diff --git a/arch/parisc/hpux/gate.S b/arch/parisc/hpux/gate.S index 2680a1c..aaaf330 100644 --- a/arch/parisc/hpux/gate.S +++ b/arch/parisc/hpux/gate.S @@ -9,7 +9,7 @@ */ #include -#include +#include #include #include diff --git a/arch/parisc/hpux/wrappers.S b/arch/parisc/hpux/wrappers.S index 1aa936d..0b0c3a6 100644 --- a/arch/parisc/hpux/wrappers.S +++ b/arch/parisc/hpux/wrappers.S @@ -24,7 +24,7 @@ #warning PA64 support needs more work...did first cut #endif -#include +#include #include #include diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S index ee58d37..be0f07f 100644 --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -23,7 +23,7 @@ */ #include -#include +#include /* we have the following possibilities to act on an interruption: * - handle in assembly and use shadowed registers only diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S index ddf7e91..28405ed 100644 --- a/arch/parisc/kernel/head.S +++ b/arch/parisc/kernel/head.S @@ -14,7 +14,7 @@ #include /* for CONFIG_SMP */ -#include +#include #include #include diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 4fc0450..46b7593 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index c07db9d..f3428e5 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include /* PSW bits we allow the debugger to modify */ #define USER_PSW_BITS (PSW_N | PSW_V | PSW_CB) diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index 55d71c1..0224651 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #ifdef CONFIG_COMPAT #include diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S index 32ea701..8c7a718 100644 --- a/arch/parisc/kernel/syscall.S +++ b/arch/parisc/kernel/syscall.S @@ -7,7 +7,7 @@ * sorry about the wall, puffin.. */ -#include +#include #include #include #include diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S index 134f0cd..1b91612 100644 --- a/arch/parisc/lib/fixup.S +++ b/arch/parisc/lib/fixup.S @@ -20,7 +20,7 @@ * Fixup routines for kernel exception handling. */ #include -#include +#include #include #include diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile index d1b6e6d..4b3fe39 100644 --- a/arch/ppc/Makefile +++ b/arch/ppc/Makefile @@ -105,13 +105,7 @@ archclean: $(Q)$(MAKE) $(clean)=arch/ppc/boot $(Q)rm -rf include3 -prepare: include/asm-$(ARCH)/offsets.h checkbin - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) +prepare: checkbin # Temporary hack until we have migrated to asm-powerpc include/asm: include3/asm @@ -143,7 +137,5 @@ checkbin: false ; \ fi -CLEAN_FILES += include/asm-$(ARCH)/offsets.h \ - arch/$(ARCH)/kernel/asm-offsets.s \ - $(TOUT) +CLEAN_FILES += $(TOUT) diff --git a/arch/ppc/kernel/cpu_setup_6xx.S b/arch/ppc/kernel/cpu_setup_6xx.S index bd037ca..1f37b7e 100644 --- a/arch/ppc/kernel/cpu_setup_6xx.S +++ b/arch/ppc/kernel/cpu_setup_6xx.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__setup_cpu_601) diff --git a/arch/ppc/kernel/cpu_setup_power4.S b/arch/ppc/kernel/cpu_setup_power4.S index f2ea1a9..304589a 100644 --- a/arch/ppc/kernel/cpu_setup_power4.S +++ b/arch/ppc/kernel/cpu_setup_power4.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__970_cpu_preinit) diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S index cb83045..03d4886 100644 --- a/arch/ppc/kernel/entry.S +++ b/arch/ppc/kernel/entry.S @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #undef SHOW_SYSCALLS diff --git a/arch/ppc/kernel/fpu.S b/arch/ppc/kernel/fpu.S index 6189b26..665d7d3 100644 --- a/arch/ppc/kernel/fpu.S +++ b/arch/ppc/kernel/fpu.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include /* * This task wants to use the FPU now. diff --git a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S index a931d77..55daf12 100644 --- a/arch/ppc/kernel/head.S +++ b/arch/ppc/kernel/head.S @@ -31,7 +31,7 @@ #include #include #include -#include +#include #ifdef CONFIG_APUS #include diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S index 9e68e32..599245b 100644 --- a/arch/ppc/kernel/head_44x.S +++ b/arch/ppc/kernel/head_44x.S @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include "head_booke.h" diff --git a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S index ca9518b..8562b80 100644 --- a/arch/ppc/kernel/head_4xx.S +++ b/arch/ppc/kernel/head_4xx.S @@ -40,7 +40,7 @@ #include #include #include -#include +#include /* As with the other PowerPC ports, it is expected that when code * execution begins here, the following registers contain valid, yet diff --git a/arch/ppc/kernel/head_8xx.S b/arch/ppc/kernel/head_8xx.S index eb18cad..cb1a3a5 100644 --- a/arch/ppc/kernel/head_8xx.S +++ b/arch/ppc/kernel/head_8xx.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include /* Macro to make the code more readable. */ #ifdef CONFIG_8xx_CPU6 diff --git a/arch/ppc/kernel/head_fsl_booke.S b/arch/ppc/kernel/head_fsl_booke.S index 4028f4c..8e52e84 100644 --- a/arch/ppc/kernel/head_fsl_booke.S +++ b/arch/ppc/kernel/head_fsl_booke.S @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include "head_booke.h" /* As with the other PowerPC ports, it is expected that when code diff --git a/arch/ppc/kernel/idle_6xx.S b/arch/ppc/kernel/idle_6xx.S index 25d009c..1a2194c 100644 --- a/arch/ppc/kernel/idle_6xx.S +++ b/arch/ppc/kernel/idle_6xx.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc/kernel/idle_power4.S b/arch/ppc/kernel/idle_power4.S index 73a58ff..cc0d535 100644 --- a/arch/ppc/kernel/idle_power4.S +++ b/arch/ppc/kernel/idle_power4.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S index ce71b4a..90d917d 100644 --- a/arch/ppc/kernel/misc.S +++ b/arch/ppc/kernel/misc.S @@ -23,7 +23,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc/kernel/swsusp.S b/arch/ppc/kernel/swsusp.S index 55148bb..69773cc 100644 --- a/arch/ppc/kernel/swsusp.S +++ b/arch/ppc/kernel/swsusp.S @@ -5,7 +5,7 @@ #include #include #include -#include +#include /* diff --git a/arch/ppc/mm/hashtable.S b/arch/ppc/mm/hashtable.S index ab83132..3ec87c9 100644 --- a/arch/ppc/mm/hashtable.S +++ b/arch/ppc/mm/hashtable.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #ifdef CONFIG_SMP .comm mmu_hash_lock,4 diff --git a/arch/ppc/platforms/pmac_sleep.S b/arch/ppc/platforms/pmac_sleep.S index 016a746..8d67adc 100644 --- a/arch/ppc/platforms/pmac_sleep.S +++ b/arch/ppc/platforms/pmac_sleep.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define MAGIC 0x4c617273 /* 'Lars' */ diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile index 8189953..d795775 100644 --- a/arch/ppc64/Makefile +++ b/arch/ppc64/Makefile @@ -116,13 +116,6 @@ archclean: $(Q)$(MAKE) $(clean)=$(boot) $(Q)rm -rf include3 -prepare: include/asm-ppc64/offsets.h - -arch/ppc64/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-ppc64/offsets.h: arch/ppc64/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) # Temporary hack until we have migrated to asm-powerpc include/asm: include3/asm @@ -136,5 +129,3 @@ define archhelp echo ' sourced from arch/$(ARCH)/boot/ramdisk.image.gz' echo ' (arch/$(ARCH)/boot/zImage.initrd)' endef - -CLEAN_FILES += include/asm-ppc64/offsets.h diff --git a/arch/ppc64/kernel/cpu_setup_power4.S b/arch/ppc64/kernel/cpu_setup_power4.S index 0482c06..bfce609 100644 --- a/arch/ppc64/kernel/cpu_setup_power4.S +++ b/arch/ppc64/kernel/cpu_setup_power4.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include _GLOBAL(__970_cpu_preinit) diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index bf99b4a..d133a49 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_PPC_ISERIES diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S index b436206..58c3147 100644 --- a/arch/ppc64/kernel/head.S +++ b/arch/ppc64/kernel/head.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ppc64/kernel/idle_power4.S b/arch/ppc64/kernel/idle_power4.S index 97e4a26..ca02afe 100644 --- a/arch/ppc64/kernel/idle_power4.S +++ b/arch/ppc64/kernel/idle_power4.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #undef DEBUG diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S index 6d860c1..7579035 100644 --- a/arch/ppc64/kernel/misc.S +++ b/arch/ppc64/kernel/misc.S @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/kernel/vdso32/cacheflush.S b/arch/ppc64/kernel/vdso32/cacheflush.S index 0ed7ea7..c8db993 100644 --- a/arch/ppc64/kernel/vdso32/cacheflush.S +++ b/arch/ppc64/kernel/vdso32/cacheflush.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc64/kernel/vdso32/datapage.S b/arch/ppc64/kernel/vdso32/datapage.S index 29b6bd3..4f4eb0b 100644 --- a/arch/ppc64/kernel/vdso32/datapage.S +++ b/arch/ppc64/kernel/vdso32/datapage.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/ppc64/kernel/vdso32/gettimeofday.S b/arch/ppc64/kernel/vdso32/gettimeofday.S index 2b48bf1..07f1c1c 100644 --- a/arch/ppc64/kernel/vdso32/gettimeofday.S +++ b/arch/ppc64/kernel/vdso32/gettimeofday.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/kernel/vdso64/cacheflush.S b/arch/ppc64/kernel/vdso64/cacheflush.S index e0725b7..d4a0ad2 100644 --- a/arch/ppc64/kernel/vdso64/cacheflush.S +++ b/arch/ppc64/kernel/vdso64/cacheflush.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/ppc64/kernel/vdso64/datapage.S b/arch/ppc64/kernel/vdso64/datapage.S index 18afd97..ed6e599 100644 --- a/arch/ppc64/kernel/vdso64/datapage.S +++ b/arch/ppc64/kernel/vdso64/datapage.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/ppc64/kernel/vdso64/gettimeofday.S b/arch/ppc64/kernel/vdso64/gettimeofday.S index ed3f970..f6df802 100644 --- a/arch/ppc64/kernel/vdso64/gettimeofday.S +++ b/arch/ppc64/kernel/vdso64/gettimeofday.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include .text /* diff --git a/arch/ppc64/mm/hash_low.S b/arch/ppc64/mm/hash_low.S index 35eb49e..ee5a5d3 100644 --- a/arch/ppc64/mm/hash_low.S +++ b/arch/ppc64/mm/hash_low.S @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/ppc64/mm/slb_low.S b/arch/ppc64/mm/slb_low.S index 698d6b9..a3a03da 100644 --- a/arch/ppc64/mm/slb_low.S +++ b/arch/ppc64/mm/slb_low.S @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include /* void slb_allocate(unsigned long ea); diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 3cd8dd2..189c8f3 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -100,16 +100,6 @@ image: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/offsets.h - # Don't use tabs in echo arguments define archhelp echo '* image - Kernel image for IPL ($(boot)/image)' diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index cbe7d6a..58fc7fb 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index fb77b72..d0c9ffa 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index 2710e66..55654b6 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S index 9a8263a..c9ff040 100644 --- a/arch/s390/kernel/head64.S +++ b/arch/s390/kernel/head64.S @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/s390/lib/uaccess.S b/arch/s390/lib/uaccess.S index e8029ef..88fc94f 100644 --- a/arch/s390/lib/uaccess.S +++ b/arch/s390/lib/uaccess.S @@ -11,7 +11,7 @@ #include #include -#include +#include .text .align 4 diff --git a/arch/s390/lib/uaccess64.S b/arch/s390/lib/uaccess64.S index 0ca5697..5021978 100644 --- a/arch/s390/lib/uaccess64.S +++ b/arch/s390/lib/uaccess64.S @@ -11,7 +11,7 @@ #include #include -#include +#include .text .align 4 diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index 27847e4..67ef4cd 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile @@ -66,13 +66,7 @@ boot := arch/xtensa/boot archinc := include/asm-xtensa -arch/xtensa/kernel/asm-offsets.s: \ - arch/xtensa/kernel/asm-offsets.c $(archinc)/.platform - -include/asm-xtensa/offsets.h: arch/xtensa/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -prepare: $(archinc)/.platform $(archinc)/offsets.h +prepare: $(archinc)/.platform # Update machine cpu and platform symlinks if something which affects # them changed. @@ -94,7 +88,7 @@ bzImage : zImage zImage zImage.initrd: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ -CLEAN_FILES += arch/xtensa/vmlinux.lds $(archinc)/offset.h \ +CLEAN_FILES += arch/xtensa/vmlinux.lds \ $(archinc)/platform $(archinc)/xtensa/config \ $(archinc)/.platform diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S index 74b1e90..a495657 100644 --- a/arch/xtensa/kernel/align.S +++ b/arch/xtensa/kernel/align.S @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index c64a01f..5c018c5 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S @@ -14,7 +14,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 4099703..c83bb0d 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include extern void ret_from_fork(void); diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S index 81808f0..0e74397 100644 --- a/arch/xtensa/kernel/vectors.S +++ b/arch/xtensa/kernel/vectors.S @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/asm-ia64/ptrace.h b/include/asm-ia64/ptrace.h index 0bef195..c8766de 100644 --- a/include/asm-ia64/ptrace.h +++ b/include/asm-ia64/ptrace.h @@ -57,7 +57,7 @@ #include #include -#include +#include /* * Base-2 logarithm of number of pages to allocate per task structure diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h index 7dc8951..b2c79f0 100644 --- a/include/asm-ia64/thread_info.h +++ b/include/asm-ia64/thread_info.h @@ -5,7 +5,7 @@ #ifndef _ASM_IA64_THREAD_INFO_H #define _ASM_IA64_THREAD_INFO_H -#include +#include #include #include diff --git a/include/asm-parisc/assembly.h b/include/asm-parisc/assembly.h index cbc286f..30b0234 100644 --- a/include/asm-parisc/assembly.h +++ b/include/asm-parisc/assembly.h @@ -63,7 +63,7 @@ .level 2.0w #endif -#include +#include #include #include diff --git a/include/asm-xtensa/ptrace.h b/include/asm-xtensa/ptrace.h index 2848a5f..aa4fd7f 100644 --- a/include/asm-xtensa/ptrace.h +++ b/include/asm-xtensa/ptrace.h @@ -127,7 +127,7 @@ extern void show_regs(struct pt_regs *); #else /* __ASSEMBLY__ */ #ifdef __KERNEL__ -# include +# include #define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE) #endif diff --git a/include/asm-xtensa/uaccess.h b/include/asm-xtensa/uaccess.h index fc268ac..06a22b8 100644 --- a/include/asm-xtensa/uaccess.h +++ b/include/asm-xtensa/uaccess.h @@ -25,7 +25,7 @@ #define _ASMLANGUAGE #include -#include +#include #include /* -- cgit v0.10.2 From e6ae744dd2eae8e00af328b11b1fe77cb0931136 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:08:59 +0200 Subject: kbuild: arm - use generic asm-offsets.h support Delete obsoleted stuff from arch Makefile and rename constants.h to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 67f1453..e625ac6 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -178,7 +178,7 @@ endif prepare: maketools include/asm-arm/.arch .PHONY: maketools FORCE -maketools: include/asm-arm/constants.h include/linux/version.h FORCE +maketools: include/linux/version.h FORCE $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h # Convert bzImage to zImage @@ -190,7 +190,7 @@ zImage Image xipImage bootpImage uImage: vmlinux zinstall install: vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ -CLEAN_FILES += include/asm-arm/constants.h* include/asm-arm/mach-types.h \ +CLEAN_FILES += include/asm-arm/mach-types.h \ include/asm-arm/arch include/asm-arm/.arch # We use MRPROPER_FILES and CLEAN_FILES now @@ -201,11 +201,6 @@ archclean: bp:; $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/bootpImage i zi:; $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/asm-arm/.arch - -include/asm-$(ARCH)/constants.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) define archhelp echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index afef212..648cfff 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 1155cf0..5396263 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index 8f74e24..24c7b04 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define MMX_WR0 (0x00) #define MMX_WR1 (0x08) diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S index 4c38abd..6811796 100644 --- a/arch/arm/lib/copy_page.S +++ b/arch/arm/lib/copy_page.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include #define COPY_COUNT (PAGE_SZ/64 PLD( -1 )) diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S index 46a2dc9..333bca2 100644 --- a/arch/arm/lib/csumpartialcopyuser.S +++ b/arch/arm/lib/csumpartialcopyuser.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include .text diff --git a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S index 64aa6f4..d204018 100644 --- a/arch/arm/lib/getuser.S +++ b/arch/arm/lib/getuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000. * Note also that it is intended that __get_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm/lib/putuser.S b/arch/arm/lib/putuser.S index b09398d..4593e9c 100644 --- a/arch/arm/lib/putuser.S +++ b/arch/arm/lib/putuser.S @@ -26,7 +26,7 @@ * Note that ADDR_LIMIT is either 0 or 0xc0000000 * Note also that it is intended that __put_user_bad is not global. */ -#include +#include #include #include diff --git a/arch/arm/mm/copypage-v3.S b/arch/arm/mm/copypage-v3.S index 4940f19..3c58ebb 100644 --- a/arch/arm/mm/copypage-v3.S +++ b/arch/arm/mm/copypage-v3.S @@ -12,7 +12,7 @@ #include #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/copypage-v4wb.S b/arch/arm/mm/copypage-v4wb.S index b94c345..8311735 100644 --- a/arch/arm/mm/copypage-v4wb.S +++ b/arch/arm/mm/copypage-v4wb.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/copypage-v4wt.S b/arch/arm/mm/copypage-v4wt.S index 9767939..e1f2af2 100644 --- a/arch/arm/mm/copypage-v4wt.S +++ b/arch/arm/mm/copypage-v4wt.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include .text .align 5 diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S index 5c0ae52..1d739d2 100644 --- a/arch/arm/mm/proc-arm1020.S +++ b/arch/arm/mm/proc-arm1020.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S index d69389c..9b72566 100644 --- a/arch/arm/mm/proc-arm1020e.S +++ b/arch/arm/mm/proc-arm1020e.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S index 747ed96..37b70fa 100644 --- a/arch/arm/mm/proc-arm1022.S +++ b/arch/arm/mm/proc-arm1022.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S index 248110c..931b690 100644 --- a/arch/arm/mm/proc-arm1026.S +++ b/arch/arm/mm/proc-arm1026.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S index 189ef6a..d0f1bbb 100644 --- a/arch/arm/mm/proc-arm6_7.S +++ b/arch/arm/mm/proc-arm6_7.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S index 57cfa6a..c69c9de 100644 --- a/arch/arm/mm/proc-arm720.S +++ b/arch/arm/mm/proc-arm720.S @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 9137fe5..7cfc260 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -4,7 +4,7 @@ * VMA_VM_FLAGS * VM_EXEC */ -#include +#include #include /* diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S index 360cae9..34f7e7d 100644 --- a/arch/arm/mm/proc-sa110.S +++ b/arch/arm/mm/proc-sa110.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S index d447cd5..ca14f80 100644 --- a/arch/arm/mm/proc-sa1100.S +++ b/arch/arm/mm/proc-sa1100.S @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S index 139a386..eb34823 100644 --- a/arch/arm/mm/proc-v6.S +++ b/arch/arm/mm/proc-v6.S @@ -11,7 +11,7 @@ */ #include #include -#include +#include #include #include diff --git a/arch/arm/mm/tlb-v3.S b/arch/arm/mm/tlb-v3.S index 44b0dae..c10786e 100644 --- a/arch/arm/mm/tlb-v3.S +++ b/arch/arm/mm/tlb-v3.S @@ -13,7 +13,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4.S b/arch/arm/mm/tlb-v4.S index db82ee4..d6c9445 100644 --- a/arch/arm/mm/tlb-v4.S +++ b/arch/arm/mm/tlb-v4.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4wb.S b/arch/arm/mm/tlb-v4wb.S index 7908d5f..cb829ca 100644 --- a/arch/arm/mm/tlb-v4wb.S +++ b/arch/arm/mm/tlb-v4wb.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v4wbi.S b/arch/arm/mm/tlb-v4wbi.S index efbe94b..60cfc4a 100644 --- a/arch/arm/mm/tlb-v4wbi.S +++ b/arch/arm/mm/tlb-v4wbi.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #include "proc-macros.S" diff --git a/arch/arm/mm/tlb-v6.S b/arch/arm/mm/tlb-v6.S index 99ed26e..6f76b89 100644 --- a/arch/arm/mm/tlb-v6.S +++ b/arch/arm/mm/tlb-v6.S @@ -11,7 +11,7 @@ * These assume a split I/D TLB. */ #include -#include +#include #include #include #include "proc-macros.S" diff --git a/arch/arm/nwfpe/entry26.S b/arch/arm/nwfpe/entry26.S index 0ed38b0..51940a9 100644 --- a/arch/arm/nwfpe/entry26.S +++ b/arch/arm/nwfpe/entry26.S @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include /* This is the kernel's entry point into the floating point emulator. It is called from the kernel with code similar to this: diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S index e73c8de..6f17187 100644 --- a/arch/arm/vfp/entry.S +++ b/arch/arm/vfp/entry.S @@ -17,7 +17,7 @@ */ #include #include -#include +#include #include .globl do_vfp -- cgit v0.10.2 From e2d5df935d8a82cb7a2c50726628fa928aa89b9b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:28:48 +0200 Subject: kbuild: alpha,x86_64 use generic asm-offsets.h support Delete obsolete stuff from arch makefiles Rename .h file to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index 22ebfb2..1b704ee 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -108,20 +108,9 @@ $(boot)/vmlinux.gz: vmlinux bootimage bootpfile bootpzfile: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ - -prepare: include/asm-$(ARCH)/asm_offsets.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h - define archhelp echo '* boot - Compressed kernel image (arch/alpha/boot/vmlinux.gz)' echo ' bootimage - SRM bootable image (arch/alpha/boot/bootimage)' diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index f0927ee..76cc0cb 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/alpha/kernel/head.S b/arch/alpha/kernel/head.S index 4ca2e40..0905721 100644 --- a/arch/alpha/kernel/head.S +++ b/arch/alpha/kernel/head.S @@ -9,7 +9,7 @@ #include #include -#include +#include .globl swapper_pg_dir .globl _stext diff --git a/arch/alpha/lib/dbg_stackcheck.S b/arch/alpha/lib/dbg_stackcheck.S index cc5ce3a..3c1f3e6 100644 --- a/arch/alpha/lib/dbg_stackcheck.S +++ b/arch/alpha/lib/dbg_stackcheck.S @@ -5,7 +5,7 @@ * Verify that we have not overflowed the stack. Oops if we have. */ -#include +#include .text .set noat diff --git a/arch/alpha/lib/dbg_stackkill.S b/arch/alpha/lib/dbg_stackkill.S index e09f2ae..e9f6a9d 100644 --- a/arch/alpha/lib/dbg_stackkill.S +++ b/arch/alpha/lib/dbg_stackkill.S @@ -6,7 +6,7 @@ * uninitialized local variables in the act. */ -#include +#include .text .set noat diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile index 4c6ed96..a9cd42e 100644 --- a/arch/x86_64/Makefile +++ b/arch/x86_64/Makefile @@ -86,16 +86,6 @@ install fdimage fdimage144 fdimage288: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -prepare: include/asm-$(ARCH)/offset.h - -arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/offset.h: arch/$(ARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/offset.h - define archhelp echo '* bzImage - Compressed kernel image (arch/$(ARCH)/boot/bzImage)' echo ' install - Install kernel using' diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S index f174083..5244f80 100644 --- a/arch/x86_64/ia32/ia32entry.S +++ b/arch/x86_64/ia32/ia32entry.S @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/x86_64/ia32/vsyscall-syscall.S b/arch/x86_64/ia32/vsyscall-syscall.S index e2aaf3d..b024965b 100644 --- a/arch/x86_64/ia32/vsyscall-syscall.S +++ b/arch/x86_64/ia32/vsyscall-syscall.S @@ -3,7 +3,7 @@ */ #include -#include +#include #include .text diff --git a/arch/x86_64/ia32/vsyscall-sysenter.S b/arch/x86_64/ia32/vsyscall-sysenter.S index 8fb8e0f..71f3de5 100644 --- a/arch/x86_64/ia32/vsyscall-sysenter.S +++ b/arch/x86_64/ia32/vsyscall-sysenter.S @@ -3,7 +3,7 @@ */ #include -#include +#include .text .section .text.vsyscall,"ax" diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S index be51dbe..3620508 100644 --- a/arch/x86_64/kernel/entry.S +++ b/arch/x86_64/kernel/entry.S @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86_64/kernel/suspend_asm.S b/arch/x86_64/kernel/suspend_asm.S index 53f8e16..4d659e9 100644 --- a/arch/x86_64/kernel/suspend_asm.S +++ b/arch/x86_64/kernel/suspend_asm.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include ENTRY(swsusp_arch_suspend) diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S index bd556c8..dfa358b 100644 --- a/arch/x86_64/lib/copy_user.S +++ b/arch/x86_64/lib/copy_user.S @@ -7,7 +7,7 @@ #define FIX_ALIGNMENT 1 #include - #include + #include #include #include diff --git a/arch/x86_64/lib/getuser.S b/arch/x86_64/lib/getuser.S index f80bafe..3844d5e 100644 --- a/arch/x86_64/lib/getuser.S +++ b/arch/x86_64/lib/getuser.S @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include .text diff --git a/arch/x86_64/lib/putuser.S b/arch/x86_64/lib/putuser.S index 5828b81..7f55939 100644 --- a/arch/x86_64/lib/putuser.S +++ b/arch/x86_64/lib/putuser.S @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include .text diff --git a/include/asm-x86_64/current.h b/include/asm-x86_64/current.h index 7db560e..bc8adec 100644 --- a/include/asm-x86_64/current.h +++ b/include/asm-x86_64/current.h @@ -17,7 +17,7 @@ static inline struct task_struct *get_current(void) #else #ifndef ASM_OFFSET_H -#include +#include #endif #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg -- cgit v0.10.2 From fb61a8615fce15f30b1bb1cf265ed05e251b9ed8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 21:39:46 +0200 Subject: kbuild: v850 use generic asm-offsets.h support Deleted obsolete stuff from arch makefile Renamed .c file to asm-offsets.h Fix include of asm-offsets.h to use new name Signed-off-by: Sam Ravnborg diff --git a/arch/v850/Makefile b/arch/v850/Makefile index bf38ca0..8be9aac 100644 --- a/arch/v850/Makefile +++ b/arch/v850/Makefile @@ -51,16 +51,4 @@ root_fs_image_force: $(ROOT_FS_IMAGE) $(OBJCOPY) $(OBJCOPY_FLAGS_BLOB) --rename-section .data=.root,alloc,load,readonly,data,contents $< root_fs_image.o endif - -prepare: include/asm-$(ARCH)/asm-consts.h - -# Generate constants from C code for use by asm files -arch/$(ARCH)/kernel/asm-consts.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/asm-consts.h: arch/$(ARCH)/kernel/asm-consts.s - $(call filechk,gen-asm-offsets) - -CLEAN_FILES += include/asm-$(ARCH)/asm-consts.h \ - arch/$(ARCH)/kernel/asm-consts.s \ - root_fs_image.o +CLEAN_FILES += root_fs_image.o diff --git a/arch/v850/kernel/asm-consts.c b/arch/v850/kernel/asm-consts.c deleted file mode 100644 index 24f2913..0000000 --- a/arch/v850/kernel/asm-consts.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is used to generate definitions needed by - * assembly language modules. - * - * We use the technique used in the OSF Mach kernel code: - * generate asm statements containing #defines, - * compile this file to assembler, and then extract the - * #defines from the assembly-language output. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define DEFINE(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val)) - -#define BLANK() asm volatile("\n->" : : ) - -int main (void) -{ - /* offsets into the task struct */ - DEFINE (TASK_STATE, offsetof (struct task_struct, state)); - DEFINE (TASK_FLAGS, offsetof (struct task_struct, flags)); - DEFINE (TASK_PTRACE, offsetof (struct task_struct, ptrace)); - DEFINE (TASK_BLOCKED, offsetof (struct task_struct, blocked)); - DEFINE (TASK_THREAD, offsetof (struct task_struct, thread)); - DEFINE (TASK_THREAD_INFO, offsetof (struct task_struct, thread_info)); - DEFINE (TASK_MM, offsetof (struct task_struct, mm)); - DEFINE (TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm)); - DEFINE (TASK_PID, offsetof (struct task_struct, pid)); - - /* offsets into the kernel_stat struct */ - DEFINE (STAT_IRQ, offsetof (struct kernel_stat, irqs)); - - - /* signal defines */ - DEFINE (SIGSEGV, SIGSEGV); - DEFINE (SEGV_MAPERR, SEGV_MAPERR); - DEFINE (SIGTRAP, SIGTRAP); - DEFINE (SIGCHLD, SIGCHLD); - DEFINE (SIGILL, SIGILL); - DEFINE (TRAP_TRACE, TRAP_TRACE); - - /* ptrace flag bits */ - DEFINE (PT_PTRACED, PT_PTRACED); - DEFINE (PT_DTRACE, PT_DTRACE); - - /* error values */ - DEFINE (ENOSYS, ENOSYS); - - /* clone flag bits */ - DEFINE (CLONE_VFORK, CLONE_VFORK); - DEFINE (CLONE_VM, CLONE_VM); - - return 0; -} diff --git a/arch/v850/kernel/asm-offsets.c b/arch/v850/kernel/asm-offsets.c new file mode 100644 index 0000000..24f2913 --- /dev/null +++ b/arch/v850/kernel/asm-offsets.c @@ -0,0 +1,61 @@ +/* + * This program is used to generate definitions needed by + * assembly language modules. + * + * We use the technique used in the OSF Mach kernel code: + * generate asm statements containing #defines, + * compile this file to assembler, and then extract the + * #defines from the assembly-language output. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +int main (void) +{ + /* offsets into the task struct */ + DEFINE (TASK_STATE, offsetof (struct task_struct, state)); + DEFINE (TASK_FLAGS, offsetof (struct task_struct, flags)); + DEFINE (TASK_PTRACE, offsetof (struct task_struct, ptrace)); + DEFINE (TASK_BLOCKED, offsetof (struct task_struct, blocked)); + DEFINE (TASK_THREAD, offsetof (struct task_struct, thread)); + DEFINE (TASK_THREAD_INFO, offsetof (struct task_struct, thread_info)); + DEFINE (TASK_MM, offsetof (struct task_struct, mm)); + DEFINE (TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm)); + DEFINE (TASK_PID, offsetof (struct task_struct, pid)); + + /* offsets into the kernel_stat struct */ + DEFINE (STAT_IRQ, offsetof (struct kernel_stat, irqs)); + + + /* signal defines */ + DEFINE (SIGSEGV, SIGSEGV); + DEFINE (SEGV_MAPERR, SEGV_MAPERR); + DEFINE (SIGTRAP, SIGTRAP); + DEFINE (SIGCHLD, SIGCHLD); + DEFINE (SIGILL, SIGILL); + DEFINE (TRAP_TRACE, TRAP_TRACE); + + /* ptrace flag bits */ + DEFINE (PT_PTRACED, PT_PTRACED); + DEFINE (PT_DTRACE, PT_DTRACE); + + /* error values */ + DEFINE (ENOSYS, ENOSYS); + + /* clone flag bits */ + DEFINE (CLONE_VFORK, CLONE_VFORK); + DEFINE (CLONE_VM, CLONE_VM); + + return 0; +} diff --git a/arch/v850/kernel/entry.S b/arch/v850/kernel/entry.S index 895e27b..d991e45 100644 --- a/arch/v850/kernel/entry.S +++ b/arch/v850/kernel/entry.S @@ -22,7 +22,7 @@ #include #include -#include +#include /* Make a slightly more convenient alias for C_SYMBOL_NAME. */ -- cgit v0.10.2 From 39e01cb874cbf694bd0b0c44f54c4f270e2aa556 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:03:13 +0200 Subject: kbuild: ia64 use generic asm-offsets.h support Delete obsolete stuff from arch Makefile Rename file to asm-offsets.h The trick used in the arch Makefile to circumvent the circular dependency is kept. Signed-off-by: Sam Ravnborg diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index f9bd88a..7ed678c 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -82,25 +82,18 @@ unwcheck: vmlinux archclean: $(Q)$(MAKE) $(clean)=$(boot) -CLEAN_FILES += include/asm-ia64/.offsets.h.stamp vmlinux.gz bootloader - -MRPROPER_FILES += include/asm-ia64/offsets.h - -prepare: include/asm-ia64/offsets.h - -arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h include/config/MARKER - -include/asm-ia64/offsets.h: arch/ia64/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) - -arch/ia64/kernel/asm-offsets.s: include/asm-ia64/.offsets.h.stamp +prepare: include/asm-ia64/.offsets.h.stamp include/asm-ia64/.offsets.h.stamp: mkdir -p include/asm-ia64 - [ -s include/asm-ia64/offsets.h ] \ - || echo "#define IA64_TASK_SIZE 0" > include/asm-ia64/offsets.h + [ -s include/asm-ia64/asm-offsets.h ] \ + || echo "#define IA64_TASK_SIZE 0" > include/asm-ia64/asm-offsets.h touch $@ + + +CLEAN_FILES += vmlinux.gz bootloader include/asm-ia64/.offsets.h.stamp + boot: lib/lib.a vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S index 0708edb..494fad6 100644 --- a/arch/ia64/ia32/ia32_entry.S +++ b/arch/ia64/ia32/ia32_entry.S @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 9be53e1..6d70fec 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index 7d7684a..2ddbac6 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S index 86948ce..86064ca 100644 --- a/arch/ia64/kernel/gate.S +++ b/arch/ia64/kernel/gate.S @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S index 8d3a929..bfe65b2 100644 --- a/arch/ia64/kernel/head.S +++ b/arch/ia64/kernel/head.S @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S index 3bb3a13..3ba8384 100644 --- a/arch/ia64/kernel/ivt.S +++ b/arch/ia64/kernel/ivt.S @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v0.10.2 From 048eb582f3f89737d4a29668de9935e6feea7c36 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:32:31 +0200 Subject: kbuild: mips use generic asm-offsets.h support Removed obsolete stuff from arch makefile. mips had a special rule for generating asm-offsets.h so preserved it using an architecture specific hook in top-level Kbuild file. Renamed .h file to asm-offsets.h Signed-off-by: Sam Ravnborg diff --git a/Kbuild b/Kbuild index 197ece8..1880e6f 100644 --- a/Kbuild +++ b/Kbuild @@ -13,6 +13,13 @@ always := $(offsets-file) targets := $(offsets-file) targets += arch/$(ARCH)/kernel/asm-offsets.s +# Default sed regexp - multiline due to syntax constraints +define sed-y + "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" +endef +# Override default regexp for specific architectures +sed-$(CONFIG_MIPS) := "/^@@@/s///p" + quiet_cmd_offsets = GEN $@ define cmd_offsets cat $< | \ @@ -26,7 +33,7 @@ define cmd_offsets echo " *"; \ echo " */"; \ echo ""; \ - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + sed -ne $(sed-y); \ echo ""; \ echo "#endif" ) > $@ endef diff --git a/arch/mips/Makefile b/arch/mips/Makefile index b0fdaee..346e803 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -720,38 +720,7 @@ archclean: @$(MAKE) $(clean)=arch/mips/boot @$(MAKE) $(clean)=arch/mips/lasat -# Generate #include #include -#include +#include #include #define EX(a,b) \ diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S index f100196..0d9c4a3 100644 --- a/arch/mips/kernel/r2300_switch.S +++ b/arch/mips/kernel/r2300_switch.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S index aba665b..1a14c6b 100644 --- a/arch/mips/kernel/r4k_fpu.S +++ b/arch/mips/kernel/r4k_fpu.S @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include .macro EX insn, reg, src diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S index e02b772..d2afbd1 100644 --- a/arch/mips/kernel/r4k_switch.S +++ b/arch/mips/kernel/r4k_switch.S @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/r6000_fpu.S b/arch/mips/kernel/r6000_fpu.S index d8d3b13..43cda53 100644 --- a/arch/mips/kernel/r6000_fpu.S +++ b/arch/mips/kernel/r6000_fpu.S @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include .set noreorder diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S index 344f2e2..17b5030 100644 --- a/arch/mips/kernel/scall32-o32.S +++ b/arch/mips/kernel/scall32-o32.S @@ -19,7 +19,7 @@ #include #include #include -#include +#include /* Highest syscall used of any syscall flavour */ #define MAX_SYSCALL_NO __NR_O32_Linux + __NR_O32_Linux_syscalls diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S index 32efb88..ffb22a2 100644 --- a/arch/mips/kernel/scall64-64.S +++ b/arch/mips/kernel/scall64-64.S @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index ae2a131..21e3e13 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/mips/lib-32/memset.S b/arch/mips/lib-32/memset.S index ad9ff40..1981485 100644 --- a/arch/mips/lib-32/memset.S +++ b/arch/mips/lib-32/memset.S @@ -7,7 +7,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib-64/memset.S b/arch/mips/lib-64/memset.S index 242f197..e2c42c8 100644 --- a/arch/mips/lib-64/memset.S +++ b/arch/mips/lib-64/memset.S @@ -7,7 +7,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S index 90ee8d4..a78865f 100644 --- a/arch/mips/lib/memcpy.S +++ b/arch/mips/lib/memcpy.S @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include #define dst a0 diff --git a/arch/mips/lib/strlen_user.S b/arch/mips/lib/strlen_user.S index 07660e8..eca558d 100644 --- a/arch/mips/lib/strlen_user.S +++ b/arch/mips/lib/strlen_user.S @@ -7,7 +7,7 @@ * Copyright (c) 1999 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/strncpy_user.S b/arch/mips/lib/strncpy_user.S index 14bed17..d16c76f 100644 --- a/arch/mips/lib/strncpy_user.S +++ b/arch/mips/lib/strncpy_user.S @@ -7,7 +7,7 @@ */ #include #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/arch/mips/lib/strnlen_user.S b/arch/mips/lib/strnlen_user.S index 6e7a8ee..c0ea151 100644 --- a/arch/mips/lib/strnlen_user.S +++ b/arch/mips/lib/strnlen_user.S @@ -7,7 +7,7 @@ * Copyright (c) 1999 Silicon Graphics, Inc. */ #include -#include +#include #include #define EX(insn,reg,addr,handler) \ diff --git a/include/asm-mips/asmmacro-32.h b/include/asm-mips/asmmacro-32.h index ac8823d..11daf5c 100644 --- a/include/asm-mips/asmmacro-32.h +++ b/include/asm-mips/asmmacro-32.h @@ -7,7 +7,7 @@ #ifndef _ASM_ASMMACRO_32_H #define _ASM_ASMMACRO_32_H -#include +#include #include #include #include diff --git a/include/asm-mips/asmmacro-64.h b/include/asm-mips/asmmacro-64.h index bbed355..559c355 100644 --- a/include/asm-mips/asmmacro-64.h +++ b/include/asm-mips/asmmacro-64.h @@ -8,7 +8,7 @@ #ifndef _ASM_ASMMACRO_64_H #define _ASM_ASMMACRO_64_H -#include +#include #include #include #include diff --git a/include/asm-mips/sim.h b/include/asm-mips/sim.h index 3ccfe09..9c2af1b 100644 --- a/include/asm-mips/sim.h +++ b/include/asm-mips/sim.h @@ -11,7 +11,7 @@ #include -#include +#include #define __str2(x) #x #define __str(x) __str2(x) diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h index fb42f99..7b5e646 100644 --- a/include/asm-mips/stackframe.h +++ b/include/asm-mips/stackframe.h @@ -15,7 +15,7 @@ #include #include -#include +#include .macro SAVE_AT .set push -- cgit v0.10.2 From cb7b593c2c808b32a1ea188599713c434b95f849 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Sep 2005 13:35:42 -0700 Subject: [IPV4] fib_trie: fix proc interface Create one iterator for walking over FIB trie, and use it for all the /proc functions. Add a /proc/net/route output for backwards compatibility with old applications. Make initialization of fib_trie same as fib_hash so no #ifdef is needed in af_inet.c Fixes: http://bugzilla.kernel.org/show_bug.cgi?id=5209 Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index bf147f8..a9d84f9 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1248,11 +1248,6 @@ module_init(inet_init); /* ------------------------------------------------------------------------ */ #ifdef CONFIG_PROC_FS -#ifdef CONFIG_IP_FIB_TRIE -extern int fib_stat_proc_init(void); -extern void fib_stat_proc_exit(void); -#endif - static int __init ipv4_proc_init(void) { int rc = 0; @@ -1265,19 +1260,11 @@ static int __init ipv4_proc_init(void) goto out_udp; if (fib_proc_init()) goto out_fib; -#ifdef CONFIG_IP_FIB_TRIE - if (fib_stat_proc_init()) - goto out_fib_stat; -#endif if (ip_misc_proc_init()) goto out_misc; out: return rc; out_misc: -#ifdef CONFIG_IP_FIB_TRIE - fib_stat_proc_exit(); -out_fib_stat: -#endif fib_proc_exit(); out_fib: udp4_proc_exit(); diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index b2dea4e..1b63b48 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -43,7 +43,7 @@ * 2 of the License, or (at your option) any later version. */ -#define VERSION "0.402" +#define VERSION "0.403" #include #include @@ -164,7 +164,6 @@ static struct node *resize(struct trie *t, struct tnode *tn); static struct tnode *inflate(struct trie *t, struct tnode *tn); static struct tnode *halve(struct trie *t, struct tnode *tn); static void tnode_free(struct tnode *tn); -static void trie_dump_seq(struct seq_file *seq, struct trie *t); static kmem_cache_t *fn_alias_kmem __read_mostly; static struct trie *trie_local = NULL, *trie_main = NULL; @@ -1971,558 +1970,525 @@ struct fib_table * __init fib_hash_init(int id) return tb; } -/* Trie dump functions */ +#ifdef CONFIG_PROC_FS +/* Depth first Trie walk iterator */ +struct fib_trie_iter { + struct tnode *tnode; + struct trie *trie; + unsigned index; + unsigned depth; +}; -static void putspace_seq(struct seq_file *seq, int n) +static struct node *fib_trie_get_next(struct fib_trie_iter *iter) { - while (n--) - seq_printf(seq, " "); -} + struct tnode *tn = iter->tnode; + unsigned cindex = iter->index; + struct tnode *p; -static void printbin_seq(struct seq_file *seq, unsigned int v, int bits) -{ - while (bits--) - seq_printf(seq, "%s", (v & (1<tnode, iter->index, iter->depth); +rescan: + while (cindex < (1<bits)) { + struct node *n = tnode_get_child(tn, cindex); -static void printnode_seq(struct seq_file *seq, int indent, struct node *n, - int pend, int cindex, int bits) -{ - putspace_seq(seq, indent); - if (IS_LEAF(n)) - seq_printf(seq, "|"); - else - seq_printf(seq, "+"); - if (bits) { - seq_printf(seq, "%d/", cindex); - printbin_seq(seq, cindex, bits); - seq_printf(seq, ": "); - } else - seq_printf(seq, ": "); - seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n); + if (n) { + if (IS_LEAF(n)) { + iter->tnode = tn; + iter->index = cindex + 1; + } else { + /* push down one level */ + iter->tnode = (struct tnode *) n; + iter->index = 0; + ++iter->depth; + } + return n; + } - if (IS_LEAF(n)) { - struct leaf *l = (struct leaf *)n; - struct fib_alias *fa; - int i; + ++cindex; + } - seq_printf(seq, "key=%d.%d.%d.%d\n", - n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256); - - for (i = 32; i >= 0; i--) - if (find_leaf_info(&l->list, i)) { - struct list_head *fa_head = get_fa_head(l, i); - - if (!fa_head) - continue; - - if (list_empty(fa_head)) - continue; - - putspace_seq(seq, indent+2); - seq_printf(seq, "{/%d...dumping}\n", i); - - list_for_each_entry_rcu(fa, fa_head, fa_list) { - putspace_seq(seq, indent+2); - if (fa->fa_info == NULL) { - seq_printf(seq, "Error fa_info=NULL\n"); - continue; - } - if (fa->fa_info->fib_nh == NULL) { - seq_printf(seq, "Error _fib_nh=NULL\n"); - continue; - } - - seq_printf(seq, "{type=%d scope=%d TOS=%d}\n", - fa->fa_type, - fa->fa_scope, - fa->fa_tos); - } - } - } else { - struct tnode *tn = (struct tnode *)n; - int plen = ((struct tnode *)n)->pos; - t_key prf = MASK_PFX(n->key, plen); - - seq_printf(seq, "key=%d.%d.%d.%d/%d\n", - prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen); - - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{key prefix=%08x/", tn->key & TKEY_GET_MASK(0, tn->pos)); - printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos); - seq_printf(seq, "}\n"); - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{pos=%d", tn->pos); - seq_printf(seq, " (skip=%d bits)", tn->pos - pend); - seq_printf(seq, " bits=%d (%u children)}\n", tn->bits, (1 << tn->bits)); - putspace_seq(seq, indent); seq_printf(seq, "| "); - seq_printf(seq, "{empty=%d full=%d}\n", tn->empty_children, tn->full_children); + /* Current node exhausted, pop back up */ + p = NODE_PARENT(tn); + if (p) { + cindex = tkey_extract_bits(tn->key, p->pos, p->bits)+1; + tn = p; + --iter->depth; + goto rescan; } + + /* got root? */ + return NULL; } -static void trie_dump_seq(struct seq_file *seq, struct trie *t) +static struct node *fib_trie_get_first(struct fib_trie_iter *iter, + struct trie *t) { - struct node *n; - int cindex = 0; - int indent = 1; - int pend = 0; - int depth = 0; - struct tnode *tn; - - rcu_read_lock(); - n = rcu_dereference(t->trie); - seq_printf(seq, "------ trie_dump of t=%p ------\n", t); + struct node *n = rcu_dereference(t->trie); - if (!n) { - seq_printf(seq, "------ trie is empty\n"); - - rcu_read_unlock(); - return; + if (n && IS_TNODE(n)) { + iter->tnode = (struct tnode *) n; + iter->trie = t; + iter->index = 0; + iter->depth = 0; + return n; } + return NULL; +} - printnode_seq(seq, indent, n, pend, cindex, 0); - - if (!IS_TNODE(n)) { - rcu_read_unlock(); - return; - } - - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); - indent += 3; - depth++; - - while (tn && cindex < (1 << tn->bits)) { - struct node *child = rcu_dereference(tn->child[cindex]); - if (!child) - cindex++; - else { - /* Got a child */ - printnode_seq(seq, indent, child, pend, - cindex, tn->bits); - - if (IS_LEAF(child)) - cindex++; - - else { - /* - * New tnode. Decend one level - */ - - depth++; - n = child; - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - putspace_seq(seq, indent); - seq_printf(seq, "\\--\n"); - indent += 3; - cindex = 0; - } - } - - /* - * Test if we are done - */ - - while (cindex >= (1 << tn->bits)) { - /* - * Move upwards and test for root - * pop off all traversed nodes - */ +static void trie_collect_stats(struct trie *t, struct trie_stat *s) +{ + struct node *n; + struct fib_trie_iter iter; - if (NODE_PARENT(tn) == NULL) { - tn = NULL; - break; - } + memset(s, 0, sizeof(*s)); - cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); - cindex++; - tn = NODE_PARENT(tn); - pend = tn->pos + tn->bits; - indent -= 3; - depth--; + rcu_read_lock(); + for (n = fib_trie_get_first(&iter, t); n; + n = fib_trie_get_next(&iter)) { + if (IS_LEAF(n)) { + s->leaves++; + s->totdepth += iter.depth; + if (iter.depth > s->maxdepth) + s->maxdepth = iter.depth; + } else { + const struct tnode *tn = (const struct tnode *) n; + int i; + + s->tnodes++; + s->nodesizes[tn->bits]++; + for (i = 0; i < (1<bits); i++) + if (!tn->child[i]) + s->nullpointers++; } } rcu_read_unlock(); } -static struct trie_stat *trie_stat_new(void) +/* + * This outputs /proc/net/fib_triestats + */ +static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat) { - struct trie_stat *s; - int i; + unsigned i, max, pointers, bytes, avdepth; - s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); - if (!s) - return NULL; + if (stat->leaves) + avdepth = stat->totdepth*100 / stat->leaves; + else + avdepth = 0; - s->totdepth = 0; - s->maxdepth = 0; - s->tnodes = 0; - s->leaves = 0; - s->nullpointers = 0; + seq_printf(seq, "\tAver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); + seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth); - for (i = 0; i < MAX_CHILDS; i++) - s->nodesizes[i] = 0; + seq_printf(seq, "\tLeaves: %u\n", stat->leaves); - return s; -} + bytes = sizeof(struct leaf) * stat->leaves; + seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes); + bytes += sizeof(struct tnode) * stat->tnodes; -static struct trie_stat *trie_collect_stats(struct trie *t) -{ - struct node *n; - struct trie_stat *s = trie_stat_new(); - int cindex = 0; - int pend = 0; - int depth = 0; + max = MAX_CHILDS-1; + while (max >= 0 && stat->nodesizes[max] == 0) + max--; - if (!s) - return NULL; + pointers = 0; + for (i = 1; i <= max; i++) + if (stat->nodesizes[i] != 0) { + seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); + pointers += (1<nodesizes[i]; + } + seq_putc(seq, '\n'); + seq_printf(seq, "\tPointers: %d\n", pointers); - rcu_read_lock(); - n = rcu_dereference(t->trie); + bytes += sizeof(struct node *) * pointers; + seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); + seq_printf(seq, "Total size: %d kB\n", (bytes + 1023) / 1024); - if (!n) - return s; +#ifdef CONFIG_IP_FIB_TRIE_STATS + seq_printf(seq, "Counters:\n---------\n"); + seq_printf(seq,"gets = %d\n", t->stats.gets); + seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); + seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); + seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); + seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); + seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); +#ifdef CLEAR_STATS + memset(&(t->stats), 0, sizeof(t->stats)); +#endif +#endif /* CONFIG_IP_FIB_TRIE_STATS */ +} - if (IS_TNODE(n)) { - struct tnode *tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - s->nodesizes[tn->bits]++; - depth++; - - while (tn && cindex < (1 << tn->bits)) { - struct node *ch = rcu_dereference(tn->child[cindex]); - if (ch) { - - /* Got a child */ - - if (IS_LEAF(tn->child[cindex])) { - cindex++; - - /* stats */ - if (depth > s->maxdepth) - s->maxdepth = depth; - s->totdepth += depth; - s->leaves++; - } else { - /* - * New tnode. Decend one level - */ - - s->tnodes++; - s->nodesizes[tn->bits]++; - depth++; - - n = ch; - tn = (struct tnode *)n; - pend = tn->pos+tn->bits; - - cindex = 0; - } - } else { - cindex++; - s->nullpointers++; - } +static int fib_triestat_seq_show(struct seq_file *seq, void *v) +{ + struct trie_stat *stat; - /* - * Test if we are done - */ + stat = kmalloc(sizeof(*stat), GFP_KERNEL); + if (!stat) + return -ENOMEM; - while (cindex >= (1 << tn->bits)) { - /* - * Move upwards and test for root - * pop off all traversed nodes - */ + seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", + sizeof(struct leaf), sizeof(struct tnode)); - if (NODE_PARENT(tn) == NULL) { - tn = NULL; - n = NULL; - break; - } + if (trie_local) { + seq_printf(seq, "Local:\n"); + trie_collect_stats(trie_local, stat); + trie_show_stats(seq, stat); + } - cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); - tn = NODE_PARENT(tn); - cindex++; - n = (struct node *)tn; - pend = tn->pos+tn->bits; - depth--; - } - } + if (trie_main) { + seq_printf(seq, "Main:\n"); + trie_collect_stats(trie_main, stat); + trie_show_stats(seq, stat); } + kfree(stat); - rcu_read_unlock(); - return s; + return 0; } -#ifdef CONFIG_PROC_FS - -static struct fib_alias *fib_triestat_get_first(struct seq_file *seq) +static int fib_triestat_seq_open(struct inode *inode, struct file *file) { - return NULL; + return single_open(file, fib_triestat_seq_show, NULL); } -static struct fib_alias *fib_triestat_get_next(struct seq_file *seq) +static struct file_operations fib_triestat_fops = { + .owner = THIS_MODULE, + .open = fib_triestat_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, + loff_t pos) { + loff_t idx = 0; + struct node *n; + + for (n = fib_trie_get_first(iter, trie_local); + n; ++idx, n = fib_trie_get_next(iter)) { + if (pos == idx) + return n; + } + + for (n = fib_trie_get_first(iter, trie_main); + n; ++idx, n = fib_trie_get_next(iter)) { + if (pos == idx) + return n; + } return NULL; } -static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos) +static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) { - if (!ip_fib_main_table) - return NULL; - - if (*pos) - return fib_triestat_get_next(seq); - else + rcu_read_lock(); + if (*pos == 0) return SEQ_START_TOKEN; + return fib_trie_get_idx(seq->private, *pos - 1); } -static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos) +static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) { + struct fib_trie_iter *iter = seq->private; + void *l = v; + ++*pos; if (v == SEQ_START_TOKEN) - return fib_triestat_get_first(seq); - else - return fib_triestat_get_next(seq); -} + return fib_trie_get_idx(iter, 0); -static void fib_triestat_seq_stop(struct seq_file *seq, void *v) -{ + v = fib_trie_get_next(iter); + BUG_ON(v == l); + if (v) + return v; -} + /* continue scan in next trie */ + if (iter->trie == trie_local) + return fib_trie_get_first(iter, trie_main); -/* - * This outputs /proc/net/fib_triestats - * - * It always works in backward compatibility mode. - * The format of the file is not supposed to be changed. - */ + return NULL; +} -static void collect_and_show(struct trie *t, struct seq_file *seq) +static void fib_trie_seq_stop(struct seq_file *seq, void *v) { - int bytes = 0; /* How many bytes are used, a ref is 4 bytes */ - int i, max, pointers; - struct trie_stat *stat; - int avdepth; - - stat = trie_collect_stats(t); - - bytes = 0; - seq_printf(seq, "trie=%p\n", t); - - if (stat) { - if (stat->leaves) - avdepth = stat->totdepth*100 / stat->leaves; - else - avdepth = 0; - seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100); - seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); + rcu_read_unlock(); +} - seq_printf(seq, "Leaves: %d\n", stat->leaves); - bytes += sizeof(struct leaf) * stat->leaves; - seq_printf(seq, "Internal nodes: %d\n", stat->tnodes); - bytes += sizeof(struct tnode) * stat->tnodes; +static void seq_indent(struct seq_file *seq, int n) +{ + while (n-- > 0) seq_puts(seq, " "); +} - max = MAX_CHILDS-1; +static inline const char *rtn_scope(enum rt_scope_t s) +{ + static char buf[32]; - while (max >= 0 && stat->nodesizes[max] == 0) - max--; - pointers = 0; + switch(s) { + case RT_SCOPE_UNIVERSE: return "universe"; + case RT_SCOPE_SITE: return "site"; + case RT_SCOPE_LINK: return "link"; + case RT_SCOPE_HOST: return "host"; + case RT_SCOPE_NOWHERE: return "nowhere"; + default: + snprintf(buf, sizeof(buf), "scope=%d", s); + return buf; + } +} - for (i = 1; i <= max; i++) - if (stat->nodesizes[i] != 0) { - seq_printf(seq, " %d: %d", i, stat->nodesizes[i]); - pointers += (1<nodesizes[i]; - } - seq_printf(seq, "\n"); - seq_printf(seq, "Pointers: %d\n", pointers); - bytes += sizeof(struct node *) * pointers; - seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers); - seq_printf(seq, "Total size: %d kB\n", bytes / 1024); +static const char *rtn_type_names[__RTN_MAX] = { + [RTN_UNSPEC] = "UNSPEC", + [RTN_UNICAST] = "UNICAST", + [RTN_LOCAL] = "LOCAL", + [RTN_BROADCAST] = "BROADCAST", + [RTN_ANYCAST] = "ANYCAST", + [RTN_MULTICAST] = "MULTICAST", + [RTN_BLACKHOLE] = "BLACKHOLE", + [RTN_UNREACHABLE] = "UNREACHABLE", + [RTN_PROHIBIT] = "PROHIBIT", + [RTN_THROW] = "THROW", + [RTN_NAT] = "NAT", + [RTN_XRESOLVE] = "XRESOLVE", +}; - kfree(stat); - } +static inline const char *rtn_type(unsigned t) +{ + static char buf[32]; -#ifdef CONFIG_IP_FIB_TRIE_STATS - seq_printf(seq, "Counters:\n---------\n"); - seq_printf(seq,"gets = %d\n", t->stats.gets); - seq_printf(seq,"backtracks = %d\n", t->stats.backtrack); - seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed); - seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss); - seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit); - seq_printf(seq,"skipped node resize = %d\n", t->stats.resize_node_skipped); -#ifdef CLEAR_STATS - memset(&(t->stats), 0, sizeof(t->stats)); -#endif -#endif /* CONFIG_IP_FIB_TRIE_STATS */ + if (t < __RTN_MAX && rtn_type_names[t]) + return rtn_type_names[t]; + snprintf(buf, sizeof(buf), "type %d", t); + return buf; } -static int fib_triestat_seq_show(struct seq_file *seq, void *v) +/* Pretty print the trie */ +static int fib_trie_seq_show(struct seq_file *seq, void *v) { - char bf[128]; + const struct fib_trie_iter *iter = seq->private; + struct node *n = v; - if (v == SEQ_START_TOKEN) { - seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", - sizeof(struct leaf), sizeof(struct tnode)); - if (trie_local) - collect_and_show(trie_local, seq); + if (v == SEQ_START_TOKEN) + return 0; - if (trie_main) - collect_and_show(trie_main, seq); - } else { - snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400); + if (IS_TNODE(n)) { + struct tnode *tn = (struct tnode *) n; + t_key prf = ntohl(MASK_PFX(tn->key, tn->pos)); - seq_printf(seq, "%-127s\n", bf); + if (!NODE_PARENT(n)) { + if (iter->trie == trie_local) + seq_puts(seq, ":\n"); + else + seq_puts(seq, "
:\n"); + } else { + seq_indent(seq, iter->depth-1); + seq_printf(seq, " +-- %d.%d.%d.%d/%d\n", + NIPQUAD(prf), tn->pos); + } + } else { + struct leaf *l = (struct leaf *) n; + int i; + u32 val = ntohl(l->key); + + seq_indent(seq, iter->depth); + seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); + for (i = 32; i >= 0; i--) { + struct leaf_info *li = find_leaf_info(&l->list, i); + if (li) { + struct fib_alias *fa; + list_for_each_entry_rcu(fa, &li->falh, fa_list) { + seq_indent(seq, iter->depth+1); + seq_printf(seq, " /%d %s %s", i, + rtn_scope(fa->fa_scope), + rtn_type(fa->fa_type)); + if (fa->fa_tos) + seq_printf(seq, "tos =%d\n", + fa->fa_tos); + seq_putc(seq, '\n'); + } + } + } } + return 0; } -static struct seq_operations fib_triestat_seq_ops = { - .start = fib_triestat_seq_start, - .next = fib_triestat_seq_next, - .stop = fib_triestat_seq_stop, - .show = fib_triestat_seq_show, +static struct seq_operations fib_trie_seq_ops = { + .start = fib_trie_seq_start, + .next = fib_trie_seq_next, + .stop = fib_trie_seq_stop, + .show = fib_trie_seq_show, }; -static int fib_triestat_seq_open(struct inode *inode, struct file *file) +static int fib_trie_seq_open(struct inode *inode, struct file *file) { struct seq_file *seq; int rc = -ENOMEM; + struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); - rc = seq_open(file, &fib_triestat_seq_ops); + if (!s) + goto out; + + rc = seq_open(file, &fib_trie_seq_ops); if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; + seq->private = s; + memset(s, 0, sizeof(*s)); out: return rc; out_kfree: + kfree(s); goto out; } -static struct file_operations fib_triestat_seq_fops = { - .owner = THIS_MODULE, - .open = fib_triestat_seq_open, - .read = seq_read, - .llseek = seq_lseek, +static struct file_operations fib_trie_fops = { + .owner = THIS_MODULE, + .open = fib_trie_seq_open, + .read = seq_read, + .llseek = seq_lseek, .release = seq_release_private, }; -int __init fib_stat_proc_init(void) -{ - if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_seq_fops)) - return -ENOMEM; - return 0; -} - -void __init fib_stat_proc_exit(void) +static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi) { - proc_net_remove("fib_triestat"); -} + static unsigned type2flags[RTN_MAX + 1] = { + [7] = RTF_REJECT, [8] = RTF_REJECT, + }; + unsigned flags = type2flags[type]; -static struct fib_alias *fib_trie_get_first(struct seq_file *seq) -{ - return NULL; + if (fi && fi->fib_nh->nh_gw) + flags |= RTF_GATEWAY; + if (mask == 0xFFFFFFFF) + flags |= RTF_HOST; + flags |= RTF_UP; + return flags; } -static struct fib_alias *fib_trie_get_next(struct seq_file *seq) +/* + * This outputs /proc/net/route. + * The format of the file is not supposed to be changed + * and needs to be same as fib_hash output to avoid breaking + * legacy utilities + */ +static int fib_route_seq_show(struct seq_file *seq, void *v) { - return NULL; -} + struct leaf *l = v; + int i; + char bf[128]; -static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) -{ - if (!ip_fib_main_table) - return NULL; + if (v == SEQ_START_TOKEN) { + seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " + "\tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU" + "\tWindow\tIRTT"); + return 0; + } - if (*pos) - return fib_trie_get_next(seq); - else - return SEQ_START_TOKEN; -} + if (IS_TNODE(l)) + return 0; -static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) -{ - ++*pos; - if (v == SEQ_START_TOKEN) - return fib_trie_get_first(seq); - else - return fib_trie_get_next(seq); + for (i=32; i>=0; i--) { + struct leaf_info *li = find_leaf_info(&l->list, i); + struct fib_alias *fa; + u32 mask, prefix; -} + if (!li) + continue; -static void fib_trie_seq_stop(struct seq_file *seq, void *v) -{ -} + mask = inet_make_mask(li->plen); + prefix = htonl(l->key); -/* - * This outputs /proc/net/fib_trie. - * - * It always works in backward compatibility mode. - * The format of the file is not supposed to be changed. - */ + list_for_each_entry_rcu(fa, &li->falh, fa_list) { + const struct fib_info *fi = rcu_dereference(fa->fa_info); + unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); -static int fib_trie_seq_show(struct seq_file *seq, void *v) -{ - char bf[128]; + if (fa->fa_type == RTN_BROADCAST + || fa->fa_type == RTN_MULTICAST) + continue; - if (v == SEQ_START_TOKEN) { - if (trie_local) - trie_dump_seq(seq, trie_local); + if (fi) + snprintf(bf, sizeof(bf), + "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", + fi->fib_dev ? fi->fib_dev->name : "*", + prefix, + fi->fib_nh->nh_gw, flags, 0, 0, + fi->fib_priority, + mask, + (fi->fib_advmss ? fi->fib_advmss + 40 : 0), + fi->fib_window, + fi->fib_rtt >> 3); + else + snprintf(bf, sizeof(bf), + "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", + prefix, 0, flags, 0, 0, 0, + mask, 0, 0, 0); - if (trie_main) - trie_dump_seq(seq, trie_main); - } else { - snprintf(bf, sizeof(bf), - "*\t%08X\t%08X", 200, 400); - seq_printf(seq, "%-127s\n", bf); + seq_printf(seq, "%-127s\n", bf); + } } return 0; } -static struct seq_operations fib_trie_seq_ops = { - .start = fib_trie_seq_start, - .next = fib_trie_seq_next, - .stop = fib_trie_seq_stop, - .show = fib_trie_seq_show, +static struct seq_operations fib_route_seq_ops = { + .start = fib_trie_seq_start, + .next = fib_trie_seq_next, + .stop = fib_trie_seq_stop, + .show = fib_route_seq_show, }; -static int fib_trie_seq_open(struct inode *inode, struct file *file) +static int fib_route_seq_open(struct inode *inode, struct file *file) { struct seq_file *seq; int rc = -ENOMEM; + struct fib_trie_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); - rc = seq_open(file, &fib_trie_seq_ops); + if (!s) + goto out; + + rc = seq_open(file, &fib_route_seq_ops); if (rc) goto out_kfree; - seq = file->private_data; + seq = file->private_data; + seq->private = s; + memset(s, 0, sizeof(*s)); out: return rc; out_kfree: + kfree(s); goto out; } -static struct file_operations fib_trie_seq_fops = { - .owner = THIS_MODULE, - .open = fib_trie_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release= seq_release_private, +static struct file_operations fib_route_fops = { + .owner = THIS_MODULE, + .open = fib_route_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, }; int __init fib_proc_init(void) { - if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_seq_fops)) - return -ENOMEM; + if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_fops)) + goto out1; + + if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_fops)) + goto out2; + + if (!proc_net_fops_create("route", S_IRUGO, &fib_route_fops)) + goto out3; + return 0; + +out3: + proc_net_remove("fib_triestat"); +out2: + proc_net_remove("fib_trie"); +out1: + return -ENOMEM; } void __init fib_proc_exit(void) { proc_net_remove("fib_trie"); + proc_net_remove("fib_triestat"); + proc_net_remove("route"); } #endif /* CONFIG_PROC_FS */ -- cgit v0.10.2 From 5a0773698c51fdcec7eb361b6b819669ed1d249e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:44:31 +0200 Subject: kbuild: cris use generic asm-offsets.h support Cris has a dedicated asm-offsets.c file per subarchitecture. So a symlink is created to put the desired asm-offsets.c file in $(ARCH)/kernel This is absolutely not good practice, but it was the trick used in the rest of the cris code. Signed-off-by: Sam Ravnborg diff --git a/arch/cris/Makefile b/arch/cris/Makefile index 90ca873..a00043a 100644 --- a/arch/cris/Makefile +++ b/arch/cris/Makefile @@ -107,8 +107,7 @@ archclean: rm -f timage vmlinux.bin decompress.bin rescue.bin cramfs.img rm -rf $(LD_SCRIPT).tmp -prepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch \ - include/asm-$(ARCH)/$(SARCH)/offset.h +prepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch # Create some links to make all tools happy $(SRC_ARCH)/.links: @@ -120,6 +119,7 @@ $(SRC_ARCH)/.links: @ln -sfn $(SRC_ARCH)/$(SARCH)/lib $(SRC_ARCH)/lib @ln -sfn $(SRC_ARCH)/$(SARCH) $(SRC_ARCH)/arch @ln -sfn $(SRC_ARCH)/$(SARCH)/vmlinux.lds.S $(SRC_ARCH)/kernel/vmlinux.lds.S + @ln -sfn $(SRC_ARCH)/$(SARCH)/asm-offsets.c $(SRC_ARCH)/kernel/asm-offsets.c @touch $@ # Create link to sub arch includes @@ -128,9 +128,3 @@ $(srctree)/include/asm-$(ARCH)/.arch: $(wildcard include/config/arch/*.h) @rm -f include/asm-$(ARCH)/arch @ln -sf $(srctree)/include/asm-$(ARCH)/$(SARCH) $(srctree)/include/asm-$(ARCH)/arch @touch $@ - -arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ - include/config/MARKER - -include/asm-$(ARCH)/$(SARCH)/offset.h: arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s - $(call filechk,gen-asm-offsets) diff --git a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S index c0163bf..c808005 100644 --- a/arch/cris/arch-v10/kernel/entry.S +++ b/arch/cris/arch-v10/kernel/entry.S @@ -270,7 +270,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/cris/arch-v32/kernel/entry.S b/arch/cris/arch-v32/kernel/entry.S index a8ed55e..3bd8503 100644 --- a/arch/cris/arch-v32/kernel/entry.S +++ b/arch/cris/arch-v32/kernel/entry.S @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include -- cgit v0.10.2 From 1325cc79163058739b70bed9860fccbecac6236b Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Fri, 9 Sep 2005 13:45:51 -0700 Subject: [PATCH] IB: Define more SA methods ib_sa.h: Define more SA methods (initially for madeye decode) Signed-off-by: Hal Rosenstock Signed-off-by: Roland Dreier diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index c022edf..0f4f5ec 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h @@ -46,7 +46,11 @@ enum { IB_SA_METHOD_GET_TABLE = 0x12, IB_SA_METHOD_GET_TABLE_RESP = 0x92, - IB_SA_METHOD_DELETE = 0x15 + IB_SA_METHOD_DELETE = 0x15, + IB_SA_METHOD_DELETE_RESP = 0x95, + IB_SA_METHOD_GET_MULTI = 0x14, + IB_SA_METHOD_GET_MULTI_RESP = 0x94, + IB_SA_METHOD_GET_TRACE_TBL = 0x13 }; enum ib_sa_selector { -- cgit v0.10.2 From 0037c78a96bb391635bff103d401c24459c5092d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Sep 2005 22:47:53 +0200 Subject: kbuild: frv,m32r,sparc64 introduce fake asm-offsets.h file Needed to get them to build. And a hint to avoid hardcoding to many constants in assembler. Signed-off-by: Sam Ravnborg diff --git a/arch/frv/kernel/asm-offsets.c b/arch/frv/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/frv/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ diff --git a/arch/m32r/kernel/asm-offsets.c b/arch/m32r/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/m32r/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ diff --git a/arch/sparc64/kernel/asm-offsets.c b/arch/sparc64/kernel/asm-offsets.c new file mode 100644 index 0000000..9e26311 --- /dev/null +++ b/arch/sparc64/kernel/asm-offsets.c @@ -0,0 +1 @@ +/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ -- cgit v0.10.2 From 1299232b5743da454c73853b90b3d2d83dce1737 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 9 Sep 2005 13:01:21 -0700 Subject: [PATCH] x86: MP_processor_info fix Remove the weird and apparently unnecessary logic in MP_processor_info() which assumes that the BSP is the first one to run MP_processor_info(). On one of my boxes that isn't true and cpu_possible_map gets the wrong value. Cc: Zwane Mwaikambo Cc: Alexander Nyberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index cafaeff..15949fd 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -122,8 +122,8 @@ static int MP_valid_apicid(int apicid, int version) static void __init MP_processor_info (struct mpc_config_processor *m) { - int ver, apicid, cpu, found_bsp = 0; - physid_mask_t tmp; + int ver, apicid; + physid_mask_t phys_cpu; if (!(m->mpc_cpuflag & CPU_ENABLED)) return; @@ -181,7 +181,6 @@ static void __init MP_processor_info (struct mpc_config_processor *m) if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { Dprintk(" Bootup CPU\n"); boot_cpu_physical_apicid = m->mpc_apicid; - found_bsp = 1; } if (num_processors >= NR_CPUS) { @@ -195,29 +194,26 @@ static void __init MP_processor_info (struct mpc_config_processor *m) " Processor ignored.\n", maxcpus); return; } - num_processors++; ver = m->mpc_apicver; if (!MP_valid_apicid(apicid, ver)) { printk(KERN_WARNING "Processor #%d INVALID. (Max ID: %d).\n", m->mpc_apicid, MAX_APICS); - --num_processors; return; } - if (found_bsp) - cpu = 0; - else - cpu = num_processors - 1; - cpu_set(cpu, cpu_possible_map); - tmp = apicid_to_cpu_present(apicid); - physids_or(phys_cpu_present_map, phys_cpu_present_map, tmp); - + cpu_set(num_processors, cpu_possible_map); + num_processors++; + phys_cpu = apicid_to_cpu_present(apicid); + physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu); + /* * Validate version */ if (ver == 0x0) { - printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)\n", m->mpc_apicid); + printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! " + "fixing up to 0x10. (tell your hw vendor)\n", + m->mpc_apicid); ver = 0x10; } apic_version[m->mpc_apicid] = ver; -- cgit v0.10.2 From 4b5d37ac02954572e80e09255bb5737277aaee8e Mon Sep 17 00:00:00 2001 From: Giancarlo Formicuccia Date: Fri, 9 Sep 2005 13:01:22 -0700 Subject: [PATCH] Clear task_struct->fs_excl on fork() An oversight. We don't want to carry the IO scheduler's "we hold exclusive fs resources" hint over to the child across fork(). Acked-by: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/fork.c b/kernel/fork.c index 7e1ead9..dfeadf4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -176,6 +176,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) /* One for us, one for whoever does the "release_task()" (usually parent) */ atomic_set(&tsk->usage,2); + atomic_set(&tsk->fs_excl, 0); return tsk; } -- cgit v0.10.2 From abda24528ac3045511fb59291a2d6ccbddf30eda Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Fri, 9 Sep 2005 13:01:23 -0700 Subject: [PATCH] i386: CONFIG_ACPI_SRAT typo fix Fix a typo involving CONFIG_ACPI_SRAT. Signed-off-by: Magnus Damm Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h index 5164213..348fe3a 100644 --- a/include/asm-i386/mmzone.h +++ b/include/asm-i386/mmzone.h @@ -29,7 +29,7 @@ static inline void get_memcfg_numa(void) #ifdef CONFIG_X86_NUMAQ if (get_memcfg_numaq()) return; -#elif CONFIG_ACPI_SRAT +#elif defined(CONFIG_ACPI_SRAT) if (get_memcfg_from_srat()) return; #endif -- cgit v0.10.2 From 7f6fd5db2dbc28d475d67f9a6b041fefe1d6f7c8 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 9 Sep 2005 13:01:26 -0700 Subject: [PATCH] ppc32: Fix Kconfig mismerge Looks like the help comment for MPC834x got merged incorrectly. Signed-off-by: Kumar Gala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index 6ab7e5e..e3f1ce3 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig @@ -499,11 +499,6 @@ config WINCEPT MPC821 PowerPC, introduced in 1998 and designed to be used in thin-client machines. Say Y to support it directly. - Be aware that PCI buses can only function when SYS board is plugged - into the PIB (Platform IO Board) board from Freescale which provide - 3 PCI slots. The PIBs PCI initialization is the bootloader's - responsiblilty. - endchoice choice @@ -680,6 +675,11 @@ config MPC834x_SYS help This option enables support for the MPC 834x SYS evaluation board. + Be aware that PCI buses can only function when SYS board is plugged + into the PIB (Platform IO Board) board from Freescale which provide + 3 PCI slots. The PIBs PCI initialization is the bootloader's + responsiblilty. + config EV64360 bool "Marvell-EV64360BP" help -- cgit v0.10.2 From e85b565233236a2a833adea73fb2f0e0f8fa2a61 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 9 Sep 2005 13:01:29 -0700 Subject: [PATCH] move truncate_inode_pages() into ->delete_inode() Allow file systems supporting ->delete_inode() to call truncate_inode_pages() on their own. OCFS2 wants this so it can query the cluster before making a final decision on whether to wipe an inode from disk or not. In some corner cases an inode marked on the local node via voting may not actually get orphaned. A good example is node death before the transaction moving the inode to the orphan dir commits to the journal. Without this patch, the truncate_inode_pages() call in generic_delete_inode() would discard valid data for such inodes. During earlier discussion in the 2.6.13 merge plan thread, Christoph Hellwig indicated that other file systems might also find this useful. IMHO, the best solution would be to just allow ->drop_inode() to do the cluster query but it seems that would require a substantial reworking of that section of the code. Assuming it is safe to call write_inode_now() in ocfs2_delete_inode() for those inodes which won't actually get wiped, this solution should get us by for now. Trivial testing of this patch (and a related OCFS2 update) has shown this to avoid the corruption I'm seeing. Signed-off-by: Mark Fasheh Acked-by: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/inode.c b/fs/inode.c index 71df1b1..f80a79f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1034,19 +1034,21 @@ void generic_delete_inode(struct inode *inode) inodes_stat.nr_inodes--; spin_unlock(&inode_lock); - if (inode->i_data.nrpages) - truncate_inode_pages(&inode->i_data, 0); - security_inode_delete(inode); if (op->delete_inode) { void (*delete)(struct inode *) = op->delete_inode; if (!is_bad_inode(inode)) DQUOT_INIT(inode); - /* s_op->delete_inode internally recalls clear_inode() */ + /* Filesystems implementing their own + * s_op->delete_inode are required to call + * truncate_inode_pages and clear_inode() + * internally */ delete(inode); - } else + } else { + truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); + } spin_lock(&inode_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_lock); -- cgit v0.10.2 From fef266580e5cf897a1b63528fc6b1185e2d6bb87 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 9 Sep 2005 13:01:31 -0700 Subject: [PATCH] update filesystems for new delete_inode behavior Update the file systems in fs/ implementing a delete_inode() callback to call truncate_inode_pages(). One implementation note: In developing this patch I put the calls to truncate_inode_pages() at the very top of those filesystems delete_inode() callbacks in order to retain the previous behavior. I'm guessing that some of those could probably be optimized. Signed-off-by: Mark Fasheh Acked-by: Christoph Hellwig Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 7aa6f20..9ebe881 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -255,6 +255,7 @@ void affs_delete_inode(struct inode *inode) { pr_debug("AFFS: delete_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; if (S_ISREG(inode->i_mode)) affs_truncate(inode); diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 64e0fb3..628c2c1 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -143,6 +143,8 @@ static void bfs_delete_inode(struct inode * inode) dprintf("ino=%08lx\n", inode->i_ino); + truncate_inode_pages(&inode->i_data, 0); + if (inode->i_ino < BFS_ROOT_INO || inode->i_ino > info->si_lasti) { printf("invalid ino=%08lx\n", inode->i_ino); return; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 53dceb0..fdba4d1 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -71,6 +71,8 @@ void ext2_put_inode(struct inode *inode) */ void ext2_delete_inode (struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; EXT2_I(inode)->i_dtime = get_seconds(); diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 9989fdc..b5177c9 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -187,6 +187,8 @@ void ext3_delete_inode (struct inode * inode) { handle_t *handle; + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 96ae85b..a7cbe68 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -335,6 +335,8 @@ EXPORT_SYMBOL(fat_build_inode); static void fat_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); + if (!is_bad_inode(inode)) { inode->i_size = 0; fat_truncate(inode); diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index b2d1820..59c5062 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -284,6 +284,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) static void hostfs_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); if(HOSTFS_I(inode)->fd != -1) { close_file(&HOSTFS_I(inode)->fd); HOSTFS_I(inode)->fd = -1; diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 38b1741..e3d17e9 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c @@ -284,6 +284,7 @@ void hpfs_write_if_changed(struct inode *inode) void hpfs_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); lock_kernel(); hpfs_remove_fnode(inode->i_sb, inode->i_ino); unlock_kernel(); diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c index 777b900..3dcc6d2 100644 --- a/fs/jffs/inode-v23.c +++ b/fs/jffs/inode-v23.c @@ -1744,6 +1744,7 @@ jffs_delete_inode(struct inode *inode) D3(printk("jffs_delete_inode(): inode->i_ino == %lu\n", inode->i_ino)); + truncate_inode_pages(&inode->i_data, 0); lock_kernel(); inode->i_size = 0; inode->i_blocks = 0; diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 767c7ec..cff352f 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -132,6 +132,8 @@ void jfs_delete_inode(struct inode *inode) (JFS_IP(inode)->fileset != cpu_to_le32(FILESYSTEM_I))) return; + truncate_inode_pages(&inode->i_data, 0); + if (test_cflag(COMMIT_Freewmap, inode)) jfs_free_zero_link(inode); diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 3f18c21..790cc0d 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -24,6 +24,7 @@ static int minix_remount (struct super_block * sb, int * flags, char * data); static void minix_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; minix_truncate(inode); minix_free_inode(inode); diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 44795d2..8c88392 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -286,6 +286,8 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info) static void ncp_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); + if (S_ISDIR(inode->i_mode)) { DDPRINTK("ncp_delete_inode: put directory %ld\n", inode->i_ino); } diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 541b418..6922469 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -146,6 +146,8 @@ nfs_delete_inode(struct inode * inode) { dprintk("NFS: delete_inode(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); + truncate_inode_pages(&inode->i_data, 0); + nfs_wb_all(inode); /* * The following should never happen... diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 133c286..effa6c0 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -60,6 +60,8 @@ static void proc_delete_inode(struct inode *inode) struct proc_dir_entry *de; struct task_struct *tsk; + truncate_inode_pages(&inode->i_data, 0); + /* Let go of any associated process */ tsk = PROC_I(inode)->task; if (tsk) diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index b79162a..80f3291 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c @@ -63,6 +63,7 @@ int qnx4_sync_inode(struct inode *inode) static void qnx4_delete_inode(struct inode *inode) { QNX4DEBUG(("qnx4: deleting inode [%lu]\n", (unsigned long) inode->i_ino)); + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; qnx4_truncate(inode); lock_kernel(); diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index ff291c9..1a8a1bf 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -33,6 +33,8 @@ void reiserfs_delete_inode(struct inode *inode) 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); struct reiserfs_transaction_handle th; + truncate_inode_pages(&inode->i_data, 0); + reiserfs_write_lock(inode->i_sb); /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c index 4765aaa..10b9944 100644 --- a/fs/smbfs/inode.c +++ b/fs/smbfs/inode.c @@ -331,6 +331,7 @@ static void smb_delete_inode(struct inode *ino) { DEBUG1("ino=%ld\n", ino->i_ino); + truncate_inode_pages(&ino->i_data, 0); lock_kernel(); if (smb_close(ino)) PARANOIA("could not close inode %ld\n", ino->i_ino); diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index 0530077..fa33ece 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c @@ -292,6 +292,7 @@ int sysv_sync_inode(struct inode * inode) static void sysv_delete_inode(struct inode *inode) { + truncate_inode_pages(&inode->i_data, 0); inode->i_size = 0; sysv_truncate(inode); lock_kernel(); diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 3d68de3..b83890b 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -87,6 +87,8 @@ static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); */ void udf_delete_inode(struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); + if (is_bad_inode(inode)) goto no_delete; diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 718627c..55f4aa1 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -804,6 +804,7 @@ int ufs_sync_inode (struct inode *inode) void ufs_delete_inode (struct inode * inode) { + truncate_inode_pages(&inode->i_data, 0); /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/ lock_kernel(); mark_inode_dirty(inode); diff --git a/mm/shmem.c b/mm/shmem.c index db2c9e8d..0d627a3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -666,6 +666,7 @@ static void shmem_delete_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); if (inode->i_op->truncate == shmem_truncate) { + truncate_inode_pages(inode->i_mapping, 0); shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate(inode); -- cgit v0.10.2 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 diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 49afadb..f10c86d 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 v0.10.2 From 5e41ff9e0650f327a6c819841fa412da95d57319 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:35 -0700 Subject: [PATCH] security: enable atomic inode security labeling The following patch set enables atomic security labeling of newly created inodes by altering the fs code to invoke a new LSM hook to obtain the security attribute to apply to a newly created inode and to set up the incore inode security state during the inode creation transaction. This parallels the existing processing for setting ACLs on newly created inodes. Otherwise, it is possible for new inodes to be accessed by another thread via the dcache prior to complete security setup (presently handled by the post_create/mkdir/... LSM hooks in the VFS) and a newly created inode may be left unlabeled on the disk in the event of a crash. SELinux presently works around the issue by ensuring that the incore inode security label is initialized to a special SID that is inaccessible to unprivileged processes (in accordance with policy), thereby preventing inappropriate access but potentially causing false denials on legitimate accesses. A simple test program demonstrates such false denials on SELinux, and the patch solves the problem. Similar such false denials have been encountered in real applications. This patch defines a new inode_init_security LSM hook to obtain the security attribute to apply to a newly created inode and to set up the incore inode security state for it, and adds a corresponding hook function implementation to SELinux. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/linux/security.h b/include/linux/security.h index 7aab6ab..d4f3b7a 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -250,6 +250,25 @@ struct swap_info_struct; * @inode contains the inode structure. * Deallocate the inode security structure and set @inode->i_security to * NULL. + * @inode_init_security: + * Obtain the security attribute name suffix and value to set on a newly + * created inode and set up the incore security field for the new inode. + * This hook is called by the fs code as part of the inode creation + * transaction and provides for atomic labeling of the inode, unlike + * the post_create/mkdir/... hooks called by the VFS. The hook function + * is expected to allocate the name and value via kmalloc, with the caller + * being responsible for calling kfree after using them. + * If the security module does not use security attributes or does + * not wish to put a security attribute on this particular inode, + * then it should return -EOPNOTSUPP to skip this processing. + * @inode contains the inode structure of the newly created inode. + * @dir contains the inode structure of the parent directory. + * @name will be set to the allocated name suffix (e.g. selinux). + * @value will be set to the allocated attribute value. + * @len will be set to the length of the value. + * Returns 0 if @name and @value have been successfully set, + * -EOPNOTSUPP if no security attribute is needed, or + * -ENOMEM on memory allocation failure. * @inode_create: * Check permission to create a regular file. * @dir contains inode structure of the parent of the new file. @@ -1080,6 +1099,8 @@ struct security_operations { int (*inode_alloc_security) (struct inode *inode); void (*inode_free_security) (struct inode *inode); + int (*inode_init_security) (struct inode *inode, struct inode *dir, + char **name, void **value, size_t *len); int (*inode_create) (struct inode *dir, struct dentry *dentry, int mode); void (*inode_post_create) (struct inode *dir, @@ -1442,6 +1463,17 @@ static inline void security_inode_free (struct inode *inode) return; security_ops->inode_free_security (inode); } + +static inline int security_inode_init_security (struct inode *inode, + struct inode *dir, + char **name, + void **value, + size_t *len) +{ + if (unlikely (IS_PRIVATE (inode))) + return -EOPNOTSUPP; + return security_ops->inode_init_security (inode, dir, name, value, len); +} static inline int security_inode_create (struct inode *dir, struct dentry *dentry, @@ -2171,6 +2203,15 @@ static inline int security_inode_alloc (struct inode *inode) static inline void security_inode_free (struct inode *inode) { } + +static inline int security_inode_init_security (struct inode *inode, + struct inode *dir, + char **name, + void **value, + size_t *len) +{ + return -EOPNOTSUPP; +} static inline int security_inode_create (struct inode *dir, struct dentry *dentry, diff --git a/security/dummy.c b/security/dummy.c index 6ff8875..e8a00fa 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -258,6 +258,12 @@ static void dummy_inode_free_security (struct inode *inode) return; } +static int dummy_inode_init_security (struct inode *inode, struct inode *dir, + char **name, void **value, size_t *len) +{ + return -EOPNOTSUPP; +} + static int dummy_inode_create (struct inode *inode, struct dentry *dentry, int mask) { @@ -886,6 +892,7 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, sb_post_pivotroot); set_to_dummy_if_null(ops, inode_alloc_security); set_to_dummy_if_null(ops, inode_free_security); + set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); set_to_dummy_if_null(ops, inode_post_create); set_to_dummy_if_null(ops, inode_link); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 8641f88..63701fe 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1274,6 +1274,7 @@ static int post_create(struct inode *dir, struct inode *inode; struct inode_security_struct *dsec; struct superblock_security_struct *sbsec; + struct inode_security_struct *isec; u32 newsid; char *context; unsigned int len; @@ -1293,6 +1294,11 @@ static int post_create(struct inode *dir, return 0; } + isec = inode->i_security; + + if (isec->security_attr_init) + return 0; + if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { newsid = tsec->create_sid; } else { @@ -2018,6 +2024,58 @@ static void selinux_inode_free_security(struct inode *inode) inode_free_security(inode); } +static int selinux_inode_init_security(struct inode *inode, struct inode *dir, + char **name, void **value, + size_t *len) +{ + struct task_security_struct *tsec; + struct inode_security_struct *dsec; + struct superblock_security_struct *sbsec; + struct inode_security_struct *isec; + u32 newsid; + int rc; + char *namep, *context; + + tsec = current->security; + dsec = dir->i_security; + sbsec = dir->i_sb->s_security; + isec = inode->i_security; + + if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { + newsid = tsec->create_sid; + } else { + rc = security_transition_sid(tsec->sid, dsec->sid, + inode_mode_to_security_class(inode->i_mode), + &newsid); + if (rc) { + printk(KERN_WARNING "%s: " + "security_transition_sid failed, rc=%d (dev=%s " + "ino=%ld)\n", + __FUNCTION__, + -rc, inode->i_sb->s_id, inode->i_ino); + return rc; + } + } + + inode_security_set_sid(inode, newsid); + + namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); + if (!namep) + return -ENOMEM; + *name = namep; + + rc = security_sid_to_context(newsid, &context, len); + if (rc) { + kfree(namep); + return rc; + } + *value = context; + + isec->security_attr_init = 1; + + return 0; +} + static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask) { return may_create(dir, dentry, SECCLASS_FILE); @@ -4298,6 +4356,7 @@ static struct security_operations selinux_ops = { .inode_alloc_security = selinux_inode_alloc_security, .inode_free_security = selinux_inode_free_security, + .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, .inode_post_create = selinux_inode_post_create, .inode_link = selinux_inode_link, diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index 887937c..c515bc0 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -46,6 +46,7 @@ struct inode_security_struct { unsigned char initialized; /* initialization flag */ struct semaphore sem; unsigned char inherit; /* inherit SID from parent entry */ + unsigned char security_attr_init; /* security attributes init flag */ }; struct file_security_struct { -- cgit v0.10.2 From 10f47e6a1b8b276323b652053945c87a63a5812d Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:39 -0700 Subject: [PATCH] ext2: Enable atomic inode security labeling This patch modifies ext2 to call the inode_init_security LSM hook to obtain the security attribute for a newly created inode and to set the resulting attribute on the new inode. This parallels the existing processing for setting ACLs on newly created inodes. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 161f156..c8d0703 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -615,6 +615,11 @@ got: DQUOT_DROP(inode); goto fail2; } + err = ext2_init_security(inode,dir); + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } mark_inode_dirty(inode); ext2_debug("allocating inode %lu\n", inode->i_ino); ext2_preread_inode(inode); diff --git a/fs/ext2/xattr.h b/fs/ext2/xattr.h index 5f3bfde..67cfeb6 100644 --- a/fs/ext2/xattr.h +++ b/fs/ext2/xattr.h @@ -116,3 +116,11 @@ exit_ext2_xattr(void) # endif /* CONFIG_EXT2_FS_XATTR */ +#ifdef CONFIG_EXT2_FS_SECURITY +extern int ext2_init_security(struct inode *inode, struct inode *dir); +#else +static inline int ext2_init_security(struct inode *inode, struct inode *dir) +{ + return 0; +} +#endif diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 6a6c59f..a266127 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "xattr.h" static size_t @@ -45,6 +46,27 @@ ext2_xattr_security_set(struct inode *inode, const char *name, value, size, flags); } +int +ext2_init_security(struct inode *inode, struct inode *dir) +{ + int err; + size_t len; + void *value; + char *name; + + err = security_inode_init_security(inode, dir, &name, &value, &len); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + err = ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, + name, value, len, 0); + kfree(name); + kfree(value); + return err; +} + struct xattr_handler ext2_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .list = ext2_xattr_security_list, -- cgit v0.10.2 From ac50960afa31877493add6d941d8402fa879c452 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:41 -0700 Subject: [PATCH] ext3: Enable atomic inode security labeling This patch modifies ext3 to call the inode_init_security LSM hook to obtain the security attribute for a newly created inode and to set the resulting attribute on the new inode as part of the same transaction. This parallels the existing processing for setting ACLs on newly created inodes. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 6981bd0..9655276 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -607,6 +607,11 @@ got: DQUOT_DROP(inode); goto fail2; } + err = ext3_init_security(handle,inode, dir); + if (err) { + DQUOT_FREE_INODE(inode); + goto fail2; + } err = ext3_mark_inode_dirty(handle, inode); if (err) { ext3_std_error(sb, err); diff --git a/fs/ext3/xattr.h b/fs/ext3/xattr.h index eb31a69..2ceae38 100644 --- a/fs/ext3/xattr.h +++ b/fs/ext3/xattr.h @@ -133,3 +133,14 @@ exit_ext3_xattr(void) #define ext3_xattr_handlers NULL # endif /* CONFIG_EXT3_FS_XATTR */ + +#ifdef CONFIG_EXT3_FS_SECURITY +extern int ext3_init_security(handle_t *handle, struct inode *inode, + struct inode *dir); +#else +static inline int ext3_init_security(handle_t *handle, struct inode *inode, + struct inode *dir) +{ + return 0; +} +#endif diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c index ddc1c41..b9c40c1 100644 --- a/fs/ext3/xattr_security.c +++ b/fs/ext3/xattr_security.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "xattr.h" static size_t @@ -47,6 +48,27 @@ ext3_xattr_security_set(struct inode *inode, const char *name, value, size, flags); } +int +ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir) +{ + int err; + size_t len; + void *value; + char *name; + + err = security_inode_init_security(inode, dir, &name, &value, &len); + if (err) { + if (err == -EOPNOTSUPP) + return 0; + return err; + } + err = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_SECURITY, + name, value, len, 0); + kfree(name); + kfree(value); + return err; +} + struct xattr_handler ext3_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .list = ext3_xattr_security_list, -- cgit v0.10.2 From 570bc1c2e5ccdb408081e77507a385dc7ebed7fa Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:43 -0700 Subject: [PATCH] tmpfs: Enable atomic inode security labeling This patch modifies tmpfs to call the inode_init_security LSM hook to set up the incore inode security state for new inodes before the inode becomes accessible via the dcache. As there is no underlying storage of security xattrs in this case, it is not necessary for the hook to return the (name, value, len) triple to the tmpfs code, so this patch also modifies the SELinux hook function to correctly handle the case where the (name, value, len) pointers are NULL. The hook call is needed in tmpfs in order to support proper security labeling of tmpfs inodes (e.g. for udev with tmpfs /dev in Fedora). With this change in place, we should then be able to remove the security_inode_post_create/mkdir/... hooks safely. Signed-off-by: Stephen Smalley Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/shmem.c b/mm/shmem.c index 0d627a3..1f7aeb2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1608,6 +1608,15 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) int error = -ENOSPC; if (inode) { + error = security_inode_init_security(inode, dir, NULL, NULL, + NULL); + if (error) { + if (error != -EOPNOTSUPP) { + iput(inode); + return error; + } + error = 0; + } if (dir->i_mode & S_ISGID) { inode->i_gid = dir->i_gid; if (S_ISDIR(mode)) @@ -1617,7 +1626,6 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ - error = 0; } return error; } @@ -1747,6 +1755,16 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s if (!inode) return -ENOSPC; + error = security_inode_init_security(inode, dir, NULL, NULL, + NULL); + if (error) { + if (error != -EOPNOTSUPP) { + iput(inode); + return error; + } + error = 0; + } + info = SHMEM_I(inode); inode->i_size = len-1; if (len <= (char *)inode - (char *)info) { diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 63701fe..265f33d 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2032,9 +2032,9 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, struct inode_security_struct *dsec; struct superblock_security_struct *sbsec; struct inode_security_struct *isec; - u32 newsid; + u32 newsid, clen; int rc; - char *namep, *context; + char *namep = NULL, *context; tsec = current->security; dsec = dir->i_security; @@ -2059,17 +2059,22 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, inode_security_set_sid(inode, newsid); - namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); - if (!namep) - return -ENOMEM; - *name = namep; + if (name) { + namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); + if (!namep) + return -ENOMEM; + *name = namep; + } - rc = security_sid_to_context(newsid, &context, len); - if (rc) { - kfree(namep); - return rc; + if (value && len) { + rc = security_sid_to_context(newsid, &context, &clen); + if (rc) { + kfree(namep); + return rc; + } + *value = context; + *len = clen; } - *value = context; isec->security_attr_init = 1; -- cgit v0.10.2 From a74574aafea3a63add3251047601611111f44562 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:44 -0700 Subject: [PATCH] Remove security_inode_post_create/mkdir/symlink/mknod hooks This patch removes the inode_post_create/mkdir/mknod/symlink LSM hooks as they are obsoleted by the new inode_init_security hook that enables atomic inode security labeling. If anyone sees any reason to retain these hooks, please speak now. Also, is anyone using the post_rename/link hooks; if not, those could also be removed. Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/namei.c b/fs/namei.c index 145e852..993a65a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1316,10 +1316,8 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, return error; DQUOT_INIT(dir); error = dir->i_op->create(dir, dentry, mode, nd); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_create(dir, dentry, mode); - } return error; } @@ -1635,10 +1633,8 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) DQUOT_INIT(dir); error = dir->i_op->mknod(dir, dentry, mode, dev); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_mknod(dir, dentry, mode, dev); - } return error; } @@ -1708,10 +1704,8 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) DQUOT_INIT(dir); error = dir->i_op->mkdir(dir, dentry, mode); - if (!error) { + if (!error) fsnotify_mkdir(dir, dentry->d_name.name); - security_inode_post_mkdir(dir,dentry, mode); - } return error; } @@ -1947,10 +1941,8 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, i DQUOT_INIT(dir); error = dir->i_op->symlink(dir, dentry, oldname); - if (!error) { + if (!error) fsnotify_create(dir, dentry->d_name.name); - security_inode_post_symlink(dir, dentry, oldname); - } return error; } diff --git a/include/linux/security.h b/include/linux/security.h index d4f3b7a..875225b 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -275,12 +275,6 @@ struct swap_info_struct; * @dentry contains the dentry structure for the file to be created. * @mode contains the file mode of the file to be created. * Return 0 if permission is granted. - * @inode_post_create: - * Set the security attributes on a newly created regular file. This hook - * is called after a file has been successfully created. - * @dir contains the inode structure of the parent directory of the new file. - * @dentry contains the the dentry structure for the newly created file. - * @mode contains the file mode. * @inode_link: * Check permission before creating a new hard link to a file. * @old_dentry contains the dentry structure for an existing link to the file. @@ -303,13 +297,6 @@ struct swap_info_struct; * @dentry contains the dentry structure of the symbolic link. * @old_name contains the pathname of file. * Return 0 if permission is granted. - * @inode_post_symlink: - * @dir contains the inode structure of the parent directory of the new link. - * @dentry contains the dentry structure of new symbolic link. - * @old_name contains the pathname of file. - * Set security attributes for a newly created symbolic link. Note that - * @dentry->d_inode may be NULL, since the filesystem might not - * instantiate the dentry (e.g. NFS). * @inode_mkdir: * Check permissions to create a new directory in the existing directory * associated with inode strcture @dir. @@ -317,11 +304,6 @@ struct swap_info_struct; * @dentry contains the dentry structure of new directory. * @mode contains the mode of new directory. * Return 0 if permission is granted. - * @inode_post_mkdir: - * Set security attributes on a newly created directory. - * @dir contains the inode structure of parent of the directory to be created. - * @dentry contains the dentry structure of new directory. - * @mode contains the mode of new directory. * @inode_rmdir: * Check the permission to remove a directory. * @dir contains the inode structure of parent of the directory to be removed. @@ -337,13 +319,6 @@ struct swap_info_struct; * @mode contains the mode of the new file. * @dev contains the the device number. * Return 0 if permission is granted. - * @inode_post_mknod: - * Set security attributes on a newly created special file (or socket or - * fifo file created via the mknod system call). - * @dir contains the inode structure of parent of the new node. - * @dentry contains the dentry structure of the new node. - * @mode contains the mode of the new node. - * @dev contains the the device number. * @inode_rename: * Check for permission to rename a file or directory. * @old_dir contains the inode structure for parent of the old link. @@ -1103,8 +1078,6 @@ struct security_operations { char **name, void **value, size_t *len); int (*inode_create) (struct inode *dir, struct dentry *dentry, int mode); - void (*inode_post_create) (struct inode *dir, - struct dentry *dentry, int mode); int (*inode_link) (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); void (*inode_post_link) (struct dentry *old_dentry, @@ -1112,17 +1085,10 @@ struct security_operations { int (*inode_unlink) (struct inode *dir, struct dentry *dentry); int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const char *old_name); - void (*inode_post_symlink) (struct inode *dir, - struct dentry *dentry, - const char *old_name); int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); - void (*inode_post_mkdir) (struct inode *dir, struct dentry *dentry, - int mode); int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); int (*inode_mknod) (struct inode *dir, struct dentry *dentry, int mode, dev_t dev); - void (*inode_post_mknod) (struct inode *dir, struct dentry *dentry, - int mode, dev_t dev); int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); void (*inode_post_rename) (struct inode *old_dir, @@ -1484,15 +1450,6 @@ static inline int security_inode_create (struct inode *dir, return security_ops->inode_create (dir, dentry, mode); } -static inline void security_inode_post_create (struct inode *dir, - struct dentry *dentry, - int mode) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_create (dir, dentry, mode); -} - static inline int security_inode_link (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) @@ -1528,15 +1485,6 @@ static inline int security_inode_symlink (struct inode *dir, return security_ops->inode_symlink (dir, dentry, old_name); } -static inline void security_inode_post_symlink (struct inode *dir, - struct dentry *dentry, - const char *old_name) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_symlink (dir, dentry, old_name); -} - static inline int security_inode_mkdir (struct inode *dir, struct dentry *dentry, int mode) @@ -1546,15 +1494,6 @@ static inline int security_inode_mkdir (struct inode *dir, return security_ops->inode_mkdir (dir, dentry, mode); } -static inline void security_inode_post_mkdir (struct inode *dir, - struct dentry *dentry, - int mode) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_mkdir (dir, dentry, mode); -} - static inline int security_inode_rmdir (struct inode *dir, struct dentry *dentry) { @@ -1572,15 +1511,6 @@ static inline int security_inode_mknod (struct inode *dir, return security_ops->inode_mknod (dir, dentry, mode, dev); } -static inline void security_inode_post_mknod (struct inode *dir, - struct dentry *dentry, - int mode, dev_t dev) -{ - if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode))) - return; - security_ops->inode_post_mknod (dir, dentry, mode, dev); -} - static inline int security_inode_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, @@ -2220,11 +2150,6 @@ static inline int security_inode_create (struct inode *dir, return 0; } -static inline void security_inode_post_create (struct inode *dir, - struct dentry *dentry, - int mode) -{ } - static inline int security_inode_link (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) @@ -2250,11 +2175,6 @@ static inline int security_inode_symlink (struct inode *dir, return 0; } -static inline void security_inode_post_symlink (struct inode *dir, - struct dentry *dentry, - const char *old_name) -{ } - static inline int security_inode_mkdir (struct inode *dir, struct dentry *dentry, int mode) @@ -2262,11 +2182,6 @@ static inline int security_inode_mkdir (struct inode *dir, return 0; } -static inline void security_inode_post_mkdir (struct inode *dir, - struct dentry *dentry, - int mode) -{ } - static inline int security_inode_rmdir (struct inode *dir, struct dentry *dentry) { @@ -2280,11 +2195,6 @@ static inline int security_inode_mknod (struct inode *dir, return 0; } -static inline void security_inode_post_mknod (struct inode *dir, - struct dentry *dentry, - int mode, dev_t dev) -{ } - static inline int security_inode_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, diff --git a/security/dummy.c b/security/dummy.c index e8a00fa..5083314e 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -270,12 +270,6 @@ static int dummy_inode_create (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_create (struct inode *inode, struct dentry *dentry, - int mask) -{ - return; -} - static int dummy_inode_link (struct dentry *old_dentry, struct inode *inode, struct dentry *new_dentry) { @@ -300,24 +294,12 @@ static int dummy_inode_symlink (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_symlink (struct inode *inode, - struct dentry *dentry, const char *name) -{ - return; -} - static int dummy_inode_mkdir (struct inode *inode, struct dentry *dentry, int mask) { return 0; } -static void dummy_inode_post_mkdir (struct inode *inode, struct dentry *dentry, - int mask) -{ - return; -} - static int dummy_inode_rmdir (struct inode *inode, struct dentry *dentry) { return 0; @@ -329,12 +311,6 @@ static int dummy_inode_mknod (struct inode *inode, struct dentry *dentry, return 0; } -static void dummy_inode_post_mknod (struct inode *inode, struct dentry *dentry, - int mode, dev_t dev) -{ - return; -} - static int dummy_inode_rename (struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, @@ -894,17 +870,13 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, inode_free_security); set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); - set_to_dummy_if_null(ops, inode_post_create); set_to_dummy_if_null(ops, inode_link); set_to_dummy_if_null(ops, inode_post_link); set_to_dummy_if_null(ops, inode_unlink); set_to_dummy_if_null(ops, inode_symlink); - set_to_dummy_if_null(ops, inode_post_symlink); set_to_dummy_if_null(ops, inode_mkdir); - set_to_dummy_if_null(ops, inode_post_mkdir); set_to_dummy_if_null(ops, inode_rmdir); set_to_dummy_if_null(ops, inode_mknod); - set_to_dummy_if_null(ops, inode_post_mknod); set_to_dummy_if_null(ops, inode_rename); set_to_dummy_if_null(ops, inode_post_rename); set_to_dummy_if_null(ops, inode_readlink); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 265f33d..c9c2082 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1265,91 +1265,6 @@ static int inode_security_set_sid(struct inode *inode, u32 sid) return 0; } -/* Set the security attributes on a newly created file. */ -static int post_create(struct inode *dir, - struct dentry *dentry) -{ - - struct task_security_struct *tsec; - struct inode *inode; - struct inode_security_struct *dsec; - struct superblock_security_struct *sbsec; - struct inode_security_struct *isec; - u32 newsid; - char *context; - unsigned int len; - int rc; - - tsec = current->security; - dsec = dir->i_security; - sbsec = dir->i_sb->s_security; - - inode = dentry->d_inode; - if (!inode) { - /* Some file system types (e.g. NFS) may not instantiate - a dentry for all create operations (e.g. symlink), - so we have to check to see if the inode is non-NULL. */ - printk(KERN_WARNING "post_create: no inode, dir (dev=%s, " - "ino=%ld)\n", dir->i_sb->s_id, dir->i_ino); - return 0; - } - - isec = inode->i_security; - - if (isec->security_attr_init) - return 0; - - if (tsec->create_sid && sbsec->behavior != SECURITY_FS_USE_MNTPOINT) { - newsid = tsec->create_sid; - } else { - rc = security_transition_sid(tsec->sid, dsec->sid, - inode_mode_to_security_class(inode->i_mode), - &newsid); - if (rc) { - printk(KERN_WARNING "post_create: " - "security_transition_sid failed, rc=%d (dev=%s " - "ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - } - - rc = inode_security_set_sid(inode, newsid); - if (rc) { - printk(KERN_WARNING "post_create: inode_security_set_sid " - "failed, rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - - if (sbsec->behavior == SECURITY_FS_USE_XATTR && - inode->i_op->setxattr) { - /* Use extended attributes. */ - rc = security_sid_to_context(newsid, &context, &len); - if (rc) { - printk(KERN_WARNING "post_create: sid_to_context " - "failed, rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - down(&inode->i_sem); - rc = inode->i_op->setxattr(dentry, - XATTR_NAME_SELINUX, - context, len, 0); - up(&inode->i_sem); - kfree(context); - if (rc < 0) { - printk(KERN_WARNING "post_create: setxattr failed, " - "rc=%d (dev=%s ino=%ld)\n", - -rc, inode->i_sb->s_id, inode->i_ino); - return rc; - } - } - - return 0; -} - - /* Hook functions begin here. */ static int selinux_ptrace(struct task_struct *parent, struct task_struct *child) @@ -2076,8 +1991,6 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, *len = clen; } - isec->security_attr_init = 1; - return 0; } @@ -2086,11 +1999,6 @@ static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int ma return may_create(dir, dentry, SECCLASS_FILE); } -static void selinux_inode_post_create(struct inode *dir, struct dentry *dentry, int mask) -{ - post_create(dir, dentry); -} - static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) { int rc; @@ -2121,21 +2029,11 @@ static int selinux_inode_symlink(struct inode *dir, struct dentry *dentry, const return may_create(dir, dentry, SECCLASS_LNK_FILE); } -static void selinux_inode_post_symlink(struct inode *dir, struct dentry *dentry, const char *name) -{ - post_create(dir, dentry); -} - static int selinux_inode_mkdir(struct inode *dir, struct dentry *dentry, int mask) { return may_create(dir, dentry, SECCLASS_DIR); } -static void selinux_inode_post_mkdir(struct inode *dir, struct dentry *dentry, int mask) -{ - post_create(dir, dentry); -} - static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry) { return may_link(dir, dentry, MAY_RMDIR); @@ -2152,11 +2050,6 @@ static int selinux_inode_mknod(struct inode *dir, struct dentry *dentry, int mod return may_create(dir, dentry, inode_mode_to_security_class(mode)); } -static void selinux_inode_post_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) -{ - post_create(dir, dentry); -} - static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry) { @@ -4363,17 +4256,13 @@ static struct security_operations selinux_ops = { .inode_free_security = selinux_inode_free_security, .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, - .inode_post_create = selinux_inode_post_create, .inode_link = selinux_inode_link, .inode_post_link = selinux_inode_post_link, .inode_unlink = selinux_inode_unlink, .inode_symlink = selinux_inode_symlink, - .inode_post_symlink = selinux_inode_post_symlink, .inode_mkdir = selinux_inode_mkdir, - .inode_post_mkdir = selinux_inode_post_mkdir, .inode_rmdir = selinux_inode_rmdir, .inode_mknod = selinux_inode_mknod, - .inode_post_mknod = selinux_inode_post_mknod, .inode_rename = selinux_inode_rename, .inode_post_rename = selinux_inode_post_rename, .inode_readlink = selinux_inode_readlink, diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index c515bc0..887937c 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -46,7 +46,6 @@ struct inode_security_struct { unsigned char initialized; /* initialization flag */ struct semaphore sem; unsigned char inherit; /* inherit SID from parent entry */ - unsigned char security_attr_init; /* security attributes init flag */ }; struct file_security_struct { -- cgit v0.10.2 From e31e14ec356f36b131576be5bc31d8fef7e95483 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Fri, 9 Sep 2005 13:01:45 -0700 Subject: [PATCH] remove the inode_post_link and inode_post_rename LSM hooks This patch removes the inode_post_link and inode_post_rename LSM hooks as they are unused (and likely useless). Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/namei.c b/fs/namei.c index 993a65a..21d85f1 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2012,10 +2012,8 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de DQUOT_INIT(dir); error = dir->i_op->link(old_dentry, dir, new_dentry); up(&old_dentry->d_inode->i_sem); - if (!error) { + if (!error) fsnotify_create(dir, new_dentry->d_name.name); - security_inode_post_link(old_dentry, dir, new_dentry); - } return error; } @@ -2134,11 +2132,8 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, d_rehash(new_dentry); dput(new_dentry); } - if (!error) { + if (!error) d_move(old_dentry,new_dentry); - security_inode_post_rename(old_dir, old_dentry, - new_dir, new_dentry); - } return error; } @@ -2164,7 +2159,6 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, /* The following d_move() should become unconditional */ if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME)) d_move(old_dentry, new_dentry); - security_inode_post_rename(old_dir, old_dentry, new_dir, new_dentry); } if (target) up(&target->i_sem); diff --git a/include/linux/security.h b/include/linux/security.h index 875225b..55b02e1 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -281,11 +281,6 @@ struct swap_info_struct; * @dir contains the inode structure of the parent directory of the new link. * @new_dentry contains the dentry structure for the new link. * Return 0 if permission is granted. - * @inode_post_link: - * Set security attributes for a new hard link to a file. - * @old_dentry contains the dentry structure for the existing link. - * @dir contains the inode structure of the parent directory of the new file. - * @new_dentry contains the dentry structure for the new file link. * @inode_unlink: * Check the permission to remove a hard link to a file. * @dir contains the inode structure of parent directory of the file. @@ -326,12 +321,6 @@ struct swap_info_struct; * @new_dir contains the inode structure for parent of the new link. * @new_dentry contains the dentry structure of the new link. * Return 0 if permission is granted. - * @inode_post_rename: - * Set security attributes on a renamed file or directory. - * @old_dir contains the inode structure for parent of the old link. - * @old_dentry contains the dentry structure of the old link. - * @new_dir contains the inode structure for parent of the new link. - * @new_dentry contains the dentry structure of the new link. * @inode_readlink: * Check the permission to read the symbolic link. * @dentry contains the dentry structure for the file link. @@ -1080,8 +1069,6 @@ struct security_operations { struct dentry *dentry, int mode); int (*inode_link) (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); - void (*inode_post_link) (struct dentry *old_dentry, - struct inode *dir, struct dentry *new_dentry); int (*inode_unlink) (struct inode *dir, struct dentry *dentry); int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const char *old_name); @@ -1091,10 +1078,6 @@ struct security_operations { int mode, dev_t dev); int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); - void (*inode_post_rename) (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry); int (*inode_readlink) (struct dentry *dentry); int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); @@ -1459,15 +1442,6 @@ static inline int security_inode_link (struct dentry *old_dentry, return security_ops->inode_link (old_dentry, dir, new_dentry); } -static inline void security_inode_post_link (struct dentry *old_dentry, - struct inode *dir, - struct dentry *new_dentry) -{ - if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode))) - return; - security_ops->inode_post_link (old_dentry, dir, new_dentry); -} - static inline int security_inode_unlink (struct inode *dir, struct dentry *dentry) { @@ -1523,18 +1497,6 @@ static inline int security_inode_rename (struct inode *old_dir, new_dir, new_dentry); } -static inline void security_inode_post_rename (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry) -{ - if (unlikely (IS_PRIVATE (old_dentry->d_inode) || - (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode)))) - return; - security_ops->inode_post_rename (old_dir, old_dentry, - new_dir, new_dentry); -} - static inline int security_inode_readlink (struct dentry *dentry) { if (unlikely (IS_PRIVATE (dentry->d_inode))) @@ -2157,11 +2119,6 @@ static inline int security_inode_link (struct dentry *old_dentry, return 0; } -static inline void security_inode_post_link (struct dentry *old_dentry, - struct inode *dir, - struct dentry *new_dentry) -{ } - static inline int security_inode_unlink (struct inode *dir, struct dentry *dentry) { @@ -2203,12 +2160,6 @@ static inline int security_inode_rename (struct inode *old_dir, return 0; } -static inline void security_inode_post_rename (struct inode *old_dir, - struct dentry *old_dentry, - struct inode *new_dir, - struct dentry *new_dentry) -{ } - static inline int security_inode_readlink (struct dentry *dentry) { return 0; diff --git a/security/dummy.c b/security/dummy.c index 5083314e..9623a61 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -276,13 +276,6 @@ static int dummy_inode_link (struct dentry *old_dentry, struct inode *inode, return 0; } -static void dummy_inode_post_link (struct dentry *old_dentry, - struct inode *inode, - struct dentry *new_dentry) -{ - return; -} - static int dummy_inode_unlink (struct inode *inode, struct dentry *dentry) { return 0; @@ -319,14 +312,6 @@ static int dummy_inode_rename (struct inode *old_inode, return 0; } -static void dummy_inode_post_rename (struct inode *old_inode, - struct dentry *old_dentry, - struct inode *new_inode, - struct dentry *new_dentry) -{ - return; -} - static int dummy_inode_readlink (struct dentry *dentry) { return 0; @@ -871,14 +856,12 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, inode_init_security); set_to_dummy_if_null(ops, inode_create); set_to_dummy_if_null(ops, inode_link); - set_to_dummy_if_null(ops, inode_post_link); set_to_dummy_if_null(ops, inode_unlink); set_to_dummy_if_null(ops, inode_symlink); set_to_dummy_if_null(ops, inode_mkdir); set_to_dummy_if_null(ops, inode_rmdir); set_to_dummy_if_null(ops, inode_mknod); set_to_dummy_if_null(ops, inode_rename); - set_to_dummy_if_null(ops, inode_post_rename); set_to_dummy_if_null(ops, inode_readlink); set_to_dummy_if_null(ops, inode_follow_link); set_to_dummy_if_null(ops, inode_permission); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index c9c2082..3f0b533 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2009,11 +2009,6 @@ static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, stru return may_link(dir, old_dentry, MAY_LINK); } -static void selinux_inode_post_link(struct dentry *old_dentry, struct inode *inode, struct dentry *new_dentry) -{ - return; -} - static int selinux_inode_unlink(struct inode *dir, struct dentry *dentry) { int rc; @@ -2056,12 +2051,6 @@ static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dent return may_rename(old_inode, old_dentry, new_inode, new_dentry); } -static void selinux_inode_post_rename(struct inode *old_inode, struct dentry *old_dentry, - struct inode *new_inode, struct dentry *new_dentry) -{ - return; -} - static int selinux_inode_readlink(struct dentry *dentry) { return dentry_has_perm(current, NULL, dentry, FILE__READ); @@ -4257,14 +4246,12 @@ static struct security_operations selinux_ops = { .inode_init_security = selinux_inode_init_security, .inode_create = selinux_inode_create, .inode_link = selinux_inode_link, - .inode_post_link = selinux_inode_post_link, .inode_unlink = selinux_inode_unlink, .inode_symlink = selinux_inode_symlink, .inode_mkdir = selinux_inode_mkdir, .inode_rmdir = selinux_inode_rmdir, .inode_mknod = selinux_inode_mknod, .inode_rename = selinux_inode_rename, - .inode_post_rename = selinux_inode_post_rename, .inode_readlink = selinux_inode_readlink, .inode_follow_link = selinux_inode_follow_link, .inode_permission = selinux_inode_permission, -- cgit v0.10.2 From 83f7da8acd81354e921ff12d6efbeae5b1a5d6a4 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Fri, 9 Sep 2005 13:01:45 -0700 Subject: [PATCH] ppc32: make perfmon.o CONFIG_E500 specific Subject says it all, there is no need to link perfmon.o on sub-architectures other than CONFIG_E500. Signed-off-by: Marcelo Tosatti Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile index b1457a8..1fb92f1 100644 --- a/arch/ppc/kernel/Makefile +++ b/arch/ppc/kernel/Makefile @@ -15,8 +15,9 @@ extra-y += vmlinux.lds obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ process.o signal.o ptrace.o align.o \ semaphore.o syscalls.o setup.o \ - cputable.o ppc_htab.o perfmon.o + cputable.o ppc_htab.o obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o +obj-$(CONFIG_E500) += perfmon.o obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o obj-$(CONFIG_POWER4) += cpu_setup_power4.o obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c index d87423d..8356d54 100644 --- a/arch/ppc/kernel/traps.c +++ b/arch/ppc/kernel/traps.c @@ -849,10 +849,12 @@ void AltivecAssistException(struct pt_regs *regs) } #endif /* CONFIG_ALTIVEC */ +#ifdef CONFIG_E500 void PerformanceMonitorException(struct pt_regs *regs) { perf_irq(regs); } +#endif #ifdef CONFIG_FSL_BOOKE void CacheLockingException(struct pt_regs *regs, unsigned long address, -- cgit v0.10.2 From 99cc2192132ab28c495d015ed2e95dc29e2a27ad Mon Sep 17 00:00:00 2001 From: Frank van Maarseveen Date: Fri, 9 Sep 2005 13:01:46 -0700 Subject: [PATCH] ppc32: Correct an instruction in the boot code In the flush and invalidate bootcode on PPC4xx we were accidentally using the wrong instruction. Use cmplw, which reads from a register like we want. Signed-off-by: Tom Rini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S index 47e6414..c96c9f8 100644 --- a/arch/ppc/boot/common/util.S +++ b/arch/ppc/boot/common/util.S @@ -252,7 +252,7 @@ _GLOBAL(flush_instruction_cache) 1: dcbf r0,r3 # Flush the data cache icbi r0,r3 # Invalidate the instruction cache addi r3,r3,0x10 # Increment by one cache line - cmplwi cr0,r3,r4 # Are we at the end yet? + cmplw cr0,r3,r4 # Are we at the end yet? blt 1b # No, keep flushing and invalidating #else /* Enable, invalidate and then disable the L1 icache/dcache. */ -- cgit v0.10.2 From 66b375bf7d9c995fd6169191c3862071e710f456 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 9 Sep 2005 13:01:47 -0700 Subject: [PATCH] ppc32: In the boot code, don't rely on BASE_BAUD directly Modifies serial_init to get base baud rate from the rs_table entry instead of BAUD_BASE. This patch eliminates duplication between the SERIAL_PORT_DFNS macro and BAUD_BASE. Without the patch, if a port set the baud rate in SERIAL_PORT_DFNS, but did not update BASE_BAUD, the BASE_BAUD value would still be used. Signed-off-by: Grant Likely Signed-off-by: Tom Rini Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c index 9017c54..26818bb 100644 --- a/arch/ppc/boot/common/ns16550.c +++ b/arch/ppc/boot/common/ns16550.c @@ -23,7 +23,7 @@ static int shift; unsigned long serial_init(int chan, void *ignored) { - unsigned long com_port; + unsigned long com_port, base_baud; unsigned char lcr, dlm; /* We need to find out which type io we're expecting. If it's @@ -43,6 +43,8 @@ unsigned long serial_init(int chan, void *ignored) /* How far apart the registers are. */ shift = rs_table[chan].iomem_reg_shift; + /* Base baud.. */ + base_baud = rs_table[chan].baud_base; /* save the LCR */ lcr = inb(com_port + (UART_LCR << shift)); @@ -62,9 +64,9 @@ unsigned long serial_init(int chan, void *ignored) else { /* Input clock. */ outb(com_port + (UART_DLL << shift), - (BASE_BAUD / SERIAL_BAUD) & 0xFF); + (base_baud / SERIAL_BAUD) & 0xFF); outb(com_port + (UART_DLM << shift), - (BASE_BAUD / SERIAL_BAUD) >> 8); + (base_baud / SERIAL_BAUD) >> 8); /* 8 data, 1 stop, no parity */ outb(com_port + (UART_LCR << shift), 0x03); /* RTS/DTR */ -- cgit v0.10.2 From 95409aaca734700e8dcba9db685b8600b67ba05d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 9 Sep 2005 13:01:48 -0700 Subject: [PATCH] ppc32: Kill PVR_440* defines The following patch changes the usages of PVR_440* into strcmp's with the cpu_name field, and removes the defines altogether. The Ebony portion was briefly tested long ago. One benefit of moving from PVR-tests to string tests in general is that not all CPUs can be on and be able to do this type of comparison. See http://patchwork.ozlabs.org/linuxppc/patch?id=1250 for the original thread. Signed-off-by: Tom Rini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c index 0fd3442..d6b2b19 100644 --- a/arch/ppc/platforms/4xx/ebony.c +++ b/arch/ppc/platforms/4xx/ebony.c @@ -91,15 +91,10 @@ ebony_calibrate_decr(void) * on Rev. C silicon then errata forces us to * use the internal clock. */ - switch (PVR_REV(mfspr(SPRN_PVR))) { - case PVR_REV(PVR_440GP_RB): - freq = EBONY_440GP_RB_SYSCLK; - break; - case PVR_REV(PVR_440GP_RC1): - default: - freq = EBONY_440GP_RC_SYSCLK; - break; - } + if (strcmp(cur_cpu_spec[0]->cpu_name, "440GP Rev. B") == 0) + freq = EBONY_440GP_RB_SYSCLK; + else + freq = EBONY_440GP_RC_SYSCLK; ibm44x_calibrate_decr(freq); } diff --git a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c index d4776af..0bb9198 100644 --- a/arch/ppc/syslib/ibm440gx_common.c +++ b/arch/ppc/syslib/ibm440gx_common.c @@ -236,9 +236,10 @@ void __init ibm440gx_l2c_setup(struct ibm44x_clocks* p) /* Disable L2C on rev.A, rev.B and 800MHz version of rev.C, enable it on all other revisions */ - u32 pvr = mfspr(SPRN_PVR); - if (pvr == PVR_440GX_RA || pvr == PVR_440GX_RB || - (pvr == PVR_440GX_RC && p->cpu > 667000000)) + if (strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. A") == 0 || + strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. B") == 0 + || (strcmp(cur_cpu_spec[0]->cpu_name, "440GX Rev. C") + == 0 && p->cpu > 667000000)) ibm440gx_l2c_disable(); else ibm440gx_l2c_enable(); diff --git a/include/asm-ppc/reg.h b/include/asm-ppc/reg.h index 88b4222..73c33e3 100644 --- a/include/asm-ppc/reg.h +++ b/include/asm-ppc/reg.h @@ -366,12 +366,6 @@ #define PVR_STB03XXX 0x40310000 #define PVR_NP405H 0x41410000 #define PVR_NP405L 0x41610000 -#define PVR_440GP_RB 0x40120440 -#define PVR_440GP_RC1 0x40120481 -#define PVR_440GP_RC2 0x40200481 -#define PVR_440GX_RA 0x51b21850 -#define PVR_440GX_RB 0x51b21851 -#define PVR_440GX_RC 0x51b21892 #define PVR_601 0x00010000 #define PVR_602 0x00050000 #define PVR_603 0x00030000 -- cgit v0.10.2 From 4d666d7ada2e14d71d463c85b8b5ef2e2e6723f2 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Fri, 9 Sep 2005 13:01:49 -0700 Subject: [PATCH] mips: add TANBAC TB0287 support Add TANBAC TB0287 support. Signed-off-by: Yoichi Yuasa Cc: Ralf Baechle Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8d76eb1..0eb71ac 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -154,6 +154,13 @@ config TANBAC_TB0226 The TANBAC Mbase(TB0226) is a MIPS-based platform manufactured by TANBAC. Please refer to about Mbase. +config TANBAC_TB0287 + bool "Support for TANBAC Mini-ITX DIMM base(TB0287)" + depends on TANBAC_TB022X + help + The TANBAC Mini-ITX DIMM base(TB0287) is a MIPS-based platform manufactured by TANBAC. + Please refer to about Mini-ITX DIMM base. + config VICTOR_MPC30X bool "Support for Victor MP-C303/304" depends on MACH_VR41XX diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig new file mode 100644 index 0000000..17b9f2f --- /dev/null +++ b/arch/mips/configs/tb0287_defconfig @@ -0,0 +1,1041 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.13-mm1 +# Thu Sep 1 22:58:34 2005 +# +CONFIG_MIPS=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 + +# +# General setup +# +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +CONFIG_SYSCTL=y +# CONFIG_AUDIT is not set +# CONFIG_HOTPLUG is not set +CONFIG_KOBJECT_UEVENT=y +# CONFIG_IKCONFIG is not set +CONFIG_INITRAMFS_SOURCE="" +CONFIG_EMBEDDED=y +CONFIG_KALLSYMS=y +# CONFIG_KALLSYMS_EXTRA_PASS is not set +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SHMEM=y +CONFIG_CC_ALIGN_FUNCTIONS=0 +CONFIG_CC_ALIGN_LABELS=0 +CONFIG_CC_ALIGN_LOOPS=0 +CONFIG_CC_ALIGN_JUMPS=0 +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 + +# +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +CONFIG_OBSOLETE_MODPARM=y +CONFIG_MODVERSIONS=y +CONFIG_MODULE_SRCVERSION_ALL=y +CONFIG_KMOD=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y + +# +# Kernel type +# +CONFIG_32BIT=y +# CONFIG_64BIT is not set + +# +# Machine selection +# +# CONFIG_MACH_JAZZ is not set +CONFIG_MACH_VR41XX=y +# CONFIG_NEC_CMBVR4133 is not set +# CONFIG_CASIO_E55 is not set +# CONFIG_IBM_WORKPAD is not set +CONFIG_TANBAC_TB022X=y +# CONFIG_TANBAC_TB0226 is not set +CONFIG_TANBAC_TB0287=y +# CONFIG_VICTOR_MPC30X is not set +# CONFIG_ZAO_CAPCELLA is not set +CONFIG_PCI_VR41XX=y +# CONFIG_VRC4173 is not set +# CONFIG_TOSHIBA_JMR3927 is not set +# CONFIG_MIPS_COBALT is not set +# CONFIG_MACH_DECSTATION is not set +# CONFIG_MIPS_EV64120 is not set +# CONFIG_MIPS_EV96100 is not set +# CONFIG_MIPS_IVR is not set +# CONFIG_LASAT is not set +# CONFIG_MIPS_ITE8172 is not set +# CONFIG_MIPS_ATLAS is not set +# CONFIG_MIPS_MALTA is not set +# CONFIG_MIPS_SEAD is not set +# CONFIG_MOMENCO_OCELOT is not set +# CONFIG_MOMENCO_OCELOT_G is not set +# CONFIG_MOMENCO_OCELOT_C is not set +# CONFIG_MOMENCO_OCELOT_3 is not set +# CONFIG_MOMENCO_JAGUAR_ATX is not set +# CONFIG_PMC_YOSEMITE is not set +# CONFIG_DDB5074 is not set +# CONFIG_DDB5476 is not set +# CONFIG_DDB5477 is not set +# CONFIG_QEMU is not set +# CONFIG_SGI_IP22 is not set +# CONFIG_SGI_IP27 is not set +# CONFIG_SGI_IP32 is not set +# CONFIG_SOC_AU1X00 is not set +# CONFIG_SIBYTE_SB1xxx_SOC is not set +# CONFIG_SNI_RM200_PCI is not set +# CONFIG_TOSHIBA_RBTX4927 is not set +CONFIG_RWSEM_GENERIC_SPINLOCK=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_HAVE_DEC_LOCK=y +CONFIG_DMA_NONCOHERENT=y +CONFIG_DMA_NEED_PCI_MAP_STATE=y +CONFIG_CPU_LITTLE_ENDIAN=y +CONFIG_IRQ_CPU=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 + +# +# CPU selection +# +# CONFIG_CPU_MIPS32 is not set +# CONFIG_CPU_MIPS64 is not set +# CONFIG_CPU_R3000 is not set +# CONFIG_CPU_TX39XX is not set +CONFIG_CPU_VR41XX=y +# CONFIG_CPU_R4300 is not set +# CONFIG_CPU_R4X00 is not set +# CONFIG_CPU_TX49XX is not set +# CONFIG_CPU_R5000 is not set +# CONFIG_CPU_R5432 is not set +# CONFIG_CPU_R6000 is not set +# CONFIG_CPU_NEVADA is not set +# CONFIG_CPU_R8000 is not set +# CONFIG_CPU_R10000 is not set +# CONFIG_CPU_RM7000 is not set +# CONFIG_CPU_RM9000 is not set +# CONFIG_CPU_SB1 is not set +CONFIG_PAGE_SIZE_4KB=y +# CONFIG_PAGE_SIZE_8KB is not set +# CONFIG_PAGE_SIZE_16KB is not set +# CONFIG_PAGE_SIZE_64KB is not set +# CONFIG_CPU_ADVANCED is not set +CONFIG_CPU_HAS_SYNC=y +CONFIG_ARCH_FLATMEM_ENABLE=y +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +# CONFIG_SPARSEMEM_STATIC is not set +# CONFIG_PREEMPT is not set + +# +# Bus options (PCI, PCMCIA, EISA, ISA, TC) +# +CONFIG_HW_HAS_PCI=y +CONFIG_PCI=y +# CONFIG_PCI_LEGACY_PROC is not set +CONFIG_MMU=y + +# +# PCCARD (PCMCIA/CardBus) support +# +# CONFIG_PCCARD is not set + +# +# PCI Hotplug Support +# +# CONFIG_HOTPLUG_PCI is not set + +# +# Executable file formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_MISC is not set +CONFIG_TRAD_SIGNALS=y + +# +# Networking +# +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +CONFIG_XFRM_USER=m +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_ASK_IP_FIB_HASH=y +# CONFIG_IP_FIB_TRIE is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IP_PNP=y +# CONFIG_IP_PNP_DHCP is not set +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +CONFIG_NET_IPIP=m +CONFIG_NET_IPGRE=m +# CONFIG_NET_IPGRE_BROADCAST is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +CONFIG_SYN_COOKIES=y +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +CONFIG_TCP_CONG_ADVANCED=y + +# +# TCP congestion control +# +CONFIG_TCP_CONG_BIC=y +CONFIG_TCP_CONG_WESTWOOD=m +CONFIG_TCP_CONG_HTCP=m +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_IPV6 is not set +# CONFIG_NETFILTER is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_DCCP is not set + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_SCHED is not set +# CONFIG_NET_CLS_ROUTE is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NETFILTER_NETLINK is not set +# CONFIG_HAMRADIO is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_IEEE80211 is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +# CONFIG_FW_LOADER is not set + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Parallel port support +# +# CONFIG_PARPORT is not set + +# +# Plug and Play support +# + +# +# Block devices +# +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_CPQ_DA is not set +# CONFIG_BLK_CPQ_CISS_DA is not set +# CONFIG_BLK_DEV_DAC960 is not set +# CONFIG_BLK_DEV_UMEM is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=m +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=m +# CONFIG_BLK_DEV_SX8 is not set +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=4096 +# CONFIG_BLK_DEV_INITRD is not set +# CONFIG_LBD is not set +# CONFIG_CDROM_PKTCDVD is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_ATA_OVER_ETH is not set + +# +# ATA/ATAPI/MFM/RLL support +# +CONFIG_IDE=y +CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# +# CONFIG_BLK_DEV_IDE_SATA is not set +CONFIG_BLK_DEV_IDEDISK=y +# CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_BLK_DEV_IDECD is not set +# CONFIG_BLK_DEV_IDETAPE is not set +# CONFIG_BLK_DEV_IDEFLOPPY is not set +# CONFIG_BLK_DEV_IDESCSI is not set +# CONFIG_IDE_TASK_IOCTL is not set + +# +# IDE chipset support/bugfixes +# +CONFIG_IDE_GENERIC=y +CONFIG_BLK_DEV_IDEPCI=y +# CONFIG_IDEPCI_SHARE_IRQ is not set +# CONFIG_BLK_DEV_OFFBOARD is not set +# CONFIG_BLK_DEV_GENERIC is not set +# CONFIG_BLK_DEV_OPTI621 is not set +CONFIG_BLK_DEV_IDEDMA_PCI=y +# CONFIG_BLK_DEV_IDEDMA_FORCED is not set +# CONFIG_IDEDMA_PCI_AUTO is not set +# CONFIG_BLK_DEV_AEC62XX is not set +# CONFIG_BLK_DEV_ALI15X3 is not set +# CONFIG_BLK_DEV_AMD74XX is not set +# CONFIG_BLK_DEV_CMD64X is not set +# CONFIG_BLK_DEV_TRIFLEX is not set +# CONFIG_BLK_DEV_CY82C693 is not set +# CONFIG_BLK_DEV_CS5520 is not set +# CONFIG_BLK_DEV_CS5530 is not set +# CONFIG_BLK_DEV_HPT34X is not set +# CONFIG_BLK_DEV_HPT366 is not set +# CONFIG_BLK_DEV_SC1200 is not set +# CONFIG_BLK_DEV_PIIX is not set +# CONFIG_BLK_DEV_IT821X is not set +# CONFIG_BLK_DEV_NS87415 is not set +# CONFIG_BLK_DEV_PDC202XX_OLD is not set +# CONFIG_BLK_DEV_PDC202XX_NEW is not set +# CONFIG_BLK_DEV_SVWKS is not set +CONFIG_BLK_DEV_SIIMAGE=y +# CONFIG_BLK_DEV_SLC90E66 is not set +# CONFIG_BLK_DEV_TRM290 is not set +# CONFIG_BLK_DEV_VIA82CXXX is not set +# CONFIG_IDE_ARM is not set +CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_IDEDMA_AUTO is not set +# CONFIG_BLK_DEV_HD is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +# CONFIG_CHR_DEV_SG is not set +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set + +# +# SCSI Transport Attributes +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +# CONFIG_SCSI_ISCSI_ATTRS is not set + +# +# SCSI low-level drivers +# +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_SCSI_3W_9XXX is not set +# CONFIG_SCSI_ARCMSR is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_AACRAID is not set +# CONFIG_SCSI_AIC7XXX is not set +# CONFIG_SCSI_AIC7XXX_OLD is not set +# CONFIG_SCSI_AIC79XX is not set +# CONFIG_SCSI_DPT_I2O is not set +# CONFIG_MEGARAID_NEWGEN is not set +# CONFIG_MEGARAID_LEGACY is not set +# CONFIG_SCSI_SATA is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_EATA is not set +# CONFIG_SCSI_FUTURE_DOMAIN is not set +# CONFIG_SCSI_GDTH is not set +# CONFIG_SCSI_IPS is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_SYM53C8XX_2 is not set +# CONFIG_SCSI_IPR is not set +# CONFIG_SCSI_QLOGIC_FC is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +CONFIG_SCSI_QLA2XXX=y +# CONFIG_SCSI_QLA21XX is not set +# CONFIG_SCSI_QLA22XX is not set +# CONFIG_SCSI_QLA2300 is not set +# CONFIG_SCSI_QLA2322 is not set +# CONFIG_SCSI_QLA6312 is not set +# CONFIG_SCSI_QLA24XX is not set +# CONFIG_SCSI_LPFC is not set +# CONFIG_SCSI_DC395x is not set +# CONFIG_SCSI_DC390T is not set +# CONFIG_SCSI_NSP32 is not set +# CONFIG_SCSI_DEBUG is not set + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set + +# +# Fusion MPT device support +# +# CONFIG_FUSION is not set +# CONFIG_FUSION_SPI is not set +# CONFIG_FUSION_FC is not set + +# +# IEEE 1394 (FireWire) support +# +CONFIG_IEEE1394=m + +# +# Subsystem Options +# +# CONFIG_IEEE1394_VERBOSEDEBUG is not set +# CONFIG_IEEE1394_OUI_DB is not set +CONFIG_IEEE1394_EXTRA_CONFIG_ROMS=y +CONFIG_IEEE1394_CONFIG_ROM_IP1394=y +# CONFIG_IEEE1394_EXPORT_FULL_API is not set + +# +# Device Drivers +# + +# +# Texas Instruments PCILynx requires I2C +# +CONFIG_IEEE1394_OHCI1394=m + +# +# Protocol Drivers +# +CONFIG_IEEE1394_VIDEO1394=m +CONFIG_IEEE1394_SBP2=m +# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set +CONFIG_IEEE1394_ETH1394=m +CONFIG_IEEE1394_DV1394=m +CONFIG_IEEE1394_RAWIO=m +CONFIG_IEEE1394_CMP=m +CONFIG_IEEE1394_AMDTP=m + +# +# I2O device support +# +# CONFIG_I2O is not set + +# +# Network device support +# +CONFIG_NETDEVICES=y +CONFIG_DUMMY=m +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set + +# +# PHY device support +# +# CONFIG_PHYLIB is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +CONFIG_MII=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNGEM is not set +# CONFIG_NET_VENDOR_3COM is not set + +# +# Tulip family network device support +# +# CONFIG_NET_TULIP is not set +# CONFIG_HP100 is not set +# CONFIG_NET_PCI is not set + +# +# Ethernet (1000 Mbit) +# +# CONFIG_ACENIC is not set +# CONFIG_DL2K is not set +# CONFIG_E1000 is not set +# CONFIG_NS83820 is not set +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +CONFIG_R8169=y +# CONFIG_R8169_NAPI is not set +# CONFIG_SIS190 is not set +# CONFIG_SKGE is not set +# CONFIG_SKY2 is not set +# CONFIG_SK98LIN is not set +# CONFIG_TIGON3 is not set +# CONFIG_BNX2 is not set + +# +# Ethernet (10000 Mbit) +# +# CONFIG_CHELSIO_T1 is not set +# CONFIG_IXGB is not set +# CONFIG_S2IO is not set + +# +# Token Ring devices +# +# CONFIG_TR is not set + +# +# Wireless LAN (non-hamradio) +# +# CONFIG_NET_RADIO is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set +# CONFIG_FDDI is not set +# CONFIG_HIPPI is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NET_FC is not set +# CONFIG_SHAPER is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_KGDBOE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NETPOLL_RX is not set +# CONFIG_NETPOLL_TRAP is not set +# CONFIG_NET_POLL_CONTROLLER is not set + +# +# ISDN subsystem +# +# CONFIG_ISDN is not set + +# +# Telephony Support +# +# CONFIG_PHONE is not set + +# +# Input device support +# +CONFIG_INPUT=y + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_TSDEV is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +# CONFIG_SERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_SERIAL_NONSTANDARD is not set + +# +# Serial drivers +# +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_VR41XX=y +CONFIG_SERIAL_VR41XX_CONSOLE=y +# CONFIG_SERIAL_JSM is not set +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 + +# +# IPMI +# +# CONFIG_IPMI_HANDLER is not set + +# +# Watchdog Cards +# +# CONFIG_WATCHDOG is not set +# CONFIG_RTC is not set +# CONFIG_GEN_RTC is not set +# CONFIG_RTC_VR41XX is not set +# CONFIG_DTLK is not set +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set +# CONFIG_TANBAC_TB0219 is not set + +# +# Ftape, the floppy tape device driver +# +# CONFIG_DRM is not set +CONFIG_GPIO_VR41XX=y +# CONFIG_RAW_DRIVER is not set + +# +# TPM devices +# +# CONFIG_TCG_TPM is not set + +# +# I2C support +# +# CONFIG_I2C is not set + +# +# Dallas's 1-wire bus +# +# CONFIG_W1 is not set + +# +# Hardware Monitoring support +# +# CONFIG_HWMON is not set +# CONFIG_HWMON_VID is not set + +# +# Misc devices +# + +# +# Multimedia Capabilities Port drivers +# + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set + +# +# Digital Video Broadcasting Devices +# +# CONFIG_DVB is not set + +# +# Graphics support +# +# CONFIG_FB is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y + +# +# Speakup console speech +# +# CONFIG_SPEAKUP is not set + +# +# Sound +# +# CONFIG_SOUND is not set + +# +# USB support +# +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB_ARCH_HAS_OHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +# CONFIG_USB_DEVICEFS is not set +# CONFIG_USB_BANDWIDTH is not set +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_OTG is not set + +# +# USB Host Controller Drivers +# +CONFIG_USB_EHCI_HCD=m +# CONFIG_USB_EHCI_SPLIT_ISO is not set +# CONFIG_USB_EHCI_ROOT_HUB_TT is not set +# CONFIG_USB_ISP116X_HCD is not set +CONFIG_USB_OHCI_HCD=m +# CONFIG_USB_OHCI_BIG_ENDIAN is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +# CONFIG_USB_UHCI_HCD is not set +# CONFIG_USB_SL811_HCD is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_BLUETOOTH_TTY is not set +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set + +# +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set + +# +# USB Input Devices +# +CONFIG_USB_HID=m +CONFIG_USB_HIDINPUT=y +# CONFIG_HID_FF is not set +# CONFIG_USB_HIDDEV is not set + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set +# CONFIG_USB_AIPTEK is not set +# CONFIG_USB_WACOM is not set +# CONFIG_USB_ACECAD is not set +# CONFIG_USB_KBTAB is not set +# CONFIG_USB_POWERMATE is not set +# CONFIG_USB_MTOUCH is not set +# CONFIG_USB_ITMTOUCH is not set +# CONFIG_USB_EGALAX is not set +# CONFIG_USB_YEALINK is not set +# CONFIG_USB_XPAD is not set +# CONFIG_USB_ATI_REMOTE is not set +# CONFIG_USB_KEYSPAN_REMOTE is not set +# CONFIG_USB_APPLETOUCH is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB Multimedia devices +# +# CONFIG_USB_DABUSB is not set + +# +# Video4Linux support is needed for USB Multimedia device support +# + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +CONFIG_USB_MON=y + +# +# USB port drivers +# + +# +# USB Serial Converter support +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_AUERSWALD is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_GOTEMP is not set +# CONFIG_USB_PHIDGETKIT is not set +# CONFIG_USB_PHIDGETSERVO is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_LD is not set + +# +# USB DSL modem support +# + +# +# USB Gadget Support +# +# CONFIG_USB_GADGET is not set + +# +# MMC/SD Card support +# +# CONFIG_MMC is not set + +# +# InfiniBand support +# +# CONFIG_INFINIBAND is not set + +# +# SN Devices +# + +# +# Distributed Lock Manager +# +# CONFIG_DLM is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +# CONFIG_EXT2_FS_XATTR is not set +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_REISER4_FS is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_FS_POSIX_ACL is not set + +# +# XFS support +# +CONFIG_XFS_FS=y +# CONFIG_XFS_RT is not set +CONFIG_XFS_QUOTA=y +# CONFIG_XFS_SECURITY is not set +CONFIG_XFS_POSIX_ACL=y +# CONFIG_OCFS2_FS is not set +# CONFIG_MINIX_FS is not set +CONFIG_ROMFS_FS=m +CONFIG_INOTIFY=y +# CONFIG_QUOTA is not set +CONFIG_QUOTACTL=y +# CONFIG_DNOTIFY is not set +# CONFIG_AUTOFS_FS is not set +CONFIG_AUTOFS4_FS=y +# CONFIG_FUSE_FS is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +# CONFIG_MSDOS_FS is not set +# CONFIG_VFAT_FS is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_RAMFS=y +# CONFIG_CONFIGFS_FS is not set +# CONFIG_RELAYFS_FS is not set + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_ASFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_CRAMFS=m +# CONFIG_VXFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +# CONFIG_NFS_V3_ACL is not set +# CONFIG_NFS_V4 is not set +# CONFIG_NFS_DIRECTIO is not set +# CONFIG_NFSD is not set +CONFIG_ROOT_NFS=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +# CONFIG_9P_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y + +# +# Native Language Support +# +# CONFIG_NLS is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_DEBUG_KERNEL is not set +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_CROSSCOMPILE=y +CONFIG_CMDLINE="mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs" + +# +# Security options +# +CONFIG_KEYS=y +CONFIG_KEYS_DEBUG_PROC_KEYS=y +# CONFIG_SECURITY is not set + +# +# Cryptographic options +# +# CONFIG_CRYPTO is not set + +# +# Hardware crypto devices +# + +# +# Library routines +# +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +CONFIG_CRC32=y +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=m +CONFIG_GENERIC_HARDIRQS=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_ISA_DMA_API=y diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index c53e4cb..83d81c9 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_SIBYTE_SB1250) += fixup-sb1250.o pci-sb1250.o obj-$(CONFIG_SNI_RM200_PCI) += fixup-sni.o ops-sni.o obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o +obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o pci-jmr3927.o obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o ops-tx4927.o obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o diff --git a/arch/mips/pci/fixup-tb0287.c b/arch/mips/pci/fixup-tb0287.c new file mode 100644 index 0000000..8436d7f --- /dev/null +++ b/arch/mips/pci/fixup-tb0287.c @@ -0,0 +1,65 @@ +/* + * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups. + * + * Copyright (C) 2005 Yoichi Yuasa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include + +#include + +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +{ + unsigned char bus; + int irq = -1; + + bus = dev->bus->number; + if (bus == 0) { + switch (slot) { + case 16: + irq = TB0287_SM501_IRQ; + break; + case 17: + irq = TB0287_SIL680A_IRQ; + break; + default: + break; + } + } else if (bus == 1) { + switch (PCI_SLOT(dev->devfn)) { + case 0: + irq = TB0287_PCI_SLOT_IRQ; + break; + case 2: + case 3: + irq = TB0287_RTL8110_IRQ; + break; + default: + break; + } + } else if (bus > 1) { + irq = TB0287_PCI_SLOT_IRQ; + } + + return irq; +} + +/* Do platform specific device initialization at pci_enable_device() time */ +int pcibios_plat_dev_init(struct pci_dev *dev) +{ + return 0; +} diff --git a/include/asm-mips/vr41xx/tb0287.h b/include/asm-mips/vr41xx/tb0287.h new file mode 100644 index 0000000..dd98323 --- /dev/null +++ b/include/asm-mips/vr41xx/tb0287.h @@ -0,0 +1,43 @@ +/* + * tb0287.h, Include file for TANBAC TB0287 mini-ITX board. + * + * Copyright (C) 2005 Media Lab Inc. + * + * This code is largely based on tb0219.h. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __TANBAC_TB0287_H +#define __TANBAC_TB0287_H + +#include + +/* + * General-Purpose I/O Pin Number + */ +#define TB0287_PCI_SLOT_PIN 2 +#define TB0287_SM501_PIN 3 +#define TB0287_SIL680A_PIN 8 +#define TB0287_RTL8110_PIN 13 + +/* + * Interrupt Number + */ +#define TB0287_PCI_SLOT_IRQ GIU_IRQ(TB0287_PCI_SLOT_PIN) +#define TB0287_SM501_IRQ GIU_IRQ(TB0287_SM501_PIN) +#define TB0287_SIL680A_IRQ GIU_IRQ(TB0287_SIL680A_PIN) +#define TB0287_RTL8110_IRQ GIU_IRQ(TB0287_RTL8110_PIN) + +#endif /* __TANBAC_TB0287_H */ -- cgit v0.10.2 From 4c7fc7220f6a3cce9b3f4bd66362176df67df577 Mon Sep 17 00:00:00 2001 From: Andrea Arcangeli Date: Fri, 9 Sep 2005 13:01:51 -0700 Subject: [PATCH] i386: seccomp fix for auditing/ptrace This is the same issue as ppc64 before, when returning to userland we shouldn't re-compute the seccomp check or the task could be killed during sigreturn when orig_eax is overwritten by the sigreturn syscall. This was found by Roland. This was harmless from a security standpoint, but some i686 users reported failures with auditing enabled system wide (some distro surprisingly makes it the default) and I reproduced it too by keeping the whole workload under strace -f. Patch is tested and works for me under strace -f. nobody@athlon:~/cpushare> strace -o /tmp/o -f python seccomp_test.py make: Nothing to be done for `seccomp_test'. Starting computing some malicious bytecode init load start stop receive_data failure kill exit_code 0 signal 9 The malicious bytecode has been killed successfully by seccomp Starting computing some safe bytecode init load start stop 174 counts kill exit_code 0 signal 0 The seccomp_test.py completed successfully, thank you for testing. (akpm: collaterally cleaned up a bit of do_syscall_trace() too) Signed-off-by: Andrea Arcangeli Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c index 3409802..7b6368b 100644 --- a/arch/i386/kernel/ptrace.c +++ b/arch/i386/kernel/ptrace.c @@ -694,17 +694,22 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code) __attribute__((regparm(3))) int do_syscall_trace(struct pt_regs *regs, int entryexit) { - int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU), ret = 0; - /* With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall - * interception. */ + int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU); + /* + * With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall + * interception + */ int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP); + int ret = 0; /* do the secure computing check first */ - secure_computing(regs->orig_eax); + if (!entryexit) + secure_computing(regs->orig_eax); if (unlikely(current->audit_context)) { if (entryexit) - audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax); + audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), + regs->eax); /* Debug traps, when using PTRACE_SINGLESTEP, must be sent only * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is * not used, entry.S will call us only on syscall exit, not @@ -738,7 +743,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) /* the 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ /* Note that the debugger could change the result of test_thread_flag!*/ - ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); + ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80:0)); /* * this isn't the same as continuing with a signal, but it will do @@ -750,7 +755,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) current->exit_code = 0; } ret = is_sysemu; - out: +out: if (unlikely(current->audit_context) && !entryexit) audit_syscall_entry(current, AUDIT_ARCH_I386, regs->orig_eax, regs->ebx, regs->ecx, regs->edx, regs->esi); @@ -759,6 +764,7 @@ int do_syscall_trace(struct pt_regs *regs, int entryexit) regs->orig_eax = -1; /* force skip of syscall restarting */ if (unlikely(current->audit_context)) - audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax); + audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), + regs->eax); return 1; } -- cgit v0.10.2 From fdf26d933a8171c2a5bd35b4a5ca3b099a216a35 Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 9 Sep 2005 13:01:52 -0700 Subject: [PATCH] x86_64: Don't do broadcast IPIs when hotplug is enabled in flat mode. The use of non-shortcut version of routines breaking CPU hotplug. The option to select this via cmdline also is deleted with the physflat patch, hence directly placing this code under CONFIG_HOTPLUG_CPU. We dont want to use broadcast mode IPI's when hotplug is enabled. This causes bad effects in send IPI to a cpu that is offline which can trip when the cpu is in the process of being kicked alive. Signed-off-by: Ashok Raj Acked-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c index adc9628..6d57da9 100644 --- a/arch/x86_64/kernel/genapic_flat.c +++ b/arch/x86_64/kernel/genapic_flat.c @@ -78,8 +78,18 @@ static void flat_send_IPI_mask(cpumask_t cpumask, int vector) static void flat_send_IPI_allbutself(int vector) { +#ifndef CONFIG_HOTPLUG_CPU if (((num_online_cpus()) - 1) >= 1) __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL); +#else + cpumask_t allbutme = cpu_online_map; + int me = get_cpu(); /* Ensure we are not preempted when we clear */ + cpu_clear(me, allbutme); + + if (!cpus_empty(allbutme)) + flat_send_IPI_mask(allbutme, vector); + put_cpu(); +#endif } static void flat_send_IPI_all(int vector) -- cgit v0.10.2 From 092c948811359d8715790af0eedefc7dff1cd619 Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 9 Sep 2005 13:01:53 -0700 Subject: [PATCH] x86_64: Don't call enforce_max_cpus when hotplug is enabled enforce_max_cpus nukes out cpu_present_map and cpu_possible_map making it impossible to add new cpus in the system. Since it doesnt provide any additional value apart this call and reference is removed. Signed-off-by: Ashok Raj Acked-by: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c index 90aeccd..4fb34b5 100644 --- a/arch/x86_64/kernel/smpboot.c +++ b/arch/x86_64/kernel/smpboot.c @@ -894,23 +894,6 @@ static __init void disable_smp(void) cpu_set(0, cpu_core_map[0]); } -/* - * Handle user cpus=... parameter. - */ -static __init void enforce_max_cpus(unsigned max_cpus) -{ - int i, k; - k = 0; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; - if (++k > max_cpus) { - cpu_clear(i, cpu_possible_map); - cpu_clear(i, cpu_present_map); - } - } -} - #ifdef CONFIG_HOTPLUG_CPU /* * cpu_possible_map should be static, it cannot change as cpu's @@ -999,8 +982,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus) current_cpu_data = boot_cpu_data; current_thread_info()->cpu = 0; /* needed? */ - enforce_max_cpus(max_cpus); - #ifdef CONFIG_HOTPLUG_CPU prefill_possible_map(); #endif -- cgit v0.10.2 From 69ac59647e66c1b53fb98fe8b6d0f2099cffad60 Mon Sep 17 00:00:00 2001 From: Chaskiel Grundman Date: Fri, 9 Sep 2005 13:01:54 -0700 Subject: [PATCH] alpha: process_reloc_for_got confuses r_offset and r_addend arch/alpha/kernel/module.c:process_reloc_for_got(), which figures out how big the .got section for a module should be, appears to be confusing r_offset (the file offset that the relocation needs to be applied to) with r_addend (the offset of the relocation's actual target address from the address of the relocation's symbol). Because of this, one .got entry is allocated for each relocation instead of one each unique symbol/addend. In the module I am working with, this causes the .got section to be almost 10 times larger than it needs to be (75544 bytes instead of 7608 bytes). As the .got is accessed with global-pointer-relative instructions, it needs to be within the 64k gp "zone", and a 75544 byte .got clearly does not fit. The result of this is that relocation overflows are detected during module load and the load is aborted. Change struct got_entry/process_reloc_for_got to fix this. Acked-by: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c index fc271e3..aac6d4b 100644 --- a/arch/alpha/kernel/module.c +++ b/arch/alpha/kernel/module.c @@ -47,7 +47,7 @@ module_free(struct module *mod, void *module_region) struct got_entry { struct got_entry *next; - Elf64_Addr r_offset; + Elf64_Sxword r_addend; int got_offset; }; @@ -57,14 +57,14 @@ process_reloc_for_got(Elf64_Rela *rela, { unsigned long r_sym = ELF64_R_SYM (rela->r_info); unsigned long r_type = ELF64_R_TYPE (rela->r_info); - Elf64_Addr r_offset = rela->r_offset; + Elf64_Sxword r_addend = rela->r_addend; struct got_entry *g; if (r_type != R_ALPHA_LITERAL) return; for (g = chains + r_sym; g ; g = g->next) - if (g->r_offset == r_offset) { + if (g->r_addend == r_addend) { if (g->got_offset == 0) { g->got_offset = *poffset; *poffset += 8; @@ -74,7 +74,7 @@ process_reloc_for_got(Elf64_Rela *rela, g = kmalloc (sizeof (*g), GFP_KERNEL); g->next = chains[r_sym].next; - g->r_offset = r_offset; + g->r_addend = r_addend; g->got_offset = *poffset; *poffset += 8; chains[r_sym].next = g; -- cgit v0.10.2 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 diff --git a/drivers/char/pty.c b/drivers/char/pty.c index da32889..49f3997 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 9d65712..6a56ae4 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 v0.10.2 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 diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index d27fa91..0705cd7 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 v0.10.2 From f76baf9365bd66216bf0e0ebfc083e22eda6215b Mon Sep 17 00:00:00 2001 From: Alexander Krizhanovsky Date: Fri, 9 Sep 2005 13:01:59 -0700 Subject: [PATCH] autofs: fix "busy inodes after umount..." This patch for old autofs (version 3) cleans dentries which are not putted after killing the automount daemon (it's analogue of recent patch for autofs4). Signed-off-by: Alexander Krizhanovsky Cc: Ian Kent Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 6171431..990c28d 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -105,6 +105,7 @@ struct autofs_sb_info { struct file *pipe; pid_t oz_pgrp; int catatonic; + struct super_block *sb; unsigned long exp_timeout; ino_t next_dir_ino; struct autofs_wait_queue *queues; /* Wait queue pointer */ @@ -134,7 +135,7 @@ void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *); void autofs_hash_delete(struct autofs_dir_ent *); struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *); void autofs_hash_dputall(struct autofs_dirhash *); -void autofs_hash_nuke(struct autofs_dirhash *); +void autofs_hash_nuke(struct autofs_sb_info *); /* Expiration-handling functions */ diff --git a/fs/autofs/dirhash.c b/fs/autofs/dirhash.c index 448143f..5ccfcf2 100644 --- a/fs/autofs/dirhash.c +++ b/fs/autofs/dirhash.c @@ -232,13 +232,13 @@ void autofs_hash_dputall(struct autofs_dirhash *dh) /* Delete everything. This is used on filesystem destruction, so we make no attempt to keep the pointers valid */ -void autofs_hash_nuke(struct autofs_dirhash *dh) +void autofs_hash_nuke(struct autofs_sb_info *sbi) { int i; struct autofs_dir_ent *ent, *nent; for ( i = 0 ; i < AUTOFS_HASH_SIZE ; i++ ) { - for ( ent = dh->h[i] ; ent ; ent = nent ) { + for ( ent = sbi->dirhash.h[i] ; ent ; ent = nent ) { nent = ent->next; if ( ent->dentry ) dput(ent->dentry); @@ -246,4 +246,5 @@ void autofs_hash_nuke(struct autofs_dirhash *dh) kfree(ent); } } + shrink_dcache_sb(sbi->sb); } diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 4888c1f..65e5ed4 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -27,7 +27,7 @@ static void autofs_put_super(struct super_block *sb) if ( !sbi->catatonic ) autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ - autofs_hash_nuke(&sbi->dirhash); + autofs_hash_nuke(sbi); for ( n = 0 ; n < AUTOFS_MAX_SYMLINKS ; n++ ) { if ( test_bit(n, sbi->symlink_bitmap) ) kfree(sbi->symlink[n].data); @@ -148,6 +148,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) s->s_magic = AUTOFS_SUPER_MAGIC; s->s_op = &autofs_sops; s->s_time_gran = 1; + sbi->sb = s; root_inode = iget(s, AUTOFS_ROOT_INO); root = d_alloc_root(root_inode); -- cgit v0.10.2 From b0d62e6d5b3318b6b722121d945afa295f7201b5 Mon Sep 17 00:00:00 2001 From: Jason Baron Date: Fri, 9 Sep 2005 13:02:01 -0700 Subject: [PATCH] fix disassociate_ctty vs. fork race Race is as follows. Process A forks process B, both being part of the same session. Then, A calls disassociate_ctty while B forks C: A B ==== ==== fork() copy_signal() dissasociate_ctty() .... attach_pid(p, PIDTYPE_SID, p->signal->session); Now, C can have current->signal->tty pointing to a freed tty structure, as it hasn't yet been added to the session group (to have its controlling tty cleared on the diassociate_ctty() call). This has shown up as an oops but could be even more serious. I haven't tried to create a test case, but a customer has verified that the patch below resolves the issue, which was occuring quite frequently. I'll try and post the test case if i can. The patch simply checks for a NULL tty *after* it has been attached to the proper session group and clears it as necessary. Alternatively, we could simply do the tty assignment after the the process is added to the proper session group. Signed-off-by: Jason Baron Cc: Roland McGrath Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/fork.c b/kernel/fork.c index dfeadf4..b258020 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1116,6 +1116,9 @@ static task_t *copy_process(unsigned long clone_flags, __get_cpu_var(process_counts)++; } + if (!current->signal->tty && p->signal->tty) + p->signal->tty = NULL; + nr_threads++; total_forks++; write_unlock_irq(&tasklist_lock); -- cgit v0.10.2 From 383f2835eb9afb723af71850037b2f074ac9db60 Mon Sep 17 00:00:00 2001 From: "Chen, Kenneth W" Date: Fri, 9 Sep 2005 13:02:02 -0700 Subject: [PATCH] Prefetch kernel stacks to speed up context switch For architecture like ia64, the switch stack structure is fairly large (currently 528 bytes). For context switch intensive application, we found that significant amount of cache misses occurs in switch_to() function. The following patch adds a hook in the schedule() function to prefetch switch stack structure as soon as 'next' task is determined. This allows maximum overlap in prefetch cache lines for that structure. Signed-off-by: Ken Chen Cc: Ingo Molnar Cc: "Luck, Tony" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 3c88210..915e127 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S @@ -470,6 +470,29 @@ ENTRY(load_switch_stack) br.cond.sptk.many b7 END(load_switch_stack) +GLOBAL_ENTRY(prefetch_stack) + add r14 = -IA64_SWITCH_STACK_SIZE, sp + add r15 = IA64_TASK_THREAD_KSP_OFFSET, in0 + ;; + ld8 r16 = [r15] // load next's stack pointer + lfetch.fault.excl [r14], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault.excl [r14], 128 + lfetch.fault [r16], 128 + ;; + lfetch.fault [r16], 128 + br.ret.sptk.many rp +END(prefetch_switch_stack) + GLOBAL_ENTRY(execve) mov r15=__NR_execve // put syscall number in place break __BREAK_SYSCALL diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h index 33256db..635235f 100644 --- a/include/asm-ia64/system.h +++ b/include/asm-ia64/system.h @@ -275,6 +275,7 @@ extern void ia64_load_extra (struct task_struct *task); */ #define __ARCH_WANT_UNLOCKED_CTXSW +#define ARCH_HAS_PREFETCH_SWITCH_STACK #define ia64_platform_is(x) (strcmp(x, platform_name) == 0) void cpu_idle_wait(void); diff --git a/include/linux/sched.h b/include/linux/sched.h index ea1b5f3..c551e6a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -604,6 +604,11 @@ extern int groups_search(struct group_info *group_info, gid_t grp); #define GROUP_AT(gi, i) \ ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) +#ifdef ARCH_HAS_PREFETCH_SWITCH_STACK +extern void prefetch_stack(struct task_struct*); +#else +static inline void prefetch_stack(struct task_struct *t) { } +#endif struct audit_context; /* See audit.c */ struct mempolicy; diff --git a/kernel/sched.c b/kernel/sched.c index 18b9552..2632b81 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -2888,6 +2888,7 @@ switch_tasks: if (next == rq->idle) schedstat_inc(rq, sched_goidle); prefetch(next); + prefetch_stack(next); clear_tsk_need_resched(prev); rcu_qsctr_inc(task_cpu(prev)); -- cgit v0.10.2 From fac92becdaecff64dd91daab0292c5131de92f0d Mon Sep 17 00:00:00 2001 From: Andrew Stribblehill Date: Fri, 9 Sep 2005 13:02:04 -0700 Subject: [PATCH] bfs: fix endianness, signedness; add trivial bugfix * Makes BFS code endianness-clean. * Fixes some signedness warnings. * Fixes a problem in fs/bfs/inode.c:164 where inodes not synced to disk don't get fully marked as clean. Here's how to reproduce it: # mount -o loop -t bfs /bfs.img /mnt # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 1 47 3% /mnt # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 5 508 1% /mnt # cp 60k-archive.zip /mnt/mt.zip # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 65 447 13% /mnt # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 2 46 5% /mnt # rm /mnt/mt.zip # echo $? 0 [If the unlink happens before the buffers flush, the following happens:] # df -i /mnt Filesystem Inodes IUsed IFree IUse% Mounted on /bfs.img 48 2 46 5% /mnt # df -k /mnt Filesystem 1K-blocks Used Available Use% Mounted on /bfs.img 512 65 447 13% /mnt fs/bfs/bfs.h | 1 Signed-off-by: Andrew Stribblehill Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index 1020dbc..1fbc53f 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h @@ -20,7 +20,6 @@ struct bfs_sb_info { unsigned long si_lasti; unsigned long * si_imap; struct buffer_head * si_sbh; /* buffer header w/superblock */ - struct bfs_super_block * si_bfs_sb; /* superblock in si_sbh->b_data */ }; /* diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 5a1e5ce..e240c33 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c @@ -2,6 +2,7 @@ * fs/bfs/dir.c * BFS directory operations. * Copyright (C) 1999,2000 Tigran Aivazian + * Made endianness-clean by Andrew Stribblehill 2005 */ #include @@ -20,9 +21,9 @@ #define dprintf(x...) #endif -static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino); +static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino); static struct buffer_head * bfs_find_entry(struct inode * dir, - const char * name, int namelen, struct bfs_dirent ** res_dir); + const unsigned char * name, int namelen, struct bfs_dirent ** res_dir); static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) { @@ -53,7 +54,7 @@ static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir) de = (struct bfs_dirent *)(bh->b_data + offset); if (de->ino) { int size = strnlen(de->name, BFS_NAMELEN); - if (filldir(dirent, de->name, size, f->f_pos, de->ino, DT_UNKNOWN) < 0) { + if (filldir(dirent, de->name, size, f->f_pos, le16_to_cpu(de->ino), DT_UNKNOWN) < 0) { brelse(bh); unlock_kernel(); return 0; @@ -107,7 +108,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode, inode->i_mapping->a_ops = &bfs_aops; inode->i_mode = mode; inode->i_ino = ino; - BFS_I(inode)->i_dsk_ino = ino; + BFS_I(inode)->i_dsk_ino = cpu_to_le16(ino); BFS_I(inode)->i_sblock = 0; BFS_I(inode)->i_eblock = 0; insert_inode_hash(inode); @@ -139,7 +140,7 @@ static struct dentry * bfs_lookup(struct inode * dir, struct dentry * dentry, st lock_kernel(); bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { - unsigned long ino = le32_to_cpu(de->ino); + unsigned long ino = (unsigned long)le16_to_cpu(de->ino); brelse(bh); inode = iget(dir->i_sb, ino); if (!inode) { @@ -183,7 +184,7 @@ static int bfs_unlink(struct inode * dir, struct dentry * dentry) inode = dentry->d_inode; lock_kernel(); bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); - if (!bh || de->ino != inode->i_ino) + if (!bh || le16_to_cpu(de->ino) != inode->i_ino) goto out_brelse; if (!inode->i_nlink) { @@ -224,7 +225,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry, old_dentry->d_name.name, old_dentry->d_name.len, &old_de); - if (!old_bh || old_de->ino != old_inode->i_ino) + if (!old_bh || le16_to_cpu(old_de->ino) != old_inode->i_ino) goto end_rename; error = -EPERM; @@ -270,7 +271,7 @@ struct inode_operations bfs_dir_inops = { .rename = bfs_rename, }; -static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int ino) +static int bfs_add_entry(struct inode * dir, const unsigned char * name, int namelen, int ino) { struct buffer_head * bh; struct bfs_dirent * de; @@ -304,7 +305,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int } dir->i_mtime = CURRENT_TIME_SEC; mark_inode_dirty(dir); - de->ino = ino; + de->ino = cpu_to_le16((u16)ino); for (i=0; iname[i] = (i < namelen) ? name[i] : 0; mark_buffer_dirty(bh); @@ -317,7 +318,7 @@ static int bfs_add_entry(struct inode * dir, const char * name, int namelen, int return -ENOSPC; } -static inline int bfs_namecmp(int len, const char * name, const char * buffer) +static inline int bfs_namecmp(int len, const unsigned char * name, const char * buffer) { if (len < BFS_NAMELEN && buffer[len]) return 0; @@ -325,7 +326,7 @@ static inline int bfs_namecmp(int len, const char * name, const char * buffer) } static struct buffer_head * bfs_find_entry(struct inode * dir, - const char * name, int namelen, struct bfs_dirent ** res_dir) + const unsigned char * name, int namelen, struct bfs_dirent ** res_dir) { unsigned long block, offset; struct buffer_head * bh; @@ -346,7 +347,7 @@ static struct buffer_head * bfs_find_entry(struct inode * dir, } de = (struct bfs_dirent *)(bh->b_data + offset); offset += BFS_DIRENT_SIZE; - if (de->ino && bfs_namecmp(namelen, name, de->name)) { + if (le16_to_cpu(de->ino) && bfs_namecmp(namelen, name, de->name)) { *res_dir = de; return bh; } diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 747fd1e..807723b 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c @@ -40,8 +40,8 @@ static int bfs_move_block(unsigned long from, unsigned long to, struct super_blo return 0; } -static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned long end, - unsigned long where) +static int bfs_move_blocks(struct super_block *sb, unsigned long start, + unsigned long end, unsigned long where) { unsigned long i; @@ -57,20 +57,21 @@ static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned static int bfs_get_block(struct inode * inode, sector_t block, struct buffer_head * bh_result, int create) { - long phys; + unsigned long phys; int err; struct super_block *sb = inode->i_sb; struct bfs_sb_info *info = BFS_SB(sb); struct bfs_inode_info *bi = BFS_I(inode); struct buffer_head *sbh = info->si_sbh; - if (block < 0 || block > info->si_blocks) + if (block > info->si_blocks) return -EIO; phys = bi->i_sblock + block; if (!create) { if (phys <= bi->i_eblock) { - dprintf("c=%d, b=%08lx, phys=%08lx (granted)\n", create, block, phys); + dprintf("c=%d, b=%08lx, phys=%09lx (granted)\n", + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); } return 0; @@ -80,7 +81,7 @@ static int bfs_get_block(struct inode * inode, sector_t block, of blocks allocated for this file, we can grant it */ if (inode->i_size && phys <= bi->i_eblock) { dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n", - create, block, phys); + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); return 0; } @@ -88,11 +89,12 @@ static int bfs_get_block(struct inode * inode, sector_t block, /* the rest has to be protected against itself */ lock_kernel(); - /* if the last data block for this file is the last allocated block, we can - extend the file trivially, without moving it anywhere */ + /* if the last data block for this file is the last allocated + block, we can extend the file trivially, without moving it + anywhere */ if (bi->i_eblock == info->si_lf_eblk) { dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n", - create, block, phys); + create, (unsigned long)block, phys); map_bh(bh_result, sb, phys); info->si_freeb -= phys - bi->i_eblock; info->si_lf_eblk = bi->i_eblock = phys; @@ -114,7 +116,8 @@ static int bfs_get_block(struct inode * inode, sector_t block, } else err = 0; - dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", create, block, phys); + dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", + create, (unsigned long)block, phys); bi->i_sblock = phys; phys += block; info->si_lf_eblk = bi->i_eblock = phys; diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 628c2c1..c7b39aa2 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -3,6 +3,8 @@ * BFS superblock and inode operations. * Copyright (C) 1999,2000 Tigran Aivazian * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds. + * + * Made endianness-clean by Andrew Stribblehill , 2005. */ #include @@ -54,46 +56,50 @@ static void bfs_read_inode(struct inode * inode) off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; di = (struct bfs_inode *)bh->b_data + off; - inode->i_mode = 0x0000FFFF & di->i_mode; - if (di->i_vtype == BFS_VDIR) { + inode->i_mode = 0x0000FFFF & le32_to_cpu(di->i_mode); + if (le32_to_cpu(di->i_vtype) == BFS_VDIR) { inode->i_mode |= S_IFDIR; inode->i_op = &bfs_dir_inops; inode->i_fop = &bfs_dir_operations; - } else if (di->i_vtype == BFS_VREG) { + } else if (le32_to_cpu(di->i_vtype) == BFS_VREG) { inode->i_mode |= S_IFREG; inode->i_op = &bfs_file_inops; inode->i_fop = &bfs_file_operations; inode->i_mapping->a_ops = &bfs_aops; } - inode->i_uid = di->i_uid; - inode->i_gid = di->i_gid; - inode->i_nlink = di->i_nlink; + BFS_I(inode)->i_sblock = le32_to_cpu(di->i_sblock); + BFS_I(inode)->i_eblock = le32_to_cpu(di->i_eblock); + inode->i_uid = le32_to_cpu(di->i_uid); + inode->i_gid = le32_to_cpu(di->i_gid); + inode->i_nlink = le32_to_cpu(di->i_nlink); inode->i_size = BFS_FILESIZE(di); inode->i_blocks = BFS_FILEBLOCKS(di); + if (inode->i_size || inode->i_blocks) dprintf("Registered inode with %lld size, %ld blocks\n", inode->i_size, inode->i_blocks); inode->i_blksize = PAGE_SIZE; - inode->i_atime.tv_sec = di->i_atime; - inode->i_mtime.tv_sec = di->i_mtime; - inode->i_ctime.tv_sec = di->i_ctime; + inode->i_atime.tv_sec = le32_to_cpu(di->i_atime); + inode->i_mtime.tv_sec = le32_to_cpu(di->i_mtime); + inode->i_ctime.tv_sec = le32_to_cpu(di->i_ctime); inode->i_atime.tv_nsec = 0; inode->i_mtime.tv_nsec = 0; inode->i_ctime.tv_nsec = 0; - BFS_I(inode)->i_dsk_ino = di->i_ino; /* can be 0 so we store a copy */ - BFS_I(inode)->i_sblock = di->i_sblock; - BFS_I(inode)->i_eblock = di->i_eblock; + BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino); /* can be 0 so we store a copy */ brelse(bh); } static int bfs_write_inode(struct inode * inode, int unused) { - unsigned long ino = inode->i_ino; + unsigned int ino = (u16)inode->i_ino; + unsigned long i_sblock; struct bfs_inode * di; struct buffer_head * bh; int block, off; + dprintf("ino=%08x\n", ino); + if (ino < BFS_ROOT_INO || ino > BFS_SB(inode->i_sb)->si_lasti) { - printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); + printf("Bad inode number %s:%08x\n", inode->i_sb->s_id, ino); return -EIO; } @@ -101,7 +107,7 @@ static int bfs_write_inode(struct inode * inode, int unused) block = (ino - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1; bh = sb_bread(inode->i_sb, block); if (!bh) { - printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, ino); + printf("Unable to read inode %s:%08x\n", inode->i_sb->s_id, ino); unlock_kernel(); return -EIO; } @@ -109,24 +115,26 @@ static int bfs_write_inode(struct inode * inode, int unused) off = (ino - BFS_ROOT_INO)%BFS_INODES_PER_BLOCK; di = (struct bfs_inode *)bh->b_data + off; - if (inode->i_ino == BFS_ROOT_INO) - di->i_vtype = BFS_VDIR; + if (ino == BFS_ROOT_INO) + di->i_vtype = cpu_to_le32(BFS_VDIR); else - di->i_vtype = BFS_VREG; - - di->i_ino = inode->i_ino; - di->i_mode = inode->i_mode; - di->i_uid = inode->i_uid; - di->i_gid = inode->i_gid; - di->i_nlink = inode->i_nlink; - di->i_atime = inode->i_atime.tv_sec; - di->i_mtime = inode->i_mtime.tv_sec; - di->i_ctime = inode->i_ctime.tv_sec; - di->i_sblock = BFS_I(inode)->i_sblock; - di->i_eblock = BFS_I(inode)->i_eblock; - di->i_eoffset = di->i_sblock * BFS_BSIZE + inode->i_size - 1; + di->i_vtype = cpu_to_le32(BFS_VREG); + + di->i_ino = cpu_to_le16(ino); + di->i_mode = cpu_to_le32(inode->i_mode); + di->i_uid = cpu_to_le32(inode->i_uid); + di->i_gid = cpu_to_le32(inode->i_gid); + di->i_nlink = cpu_to_le32(inode->i_nlink); + di->i_atime = cpu_to_le32(inode->i_atime.tv_sec); + di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec); + di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec); + i_sblock = BFS_I(inode)->i_sblock; + di->i_sblock = cpu_to_le32(i_sblock); + di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock); + di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1); mark_buffer_dirty(bh); + dprintf("Written ino=%d into %d:%d\n",le16_to_cpu(di->i_ino),block,off); brelse(bh); unlock_kernel(); return 0; @@ -140,13 +148,14 @@ static void bfs_delete_inode(struct inode * inode) int block, off; struct super_block * s = inode->i_sb; struct bfs_sb_info * info = BFS_SB(s); + struct bfs_inode_info * bi = BFS_I(inode); - dprintf("ino=%08lx\n", inode->i_ino); + dprintf("ino=%08lx\n", ino); truncate_inode_pages(&inode->i_data, 0); - if (inode->i_ino < BFS_ROOT_INO || inode->i_ino > info->si_lasti) { - printf("invalid ino=%08lx\n", inode->i_ino); + if (ino < BFS_ROOT_INO || ino > info->si_lasti) { + printf("invalid ino=%08lx\n", ino); return; } @@ -162,13 +171,13 @@ static void bfs_delete_inode(struct inode * inode) return; } off = (ino - BFS_ROOT_INO)%BFS_INODES_PER_BLOCK; - di = (struct bfs_inode *)bh->b_data + off; - if (di->i_ino) { - info->si_freeb += BFS_FILEBLOCKS(di); + di = (struct bfs_inode *) bh->b_data + off; + if (bi->i_dsk_ino) { + info->si_freeb += 1 + bi->i_eblock - bi->i_sblock; info->si_freei++; - clear_bit(di->i_ino, info->si_imap); + clear_bit(ino, info->si_imap); dump_imap("delete_inode", s); - } + } di->i_ino = 0; di->i_sblock = 0; mark_buffer_dirty(bh); @@ -274,14 +283,14 @@ static struct super_operations bfs_sops = { void dump_imap(const char *prefix, struct super_block * s) { -#if 0 +#ifdef DEBUG int i; char *tmpbuf = (char *)get_zeroed_page(GFP_KERNEL); if (!tmpbuf) return; for (i=BFS_SB(s)->si_lasti; i>=0; i--) { - if (i>PAGE_SIZE-100) break; + if (i > PAGE_SIZE-100) break; if (test_bit(i, BFS_SB(s)->si_imap)) strcat(tmpbuf, "1"); else @@ -297,7 +306,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) struct buffer_head * bh; struct bfs_super_block * bfs_sb; struct inode * inode; - int i, imap_len; + unsigned i, imap_len; struct bfs_sb_info * info; info = kmalloc(sizeof(*info), GFP_KERNEL); @@ -312,19 +321,18 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) if(!bh) goto out; bfs_sb = (struct bfs_super_block *)bh->b_data; - if (bfs_sb->s_magic != BFS_MAGIC) { + if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { if (!silent) printf("No BFS filesystem on %s (magic=%08x)\n", - s->s_id, bfs_sb->s_magic); + s->s_id, le32_to_cpu(bfs_sb->s_magic)); goto out; } if (BFS_UNCLEAN(bfs_sb, s) && !silent) printf("%s is unclean, continuing\n", s->s_id); s->s_magic = BFS_MAGIC; - info->si_bfs_sb = bfs_sb; info->si_sbh = bh; - info->si_lasti = (bfs_sb->s_start - BFS_BSIZE)/sizeof(struct bfs_inode) + info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE)/sizeof(struct bfs_inode) + BFS_ROOT_INO - 1; imap_len = info->si_lasti/8 + 1; @@ -348,8 +356,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) goto out; } - info->si_blocks = (bfs_sb->s_end + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */ - info->si_freeb = (bfs_sb->s_end + 1 - bfs_sb->s_start)>>BFS_BSIZE_BITS; + info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */ + info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 - cpu_to_le32(bfs_sb->s_start))>>BFS_BSIZE_BITS; info->si_freei = 0; info->si_lf_eblk = 0; info->si_lf_sblk = 0; diff --git a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h index f7f0913..c1237aa 100644 --- a/include/linux/bfs_fs.h +++ b/include/linux/bfs_fs.h @@ -14,8 +14,9 @@ #define BFS_INODES_PER_BLOCK 8 /* SVR4 vnode type values (bfs_inode->i_vtype) */ -#define BFS_VDIR 2 -#define BFS_VREG 1 +#define BFS_VDIR 2L +#define BFS_VREG 1L + /* BFS inode layout on disk */ struct bfs_inode { @@ -58,22 +59,22 @@ struct bfs_super_block { __u32 s_padding[118]; }; -#define BFS_NZFILESIZE(ip) \ - (((ip)->i_eoffset + 1) - (ip)->i_sblock * BFS_BSIZE) - -#define BFS_FILESIZE(ip) \ - ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) - -#define BFS_FILEBLOCKS(ip) \ - ((ip)->i_sblock == 0 ? 0 : ((ip)->i_eblock + 1) - (ip)->i_sblock) #define BFS_OFF2INO(offset) \ ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO) #define BFS_INO2OFF(ino) \ ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE) +#define BFS_NZFILESIZE(ip) \ + ((cpu_to_le32((ip)->i_eoffset) + 1) - cpu_to_le32((ip)->i_sblock) * BFS_BSIZE) + +#define BFS_FILESIZE(ip) \ + ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) +#define BFS_FILEBLOCKS(ip) \ + ((ip)->i_sblock == 0 ? 0 : (cpu_to_le32((ip)->i_eblock) + 1) - cpu_to_le32((ip)->i_sblock)) #define BFS_UNCLEAN(bfs_sb, sb) \ - ((bfs_sb->s_from != -1) && (bfs_sb->s_to != -1) && !(sb->s_flags & MS_RDONLY)) + ((cpu_to_le32(bfs_sb->s_from) != -1) && (cpu_to_le32(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY)) + #endif /* _LINUX_BFS_FS_H */ -- cgit v0.10.2 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 diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index b780307..cdc07cc 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 v0.10.2 From 8f58202bf6b915656e116ece3bc4ace14bfe533a Mon Sep 17 00:00:00 2001 From: Wendy Cheng Date: Fri, 9 Sep 2005 13:02:08 -0700 Subject: [PATCH] change io_cancel return code for no cancel case Note that other than few exceptions, most of the current filesystem and/or drivers do not have aio cancel specifically defined (kiob->ki_cancel field is mostly NULL). However, sys_io_cancel system call universally sets return code to -EAGAIN. This gives applications a wrong impression that this call is implemented but just never works. We have customer inquires about this issue. Changed by Benjamin LaHaise to EINVAL instead of ENOSYS Signed-off-by: S. Wendy Cheng Acked-by: Benjamin LaHaise Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 4f641ab..769791d 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1673,7 +1673,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, ret = -EFAULT; } } else - printk(KERN_DEBUG "iocb has no cancel operation\n"); + ret = -EINVAL; put_ioctx(ctx); -- cgit v0.10.2 From ac0b1bc1edbe81c0cb36cad7e7f5b91f4d9e12ed Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Fri, 9 Sep 2005 13:02:09 -0700 Subject: [PATCH] aio: kiocb locking to serialise retry and cancel Implement a per-kiocb lock to serialise retry operations and cancel. This is done using wait_on_bit_lock() on the KIF_LOCKED bit of kiocb->ki_flags. Also, make the cancellation path lock the kiocb and subsequently release all references to it if the cancel was successful. This version includes a fix for the deadlock with __aio_run_iocbs. Signed-off-by: Benjamin LaHaise Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 769791d..201c184 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -546,6 +546,24 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id) return ioctx; } +static int lock_kiocb_action(void *param) +{ + schedule(); + return 0; +} + +static inline void lock_kiocb(struct kiocb *iocb) +{ + wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action, + TASK_UNINTERRUPTIBLE); +} + +static inline void unlock_kiocb(struct kiocb *iocb) +{ + kiocbClearLocked(iocb); + wake_up_bit(&iocb->ki_flags, KIF_LOCKED); +} + /* * use_mm * Makes the calling kernel thread take on the specified @@ -786,7 +804,9 @@ static int __aio_run_iocbs(struct kioctx *ctx) * Hold an extra reference while retrying i/o. */ iocb->ki_users++; /* grab extra reference */ + lock_kiocb(iocb); aio_run_iocb(iocb); + unlock_kiocb(iocb); if (__aio_put_req(ctx, iocb)) /* drop extra ref */ put_ioctx(ctx); } @@ -1527,10 +1547,9 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, goto out_put_req; spin_lock_irq(&ctx->ctx_lock); - if (likely(list_empty(&ctx->run_list))) { - aio_run_iocb(req); - } else { - list_add_tail(&req->ki_run_list, &ctx->run_list); + aio_run_iocb(req); + unlock_kiocb(req); + if (!list_empty(&ctx->run_list)) { /* drain the run list */ while (__aio_run_iocbs(ctx)) ; @@ -1661,6 +1680,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, if (NULL != cancel) { struct io_event tmp; pr_debug("calling cancel\n"); + lock_kiocb(kiocb); memset(&tmp, 0, sizeof(tmp)); tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user; tmp.data = kiocb->ki_user_data; @@ -1672,6 +1692,7 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb, if (copy_to_user(result, &tmp, sizeof(tmp))) ret = -EFAULT; } + unlock_kiocb(kiocb); } else ret = -EINVAL; -- cgit v0.10.2 From 73a358d1892a8233801e3fd54668075b52ec42da Mon Sep 17 00:00:00 2001 From: KUROSAWA Takahiro Date: Fri, 9 Sep 2005 13:02:10 -0700 Subject: [PATCH] fix for cpusets minor problem This patch fixes minor problem that the CPUSETS have when files in the cpuset filesystem are read after lseek()-ed beyond the EOF. Signed-off-by: KUROSAWA Takahiro Acked-by: Paul Jackson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 1f06e76..712d020 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -972,6 +972,10 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, *s++ = '\n'; *s = '\0'; + /* Do nothing if *ppos is at the eof or beyond the eof. */ + if (s - page <= *ppos) + return 0; + start = page + *ppos; n = s - start; retval = n - copy_to_user(buf, start, min(n, nbytes)); -- cgit v0.10.2 From 24b20ac6e1c80082889b3d6ae08aadda777519e5 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Fri, 9 Sep 2005 13:02:11 -0700 Subject: [PATCH] remove unnecessary handle_IRQ_event() prototypes The function prototype for handle_IRQ_event() in a few architctures is not needed because they use GENERIC_HARDIRQ. Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h index b90b11d..3f2470e 100644 --- a/include/asm-mips/irq.h +++ b/include/asm-mips/irq.h @@ -49,7 +49,4 @@ do { \ extern void arch_init_irq(void); -struct irqaction; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #endif /* _ASM_IRQ_H */ diff --git a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h index b4b2704..5575247 100644 --- a/include/asm-ppc/irq.h +++ b/include/asm-ppc/irq.h @@ -404,9 +404,5 @@ extern unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; extern unsigned long ppc_lost_interrupts[NR_MASK_WORDS]; extern atomic_t ppc_n_lost_interrupts; -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #endif /* _ASM_IRQ_H */ #endif /* __KERNEL__ */ diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h index 831e52e..614a8c1 100644 --- a/include/asm-sh/irq.h +++ b/include/asm-sh/irq.h @@ -587,10 +587,6 @@ static inline int generic_irq_demux(int irq) #define irq_canonicalize(irq) (irq) #define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq)) -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #if defined(CONFIG_CPU_SUBTYPE_SH73180) #include #endif diff --git a/include/asm-x86_64/irq.h b/include/asm-x86_64/irq.h index 4482657..fb724ba 100644 --- a/include/asm-x86_64/irq.h +++ b/include/asm-x86_64/irq.h @@ -48,10 +48,6 @@ static __inline__ int irq_canonicalize(int irq) #define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ #endif -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - #ifdef CONFIG_HOTPLUG_CPU #include extern void fixup_irqs(cpumask_t map); -- cgit v0.10.2 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 diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 24594c5..52a3ae5 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 v0.10.2 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 diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 37c8bea..747eb8d 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 v0.10.2 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 diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 747eb8d..26b421b 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 v0.10.2 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 diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 26b421b..ea2d54b 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 v0.10.2 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 diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 8982eaf..1bde04d 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 v0.10.2 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 diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 1bde04d..d55dbf1 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 v0.10.2 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 diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index d55dbf1..eb31a3b 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 v0.10.2 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 diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index eb31a3b..6fb165c 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 v0.10.2 From 59f4e7d572980a521b7bdba74ab71b21f5995538 Mon Sep 17 00:00:00 2001 From: Truxton Fulton Date: Fri, 9 Sep 2005 13:02:18 -0700 Subject: [PATCH] fix reboot via keyboard controller reset I have a system (Biostar IDEQ210M mini-pc with a VIA chipset) which will not reboot unless a keyboard is plugged in to it. I have tried all combinations of the kernel "reboot=x,y" flags to no avail. Rebooting by any method will leave the system in a wedged state (at the "Restarting system" message). I finally tracked the problem down to the machine's refusal to fully reboot unless the keyboard controller status register had bit 2 set. This is the "System flag" which when set, indicates successful completion of the keyboard controller self-test (Basic Assurance Test, BAT). I suppose that something is trying to protect against sporadic reboots unless the keyboard controller is in a good state (a keyboard is present), but I need this machine to be headless. I found that setting the system flag (via the command byte) before giving the "pulse reset line" command will allow the reboot to proceed. The patch is simple, and I think it should be fine for everybody whether they have this type of machine or not. This affects the "hard" reboot (as done when the kernel boot flags "reboot=c,h" are used). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/asm-i386/mach-default/mach_reboot.h b/include/asm-i386/mach-default/mach_reboot.h index 521e227..06ae4d8 100644 --- a/include/asm-i386/mach-default/mach_reboot.h +++ b/include/asm-i386/mach-default/mach_reboot.h @@ -22,7 +22,15 @@ static inline void mach_reboot(void) for (i = 0; i < 100; i++) { kb_wait(); udelay(50); - outb(0xfe, 0x64); /* pulse reset low */ + outb(0x60, 0x64); /* write Controller Command Byte */ + udelay(50); + kb_wait(); + udelay(50); + outb(0x14, 0x60); /* set "System flag" */ + udelay(50); + kb_wait(); + udelay(50); + outb(0xfe, 0x64); /* pulse reset low */ udelay(50); } } -- cgit v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3c5a8e2..3bfbba3 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 837623f..a73baf0 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 2923b3b..9ec8e5b 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 8222b88..555d472 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 6b663f4..b63ecf2 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 v0.10.2 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 diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c04fd11..3788898 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 6284894..45f8673 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 9ea5747..c52e9d5 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 6a968c3..33a357c 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 cd434b7..21433e1 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 cd33705..441de66 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 45c9a9a..3d08fc8 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 diff --git a/include/media/saa7146.h b/include/media/saa7146.h index 3dfb8d6..2a897c3 100644 --- a/include/media/saa7146.h +++ b/include/media/saa7146.h @@ -1,7 +1,6 @@ #ifndef __SAA7146__ #define __SAA7146__ -#include /* for version macros */ #include /* for module-version */ #include /* for delay-stuff */ #include /* for kmalloc/kfree */ @@ -15,12 +14,7 @@ #include /* for vmalloc() */ #include /* for vmalloc_to_page() */ -/* ugly, but necessary to build the dvb stuff under 2.4. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - #include "dvb_functions.h" -#endif - -#define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0) +#define SAA7146_VERSION_CODE 0x000500 /* 0.5.0 */ #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) #define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) @@ -33,13 +27,8 @@ extern unsigned int saa7146_debug; #define DEBUG_VARIABLE saa7146_debug #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) -#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_BASENAME),__FUNCTION__) -#define INFO(x) { printk("%s: ",__stringify(KBUILD_BASENAME)); printk x; } -#else #define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__) #define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; } -#endif #define ERR(x) { DEBUG_PROLOG; printk x; } -- cgit v0.10.2 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 diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 772d611..c578a52 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index fb55eaa..b86d03f 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 68050cd..6059562 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index ac9889d..3d18d3e 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index b86d03f..608461f 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 3d18d3e..8774a94 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 c09beb3..20275a2 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index 608461f..ee5be59 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 8774a94..6488206 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index ee5be59..9719a3b 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 6059562..8028c3a 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 6488206..b9cb671 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 20275a2..d149f2a 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 33a357c..8793549 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index b9cb671..528ca46 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 528ca46..dc476dd 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 d149f2a..0cc8883 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 0eb9aa7..88757e2 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index d32dc4d..cc1bc0e 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 v0.10.2 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 diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0410cc9..a36bec3 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 cfa3928..db66d41 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 79457a8..d0c4484 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 e4c6e87..c91cf89 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 9746d2b..311be50 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 a126705..88f27a5 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 8142e26..b1f21ef 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 9961917..5552ef5 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 7daf7b1..c1acd4b 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 4f396ac..c7fe27f 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 b687fc7..872028d 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 5552ef5..43d6c82 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index db66d41..2d62931 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index ab0c032..74cea9f 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 70fb44b..c6d2766 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 555d472..71b5409 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 71b5409..eb4833e 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index eb4833e..d4b9798 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 928aca0..01eb419 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 v0.10.2 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 diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index cc0a77c..b6d0eec 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 612e5b0..54e2b29 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 746d87e..2dc9aad 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 794d513..2b249c7 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 0000000..f20d8db --- /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 0000000..1f5034c --- /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 0000000..4a3e8c7 --- /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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 828b518..c9f3e90 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 2b249c7..1b97838 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 65f0c09..ea1098a 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index b032523..0a94ec2 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 47dba6e..9d74f48 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index f2fcc2f..e55322ef 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 9e96a18..d2be035 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 c9f3e90..0058505 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 e9dac43..6a0912e 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 f70e0be..24d2bc6 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 9d74f48..5aa12eb 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 1b97838..0818996 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 ea1098a..a902059 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 a80567c..0e4f103 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 258a92b..1841a66 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 2112ac3..6fd6765 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 1f5034c..de13c04 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 9ac95f5..13406a8 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 24d2bc6..74545f8 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 966de98..88a57b7 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 13406a8..0f57abe 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 v0.10.2 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 diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index d2be035..3fe383f 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 1d79016..135c2a8 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 07a0b0a..6c34ac9 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3bfbba3..f295714 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 6f857c6..b29b0f5 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index b29b0f5..514dff3 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 514dff3..c5c7672 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 6c34ac9..66e69b8 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index bfaacd5..d2e0b1c 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 66e69b8..39835ed 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 d2e0b1c..6776a59 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 ef532a6..c0ee0b19 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 39835ed..eef3448 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 c0ee0b19..3281a6c 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 v0.10.2 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 diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index eef3448..34a837a 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 v0.10.2 From 9dea88514c476d303f59e19b27ef26bb52dc193a Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:03 -0700 Subject: [PATCH] dvb: dst: ci doc update Updated documentation Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/dvb/ci.txt b/Documentation/dvb/ci.txt index 62e0701..95f0e73 100644 --- a/Documentation/dvb/ci.txt +++ b/Documentation/dvb/ci.txt @@ -23,7 +23,6 @@ This application requires the following to function properly as of now. eg: $ szap -c channels.conf -r "TMC" -x (b) a channels.conf containing a valid PMT PID - eg: TMC:11996:h:0:27500:278:512:650:321 here 278 is a valid PMT PID. the rest of the values are the @@ -31,13 +30,7 @@ This application requires the following to function properly as of now. (c) after running a szap, you have to run ca_zap, for the descrambler to function, - - eg: $ ca_zap patched_channels.conf "TMC" - - The patched means a patch to apply to scan, such that scan can - generate a channels.conf_with pmt, which has this PMT PID info - (NOTE: szap cannot use this channels.conf with the PMT_PID) - + eg: $ ca_zap channels.conf "TMC" (d) Hopeflly Enjoy your favourite subscribed channel as you do with a FTA card. -- cgit v0.10.2 From 2d6e7322b5f63d62ec8785c5fbf469c9a233baff Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 9 Sep 2005 13:03:04 -0700 Subject: [PATCH] dvb: dst: Updated Documentation Updated Documentation Signed-off-by: Manu Abraham Signed-off-by: Johannes Stezenbach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/dvb/bt8xx.txt b/Documentation/dvb/bt8xx.txt index 4b8c326..cb63b7a 100644 --- a/Documentation/dvb/bt8xx.txt +++ b/Documentation/dvb/bt8xx.txt @@ -1,55 +1,74 @@ -How to get the Nebula Electronics DigiTV, Pinnacle PCTV Sat, Twinhan DST + clones working -========================================================================================= +How to get the Nebula, PCTV and Twinhan DST cards working +========================================================= -1) General information -====================== +This class of cards has a bt878a as the PCI interface, and +require the bttv driver. -This class of cards has a bt878a chip as the PCI interface. -The different card drivers require the bttv driver to provide the means -to access the i2c bus and the gpio pins of the bt8xx chipset. +Please pay close attention to the warning about the bttv module +options below for the DST card. -2) Compilation rules for Kernel >= 2.6.12 -========================================= +1) General informations +======================= -Enable the following options: +These drivers require the bttv driver to provide the means to access +the i2c bus and the gpio pins of the bt8xx chipset. +Because of this, you need to enable "Device drivers" => "Multimedia devices" - => "Video For Linux" => "BT848 Video For Linux" + => "Video For Linux" => "BT848 Video For Linux" + +Furthermore you need to enable "Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices" - => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards" + => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards" -3) Loading Modules, described by two approaches -=============================================== +2) Loading Modules +================== In general you need to load the bttv driver, which will handle the gpio and -i2c communication for us, plus the common dvb-bt8xx device driver, -which is called the backend. -The frontends for Nebula DigiTV (nxt6000), Pinnacle PCTV Sat (cx24110), -TwinHan DST + clones (dst and dst-ca) are loaded automatically by the backend. -For further details about TwinHan DST + clones see /Documentation/dvb/ci.txt. +i2c communication for us, plus the common dvb-bt8xx device driver. +The frontends for Nebula (nxt6000), Pinnacle PCTV (cx24110) and +TwinHan (dst) are loaded automatically by the dvb-bt8xx device driver. -3a) The manual approach ------------------------ +3a) Nebula / Pinnacle PCTV +-------------------------- -Loading modules: -modprobe bttv -modprobe dvb-bt8xx + $ modprobe bttv (normally bttv is being loaded automatically by kmod) + $ modprobe dvb-bt8xx (or just place dvb-bt8xx in /etc/modules for automatic loading) -Unloading modules: -modprobe -r dvb-bt8xx -modprobe -r bttv -3b) The automatic approach +3b) TwinHan and Clones -------------------------- -If not already done by installation, place a line either in -/etc/modules.conf or in /etc/modprobe.conf containing this text: -alias char-major-81 bttv + $ modprobe bttv i2c_hw=1 card=0x71 + $ modprobe dvb-bt8xx + $ modprobe dst + +The value 0x71 will override the PCI type detection for dvb-bt8xx, +which is necessary for TwinHan cards. + +If you're having an older card (blue color circuit) and card=0x71 locks +your machine, try using 0x68, too. If that does not work, ask on the +mailing list. + +The DST module takes a couple of useful parameters. + +verbose takes values 0 to 4. These values control the verbosity level, +and can be used to debug also. + +verbose=0 means complete disabling of messages + 1 only error messages are displayed + 2 notifications are also displayed + 3 informational messages are also displayed + 4 debug setting + +dst_addons takes values 0 and 0x20. A value of 0 means it is a FTA card. +0x20 means it has a Conditional Access slot. + +The autodected values are determined bythe cards 'response +string' which you can see in your logs e.g. -Then place a line in /etc/modules containing this text: -dvb-bt8xx +dst_get_device_id: Recognise [DSTMCI] -Reboot your system and have fun! -- -Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham, Uwe Bugla +Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham -- cgit v0.10.2 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 diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 2267140..7cf4c4a 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 c52e9d5..6db0929 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e65fc36..6af74f7 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 v0.10.2 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 diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index a36bec3..47e28b0 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 01eb419..8d09afd 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 3be5359..9e53f01 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 c91cf89..48e8097 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 88f27a5..2980db3 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 311be50..8c2a290 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 8c2a290..7692cd2 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 1220826..456d529 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 456d529..7442f56 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 48e8097..b5d40d4 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 508b773..cce00ef 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 665cdb8..357a372 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index b5d40d4..22b203f 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 v0.10.2 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 diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 45f8673..fec6bea 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 v0.10.2 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 diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index c1acd4b..d200ab0 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 v0.10.2 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 diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 43da2e9..398146e 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 v0.10.2 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 diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6b0e646..657be94 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 0347a29..271a52b 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; } } diff --git a/include/linux/pci.h b/include/linux/pci.h index 6caaba0..c62e892 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -326,6 +326,7 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev); extern void pci_dev_put(struct pci_dev *dev); extern void pci_remove_bus(struct pci_bus *b); extern void pci_remove_bus_device(struct pci_dev *dev); +void pci_setup_cardbus(struct pci_bus *bus); /* Generic PCI functions exported to card drivers */ -- cgit v0.10.2 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 diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e39178f..fabd352 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 v0.10.2 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 diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 599b116..c0f4eb4 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 v0.10.2 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 diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 271a52b..f0997c3 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 v0.10.2 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 diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 6bbfbd0..4d5ffdc 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 v0.10.2 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 diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 4d5ffdc..55867bc 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 c0f4eb4..deb6d00 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 v0.10.2 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 diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 6485f75..ddc741e 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 ef694c7..a41fbb3 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 0000000..08d1c92 --- /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 v0.10.2 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 diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index f1d1ec4..dc0841b 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 v0.10.2 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 diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 398146e..080608c 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 deb6d00..89022ad 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; } diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index b707a60..cb8b6e6 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -151,6 +151,8 @@ struct pcmcia_device { uniquely define a pcmcia_device */ struct pcmcia_socket *socket; + char *devname; + u8 device_no; /* the hardware "function" device; certain subdevices can -- cgit v0.10.2 From e498be7dafd72fd68848c1eef1575aa7c5d658df Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 9 Sep 2005 13:03:32 -0700 Subject: [PATCH] Numa-aware slab allocator V5 The NUMA API change that introduced kmalloc_node was accepted for 2.6.12-rc3. Now it is possible to do slab allocations on a node to localize memory structures. This API was used by the pageset localization patch and the block layer localization patch now in mm. The existing kmalloc_node is slow since it simply searches through all pages of the slab to find a page that is on the node requested. The two patches do a one time allocation of slab structures at initialization and therefore the speed of kmalloc node does not matter. This patch allows kmalloc_node to be as fast as kmalloc by introducing node specific page lists for partial, free and full slabs. Slab allocation improves in a NUMA system so that we are seeing a performance gain in AIM7 of about 5% with this patch alone. More NUMA localizations are possible if kmalloc_node operates in an fast way like kmalloc. Test run on a 32p systems with 32G Ram. w/o patch Tasks jobs/min jti jobs/min/task real cpu 1 485.36 100 485.3640 11.99 1.91 Sat Apr 30 14:01:51 2005 100 26582.63 88 265.8263 21.89 144.96 Sat Apr 30 14:02:14 2005 200 29866.83 81 149.3342 38.97 286.08 Sat Apr 30 14:02:53 2005 300 33127.16 78 110.4239 52.71 426.54 Sat Apr 30 14:03:46 2005 400 34889.47 80 87.2237 66.72 568.90 Sat Apr 30 14:04:53 2005 500 35654.34 76 71.3087 81.62 714.55 Sat Apr 30 14:06:15 2005 600 36460.83 75 60.7681 95.77 853.42 Sat Apr 30 14:07:51 2005 700 35957.00 75 51.3671 113.30 990.67 Sat Apr 30 14:09:45 2005 800 33380.65 73 41.7258 139.48 1140.86 Sat Apr 30 14:12:05 2005 900 35095.01 76 38.9945 149.25 1281.30 Sat Apr 30 14:14:35 2005 1000 36094.37 74 36.0944 161.24 1419.66 Sat Apr 30 14:17:17 2005 w/patch Tasks jobs/min jti jobs/min/task real cpu 1 484.27 100 484.2736 12.02 1.93 Sat Apr 30 15:59:45 2005 100 28262.03 90 282.6203 20.59 143.57 Sat Apr 30 16:00:06 2005 200 32246.45 82 161.2322 36.10 282.89 Sat Apr 30 16:00:42 2005 300 37945.80 83 126.4860 46.01 418.75 Sat Apr 30 16:01:28 2005 400 40000.69 81 100.0017 58.20 561.48 Sat Apr 30 16:02:27 2005 500 40976.10 78 81.9522 71.02 696.95 Sat Apr 30 16:03:38 2005 600 41121.54 78 68.5359 84.92 834.86 Sat Apr 30 16:05:04 2005 700 44052.77 78 62.9325 92.48 971.53 Sat Apr 30 16:06:37 2005 800 41066.89 79 51.3336 113.38 1111.15 Sat Apr 30 16:08:31 2005 900 38918.77 79 43.2431 134.59 1252.57 Sat Apr 30 16:10:46 2005 1000 41842.21 76 41.8422 139.09 1392.33 Sat Apr 30 16:13:05 2005 These are measurement taken directly after boot and show a greater improvement than 5%. However, the performance improvements become less over time if the AIM7 runs are repeated and settle down at around 5%. Links to earlier discussions: http://marc.theaimsgroup.com/?t=111094594500003&r=1&w=2 http://marc.theaimsgroup.com/?t=111603406600002&r=1&w=2 Changelog V4-V5: - alloc_arraycache and alloc_aliencache take node parameter instead of cpu - fix initialization so that nodes without cpus are properly handled. - simplify code in kmem_cache_init - patch against Andrews temp mm3 release - Add Shai to credits - fallback to __cache_alloc from __cache_alloc_node if the node's cache is not available yet. Changelog V3-V4: - Patch against 2.6.12-rc5-mm1 - Cleanup patch integrated - More and better use of for_each_node and for_each_cpu - GCC 2.95 fix (do not use [] use [0]) - Correct determination of INDEX_AC - Remove hack to cause an error on platforms that have no CONFIG_NUMA but nodes. - Remove list3_data and list3_data_ptr macros for better readability Changelog V2-V3: - Made to patch against 2.6.12-rc4-mm1 - Revised bootstrap mechanism so that larger size kmem_list3 structs can be supported. Do a generic solution so that the right slab can be found for the internal structs. - use for_each_online_node Changelog V1-V2: - Batching for freeing of wrong-node objects (alien caches) - Locking changes and NUMA #ifdefs as requested by Manfred Signed-off-by: Alok N Kataria Signed-off-by: Shobhit Dayal Signed-off-by: Shai Fultheim Signed-off-by: Christoph Lameter Cc: Manfred Spraul Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/mm/slab.c b/mm/slab.c index d7c4443..a041c53 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -75,6 +75,15 @@ * * At present, each engine can be growing a cache. This should be blocked. * + * 15 March 2005. NUMA slab allocator. + * Shai Fultheim . + * Shobhit Dayal + * Alok N Kataria + * Christoph Lameter + * + * Modified the slab allocator to be node aware on NUMA systems. + * Each node has its own list of partial, free and full slabs. + * All object allocations for a node occur from node specific slab lists. */ #include @@ -93,6 +102,7 @@ #include #include #include +#include #include #include @@ -212,6 +222,7 @@ struct slab { void *s_mem; /* including colour offset */ unsigned int inuse; /* num of objs active in slab */ kmem_bufctl_t free; + unsigned short nodeid; }; /* @@ -239,7 +250,6 @@ struct slab_rcu { /* * struct array_cache * - * Per cpu structures * Purpose: * - LIFO ordering, to hand out cache-warm objects from _alloc * - reduce the number of linked list operations @@ -254,6 +264,13 @@ struct array_cache { unsigned int limit; unsigned int batchcount; unsigned int touched; + spinlock_t lock; + void *entry[0]; /* + * Must have this definition in here for the proper + * alignment of array_cache. Also simplifies accessing + * the entries. + * [0] is for gcc 2.95. It should really be []. + */ }; /* bootstrap: The caches do not work without cpuarrays anymore, @@ -266,34 +283,83 @@ struct arraycache_init { }; /* - * The slab lists of all objects. - * Hopefully reduce the internal fragmentation - * NUMA: The spinlock could be moved from the kmem_cache_t - * into this structure, too. Figure out what causes - * fewer cross-node spinlock operations. + * The slab lists for all objects. */ struct kmem_list3 { struct list_head slabs_partial; /* partial list first, better asm code */ struct list_head slabs_full; struct list_head slabs_free; unsigned long free_objects; - int free_touched; unsigned long next_reap; - struct array_cache *shared; + int free_touched; + unsigned int free_limit; + spinlock_t list_lock; + struct array_cache *shared; /* shared per node */ + struct array_cache **alien; /* on other nodes */ }; -#define LIST3_INIT(parent) \ - { \ - .slabs_full = LIST_HEAD_INIT(parent.slabs_full), \ - .slabs_partial = LIST_HEAD_INIT(parent.slabs_partial), \ - .slabs_free = LIST_HEAD_INIT(parent.slabs_free) \ +/* + * Need this for bootstrapping a per node allocator. + */ +#define NUM_INIT_LISTS (2 * MAX_NUMNODES + 1) +struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS]; +#define CACHE_CACHE 0 +#define SIZE_AC 1 +#define SIZE_L3 (1 + MAX_NUMNODES) + +/* + * This function may be completely optimized away if + * a constant is passed to it. Mostly the same as + * what is in linux/slab.h except it returns an + * index. + */ +static inline int index_of(const size_t size) +{ + if (__builtin_constant_p(size)) { + int i = 0; + +#define CACHE(x) \ + if (size <=x) \ + return i; \ + else \ + i++; +#include "linux/kmalloc_sizes.h" +#undef CACHE + { + extern void __bad_size(void); + __bad_size(); + } } -#define list3_data(cachep) \ - (&(cachep)->lists) + return 0; +} + +#define INDEX_AC index_of(sizeof(struct arraycache_init)) +#define INDEX_L3 index_of(sizeof(struct kmem_list3)) + +static inline void kmem_list3_init(struct kmem_list3 *parent) +{ + INIT_LIST_HEAD(&parent->slabs_full); + INIT_LIST_HEAD(&parent->slabs_partial); + INIT_LIST_HEAD(&parent->slabs_free); + parent->shared = NULL; + parent->alien = NULL; + spin_lock_init(&parent->list_lock); + parent->free_objects = 0; + parent->free_touched = 0; +} -/* NUMA: per-node */ -#define list3_data_ptr(cachep, ptr) \ - list3_data(cachep) +#define MAKE_LIST(cachep, listp, slab, nodeid) \ + do { \ + INIT_LIST_HEAD(listp); \ + list_splice(&(cachep->nodelists[nodeid]->slab), listp); \ + } while (0) + +#define MAKE_ALL_LISTS(cachep, ptr, nodeid) \ + do { \ + MAKE_LIST((cachep), (&(ptr)->slabs_full), slabs_full, nodeid); \ + MAKE_LIST((cachep), (&(ptr)->slabs_partial), slabs_partial, nodeid); \ + MAKE_LIST((cachep), (&(ptr)->slabs_free), slabs_free, nodeid); \ + } while (0) /* * kmem_cache_t @@ -306,13 +372,12 @@ struct kmem_cache_s { struct array_cache *array[NR_CPUS]; unsigned int batchcount; unsigned int limit; -/* 2) touched by every alloc & free from the backend */ - struct kmem_list3 lists; - /* NUMA: kmem_3list_t *nodelists[MAX_NUMNODES] */ + unsigned int shared; unsigned int objsize; +/* 2) touched by every alloc & free from the backend */ + struct kmem_list3 *nodelists[MAX_NUMNODES]; unsigned int flags; /* constant flags */ unsigned int num; /* # of objs per slab */ - unsigned int free_limit; /* upper limit of objects in the lists */ spinlock_t spinlock; /* 3) cache_grow/shrink */ @@ -349,6 +414,7 @@ struct kmem_cache_s { unsigned long errors; unsigned long max_freeable; unsigned long node_allocs; + unsigned long node_frees; atomic_t allochit; atomic_t allocmiss; atomic_t freehit; @@ -384,6 +450,7 @@ struct kmem_cache_s { } while (0) #define STATS_INC_ERR(x) ((x)->errors++) #define STATS_INC_NODEALLOCS(x) ((x)->node_allocs++) +#define STATS_INC_NODEFREES(x) ((x)->node_frees++) #define STATS_SET_FREEABLE(x, i) \ do { if ((x)->max_freeable < i) \ (x)->max_freeable = i; \ @@ -402,6 +469,7 @@ struct kmem_cache_s { #define STATS_SET_HIGH(x) do { } while (0) #define STATS_INC_ERR(x) do { } while (0) #define STATS_INC_NODEALLOCS(x) do { } while (0) +#define STATS_INC_NODEFREES(x) do { } while (0) #define STATS_SET_FREEABLE(x, i) \ do { } while (0) @@ -534,9 +602,9 @@ static struct arraycache_init initarray_generic = /* internal cache of cache description objs */ static kmem_cache_t cache_cache = { - .lists = LIST3_INIT(cache_cache.lists), .batchcount = 1, .limit = BOOT_CPUCACHE_ENTRIES, + .shared = 1, .objsize = sizeof(kmem_cache_t), .flags = SLAB_NO_REAP, .spinlock = SPIN_LOCK_UNLOCKED, @@ -557,7 +625,6 @@ static struct list_head cache_chain; * SLAB_RECLAIM_ACCOUNT turns this on per-slab */ atomic_t slab_reclaim_pages; -EXPORT_SYMBOL(slab_reclaim_pages); /* * chicken and egg problem: delay the per-cpu array allocation @@ -565,7 +632,8 @@ EXPORT_SYMBOL(slab_reclaim_pages); */ static enum { NONE, - PARTIAL, + PARTIAL_AC, + PARTIAL_L3, FULL } g_cpucache_up; @@ -574,11 +642,7 @@ static DEFINE_PER_CPU(struct work_struct, reap_work); static void free_block(kmem_cache_t* cachep, void** objpp, int len); static void enable_cpucache (kmem_cache_t *cachep); static void cache_reap (void *unused); - -static inline void **ac_entry(struct array_cache *ac) -{ - return (void**)(ac+1); -} +static int __node_shrink(kmem_cache_t *cachep, int node); static inline struct array_cache *ac_data(kmem_cache_t *cachep) { @@ -676,48 +740,160 @@ static void __devinit start_cpu_timer(int cpu) } } -static struct array_cache *alloc_arraycache(int cpu, int entries, +static struct array_cache *alloc_arraycache(int node, int entries, int batchcount) { int memsize = sizeof(void*)*entries+sizeof(struct array_cache); struct array_cache *nc = NULL; - if (cpu == -1) - nc = kmalloc(memsize, GFP_KERNEL); - else - nc = kmalloc_node(memsize, GFP_KERNEL, cpu_to_node(cpu)); - + nc = kmalloc_node(memsize, GFP_KERNEL, node); if (nc) { nc->avail = 0; nc->limit = entries; nc->batchcount = batchcount; nc->touched = 0; + spin_lock_init(&nc->lock); } return nc; } +#ifdef CONFIG_NUMA +static inline struct array_cache **alloc_alien_cache(int node, int limit) +{ + struct array_cache **ac_ptr; + int memsize = sizeof(void*)*MAX_NUMNODES; + int i; + + if (limit > 1) + limit = 12; + ac_ptr = kmalloc_node(memsize, GFP_KERNEL, node); + if (ac_ptr) { + for_each_node(i) { + if (i == node || !node_online(i)) { + ac_ptr[i] = NULL; + continue; + } + ac_ptr[i] = alloc_arraycache(node, limit, 0xbaadf00d); + if (!ac_ptr[i]) { + for (i--; i <=0; i--) + kfree(ac_ptr[i]); + kfree(ac_ptr); + return NULL; + } + } + } + return ac_ptr; +} + +static inline void free_alien_cache(struct array_cache **ac_ptr) +{ + int i; + + if (!ac_ptr) + return; + + for_each_node(i) + kfree(ac_ptr[i]); + + kfree(ac_ptr); +} + +static inline void __drain_alien_cache(kmem_cache_t *cachep, struct array_cache *ac, int node) +{ + struct kmem_list3 *rl3 = cachep->nodelists[node]; + + if (ac->avail) { + spin_lock(&rl3->list_lock); + free_block(cachep, ac->entry, ac->avail); + ac->avail = 0; + spin_unlock(&rl3->list_lock); + } +} + +static void drain_alien_cache(kmem_cache_t *cachep, struct kmem_list3 *l3) +{ + int i=0; + struct array_cache *ac; + unsigned long flags; + + for_each_online_node(i) { + ac = l3->alien[i]; + if (ac) { + spin_lock_irqsave(&ac->lock, flags); + __drain_alien_cache(cachep, ac, i); + spin_unlock_irqrestore(&ac->lock, flags); + } + } +} +#else +#define alloc_alien_cache(node, limit) do { } while (0) +#define free_alien_cache(ac_ptr) do { } while (0) +#define drain_alien_cache(cachep, l3) do { } while (0) +#endif + static int __devinit cpuup_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; kmem_cache_t* cachep; + struct kmem_list3 *l3 = NULL; + int node = cpu_to_node(cpu); + int memsize = sizeof(struct kmem_list3); + struct array_cache *nc = NULL; switch (action) { case CPU_UP_PREPARE: down(&cache_chain_sem); + /* we need to do this right in the beginning since + * alloc_arraycache's are going to use this list. + * kmalloc_node allows us to add the slab to the right + * kmem_list3 and not this cpu's kmem_list3 + */ + list_for_each_entry(cachep, &cache_chain, next) { - struct array_cache *nc; + /* setup the size64 kmemlist for cpu before we can + * begin anything. Make sure some other cpu on this + * node has not already allocated this + */ + if (!cachep->nodelists[node]) { + if (!(l3 = kmalloc_node(memsize, + GFP_KERNEL, node))) + goto bad; + kmem_list3_init(l3); + l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + + cachep->nodelists[node] = l3; + } + + spin_lock_irq(&cachep->nodelists[node]->list_lock); + cachep->nodelists[node]->free_limit = + (1 + nr_cpus_node(node)) * + cachep->batchcount + cachep->num; + spin_unlock_irq(&cachep->nodelists[node]->list_lock); + } - nc = alloc_arraycache(cpu, cachep->limit, cachep->batchcount); + /* Now we can go ahead with allocating the shared array's + & array cache's */ + list_for_each_entry(cachep, &cache_chain, next) { + nc = alloc_arraycache(node, cachep->limit, + cachep->batchcount); if (!nc) goto bad; - - spin_lock_irq(&cachep->spinlock); cachep->array[cpu] = nc; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount - + cachep->num; - spin_unlock_irq(&cachep->spinlock); + l3 = cachep->nodelists[node]; + BUG_ON(!l3); + if (!l3->shared) { + if (!(nc = alloc_arraycache(node, + cachep->shared*cachep->batchcount, + 0xbaadf00d))) + goto bad; + + /* we are serialised from CPU_DEAD or + CPU_UP_CANCELLED by the cpucontrol lock */ + l3->shared = nc; + } } up(&cache_chain_sem); break; @@ -732,13 +908,51 @@ static int __devinit cpuup_callback(struct notifier_block *nfb, list_for_each_entry(cachep, &cache_chain, next) { struct array_cache *nc; + cpumask_t mask; + mask = node_to_cpumask(node); spin_lock_irq(&cachep->spinlock); /* cpu is dead; no one can alloc from it. */ nc = cachep->array[cpu]; cachep->array[cpu] = NULL; - cachep->free_limit -= cachep->batchcount; - free_block(cachep, ac_entry(nc), nc->avail); + l3 = cachep->nodelists[node]; + + if (!l3) + goto unlock_cache; + + spin_lock(&l3->list_lock); + + /* Free limit for this kmem_list3 */ + l3->free_limit -= cachep->batchcount; + if (nc) + free_block(cachep, nc->entry, nc->avail); + + if (!cpus_empty(mask)) { + spin_unlock(&l3->list_lock); + goto unlock_cache; + } + + if (l3->shared) { + free_block(cachep, l3->shared->entry, + l3->shared->avail); + kfree(l3->shared); + l3->shared = NULL; + } + if (l3->alien) { + drain_alien_cache(cachep, l3); + free_alien_cache(l3->alien); + l3->alien = NULL; + } + + /* free slabs belonging to this node */ + if (__node_shrink(cachep, node)) { + cachep->nodelists[node] = NULL; + spin_unlock(&l3->list_lock); + kfree(l3); + } else { + spin_unlock(&l3->list_lock); + } +unlock_cache: spin_unlock_irq(&cachep->spinlock); kfree(nc); } @@ -754,6 +968,25 @@ bad: static struct notifier_block cpucache_notifier = { &cpuup_callback, NULL, 0 }; +/* + * swap the static kmem_list3 with kmalloced memory + */ +static void init_list(kmem_cache_t *cachep, struct kmem_list3 *list, + int nodeid) +{ + struct kmem_list3 *ptr; + + BUG_ON(cachep->nodelists[nodeid] != list); + ptr = kmalloc_node(sizeof(struct kmem_list3), GFP_KERNEL, nodeid); + BUG_ON(!ptr); + + local_irq_disable(); + memcpy(ptr, list, sizeof(struct kmem_list3)); + MAKE_ALL_LISTS(cachep, ptr, nodeid); + cachep->nodelists[nodeid] = ptr; + local_irq_enable(); +} + /* Initialisation. * Called after the gfp() functions have been enabled, and before smp_init(). */ @@ -762,6 +995,13 @@ void __init kmem_cache_init(void) size_t left_over; struct cache_sizes *sizes; struct cache_names *names; + int i; + + for (i = 0; i < NUM_INIT_LISTS; i++) { + kmem_list3_init(&initkmem_list3[i]); + if (i < MAX_NUMNODES) + cache_cache.nodelists[i] = NULL; + } /* * Fragmentation resistance on low memory - only use bigger @@ -770,21 +1010,24 @@ void __init kmem_cache_init(void) if (num_physpages > (32 << 20) >> PAGE_SHIFT) slab_break_gfp_order = BREAK_GFP_ORDER_HI; - /* Bootstrap is tricky, because several objects are allocated * from caches that do not exist yet: * 1) initialize the cache_cache cache: it contains the kmem_cache_t * structures of all caches, except cache_cache itself: cache_cache * is statically allocated. - * Initially an __init data area is used for the head array, it's - * replaced with a kmalloc allocated array at the end of the bootstrap. + * Initially an __init data area is used for the head array and the + * kmem_list3 structures, it's replaced with a kmalloc allocated + * array at the end of the bootstrap. * 2) Create the first kmalloc cache. - * The kmem_cache_t for the new cache is allocated normally. An __init - * data area is used for the head array. - * 3) Create the remaining kmalloc caches, with minimally sized head arrays. + * The kmem_cache_t for the new cache is allocated normally. + * An __init data area is used for the head array. + * 3) Create the remaining kmalloc caches, with minimally sized + * head arrays. * 4) Replace the __init data head arrays for cache_cache and the first * kmalloc cache with kmalloc allocated arrays. - * 5) Resize the head arrays of the kmalloc caches to their final sizes. + * 5) Replace the __init data for kmem_list3 for cache_cache and + * the other cache's with kmalloc allocated memory. + * 6) Resize the head arrays of the kmalloc caches to their final sizes. */ /* 1) create the cache_cache */ @@ -793,6 +1036,7 @@ void __init kmem_cache_init(void) list_add(&cache_cache.next, &cache_chain); cache_cache.colour_off = cache_line_size(); cache_cache.array[smp_processor_id()] = &initarray_cache.cache; + cache_cache.nodelists[numa_node_id()] = &initkmem_list3[CACHE_CACHE]; cache_cache.objsize = ALIGN(cache_cache.objsize, cache_line_size()); @@ -810,15 +1054,33 @@ void __init kmem_cache_init(void) sizes = malloc_sizes; names = cache_names; + /* Initialize the caches that provide memory for the array cache + * and the kmem_list3 structures first. + * Without this, further allocations will bug + */ + + sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name, + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + + if (INDEX_AC != INDEX_L3) + sizes[INDEX_L3].cs_cachep = + kmem_cache_create(names[INDEX_L3].name, + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + while (sizes->cs_size != ULONG_MAX) { - /* For performance, all the general caches are L1 aligned. + /* + * For performance, all the general caches are L1 aligned. * This should be particularly beneficial on SMP boxes, as it * eliminates "false sharing". * Note for systems short on memory removing the alignment will - * allow tighter packing of the smaller caches. */ - sizes->cs_cachep = kmem_cache_create(names->name, - sizes->cs_size, ARCH_KMALLOC_MINALIGN, - (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); + * allow tighter packing of the smaller caches. + */ + if(!sizes->cs_cachep) + sizes->cs_cachep = kmem_cache_create(names->name, + sizes->cs_size, ARCH_KMALLOC_MINALIGN, + (ARCH_KMALLOC_FLAGS | SLAB_PANIC), NULL, NULL); /* Inc off-slab bufctl limit until the ceiling is hit. */ if (!(OFF_SLAB(sizes->cs_cachep))) { @@ -837,24 +1099,47 @@ void __init kmem_cache_init(void) /* 4) Replace the bootstrap head arrays */ { void * ptr; - + ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + local_irq_disable(); BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache); - memcpy(ptr, ac_data(&cache_cache), sizeof(struct arraycache_init)); + memcpy(ptr, ac_data(&cache_cache), + sizeof(struct arraycache_init)); cache_cache.array[smp_processor_id()] = ptr; local_irq_enable(); - + ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); + local_irq_disable(); - BUG_ON(ac_data(malloc_sizes[0].cs_cachep) != &initarray_generic.cache); - memcpy(ptr, ac_data(malloc_sizes[0].cs_cachep), + BUG_ON(ac_data(malloc_sizes[INDEX_AC].cs_cachep) + != &initarray_generic.cache); + memcpy(ptr, ac_data(malloc_sizes[INDEX_AC].cs_cachep), sizeof(struct arraycache_init)); - malloc_sizes[0].cs_cachep->array[smp_processor_id()] = ptr; + malloc_sizes[INDEX_AC].cs_cachep->array[smp_processor_id()] = + ptr; local_irq_enable(); } + /* 5) Replace the bootstrap kmem_list3's */ + { + int node; + /* Replace the static kmem_list3 structures for the boot cpu */ + init_list(&cache_cache, &initkmem_list3[CACHE_CACHE], + numa_node_id()); + + for_each_online_node(node) { + init_list(malloc_sizes[INDEX_AC].cs_cachep, + &initkmem_list3[SIZE_AC+node], node); + + if (INDEX_AC != INDEX_L3) { + init_list(malloc_sizes[INDEX_L3].cs_cachep, + &initkmem_list3[SIZE_L3+node], + node); + } + } + } - /* 5) resize the head arrays to their final sizes */ + /* 6) resize the head arrays to their final sizes */ { kmem_cache_t *cachep; down(&cache_chain_sem); @@ -870,7 +1155,6 @@ void __init kmem_cache_init(void) * that initializes ac_data for all new cpus */ register_cpu_notifier(&cpucache_notifier); - /* The reap timers are started later, with a module init call: * That part of the kernel is not yet operational. @@ -885,10 +1169,8 @@ static int __init cpucache_init(void) * Register the timers that return unneeded * pages to gfp. */ - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (cpu_online(cpu)) - start_cpu_timer(cpu); - } + for_each_online_cpu(cpu) + start_cpu_timer(cpu); return 0; } @@ -1167,6 +1449,20 @@ static void slab_destroy (kmem_cache_t *cachep, struct slab *slabp) } } +/* For setting up all the kmem_list3s for cache whose objsize is same + as size of kmem_list3. */ +static inline void set_up_list3s(kmem_cache_t *cachep, int index) +{ + int node; + + for_each_online_node(node) { + cachep->nodelists[node] = &initkmem_list3[index+node]; + cachep->nodelists[node]->next_reap = jiffies + + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + } +} + /** * kmem_cache_create - Create a cache. * @name: A string which is used in /proc/slabinfo to identify this cache. @@ -1320,7 +1616,7 @@ kmem_cache_create (const char *name, size_t size, size_t align, size += BYTES_PER_WORD; } #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) - if (size > 128 && cachep->reallen > cache_line_size() && size < PAGE_SIZE) { + if (size >= malloc_sizes[INDEX_L3+1].cs_size && cachep->reallen > cache_line_size() && size < PAGE_SIZE) { cachep->dbghead += PAGE_SIZE - size; size = PAGE_SIZE; } @@ -1422,10 +1718,6 @@ next: cachep->gfpflags |= GFP_DMA; spin_lock_init(&cachep->spinlock); cachep->objsize = size; - /* NUMA */ - INIT_LIST_HEAD(&cachep->lists.slabs_full); - INIT_LIST_HEAD(&cachep->lists.slabs_partial); - INIT_LIST_HEAD(&cachep->lists.slabs_free); if (flags & CFLGS_OFF_SLAB) cachep->slabp_cache = kmem_find_general_cachep(slab_size,0); @@ -1444,11 +1736,43 @@ next: * the cache that's used by kmalloc(24), otherwise * the creation of further caches will BUG(). */ - cachep->array[smp_processor_id()] = &initarray_generic.cache; - g_cpucache_up = PARTIAL; + cachep->array[smp_processor_id()] = + &initarray_generic.cache; + + /* If the cache that's used by + * kmalloc(sizeof(kmem_list3)) is the first cache, + * then we need to set up all its list3s, otherwise + * the creation of further caches will BUG(). + */ + set_up_list3s(cachep, SIZE_AC); + if (INDEX_AC == INDEX_L3) + g_cpucache_up = PARTIAL_L3; + else + g_cpucache_up = PARTIAL_AC; } else { - cachep->array[smp_processor_id()] = kmalloc(sizeof(struct arraycache_init),GFP_KERNEL); + cachep->array[smp_processor_id()] = + kmalloc(sizeof(struct arraycache_init), + GFP_KERNEL); + + if (g_cpucache_up == PARTIAL_AC) { + set_up_list3s(cachep, SIZE_L3); + g_cpucache_up = PARTIAL_L3; + } else { + int node; + for_each_online_node(node) { + + cachep->nodelists[node] = + kmalloc_node(sizeof(struct kmem_list3), + GFP_KERNEL, node); + BUG_ON(!cachep->nodelists[node]); + kmem_list3_init(cachep->nodelists[node]); + } + } } + cachep->nodelists[numa_node_id()]->next_reap = + jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + BUG_ON(!ac_data(cachep)); ac_data(cachep)->avail = 0; ac_data(cachep)->limit = BOOT_CPUCACHE_ENTRIES; @@ -1456,13 +1780,8 @@ next: ac_data(cachep)->touched = 0; cachep->batchcount = 1; cachep->limit = BOOT_CPUCACHE_ENTRIES; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount - + cachep->num; } - cachep->lists.next_reap = jiffies + REAPTIMEOUT_LIST3 + - ((unsigned long)cachep)%REAPTIMEOUT_LIST3; - /* Need the semaphore to access the chain. */ down(&cache_chain_sem); { @@ -1519,13 +1838,23 @@ static void check_spinlock_acquired(kmem_cache_t *cachep) { #ifdef CONFIG_SMP check_irq_off(); - BUG_ON(spin_trylock(&cachep->spinlock)); + assert_spin_locked(&cachep->nodelists[numa_node_id()]->list_lock); #endif } + +static inline void check_spinlock_acquired_node(kmem_cache_t *cachep, int node) +{ +#ifdef CONFIG_SMP + check_irq_off(); + assert_spin_locked(&cachep->nodelists[node]->list_lock); +#endif +} + #else #define check_irq_off() do { } while(0) #define check_irq_on() do { } while(0) #define check_spinlock_acquired(x) do { } while(0) +#define check_spinlock_acquired_node(x, y) do { } while(0) #endif /* @@ -1547,7 +1876,7 @@ static void smp_call_function_all_cpus(void (*func) (void *arg), void *arg) } static void drain_array_locked(kmem_cache_t* cachep, - struct array_cache *ac, int force); + struct array_cache *ac, int force, int node); static void do_drain(void *arg) { @@ -1556,59 +1885,82 @@ static void do_drain(void *arg) check_irq_off(); ac = ac_data(cachep); - spin_lock(&cachep->spinlock); - free_block(cachep, &ac_entry(ac)[0], ac->avail); - spin_unlock(&cachep->spinlock); + spin_lock(&cachep->nodelists[numa_node_id()]->list_lock); + free_block(cachep, ac->entry, ac->avail); + spin_unlock(&cachep->nodelists[numa_node_id()]->list_lock); ac->avail = 0; } static void drain_cpu_caches(kmem_cache_t *cachep) { + struct kmem_list3 *l3; + int node; + smp_call_function_all_cpus(do_drain, cachep); check_irq_on(); spin_lock_irq(&cachep->spinlock); - if (cachep->lists.shared) - drain_array_locked(cachep, cachep->lists.shared, 1); + for_each_online_node(node) { + l3 = cachep->nodelists[node]; + if (l3) { + spin_lock(&l3->list_lock); + drain_array_locked(cachep, l3->shared, 1, node); + spin_unlock(&l3->list_lock); + if (l3->alien) + drain_alien_cache(cachep, l3); + } + } spin_unlock_irq(&cachep->spinlock); } - -/* NUMA shrink all list3s */ -static int __cache_shrink(kmem_cache_t *cachep) +static int __node_shrink(kmem_cache_t *cachep, int node) { struct slab *slabp; + struct kmem_list3 *l3 = cachep->nodelists[node]; int ret; - drain_cpu_caches(cachep); - - check_irq_on(); - spin_lock_irq(&cachep->spinlock); - - for(;;) { + for (;;) { struct list_head *p; - p = cachep->lists.slabs_free.prev; - if (p == &cachep->lists.slabs_free) + p = l3->slabs_free.prev; + if (p == &l3->slabs_free) break; - slabp = list_entry(cachep->lists.slabs_free.prev, struct slab, list); + slabp = list_entry(l3->slabs_free.prev, struct slab, list); #if DEBUG if (slabp->inuse) BUG(); #endif list_del(&slabp->list); - cachep->lists.free_objects -= cachep->num; - spin_unlock_irq(&cachep->spinlock); + l3->free_objects -= cachep->num; + spin_unlock_irq(&l3->list_lock); slab_destroy(cachep, slabp); - spin_lock_irq(&cachep->spinlock); + spin_lock_irq(&l3->list_lock); } - ret = !list_empty(&cachep->lists.slabs_full) || - !list_empty(&cachep->lists.slabs_partial); - spin_unlock_irq(&cachep->spinlock); + ret = !list_empty(&l3->slabs_full) || + !list_empty(&l3->slabs_partial); return ret; } +static int __cache_shrink(kmem_cache_t *cachep) +{ + int ret = 0, i = 0; + struct kmem_list3 *l3; + + drain_cpu_caches(cachep); + + check_irq_on(); + for_each_online_node(i) { + l3 = cachep->nodelists[i]; + if (l3) { + spin_lock_irq(&l3->list_lock); + ret += __node_shrink(cachep, i); + spin_unlock_irq(&l3->list_lock); + } + } + return (ret ? 1 : 0); +} + /** * kmem_cache_shrink - Shrink a cache. * @cachep: The cache to shrink. @@ -1645,6 +1997,7 @@ EXPORT_SYMBOL(kmem_cache_shrink); int kmem_cache_destroy(kmem_cache_t * cachep) { int i; + struct kmem_list3 *l3; if (!cachep || in_interrupt()) BUG(); @@ -1672,15 +2025,17 @@ int kmem_cache_destroy(kmem_cache_t * cachep) if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) synchronize_rcu(); - /* no cpu_online check required here since we clear the percpu - * array on cpu offline and set this to NULL. - */ - for (i = 0; i < NR_CPUS; i++) + for_each_online_cpu(i) kfree(cachep->array[i]); /* NUMA: free the list3 structures */ - kfree(cachep->lists.shared); - cachep->lists.shared = NULL; + for_each_online_node(i) { + if ((l3 = cachep->nodelists[i])) { + kfree(l3->shared); + free_alien_cache(l3->alien); + kfree(l3); + } + } kmem_cache_free(&cache_cache, cachep); unlock_cpu_hotplug(); @@ -1690,8 +2045,8 @@ int kmem_cache_destroy(kmem_cache_t * cachep) EXPORT_SYMBOL(kmem_cache_destroy); /* Get the memory for a slab management obj. */ -static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, - void *objp, int colour_off, unsigned int __nocast local_flags) +static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, void *objp, + int colour_off, unsigned int __nocast local_flags) { struct slab *slabp; @@ -1722,7 +2077,7 @@ static void cache_init_objs(kmem_cache_t *cachep, int i; for (i = 0; i < cachep->num; i++) { - void* objp = slabp->s_mem+cachep->objsize*i; + void *objp = slabp->s_mem+cachep->objsize*i; #if DEBUG /* need to poison the objs? */ if (cachep->flags & SLAB_POISON) @@ -1799,6 +2154,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod size_t offset; unsigned int local_flags; unsigned long ctor_flags; + struct kmem_list3 *l3; /* Be lazy and only check for valid flags here, * keeping it out of the critical path in kmem_cache_alloc(). @@ -1830,6 +2186,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod spin_unlock(&cachep->spinlock); + check_irq_off(); if (local_flags & __GFP_WAIT) local_irq_enable(); @@ -1841,8 +2198,9 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod */ kmem_flagcheck(cachep, flags); - - /* Get mem for the objs. */ + /* Get mem for the objs. + * Attempt to allocate a physical page from 'nodeid', + */ if (!(objp = kmem_getpages(cachep, flags, nodeid))) goto failed; @@ -1850,6 +2208,7 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod if (!(slabp = alloc_slabmgmt(cachep, objp, offset, local_flags))) goto opps1; + slabp->nodeid = nodeid; set_slab_attr(cachep, slabp, objp); cache_init_objs(cachep, slabp, ctor_flags); @@ -1857,13 +2216,14 @@ static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nod if (local_flags & __GFP_WAIT) local_irq_disable(); check_irq_off(); - spin_lock(&cachep->spinlock); + l3 = cachep->nodelists[nodeid]; + spin_lock(&l3->list_lock); /* Make slab active. */ - list_add_tail(&slabp->list, &(list3_data(cachep)->slabs_free)); + list_add_tail(&slabp->list, &(l3->slabs_free)); STATS_INC_GROWN(cachep); - list3_data(cachep)->free_objects += cachep->num; - spin_unlock(&cachep->spinlock); + l3->free_objects += cachep->num; + spin_unlock(&l3->list_lock); return 1; opps1: kmem_freepages(cachep, objp); @@ -1969,7 +2329,6 @@ static void check_slabp(kmem_cache_t *cachep, struct slab *slabp) kmem_bufctl_t i; int entries = 0; - check_spinlock_acquired(cachep); /* Check slab's freelist to see if this obj is there. */ for (i = slabp->free; i != BUFCTL_END; i = slab_bufctl(slabp)[i]) { entries++; @@ -2012,10 +2371,11 @@ retry: */ batchcount = BATCHREFILL_LIMIT; } - l3 = list3_data(cachep); + l3 = cachep->nodelists[numa_node_id()]; + + BUG_ON(ac->avail > 0 || !l3); + spin_lock(&l3->list_lock); - BUG_ON(ac->avail > 0); - spin_lock(&cachep->spinlock); if (l3->shared) { struct array_cache *shared_array = l3->shared; if (shared_array->avail) { @@ -2023,8 +2383,9 @@ retry: batchcount = shared_array->avail; shared_array->avail -= batchcount; ac->avail = batchcount; - memcpy(ac_entry(ac), &ac_entry(shared_array)[shared_array->avail], - sizeof(void*)*batchcount); + memcpy(ac->entry, + &(shared_array->entry[shared_array->avail]), + sizeof(void*)*batchcount); shared_array->touched = 1; goto alloc_done; } @@ -2051,7 +2412,8 @@ retry: STATS_SET_HIGH(cachep); /* get obj pointer */ - ac_entry(ac)[ac->avail++] = slabp->s_mem + slabp->free*cachep->objsize; + ac->entry[ac->avail++] = slabp->s_mem + + slabp->free*cachep->objsize; slabp->inuse++; next = slab_bufctl(slabp)[slabp->free]; @@ -2073,12 +2435,12 @@ retry: must_grow: l3->free_objects -= ac->avail; alloc_done: - spin_unlock(&cachep->spinlock); + spin_unlock(&l3->list_lock); if (unlikely(!ac->avail)) { int x; - x = cache_grow(cachep, flags, -1); - + x = cache_grow(cachep, flags, numa_node_id()); + // cache_grow can reenable interrupts, then ac could change. ac = ac_data(cachep); if (!x && ac->avail == 0) // no objects in sight? abort @@ -2088,7 +2450,7 @@ alloc_done: goto retry; } ac->touched = 1; - return ac_entry(ac)[--ac->avail]; + return ac->entry[--ac->avail]; } static inline void @@ -2160,7 +2522,7 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl if (likely(ac->avail)) { STATS_INC_ALLOCHIT(cachep); ac->touched = 1; - objp = ac_entry(ac)[--ac->avail]; + objp = ac->entry[--ac->avail]; } else { STATS_INC_ALLOCMISS(cachep); objp = cache_alloc_refill(cachep, flags); @@ -2172,33 +2534,104 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl return objp; } -/* - * NUMA: different approach needed if the spinlock is moved into - * the l3 structure +#ifdef CONFIG_NUMA +/* + * A interface to enable slab creation on nodeid */ +static void *__cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid) +{ + struct list_head *entry; + struct slab *slabp; + struct kmem_list3 *l3; + void *obj; + kmem_bufctl_t next; + int x; + + l3 = cachep->nodelists[nodeid]; + BUG_ON(!l3); + +retry: + spin_lock(&l3->list_lock); + entry = l3->slabs_partial.next; + if (entry == &l3->slabs_partial) { + l3->free_touched = 1; + entry = l3->slabs_free.next; + if (entry == &l3->slabs_free) + goto must_grow; + } + + slabp = list_entry(entry, struct slab, list); + check_spinlock_acquired_node(cachep, nodeid); + check_slabp(cachep, slabp); + + STATS_INC_NODEALLOCS(cachep); + STATS_INC_ACTIVE(cachep); + STATS_SET_HIGH(cachep); + + BUG_ON(slabp->inuse == cachep->num); + + /* get obj pointer */ + obj = slabp->s_mem + slabp->free*cachep->objsize; + slabp->inuse++; + next = slab_bufctl(slabp)[slabp->free]; +#if DEBUG + slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE; +#endif + slabp->free = next; + check_slabp(cachep, slabp); + l3->free_objects--; + /* move slabp to correct slabp list: */ + list_del(&slabp->list); + + if (slabp->free == BUFCTL_END) { + list_add(&slabp->list, &l3->slabs_full); + } else { + list_add(&slabp->list, &l3->slabs_partial); + } + + spin_unlock(&l3->list_lock); + goto done; + +must_grow: + spin_unlock(&l3->list_lock); + x = cache_grow(cachep, flags, nodeid); + if (!x) + return NULL; + + goto retry; +done: + return obj; +} +#endif + +/* + * Caller needs to acquire correct kmem_list's list_lock + */ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) { int i; - - check_spinlock_acquired(cachep); - - /* NUMA: move add into loop */ - cachep->lists.free_objects += nr_objects; + struct kmem_list3 *l3; for (i = 0; i < nr_objects; i++) { void *objp = objpp[i]; struct slab *slabp; unsigned int objnr; + int nodeid = 0; slabp = GET_PAGE_SLAB(virt_to_page(objp)); + nodeid = slabp->nodeid; + l3 = cachep->nodelists[nodeid]; list_del(&slabp->list); objnr = (objp - slabp->s_mem) / cachep->objsize; + check_spinlock_acquired_node(cachep, nodeid); check_slabp(cachep, slabp); + + #if DEBUG if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) { - printk(KERN_ERR "slab: double free detected in cache '%s', objp %p.\n", - cachep->name, objp); + printk(KERN_ERR "slab: double free detected in cache " + "'%s', objp %p\n", cachep->name, objp); BUG(); } #endif @@ -2206,24 +2639,23 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) slabp->free = objnr; STATS_DEC_ACTIVE(cachep); slabp->inuse--; + l3->free_objects++; check_slabp(cachep, slabp); /* fixup slab chains */ if (slabp->inuse == 0) { - if (cachep->lists.free_objects > cachep->free_limit) { - cachep->lists.free_objects -= cachep->num; + if (l3->free_objects > l3->free_limit) { + l3->free_objects -= cachep->num; slab_destroy(cachep, slabp); } else { - list_add(&slabp->list, - &list3_data_ptr(cachep, objp)->slabs_free); + list_add(&slabp->list, &l3->slabs_free); } } else { /* Unconditionally move a slab to the end of the * partial list on free - maximum time for the * other objects to be freed, too. */ - list_add_tail(&slabp->list, - &list3_data_ptr(cachep, objp)->slabs_partial); + list_add_tail(&slabp->list, &l3->slabs_partial); } } } @@ -2231,36 +2663,38 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac) { int batchcount; + struct kmem_list3 *l3; batchcount = ac->batchcount; #if DEBUG BUG_ON(!batchcount || batchcount > ac->avail); #endif check_irq_off(); - spin_lock(&cachep->spinlock); - if (cachep->lists.shared) { - struct array_cache *shared_array = cachep->lists.shared; + l3 = cachep->nodelists[numa_node_id()]; + spin_lock(&l3->list_lock); + if (l3->shared) { + struct array_cache *shared_array = l3->shared; int max = shared_array->limit-shared_array->avail; if (max) { if (batchcount > max) batchcount = max; - memcpy(&ac_entry(shared_array)[shared_array->avail], - &ac_entry(ac)[0], + memcpy(&(shared_array->entry[shared_array->avail]), + ac->entry, sizeof(void*)*batchcount); shared_array->avail += batchcount; goto free_done; } } - free_block(cachep, &ac_entry(ac)[0], batchcount); + free_block(cachep, ac->entry, batchcount); free_done: #if STATS { int i = 0; struct list_head *p; - p = list3_data(cachep)->slabs_free.next; - while (p != &(list3_data(cachep)->slabs_free)) { + p = l3->slabs_free.next; + while (p != &(l3->slabs_free)) { struct slab *slabp; slabp = list_entry(p, struct slab, list); @@ -2272,12 +2706,13 @@ free_done: STATS_SET_FREEABLE(cachep, i); } #endif - spin_unlock(&cachep->spinlock); + spin_unlock(&l3->list_lock); ac->avail -= batchcount; - memmove(&ac_entry(ac)[0], &ac_entry(ac)[batchcount], + memmove(ac->entry, &(ac->entry[batchcount]), sizeof(void*)*ac->avail); } + /* * __cache_free * Release an obj back to its cache. If the obj has a constructed @@ -2292,14 +2727,46 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp) check_irq_off(); objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0)); + /* Make sure we are not freeing a object from another + * node to the array cache on this cpu. + */ +#ifdef CONFIG_NUMA + { + struct slab *slabp; + slabp = GET_PAGE_SLAB(virt_to_page(objp)); + if (unlikely(slabp->nodeid != numa_node_id())) { + struct array_cache *alien = NULL; + int nodeid = slabp->nodeid; + struct kmem_list3 *l3 = cachep->nodelists[numa_node_id()]; + + STATS_INC_NODEFREES(cachep); + if (l3->alien && l3->alien[nodeid]) { + alien = l3->alien[nodeid]; + spin_lock(&alien->lock); + if (unlikely(alien->avail == alien->limit)) + __drain_alien_cache(cachep, + alien, nodeid); + alien->entry[alien->avail++] = objp; + spin_unlock(&alien->lock); + } else { + spin_lock(&(cachep->nodelists[nodeid])-> + list_lock); + free_block(cachep, &objp, 1); + spin_unlock(&(cachep->nodelists[nodeid])-> + list_lock); + } + return; + } + } +#endif if (likely(ac->avail < ac->limit)) { STATS_INC_FREEHIT(cachep); - ac_entry(ac)[ac->avail++] = objp; + ac->entry[ac->avail++] = objp; return; } else { STATS_INC_FREEMISS(cachep); cache_flusharray(cachep, ac); - ac_entry(ac)[ac->avail++] = objp; + ac->entry[ac->avail++] = objp; } } @@ -2369,81 +2836,30 @@ out: * Identical to kmem_cache_alloc, except that this function is slow * and can sleep. And it will allocate memory on the given node, which * can improve the performance for cpu bound structures. + * New and improved: it will now make sure that the object gets + * put on the correct node list so that there is no false sharing. */ void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid) { - int loop; - void *objp; - struct slab *slabp; - kmem_bufctl_t next; - - if (nodeid == -1) - return kmem_cache_alloc(cachep, flags); - - for (loop = 0;;loop++) { - struct list_head *q; - - objp = NULL; - check_irq_on(); - spin_lock_irq(&cachep->spinlock); - /* walk through all partial and empty slab and find one - * from the right node */ - list_for_each(q,&cachep->lists.slabs_partial) { - slabp = list_entry(q, struct slab, list); - - if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid || - loop > 2) - goto got_slabp; - } - list_for_each(q, &cachep->lists.slabs_free) { - slabp = list_entry(q, struct slab, list); + unsigned long save_flags; + void *ptr; - if (page_to_nid(virt_to_page(slabp->s_mem)) == nodeid || - loop > 2) - goto got_slabp; - } - spin_unlock_irq(&cachep->spinlock); + if (nodeid == numa_node_id() || nodeid == -1) + return __cache_alloc(cachep, flags); - local_irq_disable(); - if (!cache_grow(cachep, flags, nodeid)) { - local_irq_enable(); - return NULL; - } - local_irq_enable(); + if (unlikely(!cachep->nodelists[nodeid])) { + /* Fall back to __cache_alloc if we run into trouble */ + printk(KERN_WARNING "slab: not allocating in inactive node %d for cache %s\n", nodeid, cachep->name); + return __cache_alloc(cachep,flags); } -got_slabp: - /* found one: allocate object */ - check_slabp(cachep, slabp); - check_spinlock_acquired(cachep); - STATS_INC_ALLOCED(cachep); - STATS_INC_ACTIVE(cachep); - STATS_SET_HIGH(cachep); - STATS_INC_NODEALLOCS(cachep); - - objp = slabp->s_mem + slabp->free*cachep->objsize; - - slabp->inuse++; - next = slab_bufctl(slabp)[slabp->free]; -#if DEBUG - slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE; -#endif - slabp->free = next; - check_slabp(cachep, slabp); - - /* move slabp to correct slabp list: */ - list_del(&slabp->list); - if (slabp->free == BUFCTL_END) - list_add(&slabp->list, &cachep->lists.slabs_full); - else - list_add(&slabp->list, &cachep->lists.slabs_partial); - - list3_data(cachep)->free_objects--; - spin_unlock_irq(&cachep->spinlock); + cache_alloc_debugcheck_before(cachep, flags); + local_irq_save(save_flags); + ptr = __cache_alloc_node(cachep, flags, nodeid); + local_irq_restore(save_flags); + ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); - objp = cache_alloc_debugcheck_after(cachep, GFP_KERNEL, objp, - __builtin_return_address(0)); - return objp; + return ptr; } EXPORT_SYMBOL(kmem_cache_alloc_node); @@ -2513,11 +2929,18 @@ void *__alloc_percpu(size_t size, size_t align) if (!pdata) return NULL; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; - pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL, - cpu_to_node(i)); + /* + * Cannot use for_each_online_cpu since a cpu may come online + * and we have no way of figuring out how to fix the array + * that we have allocated then.... + */ + for_each_cpu(i) { + int node = cpu_to_node(i); + + if (node_online(node)) + pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL, node); + else + pdata->ptrs[i] = kmalloc(size, GFP_KERNEL); if (!pdata->ptrs[i]) goto unwind_oom; @@ -2607,11 +3030,11 @@ free_percpu(const void *objp) int i; struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp); - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_possible(i)) - continue; + /* + * We allocate for all cpus so we cannot use for online cpu here. + */ + for_each_cpu(i) kfree(p->ptrs[i]); - } kfree(p); } EXPORT_SYMBOL(free_percpu); @@ -2629,6 +3052,64 @@ const char *kmem_cache_name(kmem_cache_t *cachep) } EXPORT_SYMBOL_GPL(kmem_cache_name); +/* + * This initializes kmem_list3 for all nodes. + */ +static int alloc_kmemlist(kmem_cache_t *cachep) +{ + int node; + struct kmem_list3 *l3; + int err = 0; + + for_each_online_node(node) { + struct array_cache *nc = NULL, *new; + struct array_cache **new_alien = NULL; +#ifdef CONFIG_NUMA + if (!(new_alien = alloc_alien_cache(node, cachep->limit))) + goto fail; +#endif + if (!(new = alloc_arraycache(node, (cachep->shared* + cachep->batchcount), 0xbaadf00d))) + goto fail; + if ((l3 = cachep->nodelists[node])) { + + spin_lock_irq(&l3->list_lock); + + if ((nc = cachep->nodelists[node]->shared)) + free_block(cachep, nc->entry, + nc->avail); + + l3->shared = new; + if (!cachep->nodelists[node]->alien) { + l3->alien = new_alien; + new_alien = NULL; + } + l3->free_limit = (1 + nr_cpus_node(node))* + cachep->batchcount + cachep->num; + spin_unlock_irq(&l3->list_lock); + kfree(nc); + free_alien_cache(new_alien); + continue; + } + if (!(l3 = kmalloc_node(sizeof(struct kmem_list3), + GFP_KERNEL, node))) + goto fail; + + kmem_list3_init(l3); + l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + + ((unsigned long)cachep)%REAPTIMEOUT_LIST3; + l3->shared = new; + l3->alien = new_alien; + l3->free_limit = (1 + nr_cpus_node(node))* + cachep->batchcount + cachep->num; + cachep->nodelists[node] = l3; + } + return err; +fail: + err = -ENOMEM; + return err; +} + struct ccupdate_struct { kmem_cache_t *cachep; struct array_cache *new[NR_CPUS]; @@ -2641,7 +3122,7 @@ static void do_ccupdate_local(void *info) check_irq_off(); old = ac_data(new->cachep); - + new->cachep->array[smp_processor_id()] = new->new[smp_processor_id()]; new->new[smp_processor_id()] = old; } @@ -2651,54 +3132,43 @@ static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount, int shared) { struct ccupdate_struct new; - struct array_cache *new_shared; - int i; + int i, err; memset(&new.new,0,sizeof(new.new)); - for (i = 0; i < NR_CPUS; i++) { - if (cpu_online(i)) { - new.new[i] = alloc_arraycache(i, limit, batchcount); - if (!new.new[i]) { - for (i--; i >= 0; i--) kfree(new.new[i]); - return -ENOMEM; - } - } else { - new.new[i] = NULL; + for_each_online_cpu(i) { + new.new[i] = alloc_arraycache(cpu_to_node(i), limit, batchcount); + if (!new.new[i]) { + for (i--; i >= 0; i--) kfree(new.new[i]); + return -ENOMEM; } } new.cachep = cachep; smp_call_function_all_cpus(do_ccupdate_local, (void *)&new); - + check_irq_on(); spin_lock_irq(&cachep->spinlock); cachep->batchcount = batchcount; cachep->limit = limit; - cachep->free_limit = (1+num_online_cpus())*cachep->batchcount + cachep->num; + cachep->shared = shared; spin_unlock_irq(&cachep->spinlock); - for (i = 0; i < NR_CPUS; i++) { + for_each_online_cpu(i) { struct array_cache *ccold = new.new[i]; if (!ccold) continue; - spin_lock_irq(&cachep->spinlock); - free_block(cachep, ac_entry(ccold), ccold->avail); - spin_unlock_irq(&cachep->spinlock); + spin_lock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); + free_block(cachep, ccold->entry, ccold->avail); + spin_unlock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); kfree(ccold); } - new_shared = alloc_arraycache(-1, batchcount*shared, 0xbaadf00d); - if (new_shared) { - struct array_cache *old; - spin_lock_irq(&cachep->spinlock); - old = cachep->lists.shared; - cachep->lists.shared = new_shared; - if (old) - free_block(cachep, ac_entry(old), old->avail); - spin_unlock_irq(&cachep->spinlock); - kfree(old); + err = alloc_kmemlist(cachep); + if (err) { + printk(KERN_ERR "alloc_kmemlist failed for %s, error %d.\n", + cachep->name, -err); + BUG(); } - return 0; } @@ -2756,11 +3226,11 @@ static void enable_cpucache(kmem_cache_t *cachep) } static void drain_array_locked(kmem_cache_t *cachep, - struct array_cache *ac, int force) + struct array_cache *ac, int force, int node) { int tofree; - check_spinlock_acquired(cachep); + check_spinlock_acquired_node(cachep, node); if (ac->touched && !force) { ac->touched = 0; } else if (ac->avail) { @@ -2768,9 +3238,9 @@ static void drain_array_locked(kmem_cache_t *cachep, if (tofree > ac->avail) { tofree = (ac->avail+1)/2; } - free_block(cachep, ac_entry(ac), tofree); + free_block(cachep, ac->entry, tofree); ac->avail -= tofree; - memmove(&ac_entry(ac)[0], &ac_entry(ac)[tofree], + memmove(ac->entry, &(ac->entry[tofree]), sizeof(void*)*ac->avail); } } @@ -2789,6 +3259,7 @@ static void drain_array_locked(kmem_cache_t *cachep, static void cache_reap(void *unused) { struct list_head *walk; + struct kmem_list3 *l3; if (down_trylock(&cache_chain_sem)) { /* Give up. Setup the next iteration. */ @@ -2809,27 +3280,32 @@ static void cache_reap(void *unused) check_irq_on(); - spin_lock_irq(&searchp->spinlock); + l3 = searchp->nodelists[numa_node_id()]; + if (l3->alien) + drain_alien_cache(searchp, l3); + spin_lock_irq(&l3->list_lock); - drain_array_locked(searchp, ac_data(searchp), 0); + drain_array_locked(searchp, ac_data(searchp), 0, + numa_node_id()); - if(time_after(searchp->lists.next_reap, jiffies)) + if (time_after(l3->next_reap, jiffies)) goto next_unlock; - searchp->lists.next_reap = jiffies + REAPTIMEOUT_LIST3; + l3->next_reap = jiffies + REAPTIMEOUT_LIST3; - if (searchp->lists.shared) - drain_array_locked(searchp, searchp->lists.shared, 0); + if (l3->shared) + drain_array_locked(searchp, l3->shared, 0, + numa_node_id()); - if (searchp->lists.free_touched) { - searchp->lists.free_touched = 0; + if (l3->free_touched) { + l3->free_touched = 0; goto next_unlock; } - tofree = (searchp->free_limit+5*searchp->num-1)/(5*searchp->num); + tofree = (l3->free_limit+5*searchp->num-1)/(5*searchp->num); do { - p = list3_data(searchp)->slabs_free.next; - if (p == &(list3_data(searchp)->slabs_free)) + p = l3->slabs_free.next; + if (p == &(l3->slabs_free)) break; slabp = list_entry(p, struct slab, list); @@ -2842,13 +3318,13 @@ static void cache_reap(void *unused) * searchp cannot disappear, we hold * cache_chain_lock */ - searchp->lists.free_objects -= searchp->num; - spin_unlock_irq(&searchp->spinlock); + l3->free_objects -= searchp->num; + spin_unlock_irq(&l3->list_lock); slab_destroy(searchp, slabp); - spin_lock_irq(&searchp->spinlock); + spin_lock_irq(&l3->list_lock); } while(--tofree > 0); next_unlock: - spin_unlock_irq(&searchp->spinlock); + spin_unlock_irq(&l3->list_lock); next: cond_resched(); } @@ -2882,7 +3358,7 @@ static void *s_start(struct seq_file *m, loff_t *pos) seq_puts(m, " : slabdata "); #if STATS seq_puts(m, " : globalstat " - " "); + " "); seq_puts(m, " : cpustat "); #endif seq_putc(m, '\n'); @@ -2917,39 +3393,53 @@ static int s_show(struct seq_file *m, void *p) unsigned long active_objs; unsigned long num_objs; unsigned long active_slabs = 0; - unsigned long num_slabs; - const char *name; + unsigned long num_slabs, free_objects = 0, shared_avail = 0; + const char *name; char *error = NULL; + int node; + struct kmem_list3 *l3; check_irq_on(); spin_lock_irq(&cachep->spinlock); active_objs = 0; num_slabs = 0; - list_for_each(q,&cachep->lists.slabs_full) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse != cachep->num && !error) - error = "slabs_full accounting error"; - active_objs += cachep->num; - active_slabs++; - } - list_for_each(q,&cachep->lists.slabs_partial) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse == cachep->num && !error) - error = "slabs_partial inuse accounting error"; - if (!slabp->inuse && !error) - error = "slabs_partial/inuse accounting error"; - active_objs += slabp->inuse; - active_slabs++; - } - list_for_each(q,&cachep->lists.slabs_free) { - slabp = list_entry(q, struct slab, list); - if (slabp->inuse && !error) - error = "slabs_free/inuse accounting error"; - num_slabs++; + for_each_online_node(node) { + l3 = cachep->nodelists[node]; + if (!l3) + continue; + + spin_lock(&l3->list_lock); + + list_for_each(q,&l3->slabs_full) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse != cachep->num && !error) + error = "slabs_full accounting error"; + active_objs += cachep->num; + active_slabs++; + } + list_for_each(q,&l3->slabs_partial) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse == cachep->num && !error) + error = "slabs_partial inuse accounting error"; + if (!slabp->inuse && !error) + error = "slabs_partial/inuse accounting error"; + active_objs += slabp->inuse; + active_slabs++; + } + list_for_each(q,&l3->slabs_free) { + slabp = list_entry(q, struct slab, list); + if (slabp->inuse && !error) + error = "slabs_free/inuse accounting error"; + num_slabs++; + } + free_objects += l3->free_objects; + shared_avail += l3->shared->avail; + + spin_unlock(&l3->list_lock); } num_slabs+=active_slabs; num_objs = num_slabs*cachep->num; - if (num_objs - active_objs != cachep->lists.free_objects && !error) + if (num_objs - active_objs != free_objects && !error) error = "free_objects accounting error"; name = cachep->name; @@ -2961,9 +3451,9 @@ static int s_show(struct seq_file *m, void *p) cachep->num, (1<gfporder)); seq_printf(m, " : tunables %4u %4u %4u", cachep->limit, cachep->batchcount, - cachep->lists.shared->limit/cachep->batchcount); - seq_printf(m, " : slabdata %6lu %6lu %6u", - active_slabs, num_slabs, cachep->lists.shared->avail); + cachep->shared); + seq_printf(m, " : slabdata %6lu %6lu %6lu", + active_slabs, num_slabs, shared_avail); #if STATS { /* list3 stats */ unsigned long high = cachep->high_mark; @@ -2972,12 +3462,13 @@ static int s_show(struct seq_file *m, void *p) unsigned long reaped = cachep->reaped; unsigned long errors = cachep->errors; unsigned long max_freeable = cachep->max_freeable; - unsigned long free_limit = cachep->free_limit; unsigned long node_allocs = cachep->node_allocs; + unsigned long node_frees = cachep->node_frees; - seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu %4lu %4lu %4lu %4lu", - allocs, high, grown, reaped, errors, - max_freeable, free_limit, node_allocs); + seq_printf(m, " : globalstat %7lu %6lu %5lu %4lu \ + %4lu %4lu %4lu %4lu", + allocs, high, grown, reaped, errors, + max_freeable, node_allocs, node_frees); } /* cpu stats */ { @@ -3056,9 +3547,10 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer, batchcount < 1 || batchcount > limit || shared < 0) { - res = -EINVAL; + res = 0; } else { - res = do_tune_cpucache(cachep, limit, batchcount, shared); + res = do_tune_cpucache(cachep, limit, + batchcount, shared); } break; } -- cgit v0.10.2 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 diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 16c85c0..077720c 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 v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner index f3302e1..f5876be 100644 --- a/Documentation/video4linux/CARDLIST.tuner +++ b/Documentation/video4linux/CARDLIST.tuner @@ -64,3 +64,4 @@ tuner=62 - Philips TEA5767HN FM Radio tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner tuner=64 - LG TDVS-H062F/TUA6034 tuner=65 - Ymec TVF66T5-B/DFF +tuner=66 - LG NTSC (TALN mini series) diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c index ab7a1fb..a0e700d 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 7f2d515..a48de3c 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 41f6039..503e6c6 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 a565823..eddadc7 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 1e273ff..67105b9 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 023f330..2d9ff40 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 2fb7c2d..972aa5e 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 a8b6a8d..c65f0c7 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 d60fc56..79e0bd1 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 cebcc1f..38bf509 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 3b1893c..afc96bb 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 de0c93a..2603440 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 3c3356a..d0a00d3 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 a43301a..d86e08e 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 70ecbdb..59bb713 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 b5e0cf3..597b8db 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 15f5bb4..55f129e 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 5afdc78..97354f2 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. diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 9d6fbde..1cc8c31 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h @@ -3,7 +3,6 @@ #include #include -#include #define HAVE_V4L2 1 #include @@ -29,7 +28,6 @@ struct video_device void (*release)(struct video_device *vfd); -#if 1 /* to be removed in 2.7.x */ /* obsolete -- fops->owner is used instead */ struct module *owner; /* dev->driver_data will be used instead some day. @@ -37,7 +35,6 @@ struct video_device * so the switch over will be transparent for you. * Or use {pci|usb}_{get|set}_drvdata() directly. */ void *priv; -#endif /* for videodev.c intenal usage -- please don't touch */ int users; /* video_exclusive_{open|close} ... */ diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index acbfc52..f623a33 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -270,7 +270,6 @@ struct v4l2_timecode /* The above is based on SMPTE timecodes */ -#if 1 /* * M P E G C O M P R E S S I O N P A R A M E T E R S * @@ -357,7 +356,6 @@ struct v4l2_mpeg_compression { /* I don't expect the above being perfect yet ;) */ __u32 reserved_5[8]; }; -#endif struct v4l2_jpegcompression { @@ -871,10 +869,8 @@ struct v4l2_streamparm #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) -#if 1 /* experimental */ #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) -#endif #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) diff --git a/include/media/audiochip.h b/include/media/audiochip.h index cd83116..a7ceee9 100644 --- a/include/media/audiochip.h +++ b/include/media/audiochip.h @@ -1,5 +1,4 @@ /* - * $Id: audiochip.h,v 1.5 2005/06/16 22:59:16 hhackmann Exp $ */ #ifndef AUDIOCHIP_H diff --git a/include/media/id.h b/include/media/id.h index 801ddef..6d02c94 100644 --- a/include/media/id.h +++ b/include/media/id.h @@ -1,5 +1,4 @@ /* - * $Id: id.h,v 1.4 2005/06/12 04:19:19 mchehab Exp $ */ /* FIXME: this temporarely, until these are included in linux/i2c-id.h */ diff --git a/include/media/ir-common.h b/include/media/ir-common.h index 6986705..01b5682 100644 --- a/include/media/ir-common.h +++ b/include/media/ir-common.h @@ -1,5 +1,4 @@ /* - * $Id: ir-common.h,v 1.9 2005/05/15 19:01:26 mchehab Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -21,11 +20,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #define IR_TYPE_RC5 1 +#define IR_TYPE_PD 2 /* Pulse distance encoded IR */ #define IR_TYPE_OTHER 99 #define IR_KEYTAB_TYPE u32 @@ -60,6 +59,7 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, u32 ir_extract_bits(u32 data, u32 mask); int ir_dump_samples(u32 *samples, int count); int ir_decode_biphase(u32 *samples, int count, int low, int high); +int ir_decode_pulsedistance(u32 *samples, int count, int low, int high); /* * Local variables: diff --git a/include/media/tuner.h b/include/media/tuner.h index eeaa15d..252673b 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -1,5 +1,3 @@ - -/* $Id: tuner.h,v 1.45 2005/07/28 18:41:21 mchehab Exp $ * tuner.h - definition for different tuners @@ -111,6 +109,8 @@ #define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ #define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ +#define TUNER_LG_NTSC_TALN_MINI 66 + #define NOTUNER 0 #define PAL 1 /* PAL_BG */ #define PAL_I 2 @@ -134,6 +134,7 @@ #define THOMSON 12 #define TUNER_SET_TYPE_ADDR _IOW('T',3,int) +#define TUNER_SET_STANDBY _IOW('T',4,int) #define TDA9887_SET_CONFIG _IOW('t',5,int) /* tv card specific */ @@ -153,9 +154,6 @@ #ifdef __KERNEL__ -#define I2C_ADDR_TDA8290 0x4b -#define I2C_ADDR_TDA8275 0x61 - enum tuner_mode { T_UNINITIALIZED = 0, T_RADIO = 1 << V4L2_TUNER_RADIO, @@ -198,6 +196,7 @@ struct tuner { void (*radio_freq)(struct i2c_client *c, unsigned int freq); int (*has_signal)(struct i2c_client *c); int (*is_stereo)(struct i2c_client *c); + void (*standby)(struct i2c_client *c); }; extern unsigned int tuner_debug; @@ -209,12 +208,16 @@ extern int tea5767_tuner_init(struct i2c_client *c); extern int default_tuner_init(struct i2c_client *c); extern int tea5767_autodetection(struct i2c_client *c); -#define tuner_warn(fmt, arg...) \ - dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg) -#define tuner_info(fmt, arg...) \ - dev_printk(KERN_INFO , &t->i2c.dev , fmt , ## arg) -#define tuner_dbg(fmt, arg...) \ - if (tuner_debug) dev_printk(KERN_DEBUG , &t->i2c.dev , fmt , ## arg) +#define tuner_warn(fmt, arg...) do {\ + printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) +#define tuner_info(fmt, arg...) do {\ + printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) +#define tuner_dbg(fmt, arg...) do {\ + if (tuner_debug) \ + printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->name, \ + t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) #endif /* __KERNEL__ */ diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h index 854a2c2..e24e841 100644 --- a/include/media/tveeprom.h +++ b/include/media/tveeprom.h @@ -1,5 +1,4 @@ /* - * $Id: tveeprom.h,v 1.2 2005/06/12 04:19:19 mchehab Exp $ */ struct tveeprom { diff --git a/include/media/video-buf.h b/include/media/video-buf.h index ae6da6d..ae8d7a0 100644 --- a/include/media/video-buf.h +++ b/include/media/video-buf.h @@ -1,5 +1,4 @@ /* - * $Id: video-buf.h,v 1.9 2004/11/07 13:17:15 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. -- cgit v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 62a12a0..7979c06 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -133,3 +133,5 @@ card=131 - Tibet Systems 'Progress DVR' CS16 card=132 - Kodicom 4400R (master) card=133 - Kodicom 4400R (slave) card=134 - Adlink RTV24 +card=135 - DVICO FusionHDTV 5 Lite +card=136 - Acorp Y878F diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index a97b9b9..3cb398b 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 087efb4..53ecdbf 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 77320cd..6b280c0 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 706dc48..e684df3 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 f7b5543..e8aada7 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 9ed21fd..a5ed99b 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 06f3e62..f4f58c6 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 f2af9e1..d254e90 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 aab094b..a0eb0ce 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 v0.10.2 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 diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 4f39688..0c0c59e 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 ebf02a7..9262323 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 5e868f5..dc5c5c1 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 78d2232..cc71caf 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 7f59803..761cebd 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 2148877..d7980c5 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 fe2767c..6d0d15c 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 37f8266..0a3a62f 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 91207f1..2765ace 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 320d578..9bc6c89 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 5f58c10..61d4b29 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 da65dc9..13b8fb7 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 v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 1b5a3a9..9c8b1ca 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -62,3 +62,4 @@ 61 -> Philips TOUGH DVB-T reference design [1131:2004] 62 -> Compro VideoMate TV Gold+II 63 -> Kworld Xpert TV PVR7134 + 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 88b71a2..c277b3b 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 1dbe617..e5e36f3 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 8be6a90..fa29dd5 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 c85348d0..77b627e 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 eae6b52..711aa8e 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 2137401..0e97b1e 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 b5bede9..c20630c 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 87734f2..ae0c7a1 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 4dd9f1b..4638856 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 eeafa5a..badf2f9 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 29e51ca..f4aee0a 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 a4c2f75..35e5e85 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 2af0cb2..7a7fa42 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 v0.10.2 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 diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index ca02f6f..01d567c 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 v0.10.2 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 diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index d0a00d3..3674014 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 v0.10.2 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 diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 2603440..6f153ca 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 v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 9c8b1ca..0351282 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -63,3 +63,4 @@ 62 -> Compro VideoMate TV Gold+II 63 -> Kworld Xpert TV PVR7134 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] + 65 -> V-Stream Studio TV Terminator diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index c277b3b..ea0237a 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 7a7fa42..26ec944 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 v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 0351282..dc57225 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -64,3 +64,4 @@ 63 -> Kworld Xpert TV PVR7134 64 -> FlyTV mini Asus Digimatrix [1043:0210,1043:0210] 65 -> V-Stream Studio TV Terminator + 66 -> Yuan TUN-900 (saa7135) diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index ea0237a..f991f23 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 26ec944..1d70f34 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 v0.10.2 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 diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 7979c06..ec785f9 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -126,12 +126,12 @@ card=124 - AverMedia AverTV DVB-T 761 card=125 - MATRIX Vision Sigma-SQ card=126 - MATRIX Vision Sigma-SLC card=127 - APAC Viewcomp 878(AMAX) -card=128 - DVICO FusionHDTV DVB-T Lite +card=128 - DViCO FusionHDTV DVB-T Lite card=129 - V-Gear MyVCD card=130 - Super TV Tuner card=131 - Tibet Systems 'Progress DVR' CS16 card=132 - Kodicom 4400R (master) card=133 - Kodicom 4400R (slave) card=134 - Adlink RTV24 -card=135 - DVICO FusionHDTV 5 Lite +card=135 - DViCO FusionHDTV 5 Lite card=136 - Acorp Y878F diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 3cb398b..64785d3 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 cc71caf..c9106b1 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 f991f23..07d3ee0 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -2380,12 +2380,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .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, .subvendor = 0x1461, /* Avermedia Technologies Inc */ .subdevice = 0x9715, -- cgit v0.10.2 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 diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 6f153ca..5e99b24 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, diff --git a/include/media/tuner.h b/include/media/tuner.h index 252673b..5b01ee6 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -26,90 +26,90 @@ #define ADDR_UNSET (255) -#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ -#define TUNER_PHILIPS_PAL_I 1 -#define TUNER_PHILIPS_NTSC 2 -#define TUNER_PHILIPS_SECAM 3 /* you must actively select B/G, L, L` */ - -#define TUNER_ABSENT 4 -#define TUNER_PHILIPS_PAL 5 -#define TUNER_TEMIC_NTSC 6 /* 4032 FY5 (3X 7004, 9498, 9789) */ -#define TUNER_TEMIC_PAL_I 7 /* 4062 FY5 (3X 8501, 9957) */ - -#define TUNER_TEMIC_4036FY5_NTSC 8 /* 4036 FY5 (3X 1223, 1981, 7686) */ -#define TUNER_ALPS_TSBH1_NTSC 9 -#define TUNER_ALPS_TSBE1_PAL 10 -#define TUNER_ALPS_TSBB5_PAL_I 11 - -#define TUNER_ALPS_TSBE5_PAL 12 -#define TUNER_ALPS_TSBC5_PAL 13 -#define TUNER_TEMIC_4006FH5_PAL 14 /* 4006 FH5 (3X 9500, 9501, 7291) */ -#define TUNER_ALPS_TSHC6_NTSC 15 - -#define TUNER_TEMIC_PAL_DK 16 /* 4016 FY5 (3X 1392, 1393) */ -#define TUNER_PHILIPS_NTSC_M 17 -#define TUNER_TEMIC_4066FY5_PAL_I 18 /* 4066 FY5 (3X 7032, 7035) */ -#define TUNER_TEMIC_4006FN5_MULTI_PAL 19 /* B/G, I and D/K autodetected (3X 7595, 7606, 7657)*/ - -#define TUNER_TEMIC_4009FR5_PAL 20 /* incl. FM radio (3X 7607, 7488, 7711)*/ -#define TUNER_TEMIC_4039FR5_NTSC 21 /* incl. FM radio (3X 7246, 7578, 7732)*/ -#define TUNER_TEMIC_4046FM5 22 /* you must actively select B/G, D/K, I, L, L` ! (3X 7804, 7806, 8103, 8104)*/ +#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ +#define TUNER_PHILIPS_PAL_I 1 +#define TUNER_PHILIPS_NTSC 2 +#define TUNER_PHILIPS_SECAM 3 /* you must actively select B/G, L, L` */ + +#define TUNER_ABSENT 4 +#define TUNER_PHILIPS_PAL 5 +#define TUNER_TEMIC_NTSC 6 /* 4032 FY5 (3X 7004, 9498, 9789) */ +#define TUNER_TEMIC_PAL_I 7 /* 4062 FY5 (3X 8501, 9957) */ + +#define TUNER_TEMIC_4036FY5_NTSC 8 /* 4036 FY5 (3X 1223, 1981, 7686) */ +#define TUNER_ALPS_TSBH1_NTSC 9 +#define TUNER_ALPS_TSBE1_PAL 10 +#define TUNER_ALPS_TSBB5_PAL_I 11 + +#define TUNER_ALPS_TSBE5_PAL 12 +#define TUNER_ALPS_TSBC5_PAL 13 +#define TUNER_TEMIC_4006FH5_PAL 14 /* 4006 FH5 (3X 9500, 9501, 7291) */ +#define TUNER_ALPS_TSHC6_NTSC 15 + +#define TUNER_TEMIC_PAL_DK 16 /* 4016 FY5 (3X 1392, 1393) */ +#define TUNER_PHILIPS_NTSC_M 17 +#define TUNER_TEMIC_4066FY5_PAL_I 18 /* 4066 FY5 (3X 7032, 7035) */ +#define TUNER_TEMIC_4006FN5_MULTI_PAL 19 /* B/G, I and D/K autodetected (3X 7595, 7606, 7657) */ + +#define TUNER_TEMIC_4009FR5_PAL 20 /* incl. FM radio (3X 7607, 7488, 7711) */ +#define TUNER_TEMIC_4039FR5_NTSC 21 /* incl. FM radio (3X 7246, 7578, 7732) */ +#define TUNER_TEMIC_4046FM5 22 /* you must actively select B/G, D/K, I, L, L` ! (3X 7804, 7806, 8103, 8104) */ #define TUNER_PHILIPS_PAL_DK 23 -#define TUNER_PHILIPS_FQ1216ME 24 /* you must actively select B/G/D/K, I, L, L` */ -#define TUNER_LG_PAL_I_FM 25 -#define TUNER_LG_PAL_I 26 -#define TUNER_LG_NTSC_FM 27 +#define TUNER_PHILIPS_FQ1216ME 24 /* you must actively select B/G/D/K, I, L, L` */ +#define TUNER_LG_PAL_I_FM 25 +#define TUNER_LG_PAL_I 26 +#define TUNER_LG_NTSC_FM 27 -#define TUNER_LG_PAL_FM 28 -#define TUNER_LG_PAL 29 -#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM 30 /* B/G, I and D/K autodetected (3X 8155, 8160, 8163)*/ -#define TUNER_SHARP_2U5JF5540_NTSC 31 +#define TUNER_LG_PAL_FM 28 +#define TUNER_LG_PAL 29 +#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM 30 /* B/G, I and D/K autodetected (3X 8155, 8160, 8163) */ +#define TUNER_SHARP_2U5JF5540_NTSC 31 -#define TUNER_Samsung_PAL_TCPM9091PD27 32 -#define TUNER_MT2032 33 -#define TUNER_TEMIC_4106FH5 34 /* 4106 FH5 (3X 7808, 7865)*/ -#define TUNER_TEMIC_4012FY5 35 /* 4012 FY5 (3X 0971, 1099)*/ +#define TUNER_Samsung_PAL_TCPM9091PD27 32 +#define TUNER_MT2032 33 +#define TUNER_TEMIC_4106FH5 34 /* 4106 FH5 (3X 7808, 7865) */ +#define TUNER_TEMIC_4012FY5 35 /* 4012 FY5 (3X 0971, 1099) */ -#define TUNER_TEMIC_4136FY5 36 /* 4136 FY5 (3X 7708, 7746)*/ -#define TUNER_LG_PAL_NEW_TAPC 37 -#define TUNER_PHILIPS_FM1216ME_MK3 38 -#define TUNER_LG_NTSC_NEW_TAPC 39 +#define TUNER_TEMIC_4136FY5 36 /* 4136 FY5 (3X 7708, 7746) */ +#define TUNER_LG_PAL_NEW_TAPC 37 +#define TUNER_PHILIPS_FM1216ME_MK3 38 +#define TUNER_LG_NTSC_NEW_TAPC 39 -#define TUNER_HITACHI_NTSC 40 -#define TUNER_PHILIPS_PAL_MK 41 -#define TUNER_PHILIPS_ATSC 42 -#define TUNER_PHILIPS_FM1236_MK3 43 +#define TUNER_HITACHI_NTSC 40 +#define TUNER_PHILIPS_PAL_MK 41 +#define TUNER_PHILIPS_ATSC 42 +#define TUNER_PHILIPS_FM1236_MK3 43 -#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ +#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ /* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */ -#define TUNER_MICROTUNE_4049FM5 45 -#define TUNER_LG_NTSC_TAPE 47 - -#define TUNER_TNF_8831BGFF 48 -#define TUNER_MICROTUNE_4042FI5 49 /* DViCO FusionHDTV 3 Gold-Q - 4042 FI5 (3X 8147) */ -#define TUNER_TCL_2002N 50 -#define TUNER_PHILIPS_FM1256_IH3 51 - -#define TUNER_THOMSON_DTT7610 52 -#define TUNER_PHILIPS_FQ1286 53 -#define TUNER_PHILIPS_TDA8290 54 -#define TUNER_LG_PAL_TAPE 55 /* Hauppauge PVR-150 PAL */ - -#define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */ -#define TUNER_PHILIPS_FQ1236A_MK4 57 /* Hauppauge PVR-500MCE NTSC */ - -#define TUNER_YMEC_TVF_8531MF 58 -#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ -#define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */ -#define TUNER_TENA_9533_DI 61 - -#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ -#define TUNER_PHILIPS_FMD1216ME_MK3 63 -#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ -#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ - -#define TUNER_LG_NTSC_TALN_MINI 66 +#define TUNER_MICROTUNE_4049FM5 45 +#define TUNER_MICROTUNE_4042_FI5 46 +#define TUNER_LG_NTSC_TAPE 47 + +#define TUNER_TNF_8831BGFF 48 +#define TUNER_MICROTUNE_4042FI5 49 /* DViCO FusionHDTV 3 Gold-Q - 4042 FI5 (3X 8147) */ +#define TUNER_TCL_2002N 50 +#define TUNER_PHILIPS_FM1256_IH3 51 + +#define TUNER_THOMSON_DTT7610 52 +#define TUNER_PHILIPS_FQ1286 53 +#define TUNER_PHILIPS_TDA8290 54 +#define TUNER_LG_PAL_TAPE 55 /* Hauppauge PVR-150 PAL */ + +#define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */ +#define TUNER_PHILIPS_FQ1236A_MK4 57 /* Hauppauge PVR-500MCE NTSC */ +#define TUNER_YMEC_TVF_8531MF 58 +#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ + +#define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */ +#define TUNER_TENA_9533_DI 61 +#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ +#define TUNER_PHILIPS_FMD1216ME_MK3 63 + +#define TUNER_LG_TDVS_H062F 64 /* DViCO FusionHDTV 5 */ +#define TUNER_YMEC_TVF66T5_B_DFF 65 /* Acorp Y878F */ +#define TUNER_LG_NTSC_TALN_MINI 66 #define NOTUNER 0 #define PAL 1 /* PAL_BG */ @@ -117,7 +117,7 @@ #define NTSC 3 #define SECAM 4 #define ATSC 5 -#define RADIO 6 +#define RADIO 6 #define NoTuner 0 #define Philips 1 @@ -163,21 +163,21 @@ enum tuner_mode { }; struct tuner_setup { - unsigned short addr; - unsigned int type; - unsigned int mode_mask; + unsigned short addr; + unsigned int type; + unsigned int mode_mask; }; struct tuner { /* device */ struct i2c_client i2c; - unsigned int type; /* chip type */ + unsigned int type; /* chip type */ - unsigned int mode; - unsigned int mode_mask; /* Combination of allowable modes */ + unsigned int mode; + unsigned int mode_mask; /* Combination of allowable modes */ - unsigned int freq; /* keep track of the current settings */ + unsigned int freq; /* keep track of the current settings */ unsigned int audmode; v4l2_std_id std; @@ -221,7 +221,7 @@ extern int tea5767_autodetection(struct i2c_client *c); #endif /* __KERNEL__ */ -#endif +#endif /* _TUNER_H */ /* * Overrides for Emacs so that we follow Linus's tabbing style. -- cgit v0.10.2 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 diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 5e99b24..61dee53 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 v0.10.2 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 diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 53ecdbf..b35c586 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 6d0d15c..ee2300e 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 61d4b29..3dbc074 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 v0.10.2 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 diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 64785d3..10ab12b 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 61dee53..8edd73a 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 v0.10.2 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 diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index fa29dd5..639ae51 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 v0.10.2 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 diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 07d3ee0..acc7a43 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 v0.10.2 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 diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 79e0bd1..0456dda 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 afc96bb..0557202 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 v0.10.2 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 diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 01d567c..f0d43fc 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 v0.10.2 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 diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index d7980c5..d81b21d 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 eddadc7..cf292da 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 0e97b1e..1f456c4 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 v0.10.2 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 diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 077720c..9357035 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 3e6f534..046b82d 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 a0eb0ce..9b0b7ca 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 13b8fb7..f48dd43 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 0000000..30337d0 --- /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 0000000..1a657a7 --- /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 1d70f34..3ea0914 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 diff --git a/include/media/tuner.h b/include/media/tuner.h index 5b01ee6..4ad08e2 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -1,4 +1,4 @@ - * +/* tuner.h - definition for different tuners Copyright (C) 1997 Markus Schroeder (schroedm@uni-duesseldorf.de) -- cgit v0.10.2 From dc75fc1b924ccf44ca9f0446701acc0081605b49 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 9 Sep 2005 13:04:04 -0700 Subject: [PATCH] v4l: Remove kernel version dependency from tea575x-tuner.h - Removed kernel version dependency from tea575x-tuner.h Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h index ad3c3be..b82e408 100644 --- a/include/sound/tea575x-tuner.h +++ b/include/sound/tea575x-tuner.h @@ -34,9 +34,7 @@ struct snd_tea575x_ops { struct snd_tea575x { snd_card_t *card; struct video_device vd; /* video device */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) struct file_operations fops; -#endif int dev_nr; /* requested device number + 1 */ int vd_registered; /* video device is registered */ int tea5759; /* 5759 chip is present */ -- cgit v0.10.2 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 diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 258724b..1c31ef5 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 v0.10.2 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 diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index 10ab12b..190977a 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 b35c586..a564321 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 9262323..4da91d5 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 3674014..5344d55 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); diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h index e24e841..e2035c7 100644 --- a/include/media/tveeprom.h +++ b/include/media/tveeprom.h @@ -3,15 +3,19 @@ struct tveeprom { u32 has_radio; + u32 has_ir; /* 0: no IR, 1: IR present, 2: unknown */ u32 tuner_type; u32 tuner_formats; + u32 tuner2_type; + u32 tuner2_formats; + u32 digitizer; u32 digitizer_formats; u32 audio_processor; - /* a_p_fmts? */ + u32 decoder_processor; u32 model; u32 revision; @@ -19,7 +23,7 @@ struct tveeprom { char rev_str[5]; }; -void tveeprom_hauppauge_analog(struct tveeprom *tvee, +void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, unsigned char *eeprom_data); int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len); -- cgit v0.10.2 From 8b6490e5faafb3a16ea45654fb55f9ff086f1495 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:07 -0700 Subject: [PATCH] files: fix rcu initializers First of a number of files_lock scaability patches. Here are the x86 numbers - tiobench on a 4(8)-way (HT) P4 system on ramdisk : (lockfree) Test 2.6.10-vanilla Stdev 2.6.10-fd Stdev ------------------------------------------------------------- Seqread 1400.8 11.52 1465.4 34.27 Randread 1594 8.86 2397.2 29.21 Seqwrite 242.72 3.47 238.46 6.53 Randwrite 445.74 9.15 446.4 9.75 The performance improvement is very significant. We are getting killed by the cacheline bouncing of the files_struct lock here. Writes on ramdisk (ext2) seems to vary just too much to get any meaningful number. Also, With Tridge's thread_perf test on a 4(8)-way (HT) P4 xeon system : 2.6.12-rc5-vanilla : Running test 'readwrite' with 8 tasks Threads 0.34 +/- 0.01 seconds Processes 0.16 +/- 0.00 seconds 2.6.12-rc5-fd : Running test 'readwrite' with 8 tasks Threads 0.17 +/- 0.02 seconds Processes 0.17 +/- 0.02 seconds I repeated the measurements on ramfs (as opposed to ext2 on ramdisk in the earlier measurement) and I got more consistent results from tiobench : 4(8) way xeon P4 ----------------- (lock-free) Test 2.6.12-rc5 Stdev 2.6.12-rc5-fd Stdev ------------------------------------------------------------- Seqread 1282 18.59 1343.6 26.37 Randread 1517 7 2415 34.27 Seqwrite 702.2 5.27 709.46 5.9 Randwrite 846.86 15.15 919.68 21.4 4-way ppc64 ------------ (lock-free) Test 2.6.12-rc5 Stdev 2.6.12-rc5-fd Stdev ------------------------------------------------------------- Seqread 1549 91.16 1569.6 47.2 Randread 1473.6 25.11 1585.4 69.99 Seqwrite 1096.8 20.03 1136 29.61 Randwrite 1189.6 4.04 1275.2 32.96 Also running Tridge's thread_perf test on ppc64 : 2.6.12-rc5-vanilla -------------------- Running test 'readwrite' with 4 tasks Threads 0.20 +/- 0.02 seconds Processes 0.16 +/- 0.01 seconds 2.6.12-rc5-fd -------------------- Running test 'readwrite' with 4 tasks Threads 0.18 +/- 0.04 seconds Processes 0.16 +/- 0.01 seconds The benefits are huge (upto ~60%) in some cases on x86 primarily due to the atomic operations during acquisition of ->file_lock and cache line bouncing in fast path. ppc64 benefits are modest due to LL/SC based locking, but still statistically significant. This patch: RCU head initilizer no longer needs the head varible name since we don't use list.h lists anymore. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index fd276ad..4e65eb4 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -52,8 +52,8 @@ struct rcu_head { void (*func)(struct rcu_head *head); }; -#define RCU_HEAD_INIT(head) { .next = NULL, .func = NULL } -#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT(head) +#define RCU_HEAD_INIT { .next = NULL, .func = NULL } +#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT #define INIT_RCU_HEAD(ptr) do { \ (ptr)->next = NULL; (ptr)->func = NULL; \ } while (0) -- cgit v0.10.2 From c0dfb2905126e9e94edebbce8d3e05001301f52d Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:09 -0700 Subject: [PATCH] files: rcuref APIs Adds a set of primitives to do reference counting for objects that are looked up without locks using RCU. Signed-off-by: Ravikiran Thirumalai Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/RCU/rcuref.txt b/Documentation/RCU/rcuref.txt new file mode 100644 index 0000000..a23fee6 --- /dev/null +++ b/Documentation/RCU/rcuref.txt @@ -0,0 +1,74 @@ +Refcounter framework for elements of lists/arrays protected by +RCU. + +Refcounting on elements of lists which are protected by traditional +reader/writer spinlocks or semaphores are straight forward as in: + +1. 2. +add() search_and_reference() +{ { + alloc_object read_lock(&list_lock); + ... search_for_element + atomic_set(&el->rc, 1); atomic_inc(&el->rc); + write_lock(&list_lock); ... + add_element read_unlock(&list_lock); + ... ... + write_unlock(&list_lock); } +} + +3. 4. +release_referenced() delete() +{ { + ... write_lock(&list_lock); + atomic_dec(&el->rc, relfunc) ... + ... delete_element +} write_unlock(&list_lock); + ... + if (atomic_dec_and_test(&el->rc)) + kfree(el); + ... + } + +If this list/array is made lock free using rcu as in changing the +write_lock in add() and delete() to spin_lock and changing read_lock +in search_and_reference to rcu_read_lock(), the rcuref_get in +search_and_reference could potentially hold reference to an element which +has already been deleted from the list/array. rcuref_lf_get_rcu takes +care of this scenario. search_and_reference should look as; + +1. 2. +add() search_and_reference() +{ { + alloc_object rcu_read_lock(); + ... search_for_element + atomic_set(&el->rc, 1); if (rcuref_inc_lf(&el->rc)) { + write_lock(&list_lock); rcu_read_unlock(); + return FAIL; + add_element } + ... ... + write_unlock(&list_lock); rcu_read_unlock(); +} } +3. 4. +release_referenced() delete() +{ { + ... write_lock(&list_lock); + rcuref_dec(&el->rc, relfunc) ... + ... delete_element +} write_unlock(&list_lock); + ... + if (rcuref_dec_and_test(&el->rc)) + call_rcu(&el->head, el_free); + ... + } + +Sometimes, reference to the element need to be obtained in the +update (write) stream. In such cases, rcuref_inc_lf might be an overkill +since the spinlock serialising list updates are held. rcuref_inc +is to be used in such cases. +For arches which do not have cmpxchg rcuref_inc_lf +api uses a hashed spinlock implementation and the same hashed spinlock +is acquired in all rcuref_xxx primitives to preserve atomicity. +Note: Use rcuref_inc api only if you need to use rcuref_inc_lf on the +refcounter atleast at one place. Mixing rcuref_inc and atomic_xxx api +might lead to races. rcuref_inc_lf() must be used in lockfree +RCU critical sections only. diff --git a/include/linux/rcuref.h b/include/linux/rcuref.h new file mode 100644 index 0000000..e1adbba --- /dev/null +++ b/include/linux/rcuref.h @@ -0,0 +1,220 @@ +/* + * rcuref.h + * + * Reference counting for elements of lists/arrays protected by + * RCU. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) IBM Corporation, 2005 + * + * Author: Dipankar Sarma + * Ravikiran Thirumalai + * + * See Documentation/RCU/rcuref.txt for detailed user guide. + * + */ + +#ifndef _RCUREF_H_ +#define _RCUREF_H_ + +#ifdef __KERNEL__ + +#include +#include +#include +#include + +/* + * These APIs work on traditional atomic_t counters used in the + * kernel for reference counting. Under special circumstances + * where a lock-free get() operation races with a put() operation + * these APIs can be used. See Documentation/RCU/rcuref.txt. + */ + +#ifdef __HAVE_ARCH_CMPXCHG + +/** + * rcuref_inc - increment refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline void rcuref_inc(atomic_t *rcuref) +{ + atomic_inc(rcuref); +} + +/** + * rcuref_dec - decrement refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline void rcuref_dec(atomic_t *rcuref) +{ + atomic_dec(rcuref); +} + +/** + * rcuref_dec_and_test - decrement refcount for object and test + * @rcuref: reference counter in the object. + * @release: pointer to the function that will clean up the object + * when the last reference to the object is released. + * This pointer is required. + * + * Decrement the refcount, and if 0, return 1. Else return 0. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference + * in a lock-free reader-side critical section. + */ +static inline int rcuref_dec_and_test(atomic_t *rcuref) +{ + return atomic_dec_and_test(rcuref); +} + +/* + * cmpxchg is needed on UP too, if deletions to the list/array can happen + * in interrupt context. + */ + +/** + * rcuref_inc_lf - Take reference to an object in a read-side + * critical section protected by RCU. + * @rcuref: reference counter in the object in question. + * + * Try and increment the refcount by 1. The increment might fail if + * the reference counter has been through a 1 to 0 transition and + * is no longer part of the lock-free list. + * Returns non-zero on successful increment and zero otherwise. + */ +static inline int rcuref_inc_lf(atomic_t *rcuref) +{ + int c, old; + c = atomic_read(rcuref); + while (c && (old = cmpxchg(&rcuref->counter, c, c + 1)) != c) + c = old; + return c; +} + +#else /* !__HAVE_ARCH_CMPXCHG */ + +extern spinlock_t __rcuref_hash[]; + +/* + * Use a hash table of locks to protect the reference count + * since cmpxchg is not available in this arch. + */ +#ifdef CONFIG_SMP +#define RCUREF_HASH_SIZE 4 +#define RCUREF_HASH(k) \ + (&__rcuref_hash[(((unsigned long)k)>>8) & (RCUREF_HASH_SIZE-1)]) +#else +#define RCUREF_HASH_SIZE 1 +#define RCUREF_HASH(k) &__rcuref_hash[0] +#endif /* CONFIG_SMP */ + +/** + * rcuref_inc - increment refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline void rcuref_inc(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter += 1; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); +} + +/** + * rcuref_dec - decrement refcount for object. + * @rcuref: reference counter in the object in question. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline void rcuref_dec(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter -= 1; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); +} + +/** + * rcuref_dec_and_test - decrement refcount for object and test + * @rcuref: reference counter in the object. + * @release: pointer to the function that will clean up the object + * when the last reference to the object is released. + * This pointer is required. + * + * Decrement the refcount, and if 0, return 1. Else return 0. + * + * This should be used only for objects where we use RCU and + * use the rcuref_inc_lf() api to acquire a reference in a lock-free + * reader-side critical section. + */ +static inline int rcuref_dec_and_test(atomic_t *rcuref) +{ + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + rcuref->counter--; + if (!rcuref->counter) { + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return 1; + } else { + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return 0; + } +} + +/** + * rcuref_inc_lf - Take reference to an object of a lock-free collection + * by traversing a lock-free list/array. + * @rcuref: reference counter in the object in question. + * + * Try and increment the refcount by 1. The increment might fail if + * the reference counter has been through a 1 to 0 transition and + * object is no longer part of the lock-free list. + * Returns non-zero on successful increment and zero otherwise. + */ +static inline int rcuref_inc_lf(atomic_t *rcuref) +{ + int ret; + unsigned long flags; + spin_lock_irqsave(RCUREF_HASH(rcuref), flags); + if (rcuref->counter) + ret = rcuref->counter++; + else + ret = 0; + spin_unlock_irqrestore(RCUREF_HASH(rcuref), flags); + return ret; +} + + +#endif /* !__HAVE_ARCH_CMPXCHG */ + +#endif /* __KERNEL__ */ +#endif /* _RCUREF_H_ */ diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index f436993..bef3b69 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c @@ -45,6 +45,7 @@ #include #include #include +#include #include /* Definition for rcupdate control block. */ @@ -72,6 +73,19 @@ DEFINE_PER_CPU(struct rcu_data, rcu_bh_data) = { 0L }; static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL}; static int maxbatch = 10; +#ifndef __HAVE_ARCH_CMPXCHG +/* + * We use an array of spinlocks for the rcurefs -- similar to ones in sparc + * 32 bit atomic_t implementations, and a hash function similar to that + * for our refcounting needs. + * Can't help multiprocessors which donot have cmpxchg :( + */ + +spinlock_t __rcuref_hash[RCUREF_HASH_SIZE] = { + [0 ... (RCUREF_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED +}; +#endif + /** * call_rcu - Queue an RCU callback for invocation after a grace period. * @head: structure to be used for queueing the RCU updates. -- cgit v0.10.2 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 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 167fd89f..2b03418 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -974,6 +974,7 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, size_t size; long timeout; int ret = -EINVAL; + struct fdtable *fdt; timeout = MAX_SCHEDULE_TIMEOUT; if (tvp) { @@ -995,7 +996,8 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, } } - if (n < 0 || n > current->files->max_fdset) + fdt = files_fdtable(current->files); + if (n < 0 || n > fdt->max_fdset) goto out_nofds; /* diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index f1201ac..4ad97b3 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -2217,15 +2218,17 @@ static void pfm_free_fd(int fd, struct file *file) { struct files_struct *files = current->files; + struct fdtable *fdt = files_fdtable(files); /* * there ie no fd_uninstall(), so we do it here */ spin_lock(&files->file_lock); - files->fd[fd] = NULL; + rcu_assign_pointer(fdt->fd[fd], NULL); spin_unlock(&files->file_lock); - if (file) put_filp(file); + if (file) + put_filp(file); put_unused_fd(fd); } diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index cac0a1c..3747664 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c @@ -293,11 +293,13 @@ static struct module_info { static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) { struct inode *ino; + struct fdtable *fdt; /* I wonder which of these tests are superfluous... --patrik */ spin_lock(¤t->files->file_lock); - if (! current->files->fd[fd] || - ! current->files->fd[fd]->f_dentry || - ! (ino = current->files->fd[fd]->f_dentry->d_inode) || + fdt = files_fdtable(current->files); + if (! fdt->fd[fd] || + ! fdt->fd[fd]->f_dentry || + ! (ino = fdt->fd[fd]->f_dentry->d_inode) || ! S_ISSOCK(ino->i_mode)) { spin_unlock(¤t->files->file_lock); return TBADF; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 6a56ae4..0bfc7af 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; diff --git a/fs/exec.c b/fs/exec.c index 222ab1c..14dd039 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -798,6 +798,7 @@ no_thread_group: static inline void flush_old_files(struct files_struct * files) { long j = -1; + struct fdtable *fdt; spin_lock(&files->file_lock); for (;;) { @@ -805,12 +806,13 @@ static inline void flush_old_files(struct files_struct * files) j++; i = j * __NFDBITS; - if (i >= files->max_fds || i >= files->max_fdset) + fdt = files_fdtable(files); + if (i >= fdt->max_fds || i >= fdt->max_fdset) break; - set = files->close_on_exec->fds_bits[j]; + set = fdt->close_on_exec->fds_bits[j]; if (!set) continue; - files->close_on_exec->fds_bits[j] = 0; + fdt->close_on_exec->fds_bits[j] = 0; spin_unlock(&files->file_lock); for ( ; set ; i++,set >>= 1) { if (set & 1) { diff --git a/fs/fcntl.c b/fs/fcntl.c index 6fbc9d8..bfecc62 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -24,20 +24,24 @@ void fastcall set_close_on_exec(unsigned int fd, int flag) { struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); + fdt = files_fdtable(files); if (flag) - FD_SET(fd, files->close_on_exec); + FD_SET(fd, fdt->close_on_exec); else - FD_CLR(fd, files->close_on_exec); + FD_CLR(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); } static inline int get_close_on_exec(unsigned int fd) { struct files_struct *files = current->files; + struct fdtable *fdt; int res; spin_lock(&files->file_lock); - res = FD_ISSET(fd, files->close_on_exec); + fdt = files_fdtable(files); + res = FD_ISSET(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); return res; } @@ -54,24 +58,26 @@ static int locate_fd(struct files_struct *files, unsigned int newfd; unsigned int start; int error; + struct fdtable *fdt; error = -EINVAL; if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; + fdt = files_fdtable(files); repeat: /* * Someone might have closed fd's in the range - * orig_start..files->next_fd + * orig_start..fdt->next_fd */ start = orig_start; - if (start < files->next_fd) - start = files->next_fd; + if (start < fdt->next_fd) + start = fdt->next_fd; newfd = start; - if (start < files->max_fdset) { - newfd = find_next_zero_bit(files->open_fds->fds_bits, - files->max_fdset, start); + if (start < fdt->max_fdset) { + newfd = find_next_zero_bit(fdt->open_fds->fds_bits, + fdt->max_fdset, start); } error = -EMFILE; @@ -89,8 +95,8 @@ repeat: if (error) goto repeat; - if (start <= files->next_fd) - files->next_fd = newfd + 1; + if (start <= fdt->next_fd) + fdt->next_fd = newfd + 1; error = newfd; @@ -101,13 +107,16 @@ out: static int dupfd(struct file *file, unsigned int start) { struct files_struct * files = current->files; + struct fdtable *fdt; int fd; spin_lock(&files->file_lock); fd = locate_fd(files, file, start); if (fd >= 0) { - FD_SET(fd, files->open_fds); - FD_CLR(fd, files->close_on_exec); + /* locate_fd() may have expanded fdtable, load the ptr */ + fdt = files_fdtable(files); + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); fd_install(fd, file); } else { @@ -123,6 +132,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) int err = -EBADF; struct file * file, *tofree; struct files_struct * files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); if (!(file = fcheck(oldfd))) @@ -148,13 +158,14 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) /* Yes. It's a race. In user space. Nothing sane to do */ err = -EBUSY; - tofree = files->fd[newfd]; - if (!tofree && FD_ISSET(newfd, files->open_fds)) + fdt = files_fdtable(files); + tofree = fdt->fd[newfd]; + if (!tofree && FD_ISSET(newfd, fdt->open_fds)) goto out_fput; - files->fd[newfd] = file; - FD_SET(newfd, files->open_fds); - FD_CLR(newfd, files->close_on_exec); + fdt->fd[newfd] = file; + FD_SET(newfd, fdt->open_fds); + FD_CLR(newfd, fdt->close_on_exec); spin_unlock(&files->file_lock); if (tofree) diff --git a/fs/file.c b/fs/file.c index 92b5f25..f5926ce 100644 --- a/fs/file.c +++ b/fs/file.c @@ -59,13 +59,15 @@ static int expand_fd_array(struct files_struct *files, int nr) { struct file **new_fds; int error, nfds; + struct fdtable *fdt; error = -EMFILE; - if (files->max_fds >= NR_OPEN || nr >= NR_OPEN) + fdt = files_fdtable(files); + if (fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) goto out; - nfds = files->max_fds; + nfds = fdt->max_fds; spin_unlock(&files->file_lock); /* @@ -95,13 +97,14 @@ static int expand_fd_array(struct files_struct *files, int nr) goto out; /* Copy the existing array and install the new pointer */ + fdt = files_fdtable(files); - if (nfds > files->max_fds) { + if (nfds > fdt->max_fds) { struct file **old_fds; int i; - old_fds = xchg(&files->fd, new_fds); - i = xchg(&files->max_fds, nfds); + old_fds = xchg(&fdt->fd, new_fds); + i = xchg(&fdt->max_fds, nfds); /* Don't copy/clear the array if we are creating a new fd array for fork() */ @@ -164,12 +167,14 @@ static int expand_fdset(struct files_struct *files, int nr) { fd_set *new_openset = NULL, *new_execset = NULL; int error, nfds = 0; + struct fdtable *fdt; error = -EMFILE; - if (files->max_fdset >= NR_OPEN || nr >= NR_OPEN) + fdt = files_fdtable(files); + if (fdt->max_fdset >= NR_OPEN || nr >= NR_OPEN) goto out; - nfds = files->max_fdset; + nfds = fdt->max_fdset; spin_unlock(&files->file_lock); /* Expand to the max in easy steps */ @@ -193,24 +198,25 @@ static int expand_fdset(struct files_struct *files, int nr) error = 0; /* Copy the existing tables and install the new pointers */ - if (nfds > files->max_fdset) { - int i = files->max_fdset / (sizeof(unsigned long) * 8); - int count = (nfds - files->max_fdset) / 8; + fdt = files_fdtable(files); + if (nfds > fdt->max_fdset) { + int i = fdt->max_fdset / (sizeof(unsigned long) * 8); + int count = (nfds - fdt->max_fdset) / 8; /* * Don't copy the entire array if the current fdset is * not yet initialised. */ if (i) { - memcpy (new_openset, files->open_fds, files->max_fdset/8); - memcpy (new_execset, files->close_on_exec, files->max_fdset/8); + memcpy (new_openset, fdt->open_fds, fdt->max_fdset/8); + memcpy (new_execset, fdt->close_on_exec, fdt->max_fdset/8); memset (&new_openset->fds_bits[i], 0, count); memset (&new_execset->fds_bits[i], 0, count); } - nfds = xchg(&files->max_fdset, nfds); - new_openset = xchg(&files->open_fds, new_openset); - new_execset = xchg(&files->close_on_exec, new_execset); + nfds = xchg(&fdt->max_fdset, nfds); + new_openset = xchg(&fdt->open_fds, new_openset); + new_execset = xchg(&fdt->close_on_exec, new_execset); spin_unlock(&files->file_lock); free_fdset (new_openset, nfds); free_fdset (new_execset, nfds); @@ -237,13 +243,15 @@ out: int expand_files(struct files_struct *files, int nr) { int err, expand = 0; + struct fdtable *fdt; - if (nr >= files->max_fdset) { + fdt = files_fdtable(files); + if (nr >= fdt->max_fdset) { expand = 1; if ((err = expand_fdset(files, nr))) goto out; } - if (nr >= files->max_fds) { + if (nr >= fdt->max_fds) { expand = 1; if ((err = expand_fd_array(files, nr))) goto out; diff --git a/fs/locks.c b/fs/locks.c index 11956b6..c2c09b4 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2198,21 +2198,23 @@ void steal_locks(fl_owner_t from) { struct files_struct *files = current->files; int i, j; + struct fdtable *fdt; if (from == files) return; lock_kernel(); j = 0; + fdt = files_fdtable(files); for (;;) { unsigned long set; i = j * __NFDBITS; - if (i >= files->max_fdset || i >= files->max_fds) + if (i >= fdt->max_fdset || i >= fdt->max_fds) break; - set = files->open_fds->fds_bits[j++]; + set = fdt->open_fds->fds_bits[j++]; while (set) { if (set & 1) { - struct file *file = files->fd[i]; + struct file *file = fdt->fd[i]; if (file) __steal_locks(file, from); } diff --git a/fs/open.c b/fs/open.c index 4ee2dcc..b654251 100644 --- a/fs/open.c +++ b/fs/open.c @@ -842,14 +842,16 @@ int get_unused_fd(void) { struct files_struct * files = current->files; int fd, error; + struct fdtable *fdt; error = -EMFILE; spin_lock(&files->file_lock); repeat: - fd = find_next_zero_bit(files->open_fds->fds_bits, - files->max_fdset, - files->next_fd); + fdt = files_fdtable(files); + fd = find_next_zero_bit(fdt->open_fds->fds_bits, + fdt->max_fdset, + fdt->next_fd); /* * N.B. For clone tasks sharing a files structure, this test @@ -872,14 +874,14 @@ repeat: goto repeat; } - FD_SET(fd, files->open_fds); - FD_CLR(fd, files->close_on_exec); - files->next_fd = fd + 1; + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); + fdt->next_fd = fd + 1; #if 1 /* Sanity check */ - if (files->fd[fd] != NULL) { + if (fdt->fd[fd] != NULL) { printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd); - files->fd[fd] = NULL; + fdt->fd[fd] = NULL; } #endif error = fd; @@ -893,9 +895,10 @@ EXPORT_SYMBOL(get_unused_fd); static inline void __put_unused_fd(struct files_struct *files, unsigned int fd) { - __FD_CLR(fd, files->open_fds); - if (fd < files->next_fd) - files->next_fd = fd; + struct fdtable *fdt = files_fdtable(files); + __FD_CLR(fd, fdt->open_fds); + if (fd < fdt->next_fd) + fdt->next_fd = fd; } void fastcall put_unused_fd(unsigned int fd) @@ -924,10 +927,12 @@ EXPORT_SYMBOL(put_unused_fd); void fastcall fd_install(unsigned int fd, struct file * file) { struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); - if (unlikely(files->fd[fd] != NULL)) + fdt = files_fdtable(files); + if (unlikely(fdt->fd[fd] != NULL)) BUG(); - files->fd[fd] = file; + fdt->fd[fd] = file; spin_unlock(&files->file_lock); } @@ -1010,15 +1015,17 @@ asmlinkage long sys_close(unsigned int fd) { struct file * filp; struct files_struct *files = current->files; + struct fdtable *fdt; spin_lock(&files->file_lock); - if (fd >= files->max_fds) + fdt = files_fdtable(files); + if (fd >= fdt->max_fds) goto out_unlock; - filp = files->fd[fd]; + filp = fdt->fd[fd]; if (!filp) goto out_unlock; - files->fd[fd] = NULL; - FD_CLR(fd, files->close_on_exec); + fdt->fd[fd] = NULL; + FD_CLR(fd, fdt->close_on_exec); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); return filp_close(filp, files); diff --git a/fs/proc/array.c b/fs/proc/array.c index 37668fe..d88d518 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -159,6 +159,7 @@ static inline char * task_state(struct task_struct *p, char *buffer) { struct group_info *group_info; int g; + struct fdtable *fdt = NULL; read_lock(&tasklist_lock); buffer += sprintf(buffer, @@ -179,10 +180,12 @@ static inline char * task_state(struct task_struct *p, char *buffer) p->gid, p->egid, p->sgid, p->fsgid); read_unlock(&tasklist_lock); task_lock(p); + if (p->files) + fdt = files_fdtable(p->files); buffer += sprintf(buffer, "FDSize:\t%d\n" "Groups:\t", - p->files ? p->files->max_fds : 0); + fdt ? fdt->max_fds : 0); group_info = p->group_info; get_group_info(group_info); diff --git a/fs/proc/base.c b/fs/proc/base.c index 84751f3..d0087a0 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1039,6 +1039,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) int retval; char buf[NUMBUF]; struct files_struct * files; + struct fdtable *fdt; retval = -ENOENT; if (!pid_alive(p)) @@ -1062,8 +1063,9 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) if (!files) goto out; spin_lock(&files->file_lock); + fdt = files_fdtable(files); for (fd = filp->f_pos-2; - fd < files->max_fds; + fd < fdt->max_fds; fd++, filp->f_pos++) { unsigned int i,j; diff --git a/fs/select.c b/fs/select.c index b80e7eb..2e56325 100644 --- a/fs/select.c +++ b/fs/select.c @@ -132,11 +132,13 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds) unsigned long *open_fds; unsigned long set; int max; + struct fdtable *fdt; /* handle last in-complete long-word first */ set = ~(~0UL << (n & (__NFDBITS-1))); n /= __NFDBITS; - open_fds = current->files->open_fds->fds_bits+n; + fdt = files_fdtable(current->files); + open_fds = fdt->open_fds->fds_bits+n; max = 0; if (set) { set &= BITS(fds, n); @@ -299,6 +301,7 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s char *bits; long timeout; int ret, size, max_fdset; + struct fdtable *fdt; timeout = MAX_SCHEDULE_TIMEOUT; if (tvp) { @@ -326,7 +329,8 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s goto out_nofds; /* max_fdset can increase, so grab it once to avoid race */ - max_fdset = current->files->max_fdset; + fdt = files_fdtable(current->files); + max_fdset = fdt->max_fdset; if (n > max_fdset) n = max_fdset; @@ -464,9 +468,11 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti unsigned int i; struct poll_list *head; struct poll_list *walk; + struct fdtable *fdt; /* Do a sanity check on nfds ... */ - if (nfds > current->files->max_fdset && nfds > OPEN_MAX) + fdt = files_fdtable(current->files); + if (nfds > fdt->max_fdset && nfds > OPEN_MAX) return -EINVAL; if (timeout) { diff --git a/include/linux/file.h b/include/linux/file.h index 5206beb..db37223 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -16,23 +16,29 @@ */ #define NR_OPEN_DEFAULT BITS_PER_LONG +struct fdtable { + unsigned int max_fds; + int max_fdset; + int next_fd; + struct file ** fd; /* current fd array */ + fd_set *close_on_exec; + fd_set *open_fds; +}; + /* * Open file table structure */ struct files_struct { atomic_t count; spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ - int max_fds; - int max_fdset; - int next_fd; - struct file ** fd; /* current fd array */ - fd_set *close_on_exec; - fd_set *open_fds; + struct fdtable fdtab; fd_set close_on_exec_init; fd_set open_fds_init; struct file * fd_array[NR_OPEN_DEFAULT]; }; +#define files_fdtable(files) (&(files)->fdtab) + extern void FASTCALL(__fput(struct file *)); extern void FASTCALL(fput(struct file *)); @@ -63,9 +69,10 @@ extern int expand_files(struct files_struct *, int nr); static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) { struct file * file = NULL; + struct fdtable *fdt = files_fdtable(files); - if (fd < files->max_fds) - file = files->fd[fd]; + if (fd < fdt->max_fds) + file = fdt->fd[fd]; return file; } diff --git a/include/linux/init_task.h b/include/linux/init_task.h index c727c195..94aefa5 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -3,16 +3,21 @@ #include -#define INIT_FILES \ -{ \ - .count = ATOMIC_INIT(1), \ - .file_lock = SPIN_LOCK_UNLOCKED, \ +#define INIT_FDTABLE \ +{ \ .max_fds = NR_OPEN_DEFAULT, \ .max_fdset = __FD_SETSIZE, \ .next_fd = 0, \ .fd = &init_files.fd_array[0], \ .close_on_exec = &init_files.close_on_exec_init, \ .open_fds = &init_files.open_fds_init, \ +} + +#define INIT_FILES \ +{ \ + .count = ATOMIC_INIT(1), \ + .file_lock = SPIN_LOCK_UNLOCKED, \ + .fdtab = INIT_FDTABLE, \ .close_on_exec_init = { { 0, } }, \ .open_fds_init = { { 0, } }, \ .fd_array = { NULL, } \ diff --git a/kernel/exit.c b/kernel/exit.c index 5b0fb9f..83beb1e 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -368,17 +368,19 @@ EXPORT_SYMBOL(daemonize); static inline void close_files(struct files_struct * files) { int i, j; + struct fdtable *fdt; j = 0; + fdt = files_fdtable(files); for (;;) { unsigned long set; i = j * __NFDBITS; - if (i >= files->max_fdset || i >= files->max_fds) + if (i >= fdt->max_fdset || i >= fdt->max_fds) break; - set = files->open_fds->fds_bits[j++]; + set = fdt->open_fds->fds_bits[j++]; while (set) { if (set & 1) { - struct file * file = xchg(&files->fd[i], NULL); + struct file * file = xchg(&fdt->fd[i], NULL); if (file) filp_close(file, files); } @@ -403,16 +405,19 @@ struct files_struct *get_files_struct(struct task_struct *task) void fastcall put_files_struct(struct files_struct *files) { + struct fdtable *fdt; + if (atomic_dec_and_test(&files->count)) { close_files(files); /* * Free the fd and fdset arrays if we expanded them. */ - if (files->fd != &files->fd_array[0]) - free_fd_array(files->fd, files->max_fds); - if (files->max_fdset > __FD_SETSIZE) { - free_fdset(files->open_fds, files->max_fdset); - free_fdset(files->close_on_exec, files->max_fdset); + fdt = files_fdtable(files); + if (fdt->fd != &files->fd_array[0]) + free_fd_array(fdt->fd, fdt->max_fds); + if (fdt->max_fdset > __FD_SETSIZE) { + free_fdset(fdt->open_fds, fdt->max_fdset); + free_fdset(fdt->close_on_exec, fdt->max_fdset); } kmem_cache_free(files_cachep, files); } diff --git a/kernel/fork.c b/kernel/fork.c index b258020..ecc694d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -568,21 +568,47 @@ static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk) static int count_open_files(struct files_struct *files, int size) { int i; + struct fdtable *fdt; /* Find the last open fd */ + fdt = files_fdtable(files); for (i = size/(8*sizeof(long)); i > 0; ) { - if (files->open_fds->fds_bits[--i]) + if (fdt->open_fds->fds_bits[--i]) break; } i = (i+1) * 8 * sizeof(long); return i; } +static struct files_struct *alloc_files(void) +{ + struct files_struct *newf; + struct fdtable *fdt; + + newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); + if (!newf) + goto out; + + atomic_set(&newf->count, 1); + + spin_lock_init(&newf->file_lock); + fdt = files_fdtable(newf); + fdt->next_fd = 0; + fdt->max_fds = NR_OPEN_DEFAULT; + fdt->max_fdset = __FD_SETSIZE; + fdt->close_on_exec = &newf->close_on_exec_init; + fdt->open_fds = &newf->open_fds_init; + fdt->fd = &newf->fd_array[0]; +out: + return newf; +} + static int copy_files(unsigned long clone_flags, struct task_struct * tsk) { struct files_struct *oldf, *newf; struct file **old_fds, **new_fds; int open_files, size, i, error = 0, expand; + struct fdtable *old_fdt, *new_fdt; /* * A background process may not have any files ... @@ -603,35 +629,27 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) */ tsk->files = NULL; error = -ENOMEM; - newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); - if (!newf) + newf = alloc_files(); + if (!newf) goto out; - atomic_set(&newf->count, 1); - - spin_lock_init(&newf->file_lock); - newf->next_fd = 0; - newf->max_fds = NR_OPEN_DEFAULT; - newf->max_fdset = __FD_SETSIZE; - newf->close_on_exec = &newf->close_on_exec_init; - newf->open_fds = &newf->open_fds_init; - newf->fd = &newf->fd_array[0]; - spin_lock(&oldf->file_lock); - - open_files = count_open_files(oldf, oldf->max_fdset); + old_fdt = files_fdtable(oldf); + new_fdt = files_fdtable(newf); + size = old_fdt->max_fdset; + open_files = count_open_files(oldf, old_fdt->max_fdset); expand = 0; /* * Check whether we need to allocate a larger fd array or fd set. * Note: we're not a clone task, so the open count won't change. */ - if (open_files > newf->max_fdset) { - newf->max_fdset = 0; + if (open_files > new_fdt->max_fdset) { + new_fdt->max_fdset = 0; expand = 1; } - if (open_files > newf->max_fds) { - newf->max_fds = 0; + if (open_files > new_fdt->max_fds) { + new_fdt->max_fds = 0; expand = 1; } @@ -646,11 +664,11 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) spin_lock(&oldf->file_lock); } - old_fds = oldf->fd; - new_fds = newf->fd; + old_fds = old_fdt->fd; + new_fds = new_fdt->fd; - memcpy(newf->open_fds->fds_bits, oldf->open_fds->fds_bits, open_files/8); - memcpy(newf->close_on_exec->fds_bits, oldf->close_on_exec->fds_bits, open_files/8); + memcpy(new_fdt->open_fds->fds_bits, old_fdt->open_fds->fds_bits, open_files/8); + memcpy(new_fdt->close_on_exec->fds_bits, old_fdt->close_on_exec->fds_bits, open_files/8); for (i = open_files; i != 0; i--) { struct file *f = *old_fds++; @@ -663,24 +681,24 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) * is partway through open(). So make sure that this * fd is available to the new process. */ - FD_CLR(open_files - i, newf->open_fds); + FD_CLR(open_files - i, new_fdt->open_fds); } *new_fds++ = f; } spin_unlock(&oldf->file_lock); /* compute the remainder to be cleared */ - size = (newf->max_fds - open_files) * sizeof(struct file *); + size = (new_fdt->max_fds - open_files) * sizeof(struct file *); /* This is long word aligned thus could use a optimized version */ memset(new_fds, 0, size); - if (newf->max_fdset > open_files) { - int left = (newf->max_fdset-open_files)/8; + if (new_fdt->max_fdset > open_files) { + int left = (new_fdt->max_fdset-open_files)/8; int start = open_files / (8 * sizeof(unsigned long)); - memset(&newf->open_fds->fds_bits[start], 0, left); - memset(&newf->close_on_exec->fds_bits[start], 0, left); + memset(&new_fdt->open_fds->fds_bits[start], 0, left); + memset(&new_fdt->close_on_exec->fds_bits[start], 0, left); } tsk->files = newf; @@ -689,9 +707,9 @@ out: return error; out_release: - free_fdset (newf->close_on_exec, newf->max_fdset); - free_fdset (newf->open_fds, newf->max_fdset); - free_fd_array(newf->fd, newf->max_fds); + free_fdset (new_fdt->close_on_exec, new_fdt->max_fdset); + free_fdset (new_fdt->open_fds, new_fdt->max_fdset); + free_fd_array(new_fdt->fd, new_fdt->max_fds); kmem_cache_free(files_cachep, newf); goto out; } diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3f0b533..acb5a49 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1594,6 +1594,7 @@ static inline void flush_unauthorized_files(struct files_struct * files) struct avc_audit_data ad; struct file *file, *devnull = NULL; struct tty_struct *tty = current->signal->tty; + struct fdtable *fdt; long j = -1; if (tty) { @@ -1627,9 +1628,10 @@ static inline void flush_unauthorized_files(struct files_struct * files) j++; i = j * __NFDBITS; - if (i >= files->max_fds || i >= files->max_fdset) + fdt = files_fdtable(files); + if (i >= fdt->max_fds || i >= fdt->max_fdset) break; - set = files->open_fds->fds_bits[j]; + set = fdt->open_fds->fds_bits[j]; if (!set) continue; spin_unlock(&files->file_lock); -- cgit v0.10.2 From 6e72ad2c581de121cc7e772469e2a8f6b1fd4379 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:12 -0700 Subject: [PATCH] files-sparc64-fix 2 Fix sparc64 timod to use the new files_fdtable() api to get the fd table. This is necessary for RCUification. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c index 022c80f..aaad29c 100644 --- a/arch/sparc64/solaris/timod.c +++ b/arch/sparc64/solaris/timod.c @@ -143,9 +143,11 @@ static struct T_primsg *timod_mkctl(int size) static void timod_wake_socket(unsigned int fd) { struct socket *sock; + struct fdtable *fdt; SOLD("wakeing socket"); - sock = SOCKET_I(current->files->fd[fd]->f_dentry->d_inode); + fdt = files_fdtable(current->files); + sock = SOCKET_I(fdt->fd[fd]->f_dentry->d_inode); wake_up_interruptible(&sock->wait); read_lock(&sock->sk->sk_callback_lock); if (sock->fasync_list && !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags)) @@ -157,9 +159,11 @@ static void timod_wake_socket(unsigned int fd) static void timod_queue(unsigned int fd, struct T_primsg *it) { struct sol_socket_struct *sock; + struct fdtable *fdt; SOLD("queuing primsg"); - sock = (struct sol_socket_struct *)current->files->fd[fd]->private_data; + fdt = files_fdtable(current->files); + sock = (struct sol_socket_struct *)fdt->fd[fd]->private_data; it->next = sock->pfirst; sock->pfirst = it; if (!sock->plast) @@ -171,9 +175,11 @@ static void timod_queue(unsigned int fd, struct T_primsg *it) static void timod_queue_end(unsigned int fd, struct T_primsg *it) { struct sol_socket_struct *sock; + struct fdtable *fdt; SOLD("queuing primsg at end"); - sock = (struct sol_socket_struct *)current->files->fd[fd]->private_data; + fdt = files_fdtable(current->files); + sock = (struct sol_socket_struct *)fdt->fd[fd]->private_data; it->next = NULL; if (sock->plast) sock->plast->next = it; @@ -344,6 +350,7 @@ int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len, char *buf; struct file *filp; struct inode *ino; + struct fdtable *fdt; struct sol_socket_struct *sock; mm_segment_t old_fs = get_fs(); long args[6]; @@ -351,7 +358,9 @@ int timod_putmsg(unsigned int fd, char __user *ctl_buf, int ctl_len, (int (*)(int, unsigned long __user *))SYS(socketcall); int (*sys_sendto)(int, void __user *, size_t, unsigned, struct sockaddr __user *, int) = (int (*)(int, void __user *, size_t, unsigned, struct sockaddr __user *, int))SYS(sendto); - filp = current->files->fd[fd]; + + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; ino = filp->f_dentry->d_inode; sock = (struct sol_socket_struct *)filp->private_data; SOLD("entry"); @@ -620,6 +629,7 @@ int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, s32 __us int oldflags; struct file *filp; struct inode *ino; + struct fdtable *fdt; struct sol_socket_struct *sock; struct T_unitdata_ind udi; mm_segment_t old_fs = get_fs(); @@ -632,7 +642,8 @@ int timod_getmsg(unsigned int fd, char __user *ctl_buf, int ctl_maxlen, s32 __us SOLD("entry"); SOLDD(("%u %p %d %p %p %d %p %d\n", fd, ctl_buf, ctl_maxlen, ctl_len, data_buf, data_maxlen, data_len, *flags_p)); - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; ino = filp->f_dentry->d_inode; sock = (struct sol_socket_struct *)filp->private_data; SOLDD(("%p %p\n", sock->pfirst, sock->pfirst ? sock->pfirst->next : NULL)); @@ -844,12 +855,14 @@ asmlinkage int solaris_getmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3) int __user *flgptr; int flags; int error = -EBADF; + struct fdtable *fdt; SOLD("entry"); lock_kernel(); if(fd >= NR_OPEN) goto out; - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; if(!filp) goto out; ino = filp->f_dentry->d_inode; @@ -910,12 +923,14 @@ asmlinkage int solaris_putmsg(unsigned int fd, u32 arg1, u32 arg2, u32 arg3) struct strbuf ctl, dat; int flags = (int) arg3; int error = -EBADF; + struct fdtable *fdt; SOLD("entry"); lock_kernel(); if(fd >= NR_OPEN) goto out; - filp = current->files->fd[fd]; + fdt = files_fdtable(current->files); + filp = fdt->fd[fd]; if(!filp) goto out; ino = filp->f_dentry->d_inode; -- cgit v0.10.2 From ab2af1f5005069321c5d130f09cce577b03f43ef Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:13 -0700 Subject: [PATCH] files: files struct with RCU Patch to eliminate struct files_struct.file_lock spinlock on the reader side and use rcu refcounting rcuref_xxx api for the f_count refcounter. The updates to the fdtable are done by allocating a new fdtable structure and setting files->fdt to point to the new structure. The fdtable structure is protected by RCU thereby allowing lock-free lookup. For fd arrays/sets that are vmalloced, we use keventd to free them since RCU callbacks can't sleep. A global list of fdtable to be freed is not scalable, so we use a per-cpu list. If keventd is already handling the current cpu's work, we use a timer to defer queueing of that work. Since the last publication, this patch has been re-written to avoid using explicit memory barriers and use rcu_assign_pointer(), rcu_dereference() premitives instead. This required that the fd information is kept in a separate structure (fdtable) and updated atomically. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/aio.c b/fs/aio.c index 201c184..38f6268 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -499,7 +500,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) /* Must be done under the lock to serialise against cancellation. * Call this aio_fput as it duplicates fput via the fput_work. */ - if (unlikely(atomic_dec_and_test(&req->ki_filp->f_count))) { + if (unlikely(rcuref_dec_and_test(&req->ki_filp->f_count))) { get_ioctx(ctx); spin_lock(&fput_lock); list_add(&req->ki_list, &fput_head); diff --git a/fs/fcntl.c b/fs/fcntl.c index bfecc62..d2f3ed8 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -64,8 +65,8 @@ static int locate_fd(struct files_struct *files, if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; - fdt = files_fdtable(files); repeat: + fdt = files_fdtable(files); /* * Someone might have closed fd's in the range * orig_start..fdt->next_fd @@ -95,9 +96,15 @@ repeat: if (error) goto repeat; + /* + * We reacquired files_lock, so we are safe as long as + * we reacquire the fdtable pointer and use it while holding + * the lock, no one can free it during that time. + */ + fdt = files_fdtable(files); if (start <= fdt->next_fd) fdt->next_fd = newfd + 1; - + error = newfd; out: @@ -163,7 +170,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) if (!tofree && FD_ISSET(newfd, fdt->open_fds)) goto out_fput; - fdt->fd[newfd] = file; + rcu_assign_pointer(fdt->fd[newfd], file); FD_SET(newfd, fdt->open_fds); FD_CLR(newfd, fdt->close_on_exec); spin_unlock(&files->file_lock); diff --git a/fs/file.c b/fs/file.c index f5926ce..2127a7b 100644 --- a/fs/file.c +++ b/fs/file.c @@ -13,6 +13,25 @@ #include #include #include +#include +#include +#include +#include + +struct fdtable_defer { + spinlock_t lock; + struct work_struct wq; + struct timer_list timer; + struct fdtable *next; +}; + +/* + * We use this list to defer free fdtables that have vmalloced + * sets/arrays. By keeping a per-cpu list, we avoid having to embed + * the work_struct in fdtable itself which avoids a 64 byte (i386) increase in + * this per-task structure. + */ +static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list); /* @@ -48,85 +67,143 @@ void free_fd_array(struct file **array, int num) vfree(array); } -/* - * Expand the fd array in the files_struct. Called with the files - * spinlock held for write. - */ - -static int expand_fd_array(struct files_struct *files, int nr) - __releases(files->file_lock) - __acquires(files->file_lock) +static void __free_fdtable(struct fdtable *fdt) { - struct file **new_fds; - int error, nfds; - struct fdtable *fdt; + int fdset_size, fdarray_size; - - error = -EMFILE; - fdt = files_fdtable(files); - if (fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) - goto out; + fdset_size = fdt->max_fdset / 8; + fdarray_size = fdt->max_fds * sizeof(struct file *); + free_fdset(fdt->open_fds, fdset_size); + free_fdset(fdt->close_on_exec, fdset_size); + free_fd_array(fdt->fd, fdarray_size); + kfree(fdt); +} - nfds = fdt->max_fds; - spin_unlock(&files->file_lock); +static void fdtable_timer(unsigned long data) +{ + struct fdtable_defer *fddef = (struct fdtable_defer *)data; - /* - * Expand to the max in easy steps, and keep expanding it until - * we have enough for the requested fd array size. + spin_lock(&fddef->lock); + /* + * If someone already emptied the queue return. */ + if (!fddef->next) + goto out; + if (!schedule_work(&fddef->wq)) + mod_timer(&fddef->timer, 5); +out: + spin_unlock(&fddef->lock); +} - do { -#if NR_OPEN_DEFAULT < 256 - if (nfds < 256) - nfds = 256; - else -#endif - if (nfds < (PAGE_SIZE / sizeof(struct file *))) - nfds = PAGE_SIZE / sizeof(struct file *); - else { - nfds = nfds * 2; - if (nfds > NR_OPEN) - nfds = NR_OPEN; - } - } while (nfds <= nr); +static void free_fdtable_work(struct fdtable_defer *f) +{ + struct fdtable *fdt; - error = -ENOMEM; - new_fds = alloc_fd_array(nfds); - spin_lock(&files->file_lock); - if (!new_fds) - goto out; + spin_lock_bh(&f->lock); + fdt = f->next; + f->next = NULL; + spin_unlock_bh(&f->lock); + while(fdt) { + struct fdtable *next = fdt->next; + __free_fdtable(fdt); + fdt = next; + } +} - /* Copy the existing array and install the new pointer */ - fdt = files_fdtable(files); +static void free_fdtable_rcu(struct rcu_head *rcu) +{ + struct fdtable *fdt = container_of(rcu, struct fdtable, rcu); + int fdset_size, fdarray_size; + struct fdtable_defer *fddef; - if (nfds > fdt->max_fds) { - struct file **old_fds; - int i; - - old_fds = xchg(&fdt->fd, new_fds); - i = xchg(&fdt->max_fds, nfds); - - /* Don't copy/clear the array if we are creating a new - fd array for fork() */ - if (i) { - memcpy(new_fds, old_fds, i * sizeof(struct file *)); - /* clear the remainder of the array */ - memset(&new_fds[i], 0, - (nfds-i) * sizeof(struct file *)); - - spin_unlock(&files->file_lock); - free_fd_array(old_fds, i); - spin_lock(&files->file_lock); - } + BUG_ON(!fdt); + fdset_size = fdt->max_fdset / 8; + fdarray_size = fdt->max_fds * sizeof(struct file *); + + if (fdt->free_files) { + /* + * The this fdtable was embedded in the files structure + * and the files structure itself was getting destroyed. + * It is now safe to free the files structure. + */ + kmem_cache_free(files_cachep, fdt->free_files); + return; + } + if (fdt->max_fdset <= __FD_SETSIZE && fdt->max_fds <= NR_OPEN_DEFAULT) { + /* + * The fdtable was embedded + */ + return; + } + if (fdset_size <= PAGE_SIZE && fdarray_size <= PAGE_SIZE) { + kfree(fdt->open_fds); + kfree(fdt->close_on_exec); + kfree(fdt->fd); + kfree(fdt); } else { - /* Somebody expanded the array while we slept ... */ - spin_unlock(&files->file_lock); - free_fd_array(new_fds, nfds); - spin_lock(&files->file_lock); + fddef = &get_cpu_var(fdtable_defer_list); + spin_lock(&fddef->lock); + fdt->next = fddef->next; + fddef->next = fdt; + /* + * vmallocs are handled from the workqueue context. + * If the per-cpu workqueue is running, then we + * defer work scheduling through a timer. + */ + if (!schedule_work(&fddef->wq)) + mod_timer(&fddef->timer, 5); + spin_unlock(&fddef->lock); + put_cpu_var(fdtable_defer_list); } - error = 0; -out: - return error; +} + +void free_fdtable(struct fdtable *fdt) +{ + if (fdt->free_files || fdt->max_fdset > __FD_SETSIZE || + fdt->max_fds > NR_OPEN_DEFAULT) + call_rcu(&fdt->rcu, free_fdtable_rcu); +} + +/* + * Expand the fdset in the files_struct. Called with the files spinlock + * held for write. + */ +static void copy_fdtable(struct fdtable *nfdt, struct fdtable *fdt) +{ + int i; + int count; + + BUG_ON(nfdt->max_fdset < fdt->max_fdset); + BUG_ON(nfdt->max_fds < fdt->max_fds); + /* Copy the existing tables and install the new pointers */ + + i = fdt->max_fdset / (sizeof(unsigned long) * 8); + count = (nfdt->max_fdset - fdt->max_fdset) / 8; + + /* + * Don't copy the entire array if the current fdset is + * not yet initialised. + */ + if (i) { + memcpy (nfdt->open_fds, fdt->open_fds, + fdt->max_fdset/8); + memcpy (nfdt->close_on_exec, fdt->close_on_exec, + fdt->max_fdset/8); + memset (&nfdt->open_fds->fds_bits[i], 0, count); + memset (&nfdt->close_on_exec->fds_bits[i], 0, count); + } + + /* Don't copy/clear the array if we are creating a new + fd array for fork() */ + if (fdt->max_fds) { + memcpy(nfdt->fd, fdt->fd, + fdt->max_fds * sizeof(struct file *)); + /* clear the remainder of the array */ + memset(&nfdt->fd[fdt->max_fds], 0, + (nfdt->max_fds - fdt->max_fds) * + sizeof(struct file *)); + } + nfdt->next_fd = fdt->next_fd; } /* @@ -157,28 +234,21 @@ void free_fdset(fd_set *array, int num) vfree(array); } -/* - * Expand the fdset in the files_struct. Called with the files spinlock - * held for write. - */ -static int expand_fdset(struct files_struct *files, int nr) - __releases(file->file_lock) - __acquires(file->file_lock) +static struct fdtable *alloc_fdtable(int nr) { - fd_set *new_openset = NULL, *new_execset = NULL; - int error, nfds = 0; - struct fdtable *fdt; - - error = -EMFILE; - fdt = files_fdtable(files); - if (fdt->max_fdset >= NR_OPEN || nr >= NR_OPEN) - goto out; + struct fdtable *fdt = NULL; + int nfds = 0; + fd_set *new_openset = NULL, *new_execset = NULL; + struct file **new_fds; - nfds = fdt->max_fdset; - spin_unlock(&files->file_lock); + fdt = kmalloc(sizeof(*fdt), GFP_KERNEL); + if (!fdt) + goto out; + memset(fdt, 0, sizeof(*fdt)); - /* Expand to the max in easy steps */ - do { + nfds = __FD_SETSIZE; + /* Expand to the max in easy steps */ + do { if (nfds < (PAGE_SIZE * 8)) nfds = PAGE_SIZE * 8; else { @@ -188,50 +258,88 @@ static int expand_fdset(struct files_struct *files, int nr) } } while (nfds <= nr); - error = -ENOMEM; - new_openset = alloc_fdset(nfds); - new_execset = alloc_fdset(nfds); - spin_lock(&files->file_lock); - if (!new_openset || !new_execset) + new_openset = alloc_fdset(nfds); + new_execset = alloc_fdset(nfds); + if (!new_openset || !new_execset) + goto out; + fdt->open_fds = new_openset; + fdt->close_on_exec = new_execset; + fdt->max_fdset = nfds; + + nfds = NR_OPEN_DEFAULT; + /* + * Expand to the max in easy steps, and keep expanding it until + * we have enough for the requested fd array size. + */ + do { +#if NR_OPEN_DEFAULT < 256 + if (nfds < 256) + nfds = 256; + else +#endif + if (nfds < (PAGE_SIZE / sizeof(struct file *))) + nfds = PAGE_SIZE / sizeof(struct file *); + else { + nfds = nfds * 2; + if (nfds > NR_OPEN) + nfds = NR_OPEN; + } + } while (nfds <= nr); + new_fds = alloc_fd_array(nfds); + if (!new_fds) goto out; + fdt->fd = new_fds; + fdt->max_fds = nfds; + fdt->free_files = NULL; + return fdt; +out: + if (new_openset) + free_fdset(new_openset, nfds); + if (new_execset) + free_fdset(new_execset, nfds); + kfree(fdt); + return NULL; +} - error = 0; - - /* Copy the existing tables and install the new pointers */ +/* + * Expands the file descriptor table - it will allocate a new fdtable and + * both fd array and fdset. It is expected to be called with the + * files_lock held. + */ +static int expand_fdtable(struct files_struct *files, int nr) + __releases(files->file_lock) + __acquires(files->file_lock) +{ + int error = 0; + struct fdtable *fdt; + struct fdtable *nfdt = NULL; + + spin_unlock(&files->file_lock); + nfdt = alloc_fdtable(nr); + if (!nfdt) { + error = -ENOMEM; + spin_lock(&files->file_lock); + goto out; + } + + spin_lock(&files->file_lock); fdt = files_fdtable(files); - if (nfds > fdt->max_fdset) { - int i = fdt->max_fdset / (sizeof(unsigned long) * 8); - int count = (nfds - fdt->max_fdset) / 8; - - /* - * Don't copy the entire array if the current fdset is - * not yet initialised. - */ - if (i) { - memcpy (new_openset, fdt->open_fds, fdt->max_fdset/8); - memcpy (new_execset, fdt->close_on_exec, fdt->max_fdset/8); - memset (&new_openset->fds_bits[i], 0, count); - memset (&new_execset->fds_bits[i], 0, count); - } - - nfds = xchg(&fdt->max_fdset, nfds); - new_openset = xchg(&fdt->open_fds, new_openset); - new_execset = xchg(&fdt->close_on_exec, new_execset); + /* + * Check again since another task may have expanded the + * fd table while we dropped the lock + */ + if (nr >= fdt->max_fds || nr >= fdt->max_fdset) { + copy_fdtable(nfdt, fdt); + } else { + /* Somebody expanded while we dropped file_lock */ spin_unlock(&files->file_lock); - free_fdset (new_openset, nfds); - free_fdset (new_execset, nfds); + __free_fdtable(nfdt); spin_lock(&files->file_lock); - return 0; - } - /* Somebody expanded the array while we slept ... */ - + goto out; + } + rcu_assign_pointer(files->fdt, nfdt); + free_fdtable(fdt); out: - spin_unlock(&files->file_lock); - if (new_openset) - free_fdset(new_openset, nfds); - if (new_execset) - free_fdset(new_execset, nfds); - spin_lock(&files->file_lock); return error; } @@ -246,17 +354,36 @@ int expand_files(struct files_struct *files, int nr) struct fdtable *fdt; fdt = files_fdtable(files); - if (nr >= fdt->max_fdset) { - expand = 1; - if ((err = expand_fdset(files, nr))) + if (nr >= fdt->max_fdset || nr >= fdt->max_fds) { + if (fdt->max_fdset >= NR_OPEN || + fdt->max_fds >= NR_OPEN || nr >= NR_OPEN) { + err = -EMFILE; goto out; - } - if (nr >= fdt->max_fds) { + } expand = 1; - if ((err = expand_fd_array(files, nr))) + if ((err = expand_fdtable(files, nr))) goto out; } err = expand; out: return err; } + +static void __devinit fdtable_defer_list_init(int cpu) +{ + struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); + spin_lock_init(&fddef->lock); + INIT_WORK(&fddef->wq, (void (*)(void *))free_fdtable_work, fddef); + init_timer(&fddef->timer); + fddef->timer.data = (unsigned long)fddef; + fddef->timer.function = fdtable_timer; + fddef->next = NULL; +} + +void __init files_defer_init(void) +{ + int i; + /* Really early - can't use for_each_cpu */ + for (i = 0; i < NR_CPUS; i++) + fdtable_defer_list_init(i); +} diff --git a/fs/file_table.c b/fs/file_table.c index 43e9e17..86ec8ae 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -53,11 +54,17 @@ void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags) spin_unlock_irqrestore(&filp_count_lock, flags); } -static inline void file_free(struct file *f) +static inline void file_free_rcu(struct rcu_head *head) { + struct file *f = container_of(head, struct file, f_rcuhead); kmem_cache_free(filp_cachep, f); } +static inline void file_free(struct file *f) +{ + call_rcu(&f->f_rcuhead, file_free_rcu); +} + /* Find an unused file structure and return a pointer to it. * Returns NULL, if there are no more free file structures or * we run out of memory. @@ -110,7 +117,7 @@ EXPORT_SYMBOL(get_empty_filp); void fastcall fput(struct file *file) { - if (atomic_dec_and_test(&file->f_count)) + if (rcuref_dec_and_test(&file->f_count)) __fput(file); } @@ -156,11 +163,17 @@ struct file fastcall *fget(unsigned int fd) struct file *file; struct files_struct *files = current->files; - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); - if (file) - get_file(file); - spin_unlock(&files->file_lock); + if (file) { + if (!rcuref_inc_lf(&file->f_count)) { + /* File object ref couldn't be taken */ + rcu_read_unlock(); + return NULL; + } + } + rcu_read_unlock(); + return file; } @@ -182,21 +195,25 @@ struct file fastcall *fget_light(unsigned int fd, int *fput_needed) if (likely((atomic_read(&files->count) == 1))) { file = fcheck_files(files, fd); } else { - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (file) { - get_file(file); - *fput_needed = 1; + if (rcuref_inc_lf(&file->f_count)) + *fput_needed = 1; + else + /* Didn't get the reference, someone's freed */ + file = NULL; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); } + return file; } void put_filp(struct file *file) { - if (atomic_dec_and_test(&file->f_count)) { + if (rcuref_dec_and_test(&file->f_count)) { security_file_free(file); file_kill(file); file_free(file); @@ -257,4 +274,5 @@ void __init files_init(unsigned long mempages) files_stat.max_files = n; if (files_stat.max_files < NR_FILE) files_stat.max_files = NR_FILE; + files_defer_init(); } diff --git a/fs/open.c b/fs/open.c index b654251..2fac58c 100644 --- a/fs/open.c +++ b/fs/open.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -930,9 +931,8 @@ void fastcall fd_install(unsigned int fd, struct file * file) struct fdtable *fdt; spin_lock(&files->file_lock); fdt = files_fdtable(files); - if (unlikely(fdt->fd[fd] != NULL)) - BUG(); - fdt->fd[fd] = file; + BUG_ON(fdt->fd[fd] != NULL); + rcu_assign_pointer(fdt->fd[fd], file); spin_unlock(&files->file_lock); } @@ -1024,7 +1024,7 @@ asmlinkage long sys_close(unsigned int fd) filp = fdt->fd[fd]; if (!filp) goto out_unlock; - fdt->fd[fd] = NULL; + rcu_assign_pointer(fdt->fd[fd], NULL); FD_CLR(fd, fdt->close_on_exec); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); diff --git a/include/linux/file.h b/include/linux/file.h index db37223..f5bbd4c 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -9,6 +9,7 @@ #include #include #include +#include /* * The default fd array needs to be at least BITS_PER_LONG, @@ -23,6 +24,9 @@ struct fdtable { struct file ** fd; /* current fd array */ fd_set *close_on_exec; fd_set *open_fds; + struct rcu_head rcu; + struct files_struct *free_files; + struct fdtable *next; }; /* @@ -31,13 +35,14 @@ struct fdtable { struct files_struct { atomic_t count; spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ + struct fdtable *fdt; struct fdtable fdtab; fd_set close_on_exec_init; fd_set open_fds_init; struct file * fd_array[NR_OPEN_DEFAULT]; }; -#define files_fdtable(files) (&(files)->fdtab) +#define files_fdtable(files) (rcu_dereference((files)->fdt)) extern void FASTCALL(__fput(struct file *)); extern void FASTCALL(fput(struct file *)); @@ -65,6 +70,8 @@ extern fd_set *alloc_fdset(int); extern void free_fdset(fd_set *, int); extern int expand_files(struct files_struct *, int nr); +extern void free_fdtable(struct fdtable *fdt); +extern void __init files_defer_init(void); static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) { @@ -72,7 +79,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned in struct fdtable *fdt = files_fdtable(files); if (fd < fdt->max_fds) - file = fdt->fd[fd]; + file = rcu_dereference(fdt->fd[fd]); return file; } diff --git a/include/linux/fs.h b/include/linux/fs.h index fd93ab7..7f61227 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -9,6 +9,7 @@ #include #include #include +#include /* * It's silly to have NR_OPEN bigger than NR_FILE, but you can change @@ -597,12 +598,13 @@ struct file { spinlock_t f_ep_lock; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; + struct rcu_head f_rcuhead; }; extern spinlock_t files_lock; #define file_list_lock() spin_lock(&files_lock); #define file_list_unlock() spin_unlock(&files_lock); -#define get_file(x) atomic_inc(&(x)->f_count) +#define get_file(x) rcuref_inc(&(x)->f_count) #define file_count(x) atomic_read(&(x)->f_count) #define MAX_NON_LFS ((1UL<<31) - 1) diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 94aefa5..68ab5f2 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -2,6 +2,7 @@ #define _LINUX__INIT_TASK_H #include +#include #define INIT_FDTABLE \ { \ @@ -11,12 +12,16 @@ .fd = &init_files.fd_array[0], \ .close_on_exec = &init_files.close_on_exec_init, \ .open_fds = &init_files.open_fds_init, \ + .rcu = RCU_HEAD_INIT, \ + .free_files = NULL, \ + .next = NULL, \ } #define INIT_FILES \ { \ .count = ATOMIC_INIT(1), \ .file_lock = SPIN_LOCK_UNLOCKED, \ + .fdt = &init_files.fdtab, \ .fdtab = INIT_FDTABLE, \ .close_on_exec_init = { { 0, } }, \ .open_fds_init = { { 0, } }, \ diff --git a/kernel/exit.c b/kernel/exit.c index 83beb1e..6d2089a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -411,15 +411,16 @@ void fastcall put_files_struct(struct files_struct *files) close_files(files); /* * Free the fd and fdset arrays if we expanded them. + * If the fdtable was embedded, pass files for freeing + * at the end of the RCU grace period. Otherwise, + * you can free files immediately. */ fdt = files_fdtable(files); - if (fdt->fd != &files->fd_array[0]) - free_fd_array(fdt->fd, fdt->max_fds); - if (fdt->max_fdset > __FD_SETSIZE) { - free_fdset(fdt->open_fds, fdt->max_fdset); - free_fdset(fdt->close_on_exec, fdt->max_fdset); - } - kmem_cache_free(files_cachep, files); + if (fdt == &files->fdtab) + fdt->free_files = files; + else + kmem_cache_free(files_cachep, files); + free_fdtable(fdt); } } diff --git a/kernel/fork.c b/kernel/fork.c index ecc694d..8149f36 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -565,13 +566,12 @@ static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk) return 0; } -static int count_open_files(struct files_struct *files, int size) +static int count_open_files(struct fdtable *fdt) { + int size = fdt->max_fdset; int i; - struct fdtable *fdt; /* Find the last open fd */ - fdt = files_fdtable(files); for (i = size/(8*sizeof(long)); i > 0; ) { if (fdt->open_fds->fds_bits[--i]) break; @@ -592,13 +592,17 @@ static struct files_struct *alloc_files(void) atomic_set(&newf->count, 1); spin_lock_init(&newf->file_lock); - fdt = files_fdtable(newf); + fdt = &newf->fdtab; fdt->next_fd = 0; fdt->max_fds = NR_OPEN_DEFAULT; fdt->max_fdset = __FD_SETSIZE; fdt->close_on_exec = &newf->close_on_exec_init; fdt->open_fds = &newf->open_fds_init; fdt->fd = &newf->fd_array[0]; + INIT_RCU_HEAD(&fdt->rcu); + fdt->free_files = NULL; + fdt->next = NULL; + rcu_assign_pointer(newf->fdt, fdt); out: return newf; } @@ -637,7 +641,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) old_fdt = files_fdtable(oldf); new_fdt = files_fdtable(newf); size = old_fdt->max_fdset; - open_files = count_open_files(oldf, old_fdt->max_fdset); + open_files = count_open_files(old_fdt); expand = 0; /* @@ -661,7 +665,14 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) spin_unlock(&newf->file_lock); if (error < 0) goto out_release; + new_fdt = files_fdtable(newf); + /* + * Reacquire the oldf lock and a pointer to its fd table + * who knows it may have a new bigger fd table. We need + * the latest pointer. + */ spin_lock(&oldf->file_lock); + old_fdt = files_fdtable(oldf); } old_fds = old_fdt->fd; @@ -683,7 +694,7 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk) */ FD_CLR(open_files - i, new_fdt->open_fds); } - *new_fds++ = f; + rcu_assign_pointer(*new_fds++, f); } spin_unlock(&oldf->file_lock); -- cgit v0.10.2 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 diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c index 4cd3d38..3cdc223 100644 --- a/arch/mips/kernel/irixioctl.c +++ b/arch/mips/kernel/irixioctl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ static struct tty_struct *get_tty(int fd) struct file *filp; struct tty_struct *ttyp = NULL; - spin_lock(¤t->files->file_lock); + rcu_read_lock(); filp = fcheck(fd); if(filp && filp->private_data) { ttyp = (struct tty_struct *) filp->private_data; @@ -41,7 +42,7 @@ static struct tty_struct *get_tty(int fd) if(ttyp->magic != TTY_MAGIC) ttyp =NULL; } - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); return ttyp; } diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index 3747664..be0a054 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -295,16 +296,16 @@ static inline int solaris_sockmod(unsigned int fd, unsigned int cmd, u32 arg) struct inode *ino; struct fdtable *fdt; /* I wonder which of these tests are superfluous... --patrik */ - spin_lock(¤t->files->file_lock); + rcu_read_lock(); fdt = files_fdtable(current->files); if (! fdt->fd[fd] || ! fdt->fd[fd]->f_dentry || ! (ino = fdt->fd[fd]->f_dentry->d_inode) || ! S_ISSOCK(ino->i_mode)) { - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); return TBADF; } - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); switch (cmd & 0xff) { case 109: /* SI_SOCKPARAMS */ diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 0bfc7af..e5953f3 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); diff --git a/fs/fcntl.c b/fs/fcntl.c index d2f3ed8..863b46e 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -40,10 +40,10 @@ static inline int get_close_on_exec(unsigned int fd) struct files_struct *files = current->files; struct fdtable *fdt; int res; - spin_lock(&files->file_lock); + rcu_read_lock(); fdt = files_fdtable(files); res = FD_ISSET(fd, fdt->close_on_exec); - spin_unlock(&files->file_lock); + rcu_read_unlock(); return res; } diff --git a/fs/proc/base.c b/fs/proc/base.c index d0087a0..23db452 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -283,16 +284,16 @@ static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsm files = get_files_struct(task); if (files) { - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (file) { *mnt = mntget(file->f_vfsmnt); *dentry = dget(file->f_dentry); - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); return 0; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } return -ENOENT; @@ -1062,7 +1063,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) files = get_files_struct(p); if (!files) goto out; - spin_lock(&files->file_lock); + rcu_read_lock(); fdt = files_fdtable(files); for (fd = filp->f_pos-2; fd < fdt->max_fds; @@ -1071,7 +1072,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) if (!fcheck_files(files, fd)) continue; - spin_unlock(&files->file_lock); + rcu_read_unlock(); j = NUMBUF; i = fd; @@ -1083,12 +1084,12 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) ino = fake_ino(tid, PROC_TID_FD_DIR + fd); if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) { - spin_lock(&files->file_lock); + rcu_read_lock(); break; } - spin_lock(&files->file_lock); + rcu_read_lock(); } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } out: @@ -1263,9 +1264,9 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) files = get_files_struct(task); if (files) { - spin_lock(&files->file_lock); + rcu_read_lock(); if (fcheck_files(files, fd)) { - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); if (task_dumpable(task)) { inode->i_uid = task->euid; @@ -1277,7 +1278,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) security_task_to_inode(task, inode); return 1; } - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); } d_drop(dentry); @@ -1369,7 +1370,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, if (!files) goto out_unlock; inode->i_mode = S_IFLNK; - spin_lock(&files->file_lock); + rcu_read_lock(); file = fcheck_files(files, fd); if (!file) goto out_unlock2; @@ -1377,7 +1378,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, inode->i_mode |= S_IRUSR | S_IXUSR; if (file->f_mode & 2) inode->i_mode |= S_IWUSR | S_IXUSR; - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); inode->i_op = &proc_pid_link_inode_operations; inode->i_size = 64; @@ -1387,7 +1388,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry, return NULL; out_unlock2: - spin_unlock(&files->file_lock); + rcu_read_unlock(); put_files_struct(files); out_unlock: iput(inode); diff --git a/fs/select.c b/fs/select.c index 2e56325..f10a103 100644 --- a/fs/select.c +++ b/fs/select.c @@ -22,6 +22,7 @@ #include /* for STICKY_TIMEOUTS */ #include #include +#include #include @@ -185,9 +186,9 @@ int do_select(int n, fd_set_bits *fds, long *timeout) int retval, i; long __timeout = *timeout; - spin_lock(¤t->files->file_lock); + rcu_read_lock(); retval = max_select_fd(n, fds); - spin_unlock(¤t->files->file_lock); + rcu_read_unlock(); if (retval < 0) return retval; @@ -329,8 +330,10 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s goto out_nofds; /* max_fdset can increase, so grab it once to avoid race */ + rcu_read_lock(); fdt = files_fdtable(current->files); max_fdset = fdt->max_fdset; + rcu_read_unlock(); if (n > max_fdset) n = max_fdset; @@ -469,10 +472,14 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti struct poll_list *head; struct poll_list *walk; struct fdtable *fdt; + int max_fdset; /* Do a sanity check on nfds ... */ + rcu_read_lock(); fdt = files_fdtable(current->files); - if (nfds > fdt->max_fdset && nfds > OPEN_MAX) + max_fdset = fdt->max_fdset; + rcu_read_unlock(); + if (nfds > max_fdset && nfds > OPEN_MAX) return -EINVAL; if (timeout) { diff --git a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c index c1889f8..0cee286 100644 --- a/net/ipv4/netfilter/ipt_owner.c +++ b/net/ipv4/netfilter/ipt_owner.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c index 9b91dec..4de4cda 100644 --- a/net/ipv6/netfilter/ip6t_owner.c +++ b/net/ipv6/netfilter/ip6t_owner.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index acb5a49..f40c822 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1652,7 +1652,7 @@ static inline void flush_unauthorized_files(struct files_struct * files) continue; } if (devnull) { - atomic_inc(&devnull->f_count); + rcuref_inc(&devnull->f_count); } else { devnull = dentry_open(dget(selinux_null), mntget(selinuxfs_mount), O_RDWR); if (!devnull) { -- cgit v0.10.2 From 2822541893d88f84dd4f1525108d73effecd9d39 Mon Sep 17 00:00:00 2001 From: Dipankar Sarma Date: Fri, 9 Sep 2005 13:04:15 -0700 Subject: [PATCH] files: files locking doc Add documentation describing the new locking scheme for file descriptor table. Signed-off-by: Dipankar Sarma Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/filesystems/files.txt b/Documentation/filesystems/files.txt new file mode 100644 index 0000000..8c206f4 --- /dev/null +++ b/Documentation/filesystems/files.txt @@ -0,0 +1,123 @@ +File management in the Linux kernel +----------------------------------- + +This document describes how locking for files (struct file) +and file descriptor table (struct files) works. + +Up until 2.6.12, the file descriptor table has been protected +with a lock (files->file_lock) and reference count (files->count). +->file_lock protected accesses to all the file related fields +of the table. ->count was used for sharing the file descriptor +table between tasks cloned with CLONE_FILES flag. Typically +this would be the case for posix threads. As with the common +refcounting model in the kernel, the last task doing +a put_files_struct() frees the file descriptor (fd) table. +The files (struct file) themselves are protected using +reference count (->f_count). + +In the new lock-free model of file descriptor management, +the reference counting is similar, but the locking is +based on RCU. The file descriptor table contains multiple +elements - the fd sets (open_fds and close_on_exec, the +array of file pointers, the sizes of the sets and the array +etc.). In order for the updates to appear atomic to +a lock-free reader, all the elements of the file descriptor +table are in a separate structure - struct fdtable. +files_struct contains a pointer to struct fdtable through +which the actual fd table is accessed. Initially the +fdtable is embedded in files_struct itself. On a subsequent +expansion of fdtable, a new fdtable structure is allocated +and files->fdtab points to the new structure. The fdtable +structure is freed with RCU and lock-free readers either +see the old fdtable or the new fdtable making the update +appear atomic. Here are the locking rules for +the fdtable structure - + +1. All references to the fdtable must be done through + the files_fdtable() macro : + + struct fdtable *fdt; + + rcu_read_lock(); + + fdt = files_fdtable(files); + .... + if (n <= fdt->max_fds) + .... + ... + rcu_read_unlock(); + + files_fdtable() uses rcu_dereference() macro which takes care of + the memory barrier requirements for lock-free dereference. + The fdtable pointer must be read within the read-side + critical section. + +2. Reading of the fdtable as described above must be protected + by rcu_read_lock()/rcu_read_unlock(). + +3. For any update to the the fd table, files->file_lock must + be held. + +4. To look up the file structure given an fd, a reader + must use either fcheck() or fcheck_files() APIs. These + take care of barrier requirements due to lock-free lookup. + An example : + + struct file *file; + + rcu_read_lock(); + file = fcheck(fd); + if (file) { + ... + } + .... + rcu_read_unlock(); + +5. Handling of the file structures is special. Since the look-up + of the fd (fget()/fget_light()) are lock-free, it is possible + that look-up may race with the last put() operation on the + file structure. This is avoided using the rcuref APIs + on ->f_count : + + rcu_read_lock(); + file = fcheck_files(files, fd); + if (file) { + if (rcuref_inc_lf(&file->f_count)) + *fput_needed = 1; + else + /* Didn't get the reference, someone's freed */ + file = NULL; + } + rcu_read_unlock(); + .... + return file; + + rcuref_inc_lf() detects if refcounts is already zero or + goes to zero during increment. If it does, we fail + fget()/fget_light(). + +6. Since both fdtable and file structures can be looked up + lock-free, they must be installed using rcu_assign_pointer() + API. If they are looked up lock-free, rcu_dereference() + must be used. However it is advisable to use files_fdtable() + and fcheck()/fcheck_files() which take care of these issues. + +7. While updating, the fdtable pointer must be looked up while + holding files->file_lock. If ->file_lock is dropped, then + another thread expand the files thereby creating a new + fdtable and making the earlier fdtable pointer stale. + For example : + + spin_lock(&files->file_lock); + fd = locate_fd(files, file, start); + if (fd >= 0) { + /* locate_fd() may have expanded fdtable, load the ptr */ + fdt = files_fdtable(files); + FD_SET(fd, fdt->open_fds); + FD_CLR(fd, fdt->close_on_exec); + spin_unlock(&files->file_lock); + ..... + + Since locate_fd() can drop ->file_lock (and reacquire ->file_lock), + the fdtable pointer (fdt) must be loaded after locate_fd(). + -- cgit v0.10.2 From 93fa58cb831337fdf5d36b3b913441100a484dae Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:18 -0700 Subject: [PATCH] v9fs: Documentation, Makefiles, Configuration OVERVIEW V9FS is a distributed file system for Linux which provides an implementation of the Plan 9 resource sharing protocol 9P. It can be used to share all sorts of resources: static files, synthetic file servers (such as /proc or /sys), devices, and application file servers (such as FUSE). BACKGROUND Plan 9 (http://plan9.bell-labs.com/plan9) is a research operating system and associated applications suite developed by the Computing Science Research Center of AT&T Bell Laboratories (now a part of Lucent Technologies), the same group that developed UNIX , C, and C++. Plan 9 was initially released in 1993 to universities, and then made generally available in 1995. Its core operating systems code laid the foundation for the Inferno Operating System released as a product by Lucent Bell-Labs in 1997. The Inferno venture was the only commercial embodiment of Plan 9 and is currently maintained as a product by Vita Nuova (http://www.vitanuova.com). After updated releases in 2000 and 2002, Plan 9 was open-sourced under the OSI approved Lucent Public License in 2003. The Plan 9 project was started by Ken Thompson and Rob Pike in 1985. Their intent was to explore potential solutions to some of the shortcomings of UNIX in the face of the widespread use of high-speed networks to connect machines. In UNIX, networking was an afterthought and UNIX clusters became little more than a network of stand-alone systems. Plan 9 was designed from first principles as a seamless distributed system with integrated secure network resource sharing. Applications and services were architected in such a way as to allow for implicit distribution across a cluster of systems. Configuring an environment to use remote application components or services in place of their local equivalent could be achieved with a few simple command line instructions. For the most part, application implementations operated independent of the location of their actual resources. Commercial operating systems haven't changed much in the 20 years since Plan 9 was conceived. Network and distributed systems support is provided by a patchwork of middle-ware, with an endless number of packages supplying pieces of the puzzle. Matters are complicated by the use of different complicated protocols for individual services, and separate implementations for kernel and application resources. The V9FS project (http://v9fs.sourceforge.net) is an attempt to bring Plan 9's unified approach to resource sharing to Linux and other operating systems via support for the 9P2000 resource sharing protocol. V9FS HISTORY V9FS was originally developed by Ron Minnich and Maya Gokhale at Los Alamos National Labs (LANL) in 1997. In November of 2001, Greg Watson setup a SourceForge project as a public repository for the code which supported the Linux 2.4 kernel. About a year ago, I picked up the initial attempt Ron Minnich had made to provide 2.6 support and got the code integrated into a 2.6.5 kernel. I then went through a line-for-line re-write attempting to clean-up the code while more closely following the Linux Kernel style guidelines. I co-authored a paper with Ron Minnich on the V9FS Linux support including performance comparisons to NFSv3 using Bonnie and PostMark - this paper appeared at the USENIX/FREENIX 2005 conference in April 2005: ( http://www.usenix.org/events/usenix05/tech/freenix/hensbergen.html ). CALL FOR PARTICIPATION/REQUEST FOR COMMENTS Our 2.6 kernel support is stabilizing and we'd like to begin pursuing its integration into the official kernel tree. We would appreciate any review, comments, critiques, and additions from this community and are actively seeking people to join our project and help us produce something that would be acceptable and useful to the Linux community. STATUS The code is reasonably stable, although there are no doubt corner cases our regression tests haven't discovered yet. It is in regular use by several of the developers and has been tested on x86 and PowerPC (32-bit and 64-bit) in both small and large (LANL cluster) deployments. Our current regression tests include fsx, bonnie, and postmark. It was our intention to keep things as simple as possible for this release -- trying to focus on correctness within the core of the protocol support versus a rich set of features. For example: a more complete security model and cache layer are in the road map, but excluded from this release. Additionally, we have removed support for mmap operations at Al Viro's request. PERFORMANCE Detailed performance numbers and analysis are included in the FREENIX paper, but we show comparable performance to NFSv3 for large file operations based on the Bonnie benchmark, and superior performance for many small file operations based on the PostMark benchmark. Somewhat preliminary graphs (from the FREENIX paper) are available (http://v9fs.sourceforge.net/perf/index.html). RESOURCES The source code is available in a few different forms: tarballs: http://v9fs.sf.net CVSweb: http://cvs.sourceforge.net/viewcvs.py/v9fs/linux-9p/ CVS: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/v9fs/linux-9p Git: rsync://v9fs.graverobber.org/v9fs (webgit: http://v9fs.graverobber.org) 9P: tcp!v9fs.graverobber.org!6564 The user-level server is available from either the Plan 9 distribution or from http://v9fs.sf.net Other support applications are still being developed, but preliminary version can be downloaded from sourceforge. Documentation on the protocol has historically been the Plan 9 Man pages (http://plan9.bell-labs.com/sys/man/5/INDEX.html), but there is an effort under way to write a more complete Internet-Draft style specification (http://v9fs.sf.net/rfc). There are a couple of mailing lists supporting v9fs, but the most used is v9fs-developer@lists.sourceforge.net -- please direct/cc your comments there so the other v9fs contibutors can participate in the conversation. There is also an IRC channel: irc://freenode.net/#v9fs This part of the patch contains Documentation, Makefiles, and configuration file changes. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/Documentation/filesystems/v9fs.txt b/Documentation/filesystems/v9fs.txt new file mode 100644 index 0000000..4e92feb --- /dev/null +++ b/Documentation/filesystems/v9fs.txt @@ -0,0 +1,95 @@ + V9FS: 9P2000 for Linux + ====================== + +ABOUT +===== + +v9fs is a Unix implementation of the Plan 9 9p remote filesystem protocol. + +This software was originally developed by Ron Minnich +and Maya Gokhale . Additional development by Greg Watson + and most recently Eric Van Hensbergen + and Latchesar Ionkov . + +USAGE +===== + +For remote file server: + + mount -t 9P 10.10.1.2 /mnt/9 + +For Plan 9 From User Space applications (http://swtch.com/plan9) + + mount -t 9P `namespace`/acme /mnt/9 -o proto=unix,name=$USER + +OPTIONS +======= + + proto=name select an alternative transport. Valid options are + currently: + unix - specifying a named pipe mount point + tcp - specifying a normal TCP/IP connection + fd - used passed file descriptors for connection + (see rfdno and wfdno) + + name=name user name to attempt mount as on the remote server. The + server may override or ignore this value. Certain user + names may require authentication. + + aname=name aname specifies the file tree to access when the server is + offering several exported file systems. + + debug=n specifies debug level. The debug level is a bitmask. + 0x01 = display verbose error messages + 0x02 = developer debug (DEBUG_CURRENT) + 0x04 = display 9P trace + 0x08 = display VFS trace + 0x10 = display Marshalling debug + 0x20 = display RPC debug + 0x40 = display transport debug + 0x80 = display allocation debug + + rfdno=n the file descriptor for reading with proto=fd + + wfdno=n the file descriptor for writing with proto=fd + + maxdata=n the number of bytes to use for 9P packet payload (msize) + + port=n port to connect to on the remote server + + timeout=n request timeouts (in ms) (default 60000ms) + + noextend force legacy mode (no 9P2000.u semantics) + + uid attempt to mount as a particular uid + + gid attempt to mount with a particular gid + + afid security channel - used by Plan 9 authentication protocols + + nodevmap do not map special files - represent them as normal files. + This can be used to share devices/named pipes/sockets between + hosts. This functionality will be expanded in later versions. + +RESOURCES +========= + +The Linux version of the 9P server, along with some client-side utilities +can be found at http://v9fs.sf.net (along with a CVS repository of the +development branch of this module). There are user and developer mailing +lists here, as well as a bug-tracker. + +For more information on the Plan 9 Operating System check out +http://plan9.bell-labs.com/plan9 + +For information on Plan 9 from User Space (Plan 9 applications and libraries +ported to Linux/BSD/OSX/etc) check out http://swtch.com/plan9 + + +STATUS +====== + +The 2.6 kernel support is working on PPC and x86. + +PLEASE USE THE SOURCEFORGE BUG-TRACKER TO REPORT PROBLEMS. + diff --git a/MAINTAINERS b/MAINTAINERS index eaa4659..8429bdb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2684,6 +2684,17 @@ L: rio500-users@lists.sourceforge.net W: http://rio500.sourceforge.net S: Maintained +V9FS FILE SYSTEM +P: Eric Van Hensbergen +M: ericvh@gmail.com +P: Ron Minnich +M: rminnich@lanl.gov +P: Latchesar Ionkov +M: lucho@ionkov.net +L: v9fs-developer@lists.sourceforge.net +W: http://v9fs.sf.net +S: Maintained + VIDEO FOR LINUX P: Mauro Carvalho Chehab M: mchehab@brturbo.com.br diff --git a/fs/9p/Makefile b/fs/9p/Makefile new file mode 100644 index 0000000..e4e4ffe --- /dev/null +++ b/fs/9p/Makefile @@ -0,0 +1,17 @@ +obj-$(CONFIG_9P_FS) := 9p2000.o + +9p2000-objs := \ + vfs_super.o \ + vfs_inode.o \ + vfs_file.o \ + vfs_dir.o \ + vfs_dentry.o \ + error.o \ + mux.o \ + trans_fd.o \ + trans_sock.o \ + 9p.o \ + conv.o \ + v9fs.o \ + fid.o + diff --git a/fs/Kconfig b/fs/Kconfig index 5e81790..443aed4 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1703,6 +1703,17 @@ config AFS_FS config RXRPC tristate +config 9P_FS + tristate "Plan 9 Resource Sharing Support (9P2000) (Experimental)" + depends on INET && EXPERIMENTAL + help + If you say Y here, you will get experimental support for + Plan 9 resource sharing via the 9P2000 protocol. + + See for more information. + + If unsure, say N. + endmenu menu "Partition Types" diff --git a/fs/Makefile b/fs/Makefile index 1515830..d646502 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -94,6 +94,7 @@ obj-$(CONFIG_RELAYFS_FS) += relayfs/ obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ obj-$(CONFIG_JFS_FS) += jfs/ obj-$(CONFIG_XFS_FS) += xfs/ +obj-$(CONFIG_9P_FS) += 9p/ obj-$(CONFIG_AFS_FS) += afs/ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ -- cgit v0.10.2 From e69e7fe5b0c86b7271045444a3a681136234c659 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:18 -0700 Subject: [PATCH] v9fs: VFS file, dentry, and directory operations This part of the patch contains the VFS file, dentry & directory interfaces. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c new file mode 100644 index 0000000..306c967 --- /dev/null +++ b/fs/9p/vfs_dentry.c @@ -0,0 +1,126 @@ +/* + * linux/fs/9p/vfs_dentry.c + * + * This file contians vfs dentry ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +/** + * v9fs_dentry_validate - VFS dcache hook to validate cache + * @dentry: dentry that is being validated + * @nd: path data + * + * dcache really shouldn't be used for 9P2000 as at all due to + * potential attached semantics to directory traversal (walk). + * + * FUTURE: look into how to use dcache to allow multi-stage + * walks in Plan 9 & potential for better dcache operation which + * would remain valid for Plan 9 semantics. Older versions + * had validation via stat for those interested. However, since + * stat has the same approximate overhead as walk there really + * is no difference. The only improvement would be from a + * time-decay cache like NFS has and that undermines the + * synchronous nature of 9P2000. + * + */ + +static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd) +{ + struct dentry *dc = current->fs->pwd; + + dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); + if (v9fs_fid_lookup(dentry, FID_OP)) { + dprintk(DEBUG_VFS, "VALID\n"); + return 1; + } + + while (dc != NULL) { + if (dc == dentry) { + dprintk(DEBUG_VFS, "VALID\n"); + return 1; + } + if (dc == dc->d_parent) + break; + + dc = dc->d_parent; + } + + dprintk(DEBUG_VFS, "INVALID\n"); + return 0; +} + +/** + * v9fs_dentry_release - called when dentry is going to be freed + * @dentry: dentry that is being release + * + */ + +void v9fs_dentry_release(struct dentry *dentry) +{ + dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); + + if (dentry->d_fsdata != NULL) { + struct list_head *fid_list = dentry->d_fsdata; + struct v9fs_fid *temp = NULL; + struct v9fs_fid *current_fid = NULL; + struct v9fs_fcall *fcall = NULL; + + list_for_each_entry_safe(current_fid, temp, fid_list, list) { + if (v9fs_t_clunk + (current_fid->v9ses, current_fid->fid, &fcall)) + dprintk(DEBUG_ERROR, "clunk failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(current_fid->fid, + ¤t_fid->v9ses->fidpool); + + kfree(fcall); + v9fs_fid_destroy(current_fid); + } + + kfree(dentry->d_fsdata); /* free the list_head */ + } +} + +struct dentry_operations v9fs_dentry_operations = { + .d_revalidate = v9fs_dentry_validate, + .d_release = v9fs_dentry_release, +}; diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c new file mode 100644 index 0000000..c478a73 --- /dev/null +++ b/fs/9p/vfs_dir.c @@ -0,0 +1,226 @@ +/* + * linux/fs/9p/vfs_dir.c + * + * This file contains vfs directory ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +/** + * dt_type - return file type + * @mistat: mistat structure + * + */ + +static inline int dt_type(struct v9fs_stat *mistat) +{ + unsigned long perm = mistat->mode; + int rettype = DT_REG; + + if (perm & V9FS_DMDIR) + rettype = DT_DIR; + if (perm & V9FS_DMSYMLINK) + rettype = DT_LNK; + + return rettype; +} + +/** + * v9fs_dir_readdir - read a directory + * @filep: opened file structure + * @dirent: directory structure ??? + * @filldir: function to populate directory structure ??? + * + */ + +static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) +{ + struct v9fs_fcall *fcall = NULL; + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *file = filp->private_data; + unsigned int i, n; + int fid = -1; + int ret = 0; + struct v9fs_stat *mi = NULL; + int over = 0; + + dprintk(DEBUG_VFS, "name %s\n", filp->f_dentry->d_name.name); + + fid = file->fid; + + mi = kmalloc(v9ses->maxdata, GFP_KERNEL); + if (!mi) + return -ENOMEM; + + if (file->rdir_fcall && (filp->f_pos != file->rdir_pos)) { + kfree(file->rdir_fcall); + file->rdir_fcall = NULL; + } + + if (file->rdir_fcall) { + n = file->rdir_fcall->params.rread.count; + i = file->rdir_fpos; + while (i < n) { + int s = v9fs_deserialize_stat(v9ses, + file->rdir_fcall->params.rread.data + i, + n - i, mi, v9ses->maxdata); + + if (s == 0) { + dprintk(DEBUG_ERROR, + "error while deserializing mistat\n"); + ret = -EIO; + goto FreeStructs; + } + + over = filldir(dirent, mi->name, strlen(mi->name), + filp->f_pos, v9fs_qid2ino(&mi->qid), + dt_type(mi)); + + if (over) { + file->rdir_fpos = i; + file->rdir_pos = filp->f_pos; + break; + } + + i += s; + filp->f_pos += s; + } + + if (!over) { + kfree(file->rdir_fcall); + file->rdir_fcall = NULL; + } + } + + while (!over) { + ret = v9fs_t_read(v9ses, fid, filp->f_pos, + v9ses->maxdata-V9FS_IOHDRSZ, &fcall); + if (ret < 0) { + dprintk(DEBUG_ERROR, "error while reading: %d: %p\n", + ret, fcall); + goto FreeStructs; + } else if (ret == 0) + break; + + n = ret; + i = 0; + while (i < n) { + int s = v9fs_deserialize_stat(v9ses, + fcall->params.rread.data + i, n - i, mi, + v9ses->maxdata); + + if (s == 0) { + dprintk(DEBUG_ERROR, + "error while deserializing mistat\n"); + return -EIO; + } + + over = filldir(dirent, mi->name, strlen(mi->name), + filp->f_pos, v9fs_qid2ino(&mi->qid), + dt_type(mi)); + + if (over) { + file->rdir_fcall = fcall; + file->rdir_fpos = i; + file->rdir_pos = filp->f_pos; + fcall = NULL; + break; + } + + i += s; + filp->f_pos += s; + } + + kfree(fcall); + } + + FreeStructs: + kfree(fcall); + kfree(mi); + return ret; +} + +/** + * v9fs_dir_release - close a directory + * @inode: inode of the directory + * @filp: file pointer to a directory + * + */ + +int v9fs_dir_release(struct inode *inode, struct file *filp) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *fid = filp->private_data; + int fidnum = -1; + + dprintk(DEBUG_VFS, "inode: %p filp: %p fid: %d\n", inode, filp, + fid->fid); + fidnum = fid->fid; + + filemap_fdatawrite(inode->i_mapping); + filemap_fdatawait(inode->i_mapping); + + if (fidnum >= 0) { + fid->fidopen--; + dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, + fid->fid); + + if (fid->fidopen == 0) { + if (v9fs_t_clunk(v9ses, fidnum, NULL)) + dprintk(DEBUG_ERROR, "clunk failed\n"); + + v9fs_put_idpool(fid->fid, &v9ses->fidpool); + } + + kfree(fid->rdir_fcall); + + filp->private_data = NULL; + v9fs_fid_destroy(fid); + } + + d_drop(filp->f_dentry); + return 0; +} + +struct file_operations v9fs_dir_operations = { + .read = generic_read_dir, + .readdir = v9fs_dir_readdir, + .open = v9fs_file_open, + .release = v9fs_dir_release, +}; diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c new file mode 100644 index 0000000..1f8ae7d --- /dev/null +++ b/fs/9p/vfs_file.c @@ -0,0 +1,401 @@ +/* + * linux/fs/9p/vfs_file.c + * + * This file contians vfs file ops for 9P2000. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "fid.h" + +/** + * v9fs_file_open - open a file (or directory) + * @inode: inode to be opened + * @file: file being opened + * + */ + +int v9fs_file_open(struct inode *inode, struct file *file) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9fid = v9fs_fid_lookup(file->f_dentry, FID_WALK); + struct v9fs_fid *v9newfid = NULL; + struct v9fs_fcall *fcall = NULL; + int open_mode = 0; + unsigned int iounit = 0; + int newfid = -1; + long result = -1; + + dprintk(DEBUG_VFS, "inode: %p file: %p v9fid= %p\n", inode, file, + v9fid); + + if (!v9fid) { + struct dentry *dentry = file->f_dentry; + dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); + + /* XXX - some duplication from lookup, generalize later */ + /* basically vfs_lookup is too heavy weight */ + v9fid = v9fs_fid_lookup(file->f_dentry, FID_OP); + if (!v9fid) + return -EBADF; + + v9fid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); + if (!v9fid) + return -EBADF; + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "newfid fails!\n"); + return -ENOSPC; + } + + result = + v9fs_t_walk(v9ses, v9fid->fid, newfid, + (char *)file->f_dentry->d_name.name, NULL); + if (result < 0) { + v9fs_put_idpool(newfid, &v9ses->fidpool); + dprintk(DEBUG_ERROR, "rewalk didn't work\n"); + return -EBADF; + } + + v9fid = v9fs_fid_create(dentry); + if (v9fid == NULL) { + dprintk(DEBUG_ERROR, "couldn't insert\n"); + return -ENOMEM; + } + v9fid->fid = newfid; + } + + if (v9fid->fidcreate) { + /* create case */ + newfid = v9fid->fid; + iounit = v9fid->iounit; + v9fid->fidcreate = 0; + } else { + if (!S_ISDIR(inode->i_mode)) + newfid = v9fid->fid; + else { + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "allocation failed\n"); + return -ENOSPC; + } + /* This would be a somewhat critical clone */ + result = + v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, + &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "clone error: %s\n", + FCALL_ERROR(fcall)); + kfree(fcall); + return result; + } + + v9newfid = v9fs_fid_create(file->f_dentry); + v9newfid->fid = newfid; + v9newfid->qid = v9fid->qid; + v9newfid->iounit = v9fid->iounit; + v9newfid->fidopen = 0; + v9newfid->fidclunked = 0; + v9newfid->v9ses = v9ses; + v9fid = v9newfid; + kfree(fcall); + } + + /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ + /* translate open mode appropriately */ + open_mode = file->f_flags & 0x3; + + if (file->f_flags & O_EXCL) + open_mode |= V9FS_OEXCL; + + if (v9ses->extended) { + if (file->f_flags & O_TRUNC) + open_mode |= V9FS_OTRUNC; + + if (file->f_flags & O_APPEND) + open_mode |= V9FS_OAPPEND; + } + + result = v9fs_t_open(v9ses, newfid, open_mode, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, + "open failed, open_mode 0x%x: %s\n", open_mode, + FCALL_ERROR(fcall)); + kfree(fcall); + return result; + } + + iounit = fcall->params.ropen.iounit; + kfree(fcall); + } + + + file->private_data = v9fid; + + v9fid->rdir_pos = 0; + v9fid->rdir_fcall = NULL; + v9fid->fidopen = 1; + v9fid->filp = file; + v9fid->iounit = iounit; + + return 0; +} + +/** + * v9fs_file_lock - lock a file (or directory) + * @inode: inode to be opened + * @file: file being opened + * + * XXX - this looks like a local only lock, we should extend into 9P + * by using open exclusive + */ + +static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) +{ + int res = 0; + struct inode *inode = filp->f_dentry->d_inode; + + dprintk(DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); + + /* No mandatory locks */ + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) + return -ENOLCK; + + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { + filemap_fdatawrite(inode->i_mapping); + filemap_fdatawait(inode->i_mapping); + invalidate_inode_pages(&inode->i_data); + } + + return res; +} + +/** + * v9fs_read - read from a file (internal) + * @filep: file pointer to read + * @data: data buffer to read data into + * @count: size of buffer + * @offset: offset at which to read data + * + */ + +static ssize_t +v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9f = filp->private_data; + struct v9fs_fcall *fcall = NULL; + int fid = v9f->fid; + int rsize = 0; + int result = 0; + int total = 0; + + dprintk(DEBUG_VFS, "\n"); + + rsize = v9ses->maxdata - V9FS_IOHDRSZ; + if (v9f->iounit != 0 && rsize > v9f->iounit) + rsize = v9f->iounit; + + do { + if (count < rsize) + rsize = count; + + result = v9fs_t_read(v9ses, fid, *offset, rsize, &fcall); + + if (result < 0) { + printk(KERN_ERR "9P2000: v9fs_t_read returned %d\n", + result); + + kfree(fcall); + return total; + } else + *offset += result; + + /* XXX - extra copy */ + memcpy(buffer, fcall->params.rread.data, result); + count -= result; + buffer += result; + total += result; + + kfree(fcall); + + if (result < rsize) + break; + } while (count); + + return total; +} + +/** + * v9fs_file_read - read from a file + * @filep: file pointer to read + * @data: data buffer to read data into + * @count: size of buffer + * @offset: offset at which to read data + * + */ + +static ssize_t +v9fs_file_read(struct file *filp, char __user * data, size_t count, + loff_t * offset) +{ + int retval = -1; + int ret = 0; + char *buffer; + + buffer = kmalloc(count, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + retval = v9fs_read(filp, buffer, count, offset); + if (retval > 0) { + if ((ret = copy_to_user(data, buffer, retval)) != 0) { + dprintk(DEBUG_ERROR, "Problem copying to user %d\n", + ret); + retval = ret; + } + } + + kfree(buffer); + + return retval; +} + +/** + * v9fs_write - write to a file + * @filep: file pointer to write + * @data: data buffer to write data from + * @count: size of buffer + * @offset: offset at which to write data + * + */ + +static ssize_t +v9fs_write(struct file *filp, char *buffer, size_t count, loff_t * offset) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + struct v9fs_fid *v9fid = filp->private_data; + struct v9fs_fcall *fcall; + int fid = v9fid->fid; + int result = -EIO; + int rsize = 0; + int total = 0; + + dprintk(DEBUG_VFS, "data %p count %d offset %x\n", buffer, (int)count, + (int)*offset); + rsize = v9ses->maxdata - V9FS_IOHDRSZ; + if (v9fid->iounit != 0 && rsize > v9fid->iounit) + rsize = v9fid->iounit; + + dump_data(buffer, count); + + do { + if (count < rsize) + rsize = count; + + result = + v9fs_t_write(v9ses, fid, *offset, rsize, buffer, &fcall); + if (result < 0) { + eprintk(KERN_ERR, "error while writing: %s(%d)\n", + FCALL_ERROR(fcall), result); + kfree(fcall); + return result; + } else + *offset += result; + + kfree(fcall); + + if (result != rsize) { + eprintk(KERN_ERR, + "short write: v9fs_t_write returned %d\n", + result); + break; + } + + count -= result; + buffer += result; + total += result; + } while (count); + + return total; +} + +/** + * v9fs_file_write - write to a file + * @filep: file pointer to write + * @data: data buffer to write data from + * @count: size of buffer + * @offset: offset at which to write data + * + */ + +static ssize_t +v9fs_file_write(struct file *filp, const char __user * data, + size_t count, loff_t * offset) +{ + int ret = -1; + char *buffer; + + buffer = kmalloc(count, GFP_KERNEL); + if (buffer == NULL) + return -ENOMEM; + + ret = copy_from_user(buffer, data, count); + if (ret) { + dprintk(DEBUG_ERROR, "Problem copying from user\n"); + ret = -EFAULT; + } else { + ret = v9fs_write(filp, buffer, count, offset); + } + + kfree(buffer); + + return ret; +} + +struct file_operations v9fs_file_operations = { + .llseek = generic_file_llseek, + .read = v9fs_file_read, + .write = v9fs_file_write, + .open = v9fs_file_open, + .release = v9fs_dir_release, + .lock = v9fs_file_lock, +}; -- cgit v0.10.2 From 2bad8471511ce5cc3ea90d0940622bd4b56b9cce Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:19 -0700 Subject: [PATCH] v9fs: VFS inode operations This part of the patch contains the VFS inode interfaces. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c new file mode 100644 index 0000000..ef78af7 --- /dev/null +++ b/fs/9p/vfs_inode.c @@ -0,0 +1,1371 @@ +/* + * linux/fs/9p/vfs_inode.c + * + * This file contians vfs inode ops for the 9P2000 protocol. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +static struct inode_operations v9fs_dir_inode_operations; +static struct inode_operations v9fs_file_inode_operations; +static struct inode_operations v9fs_symlink_inode_operations; + +/** + * unixmode2p9mode - convert unix mode bits to plan 9 + * @v9ses: v9fs session information + * @mode: mode to convert + * + */ + +static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +{ + int res; + res = mode & 0777; + if (S_ISDIR(mode)) + res |= V9FS_DMDIR; + if (v9ses->extended) { + if (S_ISLNK(mode)) + res |= V9FS_DMSYMLINK; + if (v9ses->nodev == 0) { + if (S_ISSOCK(mode)) + res |= V9FS_DMSOCKET; + if (S_ISFIFO(mode)) + res |= V9FS_DMNAMEDPIPE; + if (S_ISBLK(mode)) + res |= V9FS_DMDEVICE; + if (S_ISCHR(mode)) + res |= V9FS_DMDEVICE; + } + + if ((mode & S_ISUID) == S_ISUID) + res |= V9FS_DMSETUID; + if ((mode & S_ISGID) == S_ISGID) + res |= V9FS_DMSETGID; + if ((mode & V9FS_DMLINK)) + res |= V9FS_DMLINK; + } + + return res; +} + +/** + * p9mode2unixmode- convert plan9 mode bits to unix mode bits + * @v9ses: v9fs session information + * @mode: mode to convert + * + */ + +static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) +{ + int res; + + res = mode & 0777; + + if ((mode & V9FS_DMDIR) == V9FS_DMDIR) + res |= S_IFDIR; + else if ((mode & V9FS_DMSYMLINK) && (v9ses->extended)) + res |= S_IFLNK; + else if ((mode & V9FS_DMSOCKET) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFSOCK; + else if ((mode & V9FS_DMNAMEDPIPE) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFIFO; + else if ((mode & V9FS_DMDEVICE) && (v9ses->extended) + && (v9ses->nodev == 0)) + res |= S_IFBLK; + else + res |= S_IFREG; + + if (v9ses->extended) { + if ((mode & V9FS_DMSETUID) == V9FS_DMSETUID) + res |= S_ISUID; + + if ((mode & V9FS_DMSETGID) == V9FS_DMSETGID) + res |= S_ISGID; + } + + return res; +} + +/** + * v9fs_blank_mistat - helper function to setup a 9P stat structure + * @v9ses: 9P session info (for determining extended mode) + * @mistat: structure to initialize + * + */ + +static inline void +v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) +{ + mistat->type = ~0; + mistat->dev = ~0; + mistat->qid.type = ~0; + mistat->qid.version = ~0; + *((long long *)&mistat->qid.path) = ~0; + mistat->mode = ~0; + mistat->atime = ~0; + mistat->mtime = ~0; + mistat->length = ~0; + mistat->name = mistat->data; + mistat->uid = mistat->data; + mistat->gid = mistat->data; + mistat->muid = mistat->data; + if (v9ses->extended) { + mistat->n_uid = ~0; + mistat->n_gid = ~0; + mistat->n_muid = ~0; + mistat->extension = mistat->data; + } + *mistat->data = 0; +} + +/** + * v9fs_mistat2unix - convert mistat to unix stat + * @mistat: Plan 9 metadata (mistat) structure + * @stat: unix metadata (stat) structure to populate + * @sb: superblock + * + */ + +static void +v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, + struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb ? sb->s_fs_info : NULL; + + buf->st_nlink = 1; + + buf->st_atime = mistat->atime; + buf->st_mtime = mistat->mtime; + buf->st_ctime = mistat->mtime; + + if (v9ses && v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ + buf->st_uid = mistat->n_uid; + buf->st_gid = mistat->n_gid; + + sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); + sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); + } else { + buf->st_uid = v9ses->uid; + buf->st_gid = v9ses->gid; + } + + buf->st_uid = (unsigned short)-1; + buf->st_gid = (unsigned short)-1; + + if (v9ses && v9ses->extended) { + if (mistat->n_uid != -1) + sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); + + if (mistat->n_gid != -1) + sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); + } + + if (buf->st_uid == (unsigned short)-1) + buf->st_uid = v9ses->uid; + if (buf->st_gid == (unsigned short)-1) + buf->st_gid = v9ses->gid; + + buf->st_mode = p9mode2unixmode(v9ses, mistat->mode); + if ((S_ISBLK(buf->st_mode)) || (S_ISCHR(buf->st_mode))) { + char type = 0; + int major = -1; + int minor = -1; + sscanf(mistat->extension, "%c %u %u", &type, &major, &minor); + switch (type) { + case 'c': + buf->st_mode &= ~S_IFBLK; + buf->st_mode |= S_IFCHR; + break; + case 'b': + break; + default: + dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n", + type, mistat->extension); + }; + buf->st_rdev = MKDEV(major, minor); + } else + buf->st_rdev = 0; + + buf->st_size = mistat->length; + + buf->st_blksize = sb->s_blocksize; + buf->st_blocks = + (buf->st_size + buf->st_blksize - 1) >> sb->s_blocksize_bits; +} + +/** + * v9fs_get_inode - helper function to setup an inode + * @sb: superblock + * @mode: mode to setup inode with + * + */ + +struct inode *v9fs_get_inode(struct super_block *sb, int mode) +{ + struct inode *inode = NULL; + + dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); + + inode = new_inode(sb); + if (inode) { + inode->i_mode = mode; + inode->i_uid = current->fsuid; + inode->i_gid = current->fsgid; + inode->i_blksize = sb->s_blocksize; + inode->i_blocks = 0; + inode->i_rdev = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + + switch (mode & S_IFMT) { + case S_IFIFO: + case S_IFBLK: + case S_IFCHR: + case S_IFSOCK: + case S_IFREG: + inode->i_op = &v9fs_file_inode_operations; + inode->i_fop = &v9fs_file_operations; + break; + case S_IFDIR: + inode->i_nlink++; + inode->i_op = &v9fs_dir_inode_operations; + inode->i_fop = &v9fs_dir_operations; + break; + case S_IFLNK: + inode->i_op = &v9fs_symlink_inode_operations; + break; + default: + dprintk(DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", + mode, mode & S_IFMT); + return ERR_PTR(-EINVAL); + } + } else { + eprintk(KERN_WARNING, "Problem allocating inode\n"); + return ERR_PTR(-ENOMEM); + } + return inode; +} + +/** + * v9fs_create - helper function to create files and directories + * @dir: directory inode file is being created in + * @file_dentry: dentry file is being created in + * @perm: permissions file is being created with + * @open_mode: resulting open mode for file ??? + * + */ + +static int +v9fs_create(struct inode *dir, + struct dentry *file_dentry, + unsigned int perm, unsigned int open_mode) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct super_block *sb = dir->i_sb; + struct v9fs_fid *dirfid = + v9fs_fid_lookup(file_dentry->d_parent, FID_WALK); + struct v9fs_fid *fid = NULL; + struct inode *file_inode = NULL; + struct v9fs_fcall *fcall = NULL; + struct v9fs_qid qid; + struct stat newstat; + int dirfidnum = -1; + long newfid = -1; + int result = 0; + unsigned int iounit = 0; + + perm = unixmode2p9mode(v9ses, perm); + + dprintk(DEBUG_VFS, "dir: %p dentry: %p perm: %o mode: %o\n", dir, + file_dentry, perm, open_mode); + + if (!dirfid) + return -EBADF; + + dirfidnum = dirfid->fid; + if (dirfidnum < 0) { + dprintk(DEBUG_ERROR, "No fid for the directory #%lu\n", + dir->i_ino); + return -EBADF; + } + + if (file_dentry->d_inode) { + dprintk(DEBUG_ERROR, + "Odd. There is an inode for dir %lu, name :%s:\n", + dir->i_ino, file_dentry->d_name.name); + return -EEXIST; + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "no free fids available\n"); + return -ENOSPC; + } + + result = v9fs_t_walk(v9ses, dirfidnum, newfid, NULL, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); + v9fs_put_idpool(newfid, &v9ses->fidpool); + newfid = 0; + goto CleanUpFid; + } + + kfree(fcall); + + result = v9fs_t_create(v9ses, newfid, (char *)file_dentry->d_name.name, + perm, open_mode, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "create fails: %s(%d)\n", + FCALL_ERROR(fcall), result); + + goto CleanUpFid; + } + + iounit = fcall->params.rcreate.iounit; + qid = fcall->params.rcreate.qid; + kfree(fcall); + + fid = v9fs_fid_create(file_dentry); + if (!fid) { + result = -ENOMEM; + goto CleanUpFid; + } + + fid->fid = newfid; + fid->fidopen = 0; + fid->fidcreate = 1; + fid->qid = qid; + fid->iounit = iounit; + fid->rdir_pos = 0; + fid->rdir_fcall = NULL; + fid->v9ses = v9ses; + + if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || + (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || + (perm & V9FS_DMDEVICE)) + return 0; + + result = v9fs_t_stat(v9ses, newfid, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "stat error: %s(%d)\n", FCALL_ERROR(fcall), + result); + goto CleanUpFid; + } + + v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb); + + file_inode = v9fs_get_inode(sb, newstat.st_mode); + if ((!file_inode) || IS_ERR(file_inode)) { + dprintk(DEBUG_ERROR, "create inode failed\n"); + result = -EBADF; + goto CleanUpFid; + } + + v9fs_mistat2inode(fcall->params.rstat.stat, file_inode, sb); + kfree(fcall); + d_instantiate(file_dentry, file_inode); + + if (perm & V9FS_DMDIR) { + if (v9fs_t_clunk(v9ses, newfid, &fcall)) + dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(newfid, &v9ses->fidpool); + kfree(fcall); + fid->fidopen = 0; + fid->fidcreate = 0; + d_drop(file_dentry); + } + + return 0; + + CleanUpFid: + kfree(fcall); + + if (newfid) { + if (v9fs_t_clunk(v9ses, newfid, &fcall)) + dprintk(DEBUG_ERROR, "clunk failed: %s\n", + FCALL_ERROR(fcall)); + + v9fs_put_idpool(newfid, &v9ses->fidpool); + kfree(fcall); + } + return result; +} + +/** + * v9fs_remove - helper function to remove files and directories + * @inode: directory inode that is being deleted + * @dentry: dentry that is being deleted + * @rmdir: where we are a file or a directory + * + */ + +static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir) +{ + struct v9fs_fcall *fcall = NULL; + struct super_block *sb = NULL; + struct v9fs_session_info *v9ses = NULL; + struct v9fs_fid *v9fid = NULL; + struct inode *file_inode = NULL; + int fid = -1; + int result = 0; + + dprintk(DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file, + rmdir); + + file_inode = file->d_inode; + sb = file_inode->i_sb; + v9ses = v9fs_inode2v9ses(file_inode); + v9fid = v9fs_fid_lookup(file, FID_OP); + + if (!v9fid) { + dprintk(DEBUG_ERROR, + "no v9fs_fid\n"); + return -EBADF; + } + + fid = v9fid->fid; + if (fid < 0) { + dprintk(DEBUG_ERROR, "inode #%lu, no fid!\n", + file_inode->i_ino); + return -EBADF; + } + + result = v9fs_t_remove(v9ses, fid, &fcall); + if (result < 0) + dprintk(DEBUG_ERROR, "remove of file fails: %s(%d)\n", + FCALL_ERROR(fcall), result); + else { + v9fs_put_idpool(fid, &v9ses->fidpool); + v9fs_fid_destroy(v9fid); + } + + kfree(fcall); + return result; +} + +/** + * v9fs_vfs_create - VFS hook to create files + * @inode: directory inode that is being deleted + * @dentry: dentry that is being deleted + * @perm: create permissions + * @nd: path information + * + */ + +static int +v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, + struct nameidata *nd) +{ + return v9fs_create(inode, dentry, perm, O_RDWR); +} + +/** + * v9fs_vfs_mkdir - VFS mkdir hook to create a directory + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * @mode: mode for new directory + * + */ + +static int v9fs_vfs_mkdir(struct inode *inode, struct dentry *dentry, int mode) +{ + return v9fs_create(inode, dentry, mode | S_IFDIR, O_RDONLY); +} + +/** + * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode + * @dir: inode that is being walked from + * @dentry: dentry that is being walked to? + * @nameidata: path data + * + */ + +static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, + struct nameidata *nameidata) +{ + struct super_block *sb; + struct v9fs_session_info *v9ses; + struct v9fs_fid *dirfid; + struct v9fs_fid *fid; + struct inode *inode; + struct v9fs_fcall *fcall = NULL; + struct stat newstat; + int dirfidnum = -1; + int newfid = -1; + int result = 0; + + dprintk(DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n", + dir, dentry->d_iname, dentry, nameidata); + + sb = dir->i_sb; + v9ses = v9fs_inode2v9ses(dir); + dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); + + if (!dirfid) { + dprintk(DEBUG_ERROR, "no dirfid\n"); + return ERR_PTR(-EINVAL); + } + + dirfidnum = dirfid->fid; + + if (dirfidnum < 0) { + dprintk(DEBUG_ERROR, "no dirfid for inode %p, #%lu\n", + dir, dir->i_ino); + return ERR_PTR(-EBADF); + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "newfid fails!\n"); + return ERR_PTR(-ENOSPC); + } + + result = + v9fs_t_walk(v9ses, dirfidnum, newfid, (char *)dentry->d_name.name, + NULL); + if (result < 0) { + v9fs_put_idpool(newfid, &v9ses->fidpool); + if (result == -ENOENT) { + d_add(dentry, NULL); + dprintk(DEBUG_ERROR, + "Return negative dentry %p count %d\n", + dentry, atomic_read(&dentry->d_count)); + return NULL; + } + dprintk(DEBUG_ERROR, "walk error:%d\n", result); + goto FreeFcall; + } + + result = v9fs_t_stat(v9ses, newfid, &fcall); + if (result < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + goto FreeFcall; + } + + v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb); + inode = v9fs_get_inode(sb, newstat.st_mode); + + if (IS_ERR(inode) && (PTR_ERR(inode) == -ENOSPC)) { + eprintk(KERN_WARNING, "inode alloc failes, returns %ld\n", + PTR_ERR(inode)); + + result = -ENOSPC; + goto FreeFcall; + } + + inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); + + fid = v9fs_fid_create(dentry); + if (fid == NULL) { + dprintk(DEBUG_ERROR, "couldn't insert\n"); + result = -ENOMEM; + goto FreeFcall; + } + + fid->fid = newfid; + fid->fidopen = 0; + fid->v9ses = v9ses; + fid->qid = fcall->params.rstat.stat->qid; + + dentry->d_op = &v9fs_dentry_operations; + v9fs_mistat2inode(fcall->params.rstat.stat, inode, inode->i_sb); + + d_add(dentry, inode); + kfree(fcall); + + return NULL; + + FreeFcall: + kfree(fcall); + return ERR_PTR(result); +} + +/** + * v9fs_vfs_unlink - VFS unlink hook to delete an inode + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * + */ + +static int v9fs_vfs_unlink(struct inode *i, struct dentry *d) +{ + return v9fs_remove(i, d, 0); +} + +/** + * v9fs_vfs_rmdir - VFS unlink hook to delete a directory + * @i: inode that is being unlinked + * @dentry: dentry that is being unlinked + * + */ + +static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d) +{ + return v9fs_remove(i, d, 1); +} + +/** + * v9fs_vfs_rename - VFS hook to rename an inode + * @old_dir: old dir inode + * @old_dentry: old dentry + * @new_dir: new dir inode + * @new_dentry: new dentry + * + */ + +static int +v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +{ + struct inode *old_inode = old_dentry->d_inode; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK); + struct v9fs_fid *olddirfid = + v9fs_fid_lookup(old_dentry->d_parent, FID_WALK); + struct v9fs_fid *newdirfid = + v9fs_fid_lookup(new_dentry->d_parent, FID_WALK); + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fcall *fcall = NULL; + int fid = -1; + int olddirfidnum = -1; + int newdirfidnum = -1; + int retval = 0; + + dprintk(DEBUG_VFS, "\n"); + + if ((!oldfid) || (!olddirfid) || (!newdirfid)) { + dprintk(DEBUG_ERROR, "problem with arguments\n"); + return -EBADF; + } + + /* 9P can only handle file rename in the same directory */ + if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) { + dprintk(DEBUG_ERROR, "old dir and new dir are different\n"); + retval = -EPERM; + goto FreeFcallnBail; + } + + fid = oldfid->fid; + olddirfidnum = olddirfid->fid; + newdirfidnum = newdirfid->fid; + + if (fid < 0) { + dprintk(DEBUG_ERROR, "no fid for old file #%lu\n", + old_inode->i_ino); + retval = -EBADF; + goto FreeFcallnBail; + } + + v9fs_blank_mistat(v9ses, mistat); + + strcpy(mistat->data + 1, v9ses->name); + mistat->name = mistat->data + 1 + strlen(v9ses->name); + + if (new_dentry->d_name.len > + (v9ses->maxdata - strlen(v9ses->name) - sizeof(struct v9fs_stat))) { + dprintk(DEBUG_ERROR, "new name too long\n"); + goto FreeFcallnBail; + } + + strcpy(mistat->name, new_dentry->d_name.name); + retval = v9fs_t_wstat(v9ses, fid, mistat, &fcall); + + FreeFcallnBail: + kfree(mistat); + + if (retval < 0) + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + + kfree(fcall); + return retval; +} + +/** + * v9fs_vfs_getattr - retreive file metadata + * @mnt - mount information + * @dentry - file to get attributes on + * @stat - metadata structure to populate + * + */ + +static int +v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct v9fs_fcall *fcall = NULL; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + int err = -EPERM; + + dprintk(DEBUG_VFS, "dentry: %p\n", dentry); + if (!fid) { + dprintk(DEBUG_ERROR, + "couldn't find fid associated with dentry\n"); + return -EBADF; + } + + err = v9fs_t_stat(v9ses, fid->fid, &fcall); + + if (err < 0) + dprintk(DEBUG_ERROR, "stat error\n"); + else { + v9fs_mistat2inode(fcall->params.rstat.stat, dentry->d_inode, + dentry->d_inode->i_sb); + generic_fillattr(dentry->d_inode, stat); + } + + kfree(fcall); + return err; +} + +/** + * v9fs_vfs_setattr - set file metadata + * @dentry: file whose metadata to set + * @iattr: metadata assignment structure + * + */ + +static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) +{ + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fcall *fcall = NULL; + int res = -EPERM; + + dprintk(DEBUG_VFS, "\n"); + if (!fid) { + dprintk(DEBUG_ERROR, + "Couldn't find fid associated with dentry\n"); + return -EBADF; + } + + if (!mistat) + return -ENOMEM; + + v9fs_blank_mistat(v9ses, mistat); + if (iattr->ia_valid & ATTR_MODE) + mistat->mode = unixmode2p9mode(v9ses, iattr->ia_mode); + + if (iattr->ia_valid & ATTR_MTIME) + mistat->mtime = iattr->ia_mtime.tv_sec; + + if (iattr->ia_valid & ATTR_ATIME) + mistat->atime = iattr->ia_atime.tv_sec; + + if (iattr->ia_valid & ATTR_SIZE) + mistat->length = iattr->ia_size; + + if (v9ses->extended) { + char *uid = kmalloc(strlen(mistat->uid), GFP_KERNEL); + char *gid = kmalloc(strlen(mistat->gid), GFP_KERNEL); + char *muid = kmalloc(strlen(mistat->muid), GFP_KERNEL); + char *name = kmalloc(strlen(mistat->name), GFP_KERNEL); + char *extension = kmalloc(strlen(mistat->extension), + GFP_KERNEL); + + if ((!uid) || (!gid) || (!muid) || (!name) || (!extension)) { + kfree(uid); + kfree(gid); + kfree(muid); + kfree(name); + kfree(extension); + + return -ENOMEM; + } + + strcpy(uid, mistat->uid); + strcpy(gid, mistat->gid); + strcpy(muid, mistat->muid); + strcpy(name, mistat->name); + strcpy(extension, mistat->extension); + + if (iattr->ia_valid & ATTR_UID) { + if (strlen(uid) != 8) { + dprintk(DEBUG_ERROR, "uid strlen is %u not 8\n", + (unsigned int)strlen(uid)); + sprintf(uid, "%08x", iattr->ia_uid); + } else { + kfree(uid); + uid = kmalloc(9, GFP_KERNEL); + } + + sprintf(uid, "%08x", iattr->ia_uid); + mistat->n_uid = iattr->ia_uid; + } + + if (iattr->ia_valid & ATTR_GID) { + if (strlen(gid) != 8) + dprintk(DEBUG_ERROR, "gid strlen is %u not 8\n", + (unsigned int)strlen(gid)); + else { + kfree(gid); + gid = kmalloc(9, GFP_KERNEL); + } + + sprintf(gid, "%08x", iattr->ia_gid); + mistat->n_gid = iattr->ia_gid; + } + + mistat->uid = mistat->data; + strcpy(mistat->uid, uid); + mistat->gid = mistat->data + strlen(uid) + 1; + strcpy(mistat->gid, gid); + mistat->muid = mistat->gid + strlen(gid) + 1; + strcpy(mistat->muid, muid); + mistat->name = mistat->muid + strlen(muid) + 1; + strcpy(mistat->name, name); + mistat->extension = mistat->name + strlen(name) + 1; + strcpy(mistat->extension, extension); + + kfree(uid); + kfree(gid); + kfree(muid); + kfree(name); + kfree(extension); + } + + res = v9fs_t_wstat(v9ses, fid->fid, mistat, &fcall); + + if (res < 0) + dprintk(DEBUG_ERROR, "wstat error: %s\n", FCALL_ERROR(fcall)); + + kfree(mistat); + kfree(fcall); + + if (res >= 0) + res = inode_setattr(dentry->d_inode, iattr); + + return res; +} + +/** + * v9fs_mistat2inode - populate an inode structure with mistat info + * @mistat: Plan 9 metadata (mistat) structure + * @inode: inode to populate + * @sb: superblock of filesystem + * + */ + +void +v9fs_mistat2inode(struct v9fs_stat *mistat, struct inode *inode, + struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb->s_fs_info; + + inode->i_nlink = 1; + + inode->i_atime.tv_sec = mistat->atime; + inode->i_mtime.tv_sec = mistat->mtime; + inode->i_ctime.tv_sec = mistat->mtime; + + inode->i_uid = -1; + inode->i_gid = -1; + + if (v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ + inode->i_uid = mistat->n_uid; + inode->i_gid = mistat->n_gid; + + if (mistat->n_uid == -1) + sscanf(mistat->uid, "%x", &inode->i_uid); + + if (mistat->n_gid == -1) + sscanf(mistat->gid, "%x", &inode->i_gid); + } + + if (inode->i_uid == -1) + inode->i_uid = v9ses->uid; + if (inode->i_gid == -1) + inode->i_gid = v9ses->gid; + + inode->i_mode = p9mode2unixmode(v9ses, mistat->mode); + if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { + char type = 0; + int major = -1; + int minor = -1; + sscanf(mistat->extension, "%c %u %u", &type, &major, &minor); + switch (type) { + case 'c': + inode->i_mode &= ~S_IFBLK; + inode->i_mode |= S_IFCHR; + break; + case 'b': + break; + default: + dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n", + type, mistat->extension); + }; + inode->i_rdev = MKDEV(major, minor); + } else + inode->i_rdev = 0; + + inode->i_size = mistat->length; + + inode->i_blksize = sb->s_blocksize; + inode->i_blocks = + (inode->i_size + inode->i_blksize - 1) >> sb->s_blocksize_bits; +} + +/** + * v9fs_qid2ino - convert qid into inode number + * @qid: qid to hash + * + * BUG: potential for inode number collisions? + */ + +ino_t v9fs_qid2ino(struct v9fs_qid *qid) +{ + u64 path = qid->path + 2; + ino_t i = 0; + + if (sizeof(ino_t) == sizeof(path)) + memcpy(&i, &path, sizeof(ino_t)); + else + i = (ino_t) (path ^ (path >> 32)); + + return i; +} + +/** + * v9fs_vfs_symlink - helper function to create symlinks + * @dir: directory inode containing symlink + * @dentry: dentry for symlink + * @symname: symlink data + * + * See 9P2000.u RFC for more information + * + */ + +static int +v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) +{ + int retval = -EPERM; + struct v9fs_fid *newfid; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct super_block *sb = dir ? dir->i_sb : NULL; + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + + dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, + symname); + + if ((!dentry) || (!sb) || (!v9ses)) { + dprintk(DEBUG_ERROR, "problem with arguments\n"); + return -EBADF; + } + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeFcall; + } + + /* issue a create */ + retval = v9fs_create(dir, dentry, S_IFLNK, 0); + if (retval != 0) + goto FreeFcall; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeFcall; + } + + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeFcall; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + FreeFcall: + kfree(mistat); + kfree(fcall); + + return retval; +} + +/** + * v9fs_readlink - read a symlink's location (internal version) + * @dentry: dentry for symlink + * @buf: buffer to load symlink location into + * @buflen: length of buffer + * + */ + +static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) +{ + int retval = -EPERM; + + struct v9fs_fcall *fcall = NULL; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); + struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); + + if (!fid) { + dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); + retval = -EBADF; + goto FreeFcall; + } + + if (!v9ses->extended) { + retval = -EBADF; + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeFcall; + } + + dprintk(DEBUG_VFS, " %s\n", dentry->d_name.name); + retval = v9fs_t_stat(v9ses, fid->fid, &fcall); + + if (retval < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + goto FreeFcall; + } + + if (!fcall) + return -EIO; + + if (!(fcall->params.rstat.stat->mode & V9FS_DMSYMLINK)) { + retval = -EINVAL; + goto FreeFcall; + } + + /* copy extension buffer into buffer */ + if (strlen(fcall->params.rstat.stat->extension) < buflen) + buflen = strlen(fcall->params.rstat.stat->extension); + + memcpy(buffer, fcall->params.rstat.stat->extension, buflen + 1); + + retval = buflen; + + FreeFcall: + kfree(fcall); + + return retval; +} + +/** + * v9fs_vfs_readlink - read a symlink's location + * @dentry: dentry for symlink + * @buf: buffer to load symlink location into + * @buflen: length of buffer + * + */ + +static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer, + int buflen) +{ + int retval; + int ret; + char *link = __getname(); + + if (strlen(link) < buflen) + buflen = strlen(link); + + dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); + + retval = v9fs_readlink(dentry, link, buflen); + + if (retval > 0) { + if ((ret = copy_to_user(buffer, link, retval)) != 0) { + dprintk(DEBUG_ERROR, "problem copying to user: %d\n", + ret); + retval = ret; + } + } + + putname(link); + return retval; +} + +/** + * v9fs_vfs_follow_link - follow a symlink path + * @dentry: dentry for symlink + * @nd: nameidata + * + */ + +static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) +{ + int len = 0; + char *link = __getname(); + + dprintk(DEBUG_VFS, "%s n", dentry->d_name.name); + + if (!link) + link = ERR_PTR(-ENOMEM); + else { + len = v9fs_readlink(dentry, link, strlen(link)); + + if (len < 0) { + putname(link); + link = ERR_PTR(len); + } else + link[len] = 0; + } + nd_set_link(nd, link); + + return NULL; +} + +/** + * v9fs_vfs_put_link - release a symlink path + * @dentry: dentry for symlink + * @nd: nameidata + * + */ + +static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) +{ + char *s = nd_get_link(nd); + + dprintk(DEBUG_VFS, " %s %s\n", dentry->d_name.name, s); + if (!IS_ERR(s)) + putname(s); +} + +/** + * v9fs_vfs_link - create a hardlink + * @old_dentry: dentry for file to link to + * @dir: inode destination for new link + * @new_dentry: dentry for link + * + */ + +/* XXX - lots of code dup'd from symlink and creates, + * figure out a better reuse strategy + */ + +static int +v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, + struct dentry *dentry) +{ + int retval = -EPERM; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP); + struct v9fs_fid *newfid = NULL; + char *symname = __getname(); + + dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, + old_dentry->d_name.name); + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeMem; + } + + /* get fid of old_dentry */ + sprintf(symname, "hardlink(%d)\n", oldfid->fid); + + /* issue a create */ + retval = v9fs_create(dir, dentry, V9FS_DMLINK, 0); + if (retval != 0) + goto FreeMem; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + if (!newfid) { + dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); + goto FreeMem; + } + + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + kfree(fcall); + fcall = NULL; + + FreeMem: + kfree(mistat); + kfree(fcall); + putname(symname); + return retval; +} + +/** + * v9fs_vfs_mknod - create a special file + * @dir: inode destination for new link + * @dentry: dentry for file + * @mode: mode for creation + * @dev_t: device associated with special file + * + */ + +static int +v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +{ + int retval = -EPERM; + struct v9fs_fid *newfid; + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); + struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); + char *symname = __getname(); + + dprintk(DEBUG_VFS, " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, + dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); + + if (!new_valid_dev(rdev)) { + retval = -EINVAL; + goto FreeMem; + } + + if (!v9ses->extended) { + dprintk(DEBUG_ERROR, "not extended\n"); + goto FreeMem; + } + + /* issue a create */ + retval = v9fs_create(dir, dentry, mode, 0); + + if (retval != 0) + goto FreeMem; + + newfid = v9fs_fid_lookup(dentry, FID_OP); + if (!newfid) { + dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); + retval = -EINVAL; + goto FreeMem; + } + + /* build extension */ + if (S_ISBLK(mode)) + sprintf(symname, "b %u %u", MAJOR(rdev), MINOR(rdev)); + else if (S_ISCHR(mode)) + sprintf(symname, "c %u %u", MAJOR(rdev), MINOR(rdev)); + else if (S_ISFIFO(mode)) ; /* DO NOTHING */ + else { + retval = -EINVAL; + goto FreeMem; + } + + if (!S_ISFIFO(mode)) { + /* issue a twstat */ + v9fs_blank_mistat(v9ses, mistat); + strcpy(mistat->data + 1, symname); + mistat->extension = mistat->data + 1; + retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall); + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + kfree(fcall); + } + + /* need to update dcache so we show up */ + kfree(fcall); + + if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) { + dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n", + FCALL_ERROR(fcall)); + goto FreeMem; + } + + d_drop(dentry); /* FID - will this also clunk? */ + + FreeMem: + kfree(mistat); + kfree(fcall); + putname(symname); + + return retval; +} + +static struct inode_operations v9fs_dir_inode_operations = { + .create = v9fs_vfs_create, + .lookup = v9fs_vfs_lookup, + .symlink = v9fs_vfs_symlink, + .link = v9fs_vfs_link, + .unlink = v9fs_vfs_unlink, + .mkdir = v9fs_vfs_mkdir, + .rmdir = v9fs_vfs_rmdir, + .mknod = v9fs_vfs_mknod, + .rename = v9fs_vfs_rename, + .readlink = v9fs_vfs_readlink, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + +static struct inode_operations v9fs_file_inode_operations = { + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + +static struct inode_operations v9fs_symlink_inode_operations = { + .readlink = v9fs_vfs_readlink, + .follow_link = v9fs_vfs_follow_link, + .put_link = v9fs_vfs_put_link, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; -- cgit v0.10.2 From 9e82cf6a802a72f0f447eb4c76d6a3fc8736a31d Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:20 -0700 Subject: [PATCH] v9fs: VFS superblock operations and glue This part of the patch contains VFS superblock and mapping code. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c new file mode 100644 index 0000000..14d663e --- /dev/null +++ b/fs/9p/v9fs.c @@ -0,0 +1,448 @@ +/* + * linux/fs/9p/v9fs.c + * + * This file contains functions assisting in mapping VFS to 9P2000 + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "transport.h" +#include "mux.h" +#include "conv.h" + +/* TODO: sysfs or debugfs interface */ +int v9fs_debug_level = 0; /* feature-rific global debug level */ + +/* + * Option Parsing (code inspired by NFS code) + * + */ + +enum { + /* Options that take integer arguments */ + Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug, + Opt_rfdno, Opt_wfdno, + /* String options */ + Opt_name, Opt_remotename, + /* Options that take no arguments */ + Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd, + /* Error token */ + Opt_err +}; + +static match_table_t tokens = { + {Opt_port, "port=%u"}, + {Opt_msize, "msize=%u"}, + {Opt_uid, "uid=%u"}, + {Opt_gid, "gid=%u"}, + {Opt_afid, "afid=%u"}, + {Opt_rfdno, "rfdno=%u"}, + {Opt_wfdno, "wfdno=%u"}, + {Opt_debug, "debug=%u"}, + {Opt_name, "name=%s"}, + {Opt_remotename, "aname=%s"}, + {Opt_unix, "proto=unix"}, + {Opt_tcp, "proto=tcp"}, + {Opt_fd, "proto=fd"}, + {Opt_tcp, "tcp"}, + {Opt_unix, "unix"}, + {Opt_fd, "fd"}, + {Opt_legacy, "noextend"}, + {Opt_nodevmap, "nodevmap"}, + {Opt_err, NULL} +}; + +/* + * Parse option string. + */ + +/** + * v9fs_parse_options - parse mount options into session structure + * @options: options string passed from mount + * @v9ses: existing v9fs session information + * + */ + +static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses) +{ + char *p; + substring_t args[MAX_OPT_ARGS]; + int option; + int ret; + + /* setup defaults */ + v9ses->port = V9FS_PORT; + v9ses->maxdata = 9000; + v9ses->proto = PROTO_TCP; + v9ses->extended = 1; + v9ses->afid = ~0; + v9ses->debug = 0; + v9ses->rfdno = ~0; + v9ses->wfdno = ~0; + + if (!options) + return; + + while ((p = strsep(&options, ",")) != NULL) { + int token; + if (!*p) + continue; + token = match_token(p, tokens, args); + if (token < Opt_name) { + if ((ret = match_int(&args[0], &option)) < 0) { + dprintk(DEBUG_ERROR, + "integer field, but no integer?\n"); + continue; + } + + } + switch (token) { + case Opt_port: + v9ses->port = option; + break; + case Opt_msize: + v9ses->maxdata = option; + break; + case Opt_uid: + v9ses->uid = option; + break; + case Opt_gid: + v9ses->gid = option; + break; + case Opt_afid: + v9ses->afid = option; + break; + case Opt_rfdno: + v9ses->rfdno = option; + break; + case Opt_wfdno: + v9ses->wfdno = option; + break; + case Opt_debug: + v9ses->debug = option; + break; + case Opt_tcp: + v9ses->proto = PROTO_TCP; + break; + case Opt_unix: + v9ses->proto = PROTO_UNIX; + break; + case Opt_fd: + v9ses->proto = PROTO_FD; + break; + case Opt_name: + match_strcpy(v9ses->name, &args[0]); + break; + case Opt_remotename: + match_strcpy(v9ses->remotename, &args[0]); + break; + case Opt_legacy: + v9ses->extended = 0; + break; + case Opt_nodevmap: + v9ses->nodev = 1; + break; + default: + continue; + } + } +} + +/** + * v9fs_inode2v9ses - safely extract v9fs session info from super block + * @inode: inode to extract information from + * + * Paranoid function to extract v9ses information from superblock, + * if anything is missing it will report an error. + * + */ + +struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode) +{ + return (inode->i_sb->s_fs_info); +} + +/** + * v9fs_get_idpool - allocate numeric id from pool + * @p - pool to allocate from + * + * XXX - This seems to be an awful generic function, should it be in idr.c with + * the lock included in struct idr? + */ + +int v9fs_get_idpool(struct v9fs_idpool *p) +{ + int i = 0; + int error; + +retry: + if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) + return 0; + + if (down_interruptible(&p->lock) == -EINTR) { + eprintk(KERN_WARNING, "Interrupted while locking\n"); + return -1; + } + + error = idr_get_new(&p->pool, NULL, &i); + up(&p->lock); + + if (error == -EAGAIN) + goto retry; + else if (error) + return -1; + + return i; +} + +/** + * v9fs_put_idpool - release numeric id from pool + * @p - pool to allocate from + * + * XXX - This seems to be an awful generic function, should it be in idr.c with + * the lock included in struct idr? + */ + +void v9fs_put_idpool(int id, struct v9fs_idpool *p) +{ + if (down_interruptible(&p->lock) == -EINTR) { + eprintk(KERN_WARNING, "Interrupted while locking\n"); + return; + } + idr_remove(&p->pool, id); + up(&p->lock); +} + +/** + * v9fs_session_init - initialize session + * @v9ses: session information structure + * @dev_name: device being mounted + * @data: options + * + */ + +int +v9fs_session_init(struct v9fs_session_info *v9ses, + const char *dev_name, char *data) +{ + struct v9fs_fcall *fcall = NULL; + struct v9fs_transport *trans_proto; + int n = 0; + int newfid = -1; + int retval = -EINVAL; + + v9ses->name = __getname(); + if (!v9ses->name) + return -ENOMEM; + + v9ses->remotename = __getname(); + if (!v9ses->remotename) { + putname(v9ses->name); + return -ENOMEM; + } + + strcpy(v9ses->name, V9FS_DEFUSER); + strcpy(v9ses->remotename, V9FS_DEFANAME); + + v9fs_parse_options(data, v9ses); + + /* set global debug level */ + v9fs_debug_level = v9ses->debug; + + /* id pools that are session-dependent: FIDs and TIDs */ + idr_init(&v9ses->fidpool.pool); + init_MUTEX(&v9ses->fidpool.lock); + idr_init(&v9ses->tidpool.pool); + init_MUTEX(&v9ses->tidpool.lock); + + + switch (v9ses->proto) { + case PROTO_TCP: + trans_proto = &v9fs_trans_tcp; + break; + case PROTO_UNIX: + trans_proto = &v9fs_trans_unix; + *v9ses->remotename = 0; + break; + case PROTO_FD: + trans_proto = &v9fs_trans_fd; + *v9ses->remotename = 0; + if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { + printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); + retval = -ENOPROTOOPT; + goto SessCleanUp; + } + break; + default: + printk(KERN_ERR "v9fs: Bad mount protocol %d\n", v9ses->proto); + retval = -ENOPROTOOPT; + goto SessCleanUp; + }; + + v9ses->transport = trans_proto; + + if ((retval = v9ses->transport->init(v9ses, dev_name, data)) < 0) { + eprintk(KERN_ERR, "problem initializing transport\n"); + goto SessCleanUp; + } + + v9ses->inprogress = 0; + v9ses->shutdown = 0; + v9ses->session_hung = 0; + + if ((retval = v9fs_mux_init(v9ses, dev_name)) < 0) { + dprintk(DEBUG_ERROR, "problem initializing mux\n"); + goto SessCleanUp; + } + + if (v9ses->afid == ~0) { + if (v9ses->extended) + retval = + v9fs_t_version(v9ses, v9ses->maxdata, "9P2000.u", + &fcall); + else + retval = v9fs_t_version(v9ses, v9ses->maxdata, "9P2000", + &fcall); + + if (retval < 0) { + dprintk(DEBUG_ERROR, "v9fs_t_version failed\n"); + goto FreeFcall; + } + + /* Really should check for 9P1 and report error */ + if (!strcmp(fcall->params.rversion.version, "9P2000.u")) { + dprintk(DEBUG_9P, "9P2000 UNIX extensions enabled\n"); + v9ses->extended = 1; + } else { + dprintk(DEBUG_9P, "9P2000 legacy mode enabled\n"); + v9ses->extended = 0; + } + + n = fcall->params.rversion.msize; + kfree(fcall); + + if (n < v9ses->maxdata) + v9ses->maxdata = n; + } + + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "couldn't allocate FID\n"); + retval = -ENOMEM; + goto SessCleanUp; + } + /* it is a little bit ugly, but we have to prevent newfid */ + /* being the same as afid, so if it is, get a new fid */ + if (v9ses->afid != ~0 && newfid == v9ses->afid) { + newfid = v9fs_get_idpool(&v9ses->fidpool); + if (newfid < 0) { + eprintk(KERN_WARNING, "couldn't allocate FID\n"); + retval = -ENOMEM; + goto SessCleanUp; + } + } + + if ((retval = + v9fs_t_attach(v9ses, v9ses->name, v9ses->remotename, newfid, + v9ses->afid, NULL)) + < 0) { + dprintk(DEBUG_ERROR, "cannot attach\n"); + goto SessCleanUp; + } + + if (v9ses->afid != ~0) { + if (v9fs_t_clunk(v9ses, v9ses->afid, NULL)) + dprintk(DEBUG_ERROR, "clunk failed\n"); + } + + return newfid; + + FreeFcall: + kfree(fcall); + + SessCleanUp: + v9fs_session_close(v9ses); + return retval; +} + +/** + * v9fs_session_close - shutdown a session + * @v9ses: session information structure + * + */ + +void v9fs_session_close(struct v9fs_session_info *v9ses) +{ + if (v9ses->recvproc) { + send_sig(SIGKILL, v9ses->recvproc, 1); + wait_for_completion(&v9ses->proccmpl); + } + + if (v9ses->transport) + v9ses->transport->close(v9ses->transport); + + putname(v9ses->name); + putname(v9ses->remotename); +} + +extern int v9fs_error_init(void); + +/** + * v9fs_init - Initialize module + * + */ + +static int __init init_v9fs(void) +{ + v9fs_error_init(); + + printk(KERN_INFO "Installing v9fs 9P2000 file system support\n"); + + return register_filesystem(&v9fs_fs_type); +} + +/** + * v9fs_init - shutdown module + * + */ + +static void __exit exit_v9fs(void) +{ + unregister_filesystem(&v9fs_fs_type); +} + +module_init(init_v9fs) +module_exit(exit_v9fs) + +MODULE_AUTHOR("Eric Van Hensbergen "); +MODULE_AUTHOR("Ron Minnich "); +MODULE_LICENSE("GPL"); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h new file mode 100644 index 0000000..5220302 --- /dev/null +++ b/fs/9p/v9fs.h @@ -0,0 +1,105 @@ +/* + * V9FS definitions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* + * Idpool structure provides lock and id management + * + */ + +struct v9fs_idpool { + struct semaphore lock; + struct idr pool; +}; + +/* + * Session structure provides information for an opened session + * + */ + +struct v9fs_session_info { + /* options */ + unsigned int maxdata; + unsigned char extended; /* set to 1 if we are using UNIX extensions */ + unsigned char nodev; /* set to 1 if no disable device mapping */ + unsigned short port; /* port to connect to */ + unsigned short debug; /* debug level */ + unsigned short proto; /* protocol to use */ + unsigned int afid; /* authentication fid */ + unsigned int rfdno; /* read file descriptor number */ + unsigned int wfdno; /* write file descriptor number */ + + + char *name; /* user name to mount as */ + char *remotename; /* name of remote hierarchy being mounted */ + unsigned int uid; /* default uid/muid for legacy support */ + unsigned int gid; /* default gid for legacy support */ + + /* book keeping */ + struct v9fs_idpool fidpool; /* The FID pool for file descriptors */ + struct v9fs_idpool tidpool; /* The TID pool for transactions ids */ + + /* transport information */ + struct v9fs_transport *transport; + + int inprogress; /* session in progress => true */ + int shutdown; /* session shutting down. no more attaches. */ + unsigned char session_hung; + + /* mux private data */ + struct v9fs_fcall *curfcall; + wait_queue_head_t read_wait; + struct completion fcread; + struct completion proccmpl; + struct task_struct *recvproc; + + spinlock_t muxlock; + struct list_head mux_fcalls; +}; + +/* possible values of ->proto */ +enum { + PROTO_TCP, + PROTO_UNIX, + PROTO_FD, +}; + +int v9fs_session_init(struct v9fs_session_info *, const char *, char *); +struct v9fs_session_info *v9fs_inode2v9ses(struct inode *); +void v9fs_session_close(struct v9fs_session_info *v9ses); +int v9fs_get_idpool(struct v9fs_idpool *p); +void v9fs_put_idpool(int id, struct v9fs_idpool *p); +int v9fs_get_option(char *opts, char *name, char *buf, int buflen); +long long v9fs_get_int_option(char *opts, char *name, long long dflt); +int v9fs_parse_tcp_devname(const char *devname, char **addr, char **remotename); + +#define V9FS_MAGIC 0x01021997 + +/* other default globals */ +#define V9FS_PORT 564 +#define V9FS_DEFUSER "nobody" +#define V9FS_DEFANAME "" + +/* inital pool sizes for fids and tags */ +#define V9FS_START_FIDS 8192 +#define V9FS_START_TIDS 256 diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h new file mode 100644 index 0000000..2f2cea7 --- /dev/null +++ b/fs/9p/v9fs_vfs.h @@ -0,0 +1,53 @@ +/* + * V9FS VFS extensions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* plan9 semantics are that created files are implicitly opened. + * But linux semantics are that you call create, then open. + * the plan9 approach is superior as it provides an atomic + * open. + * we track the create fid here. When the file is opened, if fidopen is + * non-zero, we use the fid and can skip some steps. + * there may be a better way to do this, but I don't know it. + * one BAD way is to clunk the fid on create, then open it again: + * you lose the atomicity of file open + */ + +/* special case: + * unlink calls remove, which is an implicit clunk. So we have to track + * that kind of thing so that we don't try to clunk a dead fid. + */ + +extern struct file_system_type v9fs_fs_type; +extern struct file_operations v9fs_file_operations; +extern struct file_operations v9fs_dir_operations; +extern struct dentry_operations v9fs_dentry_operations; + +struct inode *v9fs_get_inode(struct super_block *sb, int mode); +ino_t v9fs_qid2ino(struct v9fs_qid *qid); +void v9fs_mistat2inode(struct v9fs_stat *, struct inode *, + struct super_block *); +int v9fs_dir_release(struct inode *inode, struct file *filp); +int v9fs_file_open(struct inode *inode, struct file *file); +void v9fs_inode2mistat(struct inode *inode, struct v9fs_stat *mistat); +void v9fs_dentry_release(struct dentry *); diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c new file mode 100644 index 0000000..ce0778a --- /dev/null +++ b/fs/9p/vfs_super.c @@ -0,0 +1,271 @@ +/* + * linux/fs/9p/vfs_super.c + * + * This file contians superblock ops for 9P2000. It is intended that + * you mount this file system on directories. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "conv.h" +#include "fid.h" + +static void v9fs_clear_inode(struct inode *); +static struct super_operations v9fs_super_ops; + +/** + * v9fs_clear_inode - release an inode + * @inode: inode to release + * + */ + +static void v9fs_clear_inode(struct inode *inode) +{ + filemap_fdatawrite(inode->i_mapping); +} + +/** + * v9fs_set_super - set the superblock + * @s: super block + * @data: file system specific data + * + */ + +static int v9fs_set_super(struct super_block *s, void *data) +{ + s->s_fs_info = data; + return set_anon_super(s, data); +} + +/** + * v9fs_fill_super - populate superblock with info + * @sb: superblock + * @v9ses: session information + * + */ + +static void +v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, + int flags) +{ + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_blocksize_bits = fls(v9ses->maxdata - 1); + sb->s_blocksize = 1 << sb->s_blocksize_bits; + sb->s_magic = V9FS_MAGIC; + sb->s_op = &v9fs_super_ops; + + sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | + MS_NODIRATIME | MS_NOATIME; +} + +/** + * v9fs_get_sb - mount a superblock + * @fs_type: file system type + * @flags: mount flags + * @dev_name: device name that was mounted + * @data: mount options + * + */ + +static struct super_block *v9fs_get_sb(struct file_system_type + *fs_type, int flags, + const char *dev_name, void *data) +{ + struct super_block *sb = NULL; + struct v9fs_fcall *fcall = NULL; + struct inode *inode = NULL; + struct dentry *root = NULL; + struct v9fs_session_info *v9ses = NULL; + struct v9fs_fid *root_fid = NULL; + int mode = S_IRWXUGO | S_ISVTX; + uid_t uid = current->fsuid; + gid_t gid = current->fsgid; + int stat_result = 0; + int newfid = 0; + int retval = 0; + + dprintk(DEBUG_VFS, " \n"); + + v9ses = kcalloc(1, sizeof(struct v9fs_session_info), GFP_KERNEL); + if (!v9ses) + return ERR_PTR(-ENOMEM); + + if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { + dprintk(DEBUG_ERROR, "problem initiating session\n"); + retval = newfid; + goto free_session; + } + + sb = sget(fs_type, NULL, v9fs_set_super, v9ses); + + v9fs_fill_super(sb, v9ses, flags); + + inode = v9fs_get_inode(sb, S_IFDIR | mode); + if (IS_ERR(inode)) { + retval = PTR_ERR(inode); + goto put_back_sb; + } + + inode->i_uid = uid; + inode->i_gid = gid; + + root = d_alloc_root(inode); + + if (!root) { + retval = -ENOMEM; + goto release_inode; + } + + sb->s_root = root; + + /* Setup the Root Inode */ + root_fid = v9fs_fid_create(root); + if (root_fid == NULL) { + retval = -ENOMEM; + goto release_dentry; + } + + root_fid->fidopen = 0; + root_fid->v9ses = v9ses; + + stat_result = v9fs_t_stat(v9ses, newfid, &fcall); + if (stat_result < 0) { + dprintk(DEBUG_ERROR, "stat error\n"); + v9fs_t_clunk(v9ses, newfid, NULL); + v9fs_put_idpool(newfid, &v9ses->fidpool); + } else { + root_fid->fid = newfid; + root_fid->qid = fcall->params.rstat.stat->qid; + root->d_inode->i_ino = + v9fs_qid2ino(&fcall->params.rstat.stat->qid); + v9fs_mistat2inode(fcall->params.rstat.stat, root->d_inode, sb); + } + + kfree(fcall); + + if (stat_result < 0) { + retval = stat_result; + goto release_dentry; + } + + return sb; + + release_dentry: + dput(sb->s_root); + + release_inode: + iput(inode); + + put_back_sb: + up_write(&sb->s_umount); + deactivate_super(sb); + v9fs_session_close(v9ses); + + free_session: + kfree(v9ses); + + return ERR_PTR(retval); +} + +/** + * v9fs_kill_super - Kill Superblock + * @s: superblock + * + */ + +static void v9fs_kill_super(struct super_block *s) +{ + struct v9fs_session_info *v9ses = s->s_fs_info; + + dprintk(DEBUG_VFS, " %p\n", s); + + v9fs_dentry_release(s->s_root); /* clunk root */ + + kill_anon_super(s); + + v9fs_session_close(v9ses); + kfree(v9ses); + dprintk(DEBUG_VFS, "exiting kill_super\n"); +} + +/** + * v9fs_show_options - Show mount options in /proc/mounts + * @m: seq_file to write to + * @mnt: mount descriptor + * + */ + +static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) +{ + struct v9fs_session_info *v9ses = mnt->mnt_sb->s_fs_info; + + if (v9ses->debug != 0) + seq_printf(m, ",debug=%u", v9ses->debug); + if (v9ses->port != V9FS_PORT) + seq_printf(m, ",port=%u", v9ses->port); + if (v9ses->maxdata != 9000) + seq_printf(m, ",msize=%u", v9ses->maxdata); + if (v9ses->afid != ~0) + seq_printf(m, ",afid=%u", v9ses->afid); + if (v9ses->proto == PROTO_UNIX) + seq_puts(m, ",proto=unix"); + if (v9ses->extended == 0) + seq_puts(m, ",noextend"); + if (v9ses->nodev == 1) + seq_puts(m, ",nodevmap"); + seq_printf(m, ",name=%s", v9ses->name); + seq_printf(m, ",aname=%s", v9ses->remotename); + seq_printf(m, ",uid=%u", v9ses->uid); + seq_printf(m, ",gid=%u", v9ses->gid); + return 0; +} + +static struct super_operations v9fs_super_ops = { + .statfs = simple_statfs, + .clear_inode = v9fs_clear_inode, + .show_options = v9fs_show_options, +}; + +struct file_system_type v9fs_fs_type = { + .name = "9P", + .get_sb = v9fs_get_sb, + .kill_sb = v9fs_kill_super, + .owner = THIS_MODULE, +}; -- cgit v0.10.2 From b8cf945b3166c4394386f162a527c9950f396ce2 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:21 -0700 Subject: [PATCH] v9fs: 9P protocol implementation This part of the patch contains the 9P protocol functions. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/9p.c b/fs/9p/9p.c new file mode 100644 index 0000000..e847f50 --- /dev/null +++ b/fs/9p/9p.c @@ -0,0 +1,359 @@ +/* + * linux/fs/9p/9p.c + * + * This file contains functions 9P2000 functions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "mux.h" + +/** + * v9fs_t_version - negotiate protocol parameters with sever + * @v9ses: 9P2000 session information + * @msize: requested max size packet + * @version: requested version.extension string + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize, + char *version, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "msize: %d version: %s\n", msize, version); + msg.id = TVERSION; + msg.params.tversion.msize = msize; + msg.params.tversion.version = version; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_attach - mount the server + * @v9ses: 9P2000 session information + * @uname: user name doing the attach + * @aname: remote name being attached to + * @fid: mount fid to attatch to root node + * @afid: authentication fid (in this case result key) + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname, + u32 fid, u32 afid, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "uname '%s' aname '%s' fid %d afid %d\n", uname, + aname, fid, afid); + msg.id = TATTACH; + msg.params.tattach.fid = fid; + msg.params.tattach.afid = afid; + msg.params.tattach.uname = uname; + msg.params.tattach.aname = aname; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_clunk - release a fid (finish a transaction) + * @v9ses: 9P2000 session information + * @fid: fid to release + * @fcall: pointer to response fcall pointer + * + */ + +int +v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + msg.id = TCLUNK; + msg.params.tclunk.fid = fid; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_v9fs_t_flush - flush a pending transaction + * @v9ses: 9P2000 session information + * @tag: tid to release + * + */ + +int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 tag) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "oldtag %d\n", tag); + msg.id = TFLUSH; + msg.params.tflush.oldtag = tag; + return v9fs_mux_rpc(v9ses, &msg, NULL); +} + +/** + * v9fs_t_stat - read a file's meta-data + * @v9ses: 9P2000 session information + * @fid: fid pointing to file or directory to get info about + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + if (fcall) + *fcall = NULL; + + msg.id = TSTAT; + msg.params.tstat.fid = fid; + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_wstat - write a file's meta-data + * @v9ses: 9P2000 session information + * @fid: fid pointing to file or directory to write info about + * @stat: metadata + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_stat *stat, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d length %d\n", fid, (int)stat->length); + msg.id = TWSTAT; + msg.params.twstat.fid = fid; + msg.params.twstat.stat = stat; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_walk - walk a fid to a new file or directory + * @v9ses: 9P2000 session information + * @fid: fid to walk + * @newfid: new fid (for clone operations) + * @name: path to walk fid to + * @fcall: pointer to response fcall + * + */ + +/* TODO: support multiple walk */ + +int +v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, + char *name, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d newfid %d wname '%s'\n", fid, newfid, name); + msg.id = TWALK; + msg.params.twalk.fid = fid; + msg.params.twalk.newfid = newfid; + + if (name) { + msg.params.twalk.nwname = 1; + msg.params.twalk.wnames = &name; + } else { + msg.params.twalk.nwname = 0; + } + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_open - open a file + * + * @v9ses - 9P2000 session information + * @fid - fid to open + * @mode - mode to open file (R, RW, etc) + * @fcall - pointer to response fcall + * + */ + +int +v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d mode %d\n", fid, mode); + msg.id = TOPEN; + msg.params.topen.fid = fid; + msg.params.topen.mode = mode; + + errorno = v9fs_mux_rpc(v9ses, &msg, fcall); + + return errorno; +} + +/** + * v9fs_t_remove - remove a file or directory + * @v9ses: 9P2000 session information + * @fid: fid to remove + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d\n", fid); + msg.id = TREMOVE; + msg.params.tremove.fid = fid; + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_create - create a file or directory + * @v9ses: 9P2000 session information + * @fid: fid to create + * @name: name of the file or directory to create + * @perm: permissions to create with + * @mode: mode to open file (R, RW, etc) + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, + u32 perm, u8 mode, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + + dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n", + fid, name, perm, mode); + + msg.id = TCREATE; + msg.params.tcreate.fid = fid; + msg.params.tcreate.name = name; + msg.params.tcreate.perm = perm; + msg.params.tcreate.mode = mode; + + return v9fs_mux_rpc(v9ses, &msg, fcall); +} + +/** + * v9fs_t_read - read data + * @v9ses: 9P2000 session information + * @fid: fid to read from + * @offset: offset to start read at + * @count: how many bytes to read + * @fcall: pointer to response fcall (with data) + * + */ + +int +v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, u64 offset, + u32 count, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + struct v9fs_fcall *rc = NULL; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d offset 0x%lx count 0x%x\n", fid, + (long unsigned int)offset, count); + msg.id = TREAD; + msg.params.tread.fid = fid; + msg.params.tread.offset = offset; + msg.params.tread.count = count; + errorno = v9fs_mux_rpc(v9ses, &msg, &rc); + + if (!errorno) { + errorno = rc->params.rread.count; + dump_data(rc->params.rread.data, rc->params.rread.count); + } + + if (fcall) + *fcall = rc; + else + kfree(rc); + + return errorno; +} + +/** + * v9fs_t_write - write data + * @v9ses: 9P2000 session information + * @fid: fid to write to + * @offset: offset to start write at + * @count: how many bytes to write + * @fcall: pointer to response fcall + * + */ + +int +v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, + u64 offset, u32 count, void *data, struct v9fs_fcall **fcall) +{ + struct v9fs_fcall msg; + struct v9fs_fcall *rc = NULL; + long errorno = -1; + + dprintk(DEBUG_9P, "fid %d offset 0x%llx count 0x%x\n", fid, + (unsigned long long)offset, count); + dump_data(data, count); + + msg.id = TWRITE; + msg.params.twrite.fid = fid; + msg.params.twrite.offset = offset; + msg.params.twrite.count = count; + msg.params.twrite.data = data; + + errorno = v9fs_mux_rpc(v9ses, &msg, &rc); + + if (!errorno) + errorno = rc->params.rwrite.count; + + if (fcall) + *fcall = rc; + else + kfree(rc); + + return errorno; +} diff --git a/fs/9p/9p.h b/fs/9p/9p.h new file mode 100644 index 0000000..f554242 --- /dev/null +++ b/fs/9p/9p.h @@ -0,0 +1,341 @@ +/* + * linux/fs/9p/9p.h + * + * 9P protocol definitions. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* Message Types */ +enum { + TVERSION = 100, + RVERSION, + TAUTH = 102, + RAUTH, + TATTACH = 104, + RATTACH, + TERROR = 106, + RERROR, + TFLUSH = 108, + RFLUSH, + TWALK = 110, + RWALK, + TOPEN = 112, + ROPEN, + TCREATE = 114, + RCREATE, + TREAD = 116, + RREAD, + TWRITE = 118, + RWRITE, + TCLUNK = 120, + RCLUNK, + TREMOVE = 122, + RREMOVE, + TSTAT = 124, + RSTAT, + TWSTAT = 126, + RWSTAT, +}; + +/* modes */ +enum { + V9FS_OREAD = 0x00, + V9FS_OWRITE = 0x01, + V9FS_ORDWR = 0x02, + V9FS_OEXEC = 0x03, + V9FS_OEXCL = 0x04, + V9FS_OTRUNC = 0x10, + V9FS_OREXEC = 0x20, + V9FS_ORCLOSE = 0x40, + V9FS_OAPPEND = 0x80, +}; + +/* permissions */ +enum { + V9FS_DMDIR = 0x80000000, + V9FS_DMAPPEND = 0x40000000, + V9FS_DMEXCL = 0x20000000, + V9FS_DMMOUNT = 0x10000000, + V9FS_DMAUTH = 0x08000000, + V9FS_DMTMP = 0x04000000, + V9FS_DMSYMLINK = 0x02000000, + V9FS_DMLINK = 0x01000000, + /* 9P2000.u extensions */ + V9FS_DMDEVICE = 0x00800000, + V9FS_DMNAMEDPIPE = 0x00200000, + V9FS_DMSOCKET = 0x00100000, + V9FS_DMSETUID = 0x00080000, + V9FS_DMSETGID = 0x00040000, +}; + +/* qid.types */ +enum { + V9FS_QTDIR = 0x80, + V9FS_QTAPPEND = 0x40, + V9FS_QTEXCL = 0x20, + V9FS_QTMOUNT = 0x10, + V9FS_QTAUTH = 0x08, + V9FS_QTTMP = 0x04, + V9FS_QTSYMLINK = 0x02, + V9FS_QTLINK = 0x01, + V9FS_QTFILE = 0x00, +}; + +/* ample room for Twrite/Rread header (iounit) */ +#define V9FS_IOHDRSZ 24 + +/* qids are the unique ID for a file (like an inode */ +struct v9fs_qid { + u8 type; + u32 version; + u64 path; +}; + +/* Plan 9 file metadata (stat) structure */ +struct v9fs_stat { + u16 size; + u16 type; + u32 dev; + struct v9fs_qid qid; + u32 mode; + u32 atime; + u32 mtime; + u64 length; + char *name; + char *uid; + char *gid; + char *muid; + char *extension; /* 9p2000.u extensions */ + u32 n_uid; /* 9p2000.u extensions */ + u32 n_gid; /* 9p2000.u extensions */ + u32 n_muid; /* 9p2000.u extensions */ + char data[0]; +}; + +/* Structures for Protocol Operations */ + +struct Tversion { + u32 msize; + char *version; +}; + +struct Rversion { + u32 msize; + char *version; +}; + +struct Tauth { + u32 afid; + char *uname; + char *aname; +}; + +struct Rauth { + struct v9fs_qid qid; +}; + +struct Rerror { + char *error; + u32 errno; /* 9p2000.u extension */ +}; + +struct Tflush { + u32 oldtag; +}; + +struct Rflush { +}; + +struct Tattach { + u32 fid; + u32 afid; + char *uname; + char *aname; +}; + +struct Rattach { + struct v9fs_qid qid; +}; + +struct Twalk { + u32 fid; + u32 newfid; + u32 nwname; + char **wnames; +}; + +struct Rwalk { + u32 nwqid; + struct v9fs_qid *wqids; +}; + +struct Topen { + u32 fid; + u8 mode; +}; + +struct Ropen { + struct v9fs_qid qid; + u32 iounit; +}; + +struct Tcreate { + u32 fid; + char *name; + u32 perm; + u8 mode; +}; + +struct Rcreate { + struct v9fs_qid qid; + u32 iounit; +}; + +struct Tread { + u32 fid; + u64 offset; + u32 count; +}; + +struct Rread { + u32 count; + u8 *data; +}; + +struct Twrite { + u32 fid; + u64 offset; + u32 count; + u8 *data; +}; + +struct Rwrite { + u32 count; +}; + +struct Tclunk { + u32 fid; +}; + +struct Rclunk { +}; + +struct Tremove { + u32 fid; +}; + +struct Rremove { +}; + +struct Tstat { + u32 fid; +}; + +struct Rstat { + struct v9fs_stat *stat; +}; + +struct Twstat { + u32 fid; + struct v9fs_stat *stat; +}; + +struct Rwstat { +}; + +/* + * fcall is the primary packet structure + * + */ + +struct v9fs_fcall { + u32 size; + u8 id; + u16 tag; + + union { + struct Tversion tversion; + struct Rversion rversion; + struct Tauth tauth; + struct Rauth rauth; + struct Rerror rerror; + struct Tflush tflush; + struct Rflush rflush; + struct Tattach tattach; + struct Rattach rattach; + struct Twalk twalk; + struct Rwalk rwalk; + struct Topen topen; + struct Ropen ropen; + struct Tcreate tcreate; + struct Rcreate rcreate; + struct Tread tread; + struct Rread rread; + struct Twrite twrite; + struct Rwrite rwrite; + struct Tclunk tclunk; + struct Rclunk rclunk; + struct Tremove tremove; + struct Rremove rremove; + struct Tstat tstat; + struct Rstat rstat; + struct Twstat twstat; + struct Rwstat rwstat; + } params; +}; + +#define FCALL_ERROR(fcall) (fcall ? fcall->params.rerror.error : "") + +int v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize, + char *version, struct v9fs_fcall **rcall); + +int v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname, + u32 fid, u32 afid, struct v9fs_fcall **rcall); + +int v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag); + +int v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_stat *stat, struct v9fs_fcall **rcall); + +int v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, + char *name, struct v9fs_fcall **rcall); + +int v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, + struct v9fs_fcall **rcall); + +int v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, + struct v9fs_fcall **rcall); + +int v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, + u32 perm, u8 mode, struct v9fs_fcall **rcall); + +int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, + u64 offset, u32 count, struct v9fs_fcall **rcall); + +int v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset, + u32 count, void *data, struct v9fs_fcall **rcall); diff --git a/fs/9p/conv.c b/fs/9p/conv.c new file mode 100644 index 0000000..1554731 --- /dev/null +++ b/fs/9p/conv.c @@ -0,0 +1,693 @@ +/* + * linux/fs/9p/conv.c + * + * 9P protocol conversion functions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "conv.h" + +/* + * Buffer to help with string parsing + */ +struct cbuf { + unsigned char *sp; + unsigned char *p; + unsigned char *ep; +}; + +static inline void buf_init(struct cbuf *buf, void *data, int datalen) +{ + buf->sp = buf->p = data; + buf->ep = data + datalen; +} + +static inline int buf_check_overflow(struct cbuf *buf) +{ + return buf->p > buf->ep; +} + +static inline void buf_check_size(struct cbuf *buf, int len) +{ + if (buf->p+len > buf->ep) { + if (buf->p < buf->ep) { + eprintk(KERN_ERR, "buffer overflow\n"); + buf->p = buf->ep + 1; + } + } +} + +static inline void *buf_alloc(struct cbuf *buf, int len) +{ + void *ret = NULL; + + buf_check_size(buf, len); + ret = buf->p; + buf->p += len; + + return ret; +} + +static inline void buf_put_int8(struct cbuf *buf, u8 val) +{ + buf_check_size(buf, 1); + + buf->p[0] = val; + buf->p++; +} + +static inline void buf_put_int16(struct cbuf *buf, u16 val) +{ + buf_check_size(buf, 2); + + *(__le16 *) buf->p = cpu_to_le16(val); + buf->p += 2; +} + +static inline void buf_put_int32(struct cbuf *buf, u32 val) +{ + buf_check_size(buf, 4); + + *(__le32 *)buf->p = cpu_to_le32(val); + buf->p += 4; +} + +static inline void buf_put_int64(struct cbuf *buf, u64 val) +{ + buf_check_size(buf, 8); + + *(__le64 *)buf->p = cpu_to_le64(val); + buf->p += 8; +} + +static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) +{ + buf_check_size(buf, slen + 2); + + buf_put_int16(buf, slen); + memcpy(buf->p, s, slen); + buf->p += slen; +} + +static inline void buf_put_string(struct cbuf *buf, const char *s) +{ + buf_put_stringn(buf, s, strlen(s)); +} + +static inline void buf_put_data(struct cbuf *buf, void *data, u32 datalen) +{ + buf_check_size(buf, datalen); + + memcpy(buf->p, data, datalen); + buf->p += datalen; +} + +static inline u8 buf_get_int8(struct cbuf *buf) +{ + u8 ret = 0; + + buf_check_size(buf, 1); + ret = buf->p[0]; + + buf->p++; + + return ret; +} + +static inline u16 buf_get_int16(struct cbuf *buf) +{ + u16 ret = 0; + + buf_check_size(buf, 2); + ret = le16_to_cpu(*(__le16 *)buf->p); + + buf->p += 2; + + return ret; +} + +static inline u32 buf_get_int32(struct cbuf *buf) +{ + u32 ret = 0; + + buf_check_size(buf, 4); + ret = le32_to_cpu(*(__le32 *)buf->p); + + buf->p += 4; + + return ret; +} + +static inline u64 buf_get_int64(struct cbuf *buf) +{ + u64 ret = 0; + + buf_check_size(buf, 8); + ret = le64_to_cpu(*(__le64 *)buf->p); + + buf->p += 8; + + return ret; +} + +static inline int +buf_get_string(struct cbuf *buf, char *data, unsigned int datalen) +{ + + u16 len = buf_get_int16(buf); + buf_check_size(buf, len); + if (len + 1 > datalen) + return 0; + + memcpy(data, buf->p, len); + data[len] = 0; + buf->p += len; + + return len + 1; +} + +static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf) +{ + char *ret = NULL; + int n = buf_get_string(buf, sbuf->p, sbuf->ep - sbuf->p); + + if (n > 0) { + ret = sbuf->p; + sbuf->p += n; + } + + return ret; +} + +static inline int buf_get_data(struct cbuf *buf, void *data, int datalen) +{ + buf_check_size(buf, datalen); + + memcpy(data, buf->p, datalen); + buf->p += datalen; + + return datalen; +} + +static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf, + int datalen) +{ + char *ret = NULL; + int n = 0; + + buf_check_size(dbuf, datalen); + + n = buf_get_data(buf, dbuf->p, datalen); + + if (n > 0) { + ret = dbuf->p; + dbuf->p += n; + } + + return ret; +} + +/** + * v9fs_size_stat - calculate the size of a variable length stat struct + * @v9ses: session information + * @stat: metadata (stat) structure + * + */ + +static int v9fs_size_stat(struct v9fs_session_info *v9ses, + struct v9fs_stat *stat) +{ + int size = 0; + + if (stat == NULL) { + eprintk(KERN_ERR, "v9fs_size_stat: got a NULL stat pointer\n"); + return 0; + } + + size = /* 2 + *//* size[2] */ + 2 + /* type[2] */ + 4 + /* dev[4] */ + 1 + /* qid.type[1] */ + 4 + /* qid.vers[4] */ + 8 + /* qid.path[8] */ + 4 + /* mode[4] */ + 4 + /* atime[4] */ + 4 + /* mtime[4] */ + 8 + /* length[8] */ + 8; /* minimum sum of string lengths */ + + if (stat->name) + size += strlen(stat->name); + if (stat->uid) + size += strlen(stat->uid); + if (stat->gid) + size += strlen(stat->gid); + if (stat->muid) + size += strlen(stat->muid); + + if (v9ses->extended) { + size += 4 + /* n_uid[4] */ + 4 + /* n_gid[4] */ + 4 + /* n_muid[4] */ + 2; /* string length of extension[4] */ + if (stat->extension) + size += strlen(stat->extension); + } + + return size; +} + +/** + * serialize_stat - safely format a stat structure for transmission + * @v9ses: session info + * @stat: metadata (stat) structure + * @bufp: buffer to serialize structure into + * + */ + +static int +serialize_stat(struct v9fs_session_info *v9ses, struct v9fs_stat *stat, + struct cbuf *bufp) +{ + buf_put_int16(bufp, stat->size); + buf_put_int16(bufp, stat->type); + buf_put_int32(bufp, stat->dev); + buf_put_int8(bufp, stat->qid.type); + buf_put_int32(bufp, stat->qid.version); + buf_put_int64(bufp, stat->qid.path); + buf_put_int32(bufp, stat->mode); + buf_put_int32(bufp, stat->atime); + buf_put_int32(bufp, stat->mtime); + buf_put_int64(bufp, stat->length); + + buf_put_string(bufp, stat->name); + buf_put_string(bufp, stat->uid); + buf_put_string(bufp, stat->gid); + buf_put_string(bufp, stat->muid); + + if (v9ses->extended) { + buf_put_string(bufp, stat->extension); + buf_put_int32(bufp, stat->n_uid); + buf_put_int32(bufp, stat->n_gid); + buf_put_int32(bufp, stat->n_muid); + } + + if (buf_check_overflow(bufp)) + return 0; + + return stat->size; +} + +/** + * deserialize_stat - safely decode a recieved metadata (stat) structure + * @v9ses: session info + * @bufp: buffer to deserialize + * @stat: metadata (stat) structure + * @dbufp: buffer to deserialize variable strings into + * + */ + +static inline int +deserialize_stat(struct v9fs_session_info *v9ses, struct cbuf *bufp, + struct v9fs_stat *stat, struct cbuf *dbufp) +{ + + stat->size = buf_get_int16(bufp); + stat->type = buf_get_int16(bufp); + stat->dev = buf_get_int32(bufp); + stat->qid.type = buf_get_int8(bufp); + stat->qid.version = buf_get_int32(bufp); + stat->qid.path = buf_get_int64(bufp); + stat->mode = buf_get_int32(bufp); + stat->atime = buf_get_int32(bufp); + stat->mtime = buf_get_int32(bufp); + stat->length = buf_get_int64(bufp); + stat->name = buf_get_stringb(bufp, dbufp); + stat->uid = buf_get_stringb(bufp, dbufp); + stat->gid = buf_get_stringb(bufp, dbufp); + stat->muid = buf_get_stringb(bufp, dbufp); + + if (v9ses->extended) { + stat->extension = buf_get_stringb(bufp, dbufp); + stat->n_uid = buf_get_int32(bufp); + stat->n_gid = buf_get_int32(bufp); + stat->n_muid = buf_get_int32(bufp); + } + + if (buf_check_overflow(bufp) || buf_check_overflow(dbufp)) + return 0; + + return stat->size + 2; +} + +/** + * deserialize_statb - wrapper for decoding a received metadata structure + * @v9ses: session info + * @bufp: buffer to deserialize + * @dbufp: buffer to deserialize variable strings into + * + */ + +static inline struct v9fs_stat *deserialize_statb(struct v9fs_session_info + *v9ses, struct cbuf *bufp, + struct cbuf *dbufp) +{ + struct v9fs_stat *ret = buf_alloc(dbufp, sizeof(struct v9fs_stat)); + + if (ret) { + int n = deserialize_stat(v9ses, bufp, ret, dbufp); + if (n <= 0) + return NULL; + } + + return ret; +} + +/** + * v9fs_deserialize_stat - decode a received metadata structure + * @v9ses: session info + * @buf: buffer to deserialize + * @buflen: length of received buffer + * @stat: metadata structure to decode into + * @statlen: length of destination metadata structure + * + */ + +int +v9fs_deserialize_stat(struct v9fs_session_info *v9ses, void *buf, + u32 buflen, struct v9fs_stat *stat, u32 statlen) +{ + struct cbuf buffer; + struct cbuf *bufp = &buffer; + struct cbuf dbuffer; + struct cbuf *dbufp = &dbuffer; + + buf_init(bufp, buf, buflen); + buf_init(dbufp, (char *)stat + sizeof(struct v9fs_stat), + statlen - sizeof(struct v9fs_stat)); + + return deserialize_stat(v9ses, bufp, stat, dbufp); +} + +static inline int +v9fs_size_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall) +{ + int size = 4 + 1 + 2; /* size[4] msg[1] tag[2] */ + int i = 0; + + switch (fcall->id) { + default: + eprintk(KERN_ERR, "bad msg type %d\n", fcall->id); + return 0; + case TVERSION: /* msize[4] version[s] */ + size += 4 + 2 + strlen(fcall->params.tversion.version); + break; + case TAUTH: /* afid[4] uname[s] aname[s] */ + size += 4 + 2 + strlen(fcall->params.tauth.uname) + + 2 + strlen(fcall->params.tauth.aname); + break; + case TFLUSH: /* oldtag[2] */ + size += 2; + break; + case TATTACH: /* fid[4] afid[4] uname[s] aname[s] */ + size += 4 + 4 + 2 + strlen(fcall->params.tattach.uname) + + 2 + strlen(fcall->params.tattach.aname); + break; + case TWALK: /* fid[4] newfid[4] nwname[2] nwname*(wname[s]) */ + size += 4 + 4 + 2; + /* now compute total for the array of names */ + for (i = 0; i < fcall->params.twalk.nwname; i++) + size += 2 + strlen(fcall->params.twalk.wnames[i]); + break; + case TOPEN: /* fid[4] mode[1] */ + size += 4 + 1; + break; + case TCREATE: /* fid[4] name[s] perm[4] mode[1] */ + size += 4 + 2 + strlen(fcall->params.tcreate.name) + 4 + 1; + break; + case TREAD: /* fid[4] offset[8] count[4] */ + size += 4 + 8 + 4; + break; + case TWRITE: /* fid[4] offset[8] count[4] data[count] */ + size += 4 + 8 + 4 + fcall->params.twrite.count; + break; + case TCLUNK: /* fid[4] */ + size += 4; + break; + case TREMOVE: /* fid[4] */ + size += 4; + break; + case TSTAT: /* fid[4] */ + size += 4; + break; + case TWSTAT: /* fid[4] stat[n] */ + fcall->params.twstat.stat->size = + v9fs_size_stat(v9ses, fcall->params.twstat.stat); + size += 4 + 2 + 2 + fcall->params.twstat.stat->size; + } + return size; +} + +/* + * v9fs_serialize_fcall - marshall fcall struct into a packet + * @v9ses: session information + * @fcall: structure to convert + * @data: buffer to serialize fcall into + * @datalen: length of buffer to serialize fcall into + * + */ + +int +v9fs_serialize_fcall(struct v9fs_session_info *v9ses, struct v9fs_fcall *fcall, + void *data, u32 datalen) +{ + int i = 0; + struct v9fs_stat *stat = NULL; + struct cbuf buffer; + struct cbuf *bufp = &buffer; + + buf_init(bufp, data, datalen); + + if (!fcall) { + eprintk(KERN_ERR, "no fcall\n"); + return -EINVAL; + } + + fcall->size = v9fs_size_fcall(v9ses, fcall); + + buf_put_int32(bufp, fcall->size); + buf_put_int8(bufp, fcall->id); + buf_put_int16(bufp, fcall->tag); + + dprintk(DEBUG_CONV, "size %d id %d tag %d\n", fcall->size, fcall->id, + fcall->tag); + + /* now encode it */ + switch (fcall->id) { + default: + eprintk(KERN_ERR, "bad msg type: %d\n", fcall->id); + return -EPROTO; + case TVERSION: + buf_put_int32(bufp, fcall->params.tversion.msize); + buf_put_string(bufp, fcall->params.tversion.version); + break; + case TAUTH: + buf_put_int32(bufp, fcall->params.tauth.afid); + buf_put_string(bufp, fcall->params.tauth.uname); + buf_put_string(bufp, fcall->params.tauth.aname); + break; + case TFLUSH: + buf_put_int16(bufp, fcall->params.tflush.oldtag); + break; + case TATTACH: + buf_put_int32(bufp, fcall->params.tattach.fid); + buf_put_int32(bufp, fcall->params.tattach.afid); + buf_put_string(bufp, fcall->params.tattach.uname); + buf_put_string(bufp, fcall->params.tattach.aname); + break; + case TWALK: + buf_put_int32(bufp, fcall->params.twalk.fid); + buf_put_int32(bufp, fcall->params.twalk.newfid); + buf_put_int16(bufp, fcall->params.twalk.nwname); + for (i = 0; i < fcall->params.twalk.nwname; i++) + buf_put_string(bufp, fcall->params.twalk.wnames[i]); + break; + case TOPEN: + buf_put_int32(bufp, fcall->params.topen.fid); + buf_put_int8(bufp, fcall->params.topen.mode); + break; + case TCREATE: + buf_put_int32(bufp, fcall->params.tcreate.fid); + buf_put_string(bufp, fcall->params.tcreate.name); + buf_put_int32(bufp, fcall->params.tcreate.perm); + buf_put_int8(bufp, fcall->params.tcreate.mode); + break; + case TREAD: + buf_put_int32(bufp, fcall->params.tread.fid); + buf_put_int64(bufp, fcall->params.tread.offset); + buf_put_int32(bufp, fcall->params.tread.count); + break; + case TWRITE: + buf_put_int32(bufp, fcall->params.twrite.fid); + buf_put_int64(bufp, fcall->params.twrite.offset); + buf_put_int32(bufp, fcall->params.twrite.count); + buf_put_data(bufp, fcall->params.twrite.data, + fcall->params.twrite.count); + break; + case TCLUNK: + buf_put_int32(bufp, fcall->params.tclunk.fid); + break; + case TREMOVE: + buf_put_int32(bufp, fcall->params.tremove.fid); + break; + case TSTAT: + buf_put_int32(bufp, fcall->params.tstat.fid); + break; + case TWSTAT: + buf_put_int32(bufp, fcall->params.twstat.fid); + stat = fcall->params.twstat.stat; + + buf_put_int16(bufp, stat->size + 2); + serialize_stat(v9ses, stat, bufp); + break; + } + + if (buf_check_overflow(bufp)) + return -EIO; + + return fcall->size; +} + +/** + * deserialize_fcall - unmarshal a response + * @v9ses: session information + * @msgsize: size of rcall message + * @buf: recieved buffer + * @buflen: length of received buffer + * @rcall: fcall structure to populate + * @rcalllen: length of fcall structure to populate + * + */ + +int +v9fs_deserialize_fcall(struct v9fs_session_info *v9ses, u32 msgsize, + void *buf, u32 buflen, struct v9fs_fcall *rcall, + int rcalllen) +{ + + struct cbuf buffer; + struct cbuf *bufp = &buffer; + struct cbuf dbuffer; + struct cbuf *dbufp = &dbuffer; + int i = 0; + + buf_init(bufp, buf, buflen); + buf_init(dbufp, (char *)rcall + sizeof(struct v9fs_fcall), + rcalllen - sizeof(struct v9fs_fcall)); + + rcall->size = msgsize; + rcall->id = buf_get_int8(bufp); + rcall->tag = buf_get_int16(bufp); + + dprintk(DEBUG_CONV, "size %d id %d tag %d\n", rcall->size, rcall->id, + rcall->tag); + switch (rcall->id) { + default: + eprintk(KERN_ERR, "unknown message type: %d\n", rcall->id); + return -EPROTO; + case RVERSION: + rcall->params.rversion.msize = buf_get_int32(bufp); + rcall->params.rversion.version = buf_get_stringb(bufp, dbufp); + break; + case RFLUSH: + break; + case RATTACH: + rcall->params.rattach.qid.type = buf_get_int8(bufp); + rcall->params.rattach.qid.version = buf_get_int32(bufp); + rcall->params.rattach.qid.path = buf_get_int64(bufp); + break; + case RWALK: + rcall->params.rwalk.nwqid = buf_get_int16(bufp); + rcall->params.rwalk.wqids = buf_alloc(bufp, + rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid)); + if (rcall->params.rwalk.wqids) + for (i = 0; i < rcall->params.rwalk.nwqid; i++) { + rcall->params.rwalk.wqids[i].type = + buf_get_int8(bufp); + rcall->params.rwalk.wqids[i].version = + buf_get_int16(bufp); + rcall->params.rwalk.wqids[i].path = + buf_get_int64(bufp); + } + break; + case ROPEN: + rcall->params.ropen.qid.type = buf_get_int8(bufp); + rcall->params.ropen.qid.version = buf_get_int32(bufp); + rcall->params.ropen.qid.path = buf_get_int64(bufp); + rcall->params.ropen.iounit = buf_get_int32(bufp); + break; + case RCREATE: + rcall->params.rcreate.qid.type = buf_get_int8(bufp); + rcall->params.rcreate.qid.version = buf_get_int32(bufp); + rcall->params.rcreate.qid.path = buf_get_int64(bufp); + rcall->params.rcreate.iounit = buf_get_int32(bufp); + break; + case RREAD: + rcall->params.rread.count = buf_get_int32(bufp); + rcall->params.rread.data = buf_get_datab(bufp, dbufp, + rcall->params.rread.count); + break; + case RWRITE: + rcall->params.rwrite.count = buf_get_int32(bufp); + break; + case RCLUNK: + break; + case RREMOVE: + break; + case RSTAT: + buf_get_int16(bufp); + rcall->params.rstat.stat = + deserialize_statb(v9ses, bufp, dbufp); + break; + case RWSTAT: + break; + case RERROR: + rcall->params.rerror.error = buf_get_stringb(bufp, dbufp); + if (v9ses->extended) + rcall->params.rerror.errno = buf_get_int16(bufp); + break; + } + + if (buf_check_overflow(bufp) || buf_check_overflow(dbufp)) + return -EIO; + + return rcall->size; +} diff --git a/fs/9p/conv.h b/fs/9p/conv.h new file mode 100644 index 0000000..ee84961 --- /dev/null +++ b/fs/9p/conv.h @@ -0,0 +1,36 @@ +/* + * linux/fs/9p/conv.h + * + * 9P protocol conversion definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +int v9fs_deserialize_stat(struct v9fs_session_info *, void *buf, + u32 buflen, struct v9fs_stat *stat, u32 statlen); +int v9fs_serialize_fcall(struct v9fs_session_info *, struct v9fs_fcall *tcall, + void *buf, u32 buflen); +int v9fs_deserialize_fcall(struct v9fs_session_info *, u32 msglen, + void *buf, u32 buflen, struct v9fs_fcall *rcall, + int rcalllen); + +/* this one is actually in error.c right now */ +int v9fs_errstr2errno(char *errstr); -- cgit v0.10.2 From 426cc91aa651b50713d06d45e5c3c3e90cfd40d9 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:22 -0700 Subject: [PATCH] v9fs: transport modules This part of the patch contains transport routines. Signed-off-by: Eric Van Hensbergen Signed-off-by: Latchesar Ionkov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/mux.c b/fs/9p/mux.c new file mode 100644 index 0000000..8ebc1af --- /dev/null +++ b/fs/9p/mux.c @@ -0,0 +1,440 @@ +/* + * linux/fs/9p/mux.c + * + * Protocol Multiplexer + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2004 by Latchesar Ionkov + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "transport.h" +#include "conv.h" +#include "mux.h" + +/** + * dprintcond - print condition of session info + * @v9ses: session info structure + * @req: RPC request structure + * + */ + +static inline int +dprintcond(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + dprintk(DEBUG_MUX, "condition: %d, %p\n", v9ses->transport->status, + req->rcall); + return 0; +} + +/** + * xread - force read of a certain number of bytes + * @v9ses: session info structure + * @ptr: pointer to buffer + * @sz: number of bytes to read + * + * Chuck Cranor CS-533 project1 + */ + +static int xread(struct v9fs_session_info *v9ses, void *ptr, unsigned long sz) +{ + int rd = 0; + int ret = 0; + while (rd < sz) { + ret = v9ses->transport->read(v9ses->transport, ptr, sz - rd); + if (ret <= 0) { + dprintk(DEBUG_ERROR, "xread errno %d\n", ret); + return ret; + } + rd += ret; + ptr += ret; + } + return (rd); +} + +/** + * read_message - read a full 9P2000 fcall packet + * @v9ses: session info structure + * @rcall: fcall structure to read into + * @rcalllen: size of fcall buffer + * + */ + +static int +read_message(struct v9fs_session_info *v9ses, + struct v9fs_fcall *rcall, int rcalllen) +{ + unsigned char buf[4]; + void *data; + int size = 0; + int res = 0; + + res = xread(v9ses, buf, sizeof(buf)); + if (res < 0) { + dprintk(DEBUG_ERROR, + "Reading of count field failed returned: %d\n", res); + return res; + } + + if (res < 4) { + dprintk(DEBUG_ERROR, + "Reading of count field failed returned: %d\n", res); + return -EIO; + } + + size = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); + dprintk(DEBUG_MUX, "got a packet count: %d\n", size); + + /* adjust for the four bytes of size */ + size -= 4; + + if (size > v9ses->maxdata) { + dprintk(DEBUG_ERROR, "packet too big: %d\n", size); + return -E2BIG; + } + + data = kmalloc(size, GFP_KERNEL); + if (!data) { + eprintk(KERN_WARNING, "out of memory\n"); + return -ENOMEM; + } + + res = xread(v9ses, data, size); + if (res < size) { + dprintk(DEBUG_ERROR, "Reading of fcall failed returned: %d\n", + res); + kfree(data); + return res; + } + + /* we now have an in-memory string that is the reply. + * deserialize it. There is very little to go wrong at this point + * save for v9fs_alloc errors. + */ + res = v9fs_deserialize_fcall(v9ses, size, data, v9ses->maxdata, + rcall, rcalllen); + + kfree(data); + + if (res < 0) + return res; + + return 0; +} + +/** + * v9fs_recv - receive an RPC response for a particular tag + * @v9ses: session info structure + * @req: RPC request structure + * + */ + +static int v9fs_recv(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + int ret = 0; + + dprintk(DEBUG_MUX, "waiting for response: %d\n", req->tcall->tag); + ret = wait_event_interruptible(v9ses->read_wait, + ((v9ses->transport->status != Connected) || + (req->rcall != 0) || dprintcond(v9ses, req))); + + dprintk(DEBUG_MUX, "got it: rcall %p\n", req->rcall); + if (v9ses->transport->status == Disconnected) + return -ECONNRESET; + + if (ret == 0) { + spin_lock(&v9ses->muxlock); + list_del(&req->next); + spin_unlock(&v9ses->muxlock); + } + + return ret; +} + +/** + * v9fs_send - send a 9P request + * @v9ses: session info structure + * @req: RPC request to send + * + */ + +static int v9fs_send(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) +{ + int ret = -1; + void *data = NULL; + struct v9fs_fcall *tcall = req->tcall; + + data = kmalloc(v9ses->maxdata + V9FS_IOHDRSZ, GFP_KERNEL); + if (!data) + return -ENOMEM; + + tcall->size = 0; /* enforce size recalculation */ + ret = + v9fs_serialize_fcall(v9ses, tcall, data, + v9ses->maxdata + V9FS_IOHDRSZ); + if (ret < 0) + goto free_data; + + spin_lock(&v9ses->muxlock); + list_add(&req->next, &v9ses->mux_fcalls); + spin_unlock(&v9ses->muxlock); + + dprintk(DEBUG_MUX, "sending message: tag %d size %d\n", tcall->tag, + tcall->size); + ret = v9ses->transport->write(v9ses->transport, data, tcall->size); + + if (ret != tcall->size) { + spin_lock(&v9ses->muxlock); + list_del(&req->next); + kfree(req->rcall); + + spin_unlock(&v9ses->muxlock); + if (ret >= 0) + ret = -EREMOTEIO; + } else + ret = 0; + + free_data: + kfree(data); + return ret; +} + +/** + * v9fs_mux_rpc - send a request, receive a response + * @v9ses: session info structure + * @tcall: fcall to send + * @rcall: buffer to place response into + * + */ + +long +v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, + struct v9fs_fcall **rcall) +{ + int tid = -1; + struct v9fs_fcall *fcall = NULL; + struct v9fs_rpcreq req; + int ret = -1; + + if (!v9ses) + return -EINVAL; + + if (rcall) + *rcall = NULL; + + if (tcall->id != TVERSION) { + tid = v9fs_get_idpool(&v9ses->tidpool); + if (tid < 0) + return -ENOMEM; + } + + tcall->tag = tid; + + req.tcall = tcall; + req.rcall = NULL; + + ret = v9fs_send(v9ses, &req); + + if (ret < 0) { + if (tcall->id != TVERSION) + v9fs_put_idpool(tid, &v9ses->tidpool); + dprintk(DEBUG_MUX, "error %d\n", ret); + return ret; + } + + ret = v9fs_recv(v9ses, &req); + + fcall = req.rcall; + + dprintk(DEBUG_MUX, "received: tag=%x, ret=%d\n", tcall->tag, ret); + if (ret == -ERESTARTSYS) { + if (v9ses->transport->status != Disconnected + && tcall->id != TFLUSH) { + unsigned long flags; + + dprintk(DEBUG_MUX, "flushing the tag: %d\n", + tcall->tag); + clear_thread_flag(TIF_SIGPENDING); + v9fs_t_flush(v9ses, tcall->tag); + spin_lock_irqsave(¤t->sighand->siglock, flags); + recalc_sigpending(); + spin_unlock_irqrestore(¤t->sighand->siglock, + flags); + dprintk(DEBUG_MUX, "flushing done\n"); + } + + goto release_req; + } else if (ret < 0) + goto release_req; + + if (!fcall) + ret = -EIO; + else { + if (fcall->id == RERROR) { + ret = v9fs_errstr2errno(fcall->params.rerror.error); + if (ret == 0) { /* string match failed */ + if (fcall->params.rerror.errno) + ret = -(fcall->params.rerror.errno); + else + ret = -ESERVERFAULT; + } + } else if (fcall->id != tcall->id + 1) { + dprintk(DEBUG_ERROR, + "fcall mismatch: expected %d, got %d\n", + tcall->id + 1, fcall->id); + ret = -EIO; + } + } + + release_req: + if (tcall->id != TVERSION) + v9fs_put_idpool(tid, &v9ses->tidpool); + if (rcall) + *rcall = fcall; + else + kfree(fcall); + + return ret; +} + +/** + * v9fs_recvproc - kproc to handle demultiplexing responses + * @data: session info structure + * + */ + +static int v9fs_recvproc(void *data) +{ + struct v9fs_session_info *v9ses = (struct v9fs_session_info *)data; + struct v9fs_fcall *rcall = NULL; + struct v9fs_rpcreq *rptr; + struct v9fs_rpcreq *req; + struct v9fs_rpcreq *rreq; + int err = 0; + + allow_signal(SIGKILL); + set_current_state(TASK_INTERRUPTIBLE); + complete(&v9ses->proccmpl); + while (!kthread_should_stop() && err >= 0) { + req = rptr = rreq = NULL; + + rcall = kmalloc(v9ses->maxdata + V9FS_IOHDRSZ, GFP_KERNEL); + if (!rcall) { + eprintk(KERN_ERR, "no memory for buffers\n"); + break; + } + + err = read_message(v9ses, rcall, v9ses->maxdata + V9FS_IOHDRSZ); + if (err < 0) { + kfree(rcall); + break; + } + spin_lock(&v9ses->muxlock); + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + if (rreq->tcall->tag == rcall->tag) { + req = rreq; + req->rcall = rcall; + break; + } + } + + if (req && (req->tcall->id == TFLUSH)) { + struct v9fs_rpcreq *treq = NULL; + list_for_each_entry_safe(treq, rptr, &v9ses->mux_fcalls, next) { + if (treq->tcall->tag == + req->tcall->params.tflush.oldtag) { + list_del(&rptr->next); + kfree(treq->rcall); + break; + } + } + } + + spin_unlock(&v9ses->muxlock); + + if (!req) { + dprintk(DEBUG_ERROR, + "unexpected response: id %d tag %d\n", + rcall->id, rcall->tag); + + kfree(rcall); + } + + wake_up_all(&v9ses->read_wait); + set_current_state(TASK_INTERRUPTIBLE); + } + + /* Inform all pending processes about the failure */ + wake_up_all(&v9ses->read_wait); + + if (signal_pending(current)) + complete(&v9ses->proccmpl); + + dprintk(DEBUG_MUX, "recvproc: end\n"); + v9ses->recvproc = NULL; + + return err >= 0; +} + +/** + * v9fs_mux_init - initialize multiplexer (spawn kproc) + * @v9ses: session info structure + * @dev_name: mount device information (to create unique kproc) + * + */ + +int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name) +{ + char procname[60]; + + strncpy(procname, dev_name, sizeof(procname)); + procname[sizeof(procname) - 1] = 0; + + init_waitqueue_head(&v9ses->read_wait); + init_completion(&v9ses->fcread); + init_completion(&v9ses->proccmpl); + spin_lock_init(&v9ses->muxlock); + INIT_LIST_HEAD(&v9ses->mux_fcalls); + v9ses->recvproc = NULL; + v9ses->curfcall = NULL; + + v9ses->recvproc = kthread_create(v9fs_recvproc, v9ses, + "v9fs_recvproc %s", procname); + + if (IS_ERR(v9ses->recvproc)) { + eprintk(KERN_ERR, "cannot create receiving thread\n"); + v9fs_session_close(v9ses); + return -ECONNABORTED; + } + + wake_up_process(v9ses->recvproc); + wait_for_completion(&v9ses->proccmpl); + + return 0; +} diff --git a/fs/9p/mux.h b/fs/9p/mux.h new file mode 100644 index 0000000..d7d8fa1 --- /dev/null +++ b/fs/9p/mux.h @@ -0,0 +1,39 @@ +/* + * linux/fs/9p/mux.h + * + * Multiplexer Definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +/* structure to manage each RPC transaction */ + +struct v9fs_rpcreq { + struct v9fs_fcall *tcall; + struct v9fs_fcall *rcall; + + /* XXX - could we put scatter/gather buffers here? */ + + struct list_head next; +}; + +int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name); +long v9fs_mux_rpc(struct v9fs_session_info *v9ses, + struct v9fs_fcall *tcall, struct v9fs_fcall **rcall); diff --git a/fs/9p/trans_fd.c b/fs/9p/trans_fd.c new file mode 100644 index 0000000..63b58ce --- /dev/null +++ b/fs/9p/trans_fd.c @@ -0,0 +1,172 @@ +/* + * linux/fs/9p/trans_fd.c + * + * File Descriptor Transport Layer + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "transport.h" + +struct v9fs_trans_fd { + struct file *in_file; + struct file *out_file; +}; + +/** + * v9fs_fd_recv - receive from a socket + * @v9ses: session information + * @v: buffer to receive data into + * @len: size of receive buffer + * + */ + +static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len) +{ + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; + + if (!trans || trans->status != Connected || !ts) + return -EIO; + + return kernel_read(ts->in_file, ts->in_file->f_pos, v, len); +} + +/** + * v9fs_fd_send - send to a socket + * @v9ses: session information + * @v: buffer to send data from + * @len: size of send buffer + * + */ + +static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len) +{ + struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; + mm_segment_t oldfs = get_fs(); + int ret = 0; + + if (!trans || trans->status != Connected || !ts) + return -EIO; + + set_fs(get_ds()); + /* The cast to a user pointer is valid due to the set_fs() */ + ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos); + set_fs(oldfs); + + return ret; +} + +/** + * v9fs_fd_init - initialize file descriptor transport + * @v9ses: session information + * @addr: address of server to mount + * @data: mount options + * + */ + +static int +v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data) +{ + struct v9fs_trans_fd *ts = NULL; + struct v9fs_transport *trans = v9ses->transport; + + if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { + printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); + return -ENOPROTOOPT; + } + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + ts = kmalloc(sizeof(struct v9fs_trans_fd), GFP_KERNEL); + + if (!ts) + return -ENOMEM; + + ts->in_file = fget( v9ses->rfdno ); + ts->out_file = fget( v9ses->wfdno ); + + if (!ts->in_file || !ts->out_file) { + if (ts->in_file) + fput(ts->in_file); + + if (ts->out_file) + fput(ts->out_file); + + kfree(ts); + return -EIO; + } + + trans->priv = ts; + trans->status = Connected; + + return 0; +} + + +/** + * v9fs_fd_close - shutdown file descriptor + * @trans: private socket structure + * + */ + +static void v9fs_fd_close(struct v9fs_transport *trans) +{ + struct v9fs_trans_fd *ts; + + if (!trans) + return; + + trans->status = Disconnected; + ts = trans->priv; + + if (!ts) + return; + + if (ts->in_file) + fput(ts->in_file); + + if (ts->out_file) + fput(ts->out_file); + + kfree(ts); +} + +struct v9fs_transport v9fs_trans_fd = { + .init = v9fs_fd_init, + .write = v9fs_fd_send, + .read = v9fs_fd_recv, + .close = v9fs_fd_close, +}; + diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c new file mode 100644 index 0000000..081d1c8 --- /dev/null +++ b/fs/9p/trans_sock.c @@ -0,0 +1,282 @@ +/* + * linux/fs/9p/trans_socket.c + * + * Socket Transport Layer + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 1997-2002 by Ron Minnich + * Copyright (C) 1995, 1996 by Olaf Kirch + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "transport.h" + +#define V9FS_PORT 564 + +struct v9fs_trans_sock { + struct socket *s; +}; + +/** + * v9fs_sock_recv - receive from a socket + * @v9ses: session information + * @v: buffer to receive data into + * @len: size of receive buffer + * + */ + +static int v9fs_sock_recv(struct v9fs_transport *trans, void *v, int len) +{ + struct msghdr msg; + struct kvec iov; + int result; + mm_segment_t oldfs; + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + if (trans->status == Disconnected) + return -EREMOTEIO; + + result = -EINVAL; + + oldfs = get_fs(); + set_fs(get_ds()); + + iov.iov_base = v; + iov.iov_len = len; + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_namelen = 0; + msg.msg_flags = MSG_NOSIGNAL; + + result = kernel_recvmsg(ts->s, &msg, &iov, 1, len, 0); + + dprintk(DEBUG_TRANS, "socket state %d\n", ts->s->state); + set_fs(oldfs); + + if (result <= 0) { + if (result != -ERESTARTSYS) + trans->status = Disconnected; + } + + return result; +} + +/** + * v9fs_sock_send - send to a socket + * @v9ses: session information + * @v: buffer to send data from + * @len: size of send buffer + * + */ + +static int v9fs_sock_send(struct v9fs_transport *trans, void *v, int len) +{ + struct kvec iov; + struct msghdr msg; + int result = -1; + mm_segment_t oldfs; + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + dprintk(DEBUG_TRANS, "Sending packet size %d (%x)\n", len, len); + dump_data(v, len); + + down(&trans->writelock); + + oldfs = get_fs(); + set_fs(get_ds()); + iov.iov_base = v; + iov.iov_len = len; + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_namelen = 0; + msg.msg_flags = MSG_NOSIGNAL; + result = kernel_sendmsg(ts->s, &msg, &iov, 1, len); + set_fs(oldfs); + + if (result < 0) { + if (result != -ERESTARTSYS) + trans->status = Disconnected; + } + + up(&trans->writelock); + return result; +} + +/** + * v9fs_tcp_init - initialize TCP socket + * @v9ses: session information + * @addr: address of server to mount + * @data: mount options + * + */ + +static int +v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr, char *data) +{ + struct socket *csocket = NULL; + struct sockaddr_in sin_server; + int rc = 0; + struct v9fs_trans_sock *ts = NULL; + struct v9fs_transport *trans = v9ses->transport; + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL); + + if (!ts) + return -ENOMEM; + + trans->priv = ts; + ts->s = NULL; + + if (!addr) + return -EINVAL; + + dprintk(DEBUG_TRANS, "Connecting to %s\n", addr); + + sin_server.sin_family = AF_INET; + sin_server.sin_addr.s_addr = in_aton(addr); + sin_server.sin_port = htons(v9ses->port); + sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); + rc = csocket->ops->connect(csocket, + (struct sockaddr *)&sin_server, + sizeof(struct sockaddr_in), 0); + if (rc < 0) { + eprintk(KERN_ERR, + "v9fs_trans_tcp: problem connecting socket to %s\n", + addr); + return rc; + } + csocket->sk->sk_allocation = GFP_NOIO; + ts->s = csocket; + trans->status = Connected; + + return 0; +} + +/** + * v9fs_unix_init - initialize UNIX domain socket + * @v9ses: session information + * @dev_name: path to named pipe + * @data: mount options + * + */ + +static int +v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name, + char *data) +{ + int rc; + struct socket *csocket; + struct sockaddr_un sun_server; + struct v9fs_transport *trans; + struct v9fs_trans_sock *ts; + + rc = 0; + csocket = NULL; + trans = v9ses->transport; + + if (strlen(dev_name) > UNIX_PATH_MAX) { + eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n", + dev_name); + return -ENOMEM; + } + + ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + trans->priv = ts; + ts->s = NULL; + + sema_init(&trans->writelock, 1); + sema_init(&trans->readlock, 1); + + sun_server.sun_family = PF_UNIX; + strcpy(sun_server.sun_path, dev_name); + sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); + rc = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, + sizeof(struct sockaddr_un) - 1, 0); /* -1 *is* important */ + if (rc < 0) { + eprintk(KERN_ERR, + "v9fs_trans_unix: problem connecting socket: %s: %d\n", + dev_name, rc); + return rc; + } + csocket->sk->sk_allocation = GFP_NOIO; + ts->s = csocket; + trans->status = Connected; + + return 0; +} + +/** + * v9fs_sock_close - shutdown socket + * @trans: private socket structure + * + */ + +static void v9fs_sock_close(struct v9fs_transport *trans) +{ + struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + + if ((ts) && (ts->s)) { + dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s); + sock_release(ts->s); + ts->s = NULL; + trans->status = Disconnected; + dprintk(DEBUG_TRANS, "socket closed\n"); + } + + kfree(ts); +} + +struct v9fs_transport v9fs_trans_tcp = { + .init = v9fs_tcp_init, + .write = v9fs_sock_send, + .read = v9fs_sock_recv, + .close = v9fs_sock_close, +}; + +struct v9fs_transport v9fs_trans_unix = { + .init = v9fs_unix_init, + .write = v9fs_sock_send, + .read = v9fs_sock_recv, + .close = v9fs_sock_close, +}; diff --git a/fs/9p/transport.h b/fs/9p/transport.h new file mode 100644 index 0000000..9e9cd41 --- /dev/null +++ b/fs/9p/transport.h @@ -0,0 +1,46 @@ +/* + * linux/fs/9p/transport.h + * + * Transport Definition + * + * Copyright (C) 2004 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +enum v9fs_transport_status { + Connected, + Disconnected, + Hung, +}; + +struct v9fs_transport { + enum v9fs_transport_status status; + struct semaphore writelock; + struct semaphore readlock; + void *priv; + + int (*init) (struct v9fs_session_info *, const char *, char *); + int (*write) (struct v9fs_transport *, void *, int); + int (*read) (struct v9fs_transport *, void *, int); + void (*close) (struct v9fs_transport *); +}; + +extern struct v9fs_transport v9fs_trans_tcp; +extern struct v9fs_transport v9fs_trans_unix; +extern struct v9fs_transport v9fs_trans_fd; diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 14d663e..a573b75 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -296,11 +296,6 @@ v9fs_session_init(struct v9fs_session_info *v9ses, case PROTO_FD: trans_proto = &v9fs_trans_fd; *v9ses->remotename = 0; - if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { - printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); - retval = -ENOPROTOOPT; - goto SessCleanUp; - } break; default: printk(KERN_ERR "v9fs: Bad mount protocol %d\n", v9ses->proto); -- cgit v0.10.2 From 322b329ab787de5f45abca9c9eabfd33bc5927e8 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:23 -0700 Subject: [PATCH] v9fs: Support to force umount Support for force umount Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/mux.c b/fs/9p/mux.c index 8ebc1af..0854bef 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c @@ -324,6 +324,26 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, } /** + * v9fs_mux_cancel_requests - cancels all pending requests + * + * @v9ses: session info structure + * @err: error code to return to the requests + */ +void v9fs_mux_cancel_requests(struct v9fs_session_info *v9ses, int err) +{ + struct v9fs_rpcreq *rptr; + struct v9fs_rpcreq *rreq; + + dprintk(DEBUG_MUX, " %d\n", err); + spin_lock(&v9ses->muxlock); + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + rreq->err = err; + } + spin_unlock(&v9ses->muxlock); + wake_up_all(&v9ses->read_wait); +} + +/** * v9fs_recvproc - kproc to handle demultiplexing responses * @data: session info structure * diff --git a/fs/9p/mux.h b/fs/9p/mux.h index d7d8fa1..82ce793 100644 --- a/fs/9p/mux.h +++ b/fs/9p/mux.h @@ -37,3 +37,4 @@ struct v9fs_rpcreq { int v9fs_mux_init(struct v9fs_session_info *v9ses, const char *dev_name); long v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, struct v9fs_fcall **rcall); +void v9fs_mux_cancel_requests(struct v9fs_session_info *v9ses, int err); diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index a573b75..13bdbba 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -409,6 +409,15 @@ void v9fs_session_close(struct v9fs_session_info *v9ses) putname(v9ses->remotename); } +/** + * v9fs_session_cancel - mark transport as disconnected + * and cancel all pending requests. + */ +void v9fs_session_cancel(struct v9fs_session_info *v9ses) { + v9ses->transport->status = Disconnected; + v9fs_mux_cancel_requests(v9ses, -EIO); +} + extern int v9fs_error_init(void); /** diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 5220302..45dcef4 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -89,9 +89,7 @@ struct v9fs_session_info *v9fs_inode2v9ses(struct inode *); void v9fs_session_close(struct v9fs_session_info *v9ses); int v9fs_get_idpool(struct v9fs_idpool *p); void v9fs_put_idpool(int id, struct v9fs_idpool *p); -int v9fs_get_option(char *opts, char *name, char *buf, int buflen); -long long v9fs_get_int_option(char *opts, char *name, long long dflt); -int v9fs_parse_tcp_devname(const char *devname, char **addr, char **remotename); +void v9fs_session_cancel(struct v9fs_session_info *v9ses); #define V9FS_MAGIC 0x01021997 diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index ce0778a..868f350 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -257,10 +257,19 @@ static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) return 0; } +static void +v9fs_umount_begin(struct super_block *sb) +{ + struct v9fs_session_info *v9ses = sb->s_fs_info; + + v9fs_session_cancel(v9ses); +} + static struct super_operations v9fs_super_ops = { .statfs = simple_statfs, .clear_inode = v9fs_clear_inode, .show_options = v9fs_show_options, + .umount_begin = v9fs_umount_begin, }; struct file_system_type v9fs_fs_type = { -- cgit v0.10.2 From 3ed8491c8a75cefe95b57f7f428a3e2ddd421e97 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:24 -0700 Subject: [PATCH] v9fs: debug and support routines This part of the patch contains debug and other misc routines. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/debug.h b/fs/9p/debug.h new file mode 100644 index 0000000..4445f06 --- /dev/null +++ b/fs/9p/debug.h @@ -0,0 +1,70 @@ +/* + * linux/fs/9p/debug.h - V9FS Debug Definitions + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#define DEBUG_ERROR (1<<0) +#define DEBUG_CURRENT (1<<1) +#define DEBUG_9P (1<<2) +#define DEBUG_VFS (1<<3) +#define DEBUG_CONV (1<<4) +#define DEBUG_MUX (1<<5) +#define DEBUG_TRANS (1<<6) +#define DEBUG_SLABS (1<<7) + +#define DEBUG_DUMP_PKT 0 + +extern int v9fs_debug_level; + +#define dprintk(level, format, arg...) \ +do { \ + if((v9fs_debug_level & level)==level) \ + printk(KERN_NOTICE "-- %s (%d): " \ + format , __FUNCTION__, current->pid , ## arg); \ +} while(0) + +#define eprintk(level, format, arg...) \ +do { \ + printk(level "v9fs: %s (%d): " \ + format , __FUNCTION__, current->pid , ## arg); \ +} while(0) + +#if DEBUG_DUMP_PKT +static inline void dump_data(const unsigned char *data, unsigned int datalen) +{ + int i, j; + int len = datalen; + + printk(KERN_DEBUG "data "); + for (i = 0; i < len; i += 4) { + for (j = 0; (j < 4) && (i + j < len); j++) + printk(KERN_DEBUG "%02x", data[i + j]); + printk(KERN_DEBUG " "); + } + printk(KERN_DEBUG "\n"); +} +#else /* DEBUG_DUMP_PKT */ +static inline void dump_data(const unsigned char *data, unsigned int datalen) +{ + +} +#endif /* DEBUG_DUMP_PKT */ diff --git a/fs/9p/error.c b/fs/9p/error.c new file mode 100644 index 0000000..fee5d19 --- /dev/null +++ b/fs/9p/error.c @@ -0,0 +1,93 @@ +/* + * linux/fs/9p/error.c + * + * Error string handling + * + * Plan 9 uses error strings, Unix uses error numbers. These functions + * try to help manage that and provide for dynamically adding error + * mappings. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include + +#include +#include + +#include "debug.h" +#include "error.h" + +/** + * v9fs_error_init - preload + * @errstr: error string + * + */ + +int v9fs_error_init(void) +{ + struct errormap *c; + int bucket; + + /* initialize hash table */ + for (bucket = 0; bucket < ERRHASHSZ; bucket++) + INIT_HLIST_HEAD(&hash_errmap[bucket]); + + /* load initial error map into hash table */ + for (c = errmap; c->name != NULL; c++) { + bucket = jhash(c->name, strlen(c->name), 0) % ERRHASHSZ; + INIT_HLIST_NODE(&c->list); + hlist_add_head(&c->list, &hash_errmap[bucket]); + } + + return 1; +} + +/** + * errstr2errno - convert error string to error number + * @errstr: error string + * + */ + +int v9fs_errstr2errno(char *errstr) +{ + int errno = 0; + struct hlist_node *p = NULL; + struct errormap *c = NULL; + int bucket = jhash(errstr, strlen(errstr), 0) % ERRHASHSZ; + + hlist_for_each_entry(c, p, &hash_errmap[bucket], list) { + if (!strcmp(c->name, errstr)) { + errno = c->val; + break; + } + } + + if (errno == 0) { + /* TODO: if error isn't found, add it dynamically */ + printk(KERN_ERR "%s: errstr :%s: not found\n", __FUNCTION__, + errstr); + errno = 1; + } + + return -errno; +} diff --git a/fs/9p/error.h b/fs/9p/error.h new file mode 100644 index 0000000..4bf2cf5 --- /dev/null +++ b/fs/9p/error.h @@ -0,0 +1,181 @@ +/* + * linux/fs/9p/error.h + * + * Huge Nasty Error Table + * + * Plan 9 uses error strings, Unix uses error numbers. This table tries to + * match UNIX strings and Plan 9 strings to unix error numbers. It is used + * to preload the dynamic error table which can also track user-specific error + * strings. + * + * Copyright (C) 2004 by Eric Van Hensbergen + * Copyright (C) 2002 by Ron Minnich + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include + +struct errormap { + char *name; + int val; + + struct hlist_node list; +}; + +#define ERRHASHSZ 32 +static struct hlist_head hash_errmap[ERRHASHSZ]; + +/* FixMe - reduce to a reasonable size */ +static struct errormap errmap[] = { + {"Operation not permitted", 1}, + {"wstat prohibited", 1}, + {"No such file or directory", 2}, + {"file not found", 2}, + {"Interrupted system call", 4}, + {"Input/output error", 5}, + {"No such device or address", 6}, + {"Argument list too long", 7}, + {"Bad file descriptor", 9}, + {"Resource temporarily unavailable", 11}, + {"Cannot allocate memory", 12}, + {"Permission denied", 13}, + {"Bad address", 14}, + {"Block device required", 15}, + {"Device or resource busy", 16}, + {"File exists", 17}, + {"Invalid cross-device link", 18}, + {"No such device", 19}, + {"Not a directory", 20}, + {"Is a directory", 21}, + {"Invalid argument", 22}, + {"Too many open files in system", 23}, + {"Too many open files", 24}, + {"Text file busy", 26}, + {"File too large", 27}, + {"No space left on device", 28}, + {"Illegal seek", 29}, + {"Read-only file system", 30}, + {"Too many links", 31}, + {"Broken pipe", 32}, + {"Numerical argument out of domain", 33}, + {"Numerical result out of range", 34}, + {"Resource deadlock avoided", 35}, + {"File name too long", 36}, + {"No locks available", 37}, + {"Function not implemented", 38}, + {"Directory not empty", 39}, + {"Too many levels of symbolic links", 40}, + {"Unknown error 41", 41}, + {"No message of desired type", 42}, + {"Identifier removed", 43}, + {"File locking deadlock error", 58}, + {"No data available", 61}, + {"Machine is not on the network", 64}, + {"Package not installed", 65}, + {"Object is remote", 66}, + {"Link has been severed", 67}, + {"Communication error on send", 70}, + {"Protocol error", 71}, + {"Bad message", 74}, + {"File descriptor in bad state", 77}, + {"Streams pipe error", 86}, + {"Too many users", 87}, + {"Socket operation on non-socket", 88}, + {"Message too long", 90}, + {"Protocol not available", 92}, + {"Protocol not supported", 93}, + {"Socket type not supported", 94}, + {"Operation not supported", 95}, + {"Protocol family not supported", 96}, + {"Network is down", 100}, + {"Network is unreachable", 101}, + {"Network dropped connection on reset", 102}, + {"Software caused connection abort", 103}, + {"Connection reset by peer", 104}, + {"No buffer space available", 105}, + {"Transport endpoint is already connected", 106}, + {"Transport endpoint is not connected", 107}, + {"Cannot send after transport endpoint shutdown", 108}, + {"Connection timed out", 110}, + {"Connection refused", 111}, + {"Host is down", 112}, + {"No route to host", 113}, + {"Operation already in progress", 114}, + {"Operation now in progress", 115}, + {"Is a named type file", 120}, + {"Remote I/O error", 121}, + {"Disk quota exceeded", 122}, + {"Operation canceled", 125}, + {"Unknown error 126", 126}, + {"Unknown error 127", 127}, +/* errors from fossil, vacfs, and u9fs */ + {"fid unknown or out of range", EBADF}, + {"permission denied", EACCES}, + {"file does not exist", ENOENT}, + {"authentication failed", ECONNREFUSED}, + {"bad offset in directory read", ESPIPE}, + {"bad use of fid", EBADF}, + {"wstat can't convert between files and directories", EPERM}, + {"directory is not empty", ENOTEMPTY}, + {"file exists", EEXIST}, + {"file already exists", EEXIST}, + {"file or directory already exists", EEXIST}, + {"fid already in use", EBADF}, + {"file in use", ETXTBSY}, + {"i/o error", EIO}, + {"file already open for I/O", ETXTBSY}, + {"illegal mode", EINVAL}, + {"illegal name", ENAMETOOLONG}, + {"not a directory", ENOTDIR}, + {"not a member of proposed group", EINVAL}, + {"not owner", EACCES}, + {"only owner can change group in wstat", EACCES}, + {"read only file system", EROFS}, + {"no access to special file", EPERM}, + {"i/o count too large", EIO}, + {"unknown group", EINVAL}, + {"unknown user", EINVAL}, + {"bogus wstat buffer", EPROTO}, + {"exclusive use file already open", EAGAIN}, + {"corrupted directory entry", EIO}, + {"corrupted file entry", EIO}, + {"corrupted block label", EIO}, + {"corrupted meta data", EIO}, + {"illegal offset", EINVAL}, + {"illegal path element", ENOENT}, + {"root of file system is corrupted", EIO}, + {"corrupted super block", EIO}, + {"protocol botch", EPROTO}, + {"file system is full", ENOSPC}, + {"file is in use", EAGAIN}, + {"directory entry is not allocated", ENOENT}, + {"file is read only", EROFS}, + {"file has been removed", EIDRM}, + {"only support truncation to zero length", EPERM}, + {"cannot remove root", EPERM}, + {"file too big", EFBIG}, + {"venti i/o error", EIO}, + /* these are not errors */ + {"u9fs rhostsauth: no authentication required", 0}, + {"u9fs authnone: no authentication required", 0}, + {NULL, -1} +}; + +extern int v9fs_error_init(void); +extern int v9fs_errstr2errno(char *errstr); diff --git a/fs/9p/fid.c b/fs/9p/fid.c new file mode 100644 index 0000000..821c9c4 --- /dev/null +++ b/fs/9p/fid.c @@ -0,0 +1,241 @@ +/* + * V9FS FID Management + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include +#include +#include +#include +#include + +#include "debug.h" +#include "v9fs.h" +#include "9p.h" +#include "v9fs_vfs.h" +#include "transport.h" +#include "mux.h" +#include "conv.h" +#include "fid.h" + +/** + * v9fs_fid_insert - add a fid to a dentry + * @fid: fid to add + * @dentry: dentry that it is being added to + * + */ + +static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) +{ + struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; + dprintk(DEBUG_9P, "fid %d (%p) dentry %s (%p)\n", fid->fid, fid, + dentry->d_iname, dentry); + if (dentry->d_fsdata == NULL) { + dentry->d_fsdata = + kmalloc(sizeof(struct list_head), GFP_KERNEL); + if (dentry->d_fsdata == NULL) { + dprintk(DEBUG_ERROR, "Out of memory\n"); + return -ENOMEM; + } + fid_list = (struct list_head *)dentry->d_fsdata; + INIT_LIST_HEAD(fid_list); /* Initialize list head */ + } + + fid->uid = current->uid; + fid->pid = current->pid; + list_add(&fid->list, fid_list); + return 0; +} + +/** + * v9fs_fid_create - allocate a FID structure + * @dentry - dentry to link newly created fid to + * + */ + +struct v9fs_fid *v9fs_fid_create(struct dentry *dentry) +{ + struct v9fs_fid *new; + + new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); + if (new == NULL) { + dprintk(DEBUG_ERROR, "Out of Memory\n"); + return ERR_PTR(-ENOMEM); + } + + new->fid = -1; + new->fidopen = 0; + new->fidcreate = 0; + new->fidclunked = 0; + new->iounit = 0; + + if (v9fs_fid_insert(new, dentry) == 0) + return new; + else { + dprintk(DEBUG_ERROR, "Problems inserting to dentry\n"); + kfree(new); + return NULL; + } +} + +/** + * v9fs_fid_destroy - deallocate a FID structure + * @fid: fid to destroy + * + */ + +void v9fs_fid_destroy(struct v9fs_fid *fid) +{ + list_del(&fid->list); + kfree(fid); +} + +/** + * v9fs_fid_lookup - retrieve the right fid from a particular dentry + * @dentry: dentry to look for fid in + * @type: intent of lookup (operation or traversal) + * + * search list of fids associated with a dentry for a fid with a matching + * thread id or uid. If that fails, look up the dentry's parents to see if you + * can find a matching fid. + * + */ + +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) +{ + struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; + struct v9fs_fid *current_fid = NULL; + struct v9fs_fid *temp = NULL; + struct v9fs_fid *return_fid = NULL; + int found_parent = 0; + int found_user = 0; + + dprintk(DEBUG_9P, " dentry: %s (%p) type %d\n", dentry->d_iname, dentry, + type); + + if (fid_list && !list_empty(fid_list)) { + list_for_each_entry_safe(current_fid, temp, fid_list, list) { + if (current_fid->uid == current->uid) { + if (return_fid == NULL) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_user = 1; + } + } + } + if (current_fid->pid == current->real_parent->pid) { + if ((return_fid == NULL) || (found_parent) + || (found_user)) { + if ((type == FID_OP) + || (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 1; + found_user = 0; + } + } + } + if (current_fid->pid == current->pid) { + if ((type == FID_OP) || + (!current_fid->fidopen)) { + return_fid = current_fid; + found_parent = 0; + found_user = 0; + } + } + } + } + + /* we are at the root but didn't match */ + if ((!return_fid) && (dentry->d_parent == dentry)) { + /* TODO: clone attach with new uid */ + return_fid = current_fid; + } + + if (!return_fid) { + struct dentry *par = current->fs->pwd->d_parent; + int count = 1; + while (par != NULL) { + if (par == dentry) + break; + count++; + if (par == par->d_parent) { + dprintk(DEBUG_ERROR, + "got to root without finding dentry\n"); + break; + } + par = par->d_parent; + } + +/* XXX - there may be some duplication we can get rid of */ + if (par == dentry) { + /* we need to fid_lookup the starting point */ + int fidnum = -1; + int oldfid = -1; + int result = -1; + struct v9fs_session_info *v9ses = + v9fs_inode2v9ses(current->fs->pwd->d_inode); + + current_fid = + v9fs_fid_lookup(current->fs->pwd, FID_WALK); + if (current_fid == NULL) { + dprintk(DEBUG_ERROR, + "process cwd doesn't have a fid\n"); + return return_fid; + } + oldfid = current_fid->fid; + par = current->fs->pwd; + /* TODO: take advantage of multiwalk */ + + fidnum = v9fs_get_idpool(&v9ses->fidpool); + if (fidnum < 0) { + dprintk(DEBUG_ERROR, + "could not get a new fid num\n"); + return return_fid; + } + + while (par != dentry) { + result = + v9fs_t_walk(v9ses, oldfid, fidnum, "..", + NULL); + if (result < 0) { + dprintk(DEBUG_ERROR, + "problem walking to parent\n"); + + break; + } + oldfid = fidnum; + if (par == par->d_parent) { + dprintk(DEBUG_ERROR, + "can't find dentry\n"); + break; + } + par = par->d_parent; + } + if (par == dentry) { + return_fid = v9fs_fid_create(dentry); + return_fid->fid = fidnum; + } + } + } + + return return_fid; +} diff --git a/fs/9p/fid.h b/fs/9p/fid.h new file mode 100644 index 0000000..7db478c --- /dev/null +++ b/fs/9p/fid.h @@ -0,0 +1,57 @@ +/* + * V9FS FID Management + * + * Copyright (C) 2005 by Eric Van Hensbergen + * + * 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: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include + +#define FID_OP 0 +#define FID_WALK 1 + +struct v9fs_fid { + struct list_head list; /* list of fids associated with a dentry */ + struct list_head active; /* XXX - debug */ + + u32 fid; + unsigned char fidopen; /* set when fid is opened */ + unsigned char fidcreate; /* set when fid was just created */ + unsigned char fidclunked; /* set when fid has already been clunked */ + + struct v9fs_qid qid; + u32 iounit; + + /* readdir stuff */ + int rdir_fpos; + loff_t rdir_pos; + struct v9fs_fcall *rdir_fcall; + + /* management stuff */ + pid_t pid; /* thread associated with this fid */ + uid_t uid; /* user associated with this fid */ + + /* private data */ + struct file *filp; /* backpointer to File struct for open files */ + struct v9fs_session_info *v9ses; /* session info for this FID */ +}; + +struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type); +void v9fs_fid_destroy(struct v9fs_fid *fid); +struct v9fs_fid *v9fs_fid_create(struct dentry *); -- cgit v0.10.2 From 1346f51ede71fc1e5021062898d150e192dc4dc8 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:25 -0700 Subject: [PATCH] v9fs: Change error magic numbers to defined constants Change magic error numbers to system defined constants in v9fs error.h As suggested by Jan-Benedict Glaw. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 4bf2cf5..6dbb66f 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -30,6 +30,7 @@ */ #include +#include struct errormap { char *name; @@ -43,87 +44,82 @@ static struct hlist_head hash_errmap[ERRHASHSZ]; /* FixMe - reduce to a reasonable size */ static struct errormap errmap[] = { - {"Operation not permitted", 1}, - {"wstat prohibited", 1}, - {"No such file or directory", 2}, - {"file not found", 2}, - {"Interrupted system call", 4}, - {"Input/output error", 5}, - {"No such device or address", 6}, - {"Argument list too long", 7}, - {"Bad file descriptor", 9}, - {"Resource temporarily unavailable", 11}, - {"Cannot allocate memory", 12}, - {"Permission denied", 13}, - {"Bad address", 14}, - {"Block device required", 15}, - {"Device or resource busy", 16}, - {"File exists", 17}, - {"Invalid cross-device link", 18}, - {"No such device", 19}, - {"Not a directory", 20}, - {"Is a directory", 21}, - {"Invalid argument", 22}, - {"Too many open files in system", 23}, - {"Too many open files", 24}, - {"Text file busy", 26}, - {"File too large", 27}, - {"No space left on device", 28}, - {"Illegal seek", 29}, - {"Read-only file system", 30}, - {"Too many links", 31}, - {"Broken pipe", 32}, - {"Numerical argument out of domain", 33}, - {"Numerical result out of range", 34}, - {"Resource deadlock avoided", 35}, - {"File name too long", 36}, - {"No locks available", 37}, - {"Function not implemented", 38}, - {"Directory not empty", 39}, - {"Too many levels of symbolic links", 40}, - {"Unknown error 41", 41}, - {"No message of desired type", 42}, - {"Identifier removed", 43}, - {"File locking deadlock error", 58}, - {"No data available", 61}, - {"Machine is not on the network", 64}, - {"Package not installed", 65}, - {"Object is remote", 66}, - {"Link has been severed", 67}, - {"Communication error on send", 70}, - {"Protocol error", 71}, - {"Bad message", 74}, - {"File descriptor in bad state", 77}, - {"Streams pipe error", 86}, - {"Too many users", 87}, - {"Socket operation on non-socket", 88}, - {"Message too long", 90}, - {"Protocol not available", 92}, - {"Protocol not supported", 93}, - {"Socket type not supported", 94}, - {"Operation not supported", 95}, - {"Protocol family not supported", 96}, - {"Network is down", 100}, - {"Network is unreachable", 101}, - {"Network dropped connection on reset", 102}, - {"Software caused connection abort", 103}, - {"Connection reset by peer", 104}, - {"No buffer space available", 105}, - {"Transport endpoint is already connected", 106}, - {"Transport endpoint is not connected", 107}, - {"Cannot send after transport endpoint shutdown", 108}, - {"Connection timed out", 110}, - {"Connection refused", 111}, - {"Host is down", 112}, - {"No route to host", 113}, - {"Operation already in progress", 114}, - {"Operation now in progress", 115}, - {"Is a named type file", 120}, - {"Remote I/O error", 121}, - {"Disk quota exceeded", 122}, - {"Operation canceled", 125}, - {"Unknown error 126", 126}, - {"Unknown error 127", 127}, + {"Operation not permitted", EPERM}, + {"wstat prohibited", EPERM}, + {"No such file or directory", ENOENT}, + {"file not found", ENOENT}, + {"Interrupted system call", EINTR}, + {"Input/output error", EIO}, + {"No such device or address", ENXIO}, + {"Argument list too long", E2BIG}, + {"Bad file descriptor", EBADF}, + {"Resource temporarily unavailable", EAGAIN}, + {"Cannot allocate memory", ENOMEM}, + {"Permission denied", EACCES}, + {"Bad address", EFAULT}, + {"Block device required", ENOTBLK}, + {"Device or resource busy", EBUSY}, + {"File exists", EEXIST}, + {"Invalid cross-device link", EXDEV}, + {"No such device", ENODEV}, + {"Not a directory", ENOTDIR}, + {"Is a directory", EISDIR}, + {"Invalid argument", EINVAL}, + {"Too many open files in system", ENFILE}, + {"Too many open files", EMFILE}, + {"Text file busy", ETXTBSY}, + {"File too large", EFBIG}, + {"No space left on device", ENOSPC}, + {"Illegal seek", ESPIPE}, + {"Read-only file system", EROFS}, + {"Too many links", EMLINK}, + {"Broken pipe", EPIPE}, + {"Numerical argument out of domain", EDOM}, + {"Numerical result out of range", ERANGE}, + {"Resource deadlock avoided", EDEADLK}, + {"File name too long", ENAMETOOLONG}, + {"No locks available", ENOLCK}, + {"Function not implemented", ENOSYS}, + {"Directory not empty", ENOTEMPTY}, + {"Too many levels of symbolic links", ELOOP}, + {"No message of desired type", ENOMSG}, + {"Identifier removed", EIDRM}, + {"No data available", ENODATA}, + {"Machine is not on the network", ENONET}, + {"Package not installed", ENOPKG}, + {"Object is remote", EREMOTE}, + {"Link has been severed", ENOLINK}, + {"Communication error on send", ECOMM}, + {"Protocol error", EPROTO}, + {"Bad message", EBADMSG}, + {"File descriptor in bad state", EBADFD}, + {"Streams pipe error", ESTRPIPE}, + {"Too many users", EUSERS}, + {"Socket operation on non-socket", ENOTSOCK}, + {"Message too long", EMSGSIZE}, + {"Protocol not available", ENOPROTOOPT}, + {"Protocol not supported", EPROTONOSUPPORT}, + {"Socket type not supported", ESOCKTNOSUPPORT}, + {"Operation not supported", EOPNOTSUPP}, + {"Protocol family not supported", EPFNOSUPPORT}, + {"Network is down", ENETDOWN}, + {"Network is unreachable", ENETUNREACH}, + {"Network dropped connection on reset", ENETRESET}, + {"Software caused connection abort", ECONNABORTED}, + {"Connection reset by peer", ECONNRESET}, + {"No buffer space available", ENOBUFS}, + {"Transport endpoint is already connected", EISCONN}, + {"Transport endpoint is not connected", ENOTCONN}, + {"Cannot send after transport endpoint shutdown", ESHUTDOWN}, + {"Connection timed out", ETIMEDOUT}, + {"Connection refused", ECONNREFUSED}, + {"Host is down", EHOSTDOWN}, + {"No route to host", EHOSTUNREACH}, + {"Operation already in progress", EALREADY}, + {"Operation now in progress", EINPROGRESS}, + {"Is a named type file", EISNAM}, + {"Remote I/O error", EREMOTEIO}, + {"Disk quota exceeded", EDQUOT}, /* errors from fossil, vacfs, and u9fs */ {"fid unknown or out of range", EBADF}, {"permission denied", EACCES}, -- cgit v0.10.2 From 73c592b9b844cc353bbaea690fb4aa652ac168a6 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:26 -0700 Subject: [PATCH] v9fs: Clean-up vfs_inode and setattr functions Cleanup code in v9fs vfs_inode as suggested by Alexey Dobriyan. Did some major revamping of the v9fs setattr code to remove unnecessary allocations and clean up some dead-code. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 6dbb66f..2eb5927 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -139,7 +139,7 @@ static struct errormap errmap[] = { {"illegal mode", EINVAL}, {"illegal name", ENAMETOOLONG}, {"not a directory", ENOTDIR}, - {"not a member of proposed group", EINVAL}, + {"not a member of proposed group", EPERM}, {"not owner", EACCES}, {"only owner can change group in wstat", EACCES}, {"read only file system", EROFS}, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index ef78af7..6d2357d 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1,7 +1,7 @@ /* * linux/fs/9p/vfs_inode.c * - * This file contians vfs inode ops for the 9P2000 protocol. + * This file contains vfs inode ops for the 9P2000 protocol. * * Copyright (C) 2004 by Eric Van Hensbergen * Copyright (C) 2002 by Ron Minnich @@ -54,7 +54,7 @@ static struct inode_operations v9fs_symlink_inode_operations; * */ -static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) { int res; res = mode & 0777; @@ -92,7 +92,7 @@ static inline int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) * */ -static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) +static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) { int res; @@ -132,7 +132,7 @@ static inline int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) * */ -static inline void +static void v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) { mistat->type = ~0; @@ -160,7 +160,7 @@ v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat) /** * v9fs_mistat2unix - convert mistat to unix stat * @mistat: Plan 9 metadata (mistat) structure - * @stat: unix metadata (stat) structure to populate + * @buf: unix metadata (stat) structure to populate * @sb: superblock * */ @@ -177,22 +177,11 @@ v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, buf->st_mtime = mistat->mtime; buf->st_ctime = mistat->mtime; - if (v9ses && v9ses->extended) { - /* TODO: string to uid mapping via user-space daemon */ - buf->st_uid = mistat->n_uid; - buf->st_gid = mistat->n_gid; - - sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); - sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid); - } else { - buf->st_uid = v9ses->uid; - buf->st_gid = v9ses->gid; - } - buf->st_uid = (unsigned short)-1; buf->st_gid = (unsigned short)-1; if (v9ses && v9ses->extended) { + /* TODO: string to uid mapping via user-space daemon */ if (mistat->n_uid != -1) sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid); @@ -290,7 +279,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) * @dir: directory inode file is being created in * @file_dentry: dentry file is being created in * @perm: permissions file is being created with - * @open_mode: resulting open mode for file ??? + * @open_mode: resulting open mode for file * */ @@ -434,9 +423,9 @@ v9fs_create(struct inode *dir, /** * v9fs_remove - helper function to remove files and directories - * @inode: directory inode that is being deleted - * @dentry: dentry that is being deleted - * @rmdir: where we are a file or a directory + * @dir: directory inode that is being deleted + * @file: dentry that is being deleted + * @rmdir: removing a directory * */ @@ -502,7 +491,7 @@ v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, /** * v9fs_vfs_mkdir - VFS mkdir hook to create a directory - * @i: inode that is being unlinked + * @inode: inode that is being unlinked * @dentry: dentry that is being unlinked * @mode: mode for new directory * @@ -624,7 +613,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, /** * v9fs_vfs_unlink - VFS unlink hook to delete an inode * @i: inode that is being unlinked - * @dentry: dentry that is being unlinked + * @d: dentry that is being unlinked * */ @@ -636,7 +625,7 @@ static int v9fs_vfs_unlink(struct inode *i, struct dentry *d) /** * v9fs_vfs_rmdir - VFS unlink hook to delete a directory * @i: inode that is being unlinked - * @dentry: dentry that is being unlinked + * @d: dentry that is being unlinked * */ @@ -674,6 +663,9 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, dprintk(DEBUG_VFS, "\n"); + if (!mistat) + return -ENOMEM; + if ((!oldfid) || (!olddirfid) || (!newdirfid)) { dprintk(DEBUG_ERROR, "problem with arguments\n"); return -EBADF; @@ -771,20 +763,21 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) { struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); - struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); struct v9fs_fcall *fcall = NULL; + struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); int res = -EPERM; dprintk(DEBUG_VFS, "\n"); + + if (!mistat) + return -ENOMEM; + if (!fid) { dprintk(DEBUG_ERROR, "Couldn't find fid associated with dentry\n"); return -EBADF; } - if (!mistat) - return -ENOMEM; - v9fs_blank_mistat(v9ses, mistat); if (iattr->ia_valid & ATTR_MODE) mistat->mode = unixmode2p9mode(v9ses, iattr->ia_mode); @@ -799,72 +792,19 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) mistat->length = iattr->ia_size; if (v9ses->extended) { - char *uid = kmalloc(strlen(mistat->uid), GFP_KERNEL); - char *gid = kmalloc(strlen(mistat->gid), GFP_KERNEL); - char *muid = kmalloc(strlen(mistat->muid), GFP_KERNEL); - char *name = kmalloc(strlen(mistat->name), GFP_KERNEL); - char *extension = kmalloc(strlen(mistat->extension), - GFP_KERNEL); - - if ((!uid) || (!gid) || (!muid) || (!name) || (!extension)) { - kfree(uid); - kfree(gid); - kfree(muid); - kfree(name); - kfree(extension); - - return -ENOMEM; - } - - strcpy(uid, mistat->uid); - strcpy(gid, mistat->gid); - strcpy(muid, mistat->muid); - strcpy(name, mistat->name); - strcpy(extension, mistat->extension); + char *ptr = mistat->data+1; if (iattr->ia_valid & ATTR_UID) { - if (strlen(uid) != 8) { - dprintk(DEBUG_ERROR, "uid strlen is %u not 8\n", - (unsigned int)strlen(uid)); - sprintf(uid, "%08x", iattr->ia_uid); - } else { - kfree(uid); - uid = kmalloc(9, GFP_KERNEL); - } - - sprintf(uid, "%08x", iattr->ia_uid); + mistat->uid = ptr; + ptr += 1+sprintf(ptr, "%08x", iattr->ia_uid); mistat->n_uid = iattr->ia_uid; } if (iattr->ia_valid & ATTR_GID) { - if (strlen(gid) != 8) - dprintk(DEBUG_ERROR, "gid strlen is %u not 8\n", - (unsigned int)strlen(gid)); - else { - kfree(gid); - gid = kmalloc(9, GFP_KERNEL); - } - - sprintf(gid, "%08x", iattr->ia_gid); + mistat->gid = ptr; + ptr += 1+sprintf(ptr, "%08x", iattr->ia_gid); mistat->n_gid = iattr->ia_gid; } - - mistat->uid = mistat->data; - strcpy(mistat->uid, uid); - mistat->gid = mistat->data + strlen(uid) + 1; - strcpy(mistat->gid, gid); - mistat->muid = mistat->gid + strlen(gid) + 1; - strcpy(mistat->muid, muid); - mistat->name = mistat->muid + strlen(muid) + 1; - strcpy(mistat->name, name); - mistat->extension = mistat->name + strlen(name) + 1; - strcpy(mistat->extension, extension); - - kfree(uid); - kfree(gid); - kfree(muid); - kfree(name); - kfree(extension); } res = v9fs_t_wstat(v9ses, fid->fid, mistat, &fcall); @@ -985,17 +925,14 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) int retval = -EPERM; struct v9fs_fid *newfid; struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); - struct super_block *sb = dir ? dir->i_sb : NULL; struct v9fs_fcall *fcall = NULL; struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, symname); - if ((!dentry) || (!sb) || (!v9ses)) { - dprintk(DEBUG_ERROR, "problem with arguments\n"); - return -EBADF; - } + if (!mistat) + return -ENOMEM; if (!v9ses->extended) { dprintk(DEBUG_ERROR, "not extended\n"); @@ -1040,7 +977,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) /** * v9fs_readlink - read a symlink's location (internal version) * @dentry: dentry for symlink - * @buf: buffer to load symlink location into + * @buffer: buffer to load symlink location into * @buflen: length of buffer * */ @@ -1179,7 +1116,7 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void * v9fs_vfs_link - create a hardlink * @old_dentry: dentry for file to link to * @dir: inode destination for new link - * @new_dentry: dentry for link + * @dentry: dentry for link * */ @@ -1274,6 +1211,9 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) dprintk(DEBUG_VFS, " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); + if (!mistat) + return -ENOMEM; + if (!new_valid_dev(rdev)) { retval = -EINVAL; goto FreeMem; @@ -1302,7 +1242,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) sprintf(symname, "b %u %u", MAJOR(rdev), MINOR(rdev)); else if (S_ISCHR(mode)) sprintf(symname, "c %u %u", MAJOR(rdev), MINOR(rdev)); - else if (S_ISFIFO(mode)) ; /* DO NOTHING */ + else if (S_ISFIFO(mode)) + ; /* DO NOTHING */ else { retval = -EINVAL; goto FreeMem; @@ -1319,8 +1260,6 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) FCALL_ERROR(fcall)); goto FreeMem; } - - kfree(fcall); } /* need to update dcache so we show up */ -- cgit v0.10.2 From 5d58bec5b7a8b8303df0a4dcb9a18feeefac6091 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:27 -0700 Subject: [PATCH] v9fs: Fix support for special files (devices, named pipes, etc.) Fix v9fs special files (block, char devices) support. Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 6d2357d..36fff08 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -250,6 +250,9 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) case S_IFBLK: case S_IFCHR: case S_IFSOCK: + init_special_inode(inode, inode->i_mode, + inode->i_rdev); + break; case S_IFREG: inode->i_op = &v9fs_file_inode_operations; inode->i_fop = &v9fs_file_operations; -- cgit v0.10.2 From b501611a6f78558eafcf09b228abd866d4ea5d9f Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:27 -0700 Subject: [PATCH] v9fs: readlink extended mode check LANL reported some issues with random crashes during mount of legacy protocol servers (9P2000 versus 9P2000.u) -- crash was always happening in readlink (which should never happen in legacy mode). Added some sanity conditionals to the get_inode code which should prevent the errors LANL was seeing. Code tested benign through regression. Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 36fff08..0c13fc6 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -44,6 +44,7 @@ #include "fid.h" static struct inode_operations v9fs_dir_inode_operations; +static struct inode_operations v9fs_dir_inode_operations_ext; static struct inode_operations v9fs_file_inode_operations; static struct inode_operations v9fs_symlink_inode_operations; @@ -232,6 +233,7 @@ v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf, struct inode *v9fs_get_inode(struct super_block *sb, int mode) { struct inode *inode = NULL; + struct v9fs_session_info *v9ses = sb->s_fs_info; dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); @@ -250,6 +252,10 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) case S_IFBLK: case S_IFCHR: case S_IFSOCK: + if(!v9ses->extended) { + dprintk(DEBUG_ERROR, "special files without extended mode\n"); + return ERR_PTR(-EINVAL); + } init_special_inode(inode, inode->i_mode, inode->i_rdev); break; @@ -257,14 +263,21 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) inode->i_op = &v9fs_file_inode_operations; inode->i_fop = &v9fs_file_operations; break; + case S_IFLNK: + if(!v9ses->extended) { + dprintk(DEBUG_ERROR, "extended modes used w/o 9P2000.u\n"); + return ERR_PTR(-EINVAL); + } + inode->i_op = &v9fs_symlink_inode_operations; + break; case S_IFDIR: inode->i_nlink++; - inode->i_op = &v9fs_dir_inode_operations; + if(v9ses->extended) + inode->i_op = &v9fs_dir_inode_operations_ext; + else + inode->i_op = &v9fs_dir_inode_operations; inode->i_fop = &v9fs_dir_operations; break; - case S_IFLNK: - inode->i_op = &v9fs_symlink_inode_operations; - break; default: dprintk(DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", mode, mode & S_IFMT); @@ -1284,7 +1297,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) return retval; } -static struct inode_operations v9fs_dir_inode_operations = { +static struct inode_operations v9fs_dir_inode_operations_ext = { .create = v9fs_vfs_create, .lookup = v9fs_vfs_lookup, .symlink = v9fs_vfs_symlink, @@ -1299,6 +1312,18 @@ static struct inode_operations v9fs_dir_inode_operations = { .setattr = v9fs_vfs_setattr, }; +static struct inode_operations v9fs_dir_inode_operations = { + .create = v9fs_vfs_create, + .lookup = v9fs_vfs_lookup, + .unlink = v9fs_vfs_unlink, + .mkdir = v9fs_vfs_mkdir, + .rmdir = v9fs_vfs_rmdir, + .mknod = v9fs_vfs_mknod, + .rename = v9fs_vfs_rename, + .getattr = v9fs_vfs_getattr, + .setattr = v9fs_vfs_setattr, +}; + static struct inode_operations v9fs_file_inode_operations = { .getattr = v9fs_vfs_getattr, .setattr = v9fs_vfs_setattr, -- cgit v0.10.2 From cb2e87a65d6cd735eb06fa595bf90497af28c37b Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 9 Sep 2005 13:04:28 -0700 Subject: [PATCH] v9fs: fix handling of malformed 9P messages This patch attempts to do a better job of cleaning up after detecting errors on the transport. This should also improve error reporting on broken connections to servers. Signed-off-by: Latchesar Ionkov Signed-off-by: Eric Van Hensbergen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/fs/9p/error.h b/fs/9p/error.h index 2eb5927..78f89ac 100644 --- a/fs/9p/error.h +++ b/fs/9p/error.h @@ -47,6 +47,7 @@ static struct errormap errmap[] = { {"Operation not permitted", EPERM}, {"wstat prohibited", EPERM}, {"No such file or directory", ENOENT}, + {"directory entry not found", ENOENT}, {"file not found", ENOENT}, {"Interrupted system call", EINTR}, {"Input/output error", EIO}, diff --git a/fs/9p/mux.c b/fs/9p/mux.c index 0854bef..8835b57 100644 --- a/fs/9p/mux.c +++ b/fs/9p/mux.c @@ -162,18 +162,21 @@ static int v9fs_recv(struct v9fs_session_info *v9ses, struct v9fs_rpcreq *req) dprintk(DEBUG_MUX, "waiting for response: %d\n", req->tcall->tag); ret = wait_event_interruptible(v9ses->read_wait, ((v9ses->transport->status != Connected) || - (req->rcall != 0) || dprintcond(v9ses, req))); + (req->rcall != 0) || (req->err < 0) || + dprintcond(v9ses, req))); dprintk(DEBUG_MUX, "got it: rcall %p\n", req->rcall); + + spin_lock(&v9ses->muxlock); + list_del(&req->next); + spin_unlock(&v9ses->muxlock); + + if (req->err < 0) + return req->err; + if (v9ses->transport->status == Disconnected) return -ECONNRESET; - if (ret == 0) { - spin_lock(&v9ses->muxlock); - list_del(&req->next); - spin_unlock(&v9ses->muxlock); - } - return ret; } @@ -245,6 +248,9 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, if (!v9ses) return -EINVAL; + if (!v9ses->transport || v9ses->transport->status != Connected) + return -EIO; + if (rcall) *rcall = NULL; @@ -257,6 +263,7 @@ v9fs_mux_rpc(struct v9fs_session_info *v9ses, struct v9fs_fcall *tcall, tcall->tag = tid; req.tcall = tcall; + req.err = 0; req.rcall = NULL; ret = v9fs_send(v9ses, &req); @@ -371,16 +378,21 @@ static int v9fs_recvproc(void *data) } err = read_message(v9ses, rcall, v9ses->maxdata + V9FS_IOHDRSZ); - if (err < 0) { - kfree(rcall); - break; - } spin_lock(&v9ses->muxlock); - list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { - if (rreq->tcall->tag == rcall->tag) { - req = rreq; - req->rcall = rcall; - break; + if (err < 0) { + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + rreq->err = err; + } + if(err != -ERESTARTSYS) + eprintk(KERN_ERR, + "Transport error while reading message %d\n", err); + } else { + list_for_each_entry_safe(rreq, rptr, &v9ses->mux_fcalls, next) { + if (rreq->tcall->tag == rcall->tag) { + req = rreq; + req->rcall = rcall; + break; + } } } @@ -399,9 +411,10 @@ static int v9fs_recvproc(void *data) spin_unlock(&v9ses->muxlock); if (!req) { - dprintk(DEBUG_ERROR, - "unexpected response: id %d tag %d\n", - rcall->id, rcall->tag); + if (err >= 0) + dprintk(DEBUG_ERROR, + "unexpected response: id %d tag %d\n", + rcall->id, rcall->tag); kfree(rcall); } @@ -410,6 +423,8 @@ static int v9fs_recvproc(void *data) set_current_state(TASK_INTERRUPTIBLE); } + v9ses->transport->close(v9ses->transport); + /* Inform all pending processes about the failure */ wake_up_all(&v9ses->read_wait); diff --git a/fs/9p/mux.h b/fs/9p/mux.h index 82ce793..4994cb1 100644 --- a/fs/9p/mux.h +++ b/fs/9p/mux.h @@ -28,6 +28,7 @@ struct v9fs_rpcreq { struct v9fs_fcall *tcall; struct v9fs_fcall *rcall; + int err; /* error code if response failed */ /* XXX - could we put scatter/gather buffers here? */ diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c index 081d1c8..01e26f0 100644 --- a/fs/9p/trans_sock.c +++ b/fs/9p/trans_sock.c @@ -254,7 +254,12 @@ v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name, static void v9fs_sock_close(struct v9fs_transport *trans) { - struct v9fs_trans_sock *ts = trans ? trans->priv : NULL; + struct v9fs_trans_sock *ts; + + if (!trans) + return; + + ts = trans->priv; if ((ts) && (ts->s)) { dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s); @@ -264,7 +269,10 @@ static void v9fs_sock_close(struct v9fs_transport *trans) dprintk(DEBUG_TRANS, "socket closed\n"); } - kfree(ts); + if (ts) + kfree(ts); + + trans->priv = NULL; } struct v9fs_transport v9fs_trans_tcp = { -- cgit v0.10.2 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 diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 35c88bd..751890a 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 4ff853f..a8eee79 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); } } diff --git a/include/linux/fb.h b/include/linux/fb.h index bc24bee..70da819 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -495,6 +495,9 @@ struct fb_cursor_user { #define FB_EVENT_BLANK 0x08 /* Private modelist is to be replaced */ #define FB_EVENT_NEW_MODELIST 0x09 +/* The resolution of the passed in fb_info about to change and + all vc's should be changed */ +#define FB_EVENT_MODE_CHANGE_ALL 0x0A struct fb_event { struct fb_info *info; -- cgit v0.10.2 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 diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S index 0587477..02bf625 100644 --- a/arch/i386/boot/video.S +++ b/arch/i386/boot/video.S @@ -97,6 +97,7 @@ #define PARAM_VESAPM_OFF 0x30 #define PARAM_LFB_PAGES 0x32 #define PARAM_VESA_ATTRIB 0x34 +#define PARAM_CAPABILITIES 0x36 /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */ #ifdef CONFIG_VIDEO_RETAIN @@ -233,6 +234,10 @@ mopar_gr: movw 18(%di), %ax movl %eax, %fs:(PARAM_LFB_SIZE) +# store mode capabilities + movl 10(%di), %eax + movl %eax, %fs:(PARAM_CAPABILITIES) + # switching the DAC to 8-bit is for <= 8 bpp only movw %fs:(PARAM_LFB_DEPTH), %ax cmpw $8, %ax diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index a272592..1ca8026 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c @@ -19,6 +19,7 @@ #include #include #include +#include