summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-12-10 17:29:47 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-12-10 17:29:47 -0200
commitc3e004458c858a5cea7dc5a693c25b301c0a47a8 (patch)
treeb7aced58dd900d9afd01531ffefd1b00dffda92c
parentdf971dfe066837946222937b94068df80d1270f2 (diff)
parent73718ca8bbd9619f9d42780499c63b32fd074052 (diff)
downloadmediapointer-dvb-s2-c3e004458c858a5cea7dc5a693c25b301c0a47a8.tar.gz
mediapointer-dvb-s2-c3e004458c858a5cea7dc5a693c25b301c0a47a8.tar.bz2
merge backout patch
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--INSTALL11
-rw-r--r--linux/Documentation/video4linux/CARDLIST.ivtv6
-rw-r--r--linux/drivers/media/video/ivtv/Kconfig1
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-cards.c76
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-cards.h27
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-driver.c89
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-driver.h2
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-i2c.c107
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-i2c.h1
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-ioctl.c2
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-irq.c4
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-streams.c4
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-version.h2
-rw-r--r--linux/drivers/media/video/ivtv/ivtvfb.c2
-rw-r--r--linux/drivers/media/video/m52790.c2
-rw-r--r--linux/drivers/media/video/saa7127.c2
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-cards.c1
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--linux/drivers/media/video/upd64031a.c2
-rw-r--r--linux/drivers/media/video/upd64083.c2
-rw-r--r--linux/drivers/media/video/videobuf-core.c290
-rw-r--r--linux/drivers/media/video/videobuf-vmalloc.c6
-rw-r--r--linux/drivers/media/video/vivi.c662
-rw-r--r--linux/drivers/media/video/vp27smpx.c2
-rw-r--r--linux/drivers/media/video/wm8739.c5
-rw-r--r--linux/include/media/v4l2-i2c-drv.h3
-rw-r--r--v4l/Makefile12
-rwxr-xr-xv4l/scripts/check.pl118
-rwxr-xr-xv4l/scripts/checkpatch.pl395
29 files changed, 1183 insertions, 654 deletions
diff --git a/INSTALL b/INSTALL
index 0a0647bb5..bad6ca80b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -106,3 +106,14 @@ update - updates the tree from master repository
commit - commits the change, asking for a commit msg
push - sends outgoing stuff to master repository
+
+checkemacs - checks codingstyle and reports to emacs
+ using "make checkemacs" at emacs compile menu,
+ will report the lines with errors inside emacs.
+
+checkpatch - checks codingstyle and reports using the same
+ format as c. This way, c error parsers will
+ handle it.
+
+checkterse - checks codingstyle and reports using terse
+ syntax, used on several compilaton tools.
diff --git a/linux/Documentation/video4linux/CARDLIST.ivtv b/linux/Documentation/video4linux/CARDLIST.ivtv
index ddd76a0eb..a019e27e4 100644
--- a/linux/Documentation/video4linux/CARDLIST.ivtv
+++ b/linux/Documentation/video4linux/CARDLIST.ivtv
@@ -16,3 +16,9 @@
16 -> GOTVIEW PCI DVD2 Deluxe [ffac:0600]
17 -> Yuan MPC622 [ff01:d998]
18 -> Digital Cowboy DCT-MTVP1 [1461:bfff]
+19 -> Yuan PG600V2/GotView PCI DVD Lite [ffab:0600,ffad:0600]
+20 -> Club3D ZAP-TV1x01 [ffab:0600]
+21 -> AverTV MCE 116 Plus [1461:c439]
+22 -> ASUS Falcon2 [1043:4b66,1043:462e,1043:4b2e]
+23 -> AverMedia PVR-150 Plus [1461:c035]
+24 -> AverMedia EZMaker PCI Deluxe [1461:c03f]
diff --git a/linux/drivers/media/video/ivtv/Kconfig b/linux/drivers/media/video/ivtv/Kconfig
index 6e5eed5e2..270906fc3 100644
--- a/linux/drivers/media/video/ivtv/Kconfig
+++ b/linux/drivers/media/video/ivtv/Kconfig
@@ -3,6 +3,7 @@ config VIDEO_IVTV
depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
select I2C_ALGOBIT
select FW_LOADER
+ select VIDEO_IR
select VIDEO_TUNER
select VIDEO_TVEEPROM
select VIDEO_CX2341X
diff --git a/linux/drivers/media/video/ivtv/ivtv-cards.c b/linux/drivers/media/video/ivtv/ivtv-cards.c
index 664fdbca5..654d225a5 100644
--- a/linux/drivers/media/video/ivtv/ivtv-cards.c
+++ b/linux/drivers/media/video/ivtv/ivtv-cards.c
@@ -40,6 +40,27 @@
#define MSP_MONO MSP_INPUT(MSP_IN_MONO, MSP_IN_TUNER1, \
MSP_DSP_IN_SCART, MSP_DSP_IN_SCART)
+/* usual i2c tuner addresses to probe */
+static struct ivtv_card_tuner_i2c ivtv_i2c_std = {
+ .radio = { I2C_CLIENT_END },
+ .demod = { 0x43, I2C_CLIENT_END },
+ .tv = { 0x61, 0x60, I2C_CLIENT_END },
+};
+
+/* as above, but with possible radio tuner */
+static struct ivtv_card_tuner_i2c ivtv_i2c_radio = {
+ .radio = { 0x60, I2C_CLIENT_END },
+ .demod = { 0x43, I2C_CLIENT_END },
+ .tv = { 0x61, I2C_CLIENT_END },
+};
+
+/* using the tda8290+75a combo */
+static struct ivtv_card_tuner_i2c ivtv_i2c_tda8290 = {
+ .radio = { I2C_CLIENT_END },
+ .demod = { I2C_CLIENT_END },
+ .tv = { 0x4b, I2C_CLIENT_END },
+};
+
/********************** card configuration *******************************/
/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
@@ -73,6 +94,7 @@ static const struct ivtv_card ivtv_card_pvr250 = {
{ IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
},
.radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -127,6 +149,7 @@ static const struct ivtv_card ivtv_card_pvr350 = {
{ IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
},
.radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
+ .i2c = &ivtv_i2c_std,
};
/* PVR-350 V1 boards have a different audio tuner input and use a
@@ -158,6 +181,7 @@ static const struct ivtv_card ivtv_card_pvr350_v1 = {
{ IVTV_CARD_INPUT_LINE_IN2, MSP_SCART3 },
},
.radio_input = { IVTV_CARD_INPUT_AUD_TUNER, MSP_SCART2 },
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -193,6 +217,7 @@ static const struct ivtv_card ivtv_card_pvr150 = {
CX25840_AUDIO_SERIAL, WM8775_AIN4 },
/* apparently needed for the IR blaster */
.gpio_init = { .direction = 0x1f01, .initial_value = 0x26f3 },
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -235,6 +260,7 @@ static const struct ivtv_card ivtv_card_m179 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_NTSC },
},
.pci_list = ivtv_pci_m179,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -276,6 +302,7 @@ static const struct ivtv_card ivtv_card_mpg600 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_mpg600,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -316,6 +343,7 @@ static const struct ivtv_card ivtv_card_mpg160 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_mpg160,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -351,6 +379,7 @@ static const struct ivtv_card ivtv_card_pg600 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_pg600,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -394,6 +423,7 @@ static const struct ivtv_card ivtv_card_avc2410 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
},
.pci_list = ivtv_pci_avc2410,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -464,6 +494,7 @@ static const struct ivtv_card ivtv_card_tg5000tv = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_tg5000tv,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -494,6 +525,7 @@ static const struct ivtv_card ivtv_card_va2000 = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_va2000,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -538,6 +570,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
},
.pci_list = ivtv_pci_cx23416gyc,
+ .i2c = &ivtv_i2c_std,
};
static const struct ivtv_card ivtv_card_cx23416gyc_nogr = {
@@ -568,6 +601,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogr = {
{ .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
},
+ .i2c = &ivtv_i2c_std,
};
static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = {
@@ -597,6 +631,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = {
{ .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 },
},
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -636,6 +671,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 },
},
.pci_list = ivtv_pci_gv_mvprx,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -672,6 +708,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx2e = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 },
},
.pci_list = ivtv_pci_gv_mvprx2e,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -706,6 +743,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd = {
{ .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
},
.pci_list = ivtv_pci_gotview_pci_dvd,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -744,6 +782,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd2 = {
{ .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 },
},
.pci_list = ivtv_pci_gotview_pci_dvd2,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -779,6 +818,7 @@ static const struct ivtv_card ivtv_card_yuan_mpc622 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_TDA8290 },
},
.pci_list = ivtv_pci_yuan_mpc622,
+ .i2c = &ivtv_i2c_tda8290,
};
/* ------------------------------------------------------------------------- */
@@ -820,6 +860,7 @@ static const struct ivtv_card ivtv_card_dctmvtvp1 = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 },
},
.pci_list = ivtv_pci_dctmvtvp1,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -867,6 +908,7 @@ static const struct ivtv_card ivtv_card_pg600v2 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
},
.pci_list = ivtv_pci_pg600v2,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -913,6 +955,7 @@ static const struct ivtv_card ivtv_card_club3d = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
},
.pci_list = ivtv_pci_club3d,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -958,6 +1001,7 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = {
{ .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
},
.pci_list = ivtv_pci_avertv_mce116,
+ .i2c = &ivtv_i2c_std,
};
/* ------------------------------------------------------------------------- */
@@ -996,6 +1040,36 @@ static const struct ivtv_card ivtv_card_aver_pvr150 = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_TCL_2002N },
},
.pci_list = ivtv_pci_aver_pvr150,
+ .i2c = &ivtv_i2c_radio,
+};
+
+/* ------------------------------------------------------------------------- */
+
+/* AVerMedia EZMaker PCI Deluxe card */
+
+static const struct ivtv_card_pci_info ivtv_pci_aver_ezmaker[] = {
+ { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc03f },
+ { 0, 0, 0 }
+};
+
+static const struct ivtv_card ivtv_card_aver_ezmaker = {
+ .type = IVTV_CARD_AVER_EZMAKER,
+ .name = "AVerMedia EZMaker PCI Deluxe",
+ .v4l2_capabilities = IVTV_CAP_ENCODER,
+ .hw_video = IVTV_HW_CX25840,
+ .hw_audio = IVTV_HW_CX25840,
+ .hw_audio_ctrl = IVTV_HW_CX25840,
+ .hw_all = IVTV_HW_CX25840 | IVTV_HW_WM8739,
+ .video_inputs = {
+ { IVTV_CARD_INPUT_SVIDEO1, 0, CX25840_SVIDEO3 },
+ { IVTV_CARD_INPUT_COMPOSITE1, 0, CX25840_COMPOSITE1 },
+ },
+ .audio_inputs = {
+ { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 0 },
+ },
+ .gpio_init = { .direction = 0x4000, .initial_value = 0x4000 },
+ /* Does not have a tuner */
+ .pci_list = ivtv_pci_aver_ezmaker,
};
/* ------------------------------------------------------------------------- */
@@ -1034,6 +1108,7 @@ static const struct ivtv_card ivtv_card_asus_falcon2 = {
{ .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FM1236_MK3 },
},
.pci_list = ivtv_pci_asus_falcon2,
+ .i2c = &ivtv_i2c_std,
};
static const struct ivtv_card *ivtv_card_list[] = {
@@ -1060,6 +1135,7 @@ static const struct ivtv_card *ivtv_card_list[] = {
&ivtv_card_avertv_mce116,
&ivtv_card_asus_falcon2,
&ivtv_card_aver_pvr150,
+ &ivtv_card_aver_ezmaker,
/* Variations of standard cards but with the same PCI IDs.
These cards must come last in this list. */
diff --git a/linux/drivers/media/video/ivtv/ivtv-cards.h b/linux/drivers/media/video/ivtv/ivtv-cards.h
index 881b04473..191aafdd9 100644
--- a/linux/drivers/media/video/ivtv/ivtv-cards.h
+++ b/linux/drivers/media/video/ivtv/ivtv-cards.h
@@ -47,7 +47,8 @@
#define IVTV_CARD_AVERTV_MCE116 20 /* AVerTV MCE 116 Plus */
#define IVTV_CARD_ASUS_FALCON2 21 /* ASUS Falcon2 */
#define IVTV_CARD_AVER_PVR150PLUS 22 /* AVerMedia PVR-150 Plus */
-#define IVTV_CARD_LAST 22
+#define IVTV_CARD_AVER_EZMAKER 23 /* AVerMedia EZMaker PCI Deluxe */
+#define IVTV_CARD_LAST 23
/* Variants of existing cards but with the same PCI IDs. The driver
detects these based on other device information.
@@ -83,7 +84,7 @@
#define IVTV_PCI_ID_GOTVIEW1 0xffac
#define IVTV_PCI_ID_GOTVIEW2 0xffad
-/* hardware flags */
+/* hardware flags, no gaps allowed, IVTV_HW_GPIO must always be last */
#define IVTV_HW_CX25840 (1 << 0)
#define IVTV_HW_SAA7115 (1 << 1)
#define IVTV_HW_SAA7127 (1 << 2)
@@ -93,14 +94,13 @@
#define IVTV_HW_CS53L32A (1 << 6)
#define IVTV_HW_TVEEPROM (1 << 7)
#define IVTV_HW_SAA7114 (1 << 8)
-#define IVTV_HW_TVAUDIO (1 << 9)
-#define IVTV_HW_UPD64031A (1 << 10)
-#define IVTV_HW_UPD6408X (1 << 11)
-#define IVTV_HW_SAA717X (1 << 12)
-#define IVTV_HW_WM8739 (1 << 13)
-#define IVTV_HW_VP27SMPX (1 << 14)
-#define IVTV_HW_M52790 (1 << 15)
-#define IVTV_HW_GPIO (1 << 16)
+#define IVTV_HW_UPD64031A (1 << 9)
+#define IVTV_HW_UPD6408X (1 << 10)
+#define IVTV_HW_SAA717X (1 << 11)
+#define IVTV_HW_WM8739 (1 << 12)
+#define IVTV_HW_VP27SMPX (1 << 13)
+#define IVTV_HW_M52790 (1 << 14)
+#define IVTV_HW_GPIO (1 << 15)
#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
@@ -234,6 +234,12 @@ struct ivtv_card_tuner {
int tuner; /* tuner ID (from tuner.h) */
};
+struct ivtv_card_tuner_i2c {
+ unsigned short radio[2];/* radio tuner i2c address to probe */
+ unsigned short demod[2];/* demodulator i2c address to probe */
+ unsigned short tv[4]; /* tv tuner i2c addresses to probe */
+};
+
/* for card information/parameters */
struct ivtv_card {
int type;
@@ -261,6 +267,7 @@ struct ivtv_card {
struct ivtv_gpio_audio_detect gpio_audio_detect;
struct ivtv_card_tuner tuners[IVTV_CARD_MAX_TUNERS];
+ struct ivtv_card_tuner_i2c *i2c;
/* list of device and subsystem vendor/devices that
correspond to this card type. */
diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.c b/linux/drivers/media/video/ivtv/ivtv-driver.c
index 5a5634ee0..8cb43fc09 100644
--- a/linux/drivers/media/video/ivtv/ivtv-driver.c
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.c
@@ -187,6 +187,7 @@ MODULE_PARM_DESC(cardtype,
"\t\t\t21 = AverTV MCE 116 Plus\n"
"\t\t\t22 = ASUS Falcon2\n"
"\t\t\t23 = AverMedia PVR-150 Plus\n"
+ "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n"
"\t\t\t 0 = Autodetect (default)\n"
"\t\t\t-1 = Ignore this card\n\t\t");
MODULE_PARM_DESC(pal, "Set PAL standard: B, G, H, D, K, I, M, N, Nc, 60");
@@ -399,6 +400,7 @@ static void ivtv_process_eeprom(struct ivtv *itv)
itv->v4l2_cap = itv->card->v4l2_capabilities;
itv->card_name = itv->card->name;
+ itv->card_i2c = itv->card->i2c;
/* If this is a PVR500 then it should be possible to detect whether it is the
first or second unit by looking at the subsystem device ID: is bit 4 is
@@ -416,7 +418,14 @@ static void ivtv_process_eeprom(struct ivtv *itv)
This detection is needed since the eeprom reports incorrectly that a radio is
present on the second unit. */
if (tv.model / 1000 == 23) {
+ static const struct ivtv_card_tuner_i2c ivtv_i2c_radio = {
+ .radio = { 0x60, I2C_CLIENT_END },
+ .demod = { 0x43, I2C_CLIENT_END },
+ .tv = { 0x61, I2C_CLIENT_END },
+ };
+
itv->card_name = "WinTV PVR 500";
+ itv->card_i2c = &ivtv_i2c_radio;
if (pci_slot == 8 || pci_slot == 9) {
int is_first = (pci_slot & 1) == 0;
@@ -634,6 +643,7 @@ done:
}
itv->v4l2_cap = itv->card->v4l2_capabilities;
itv->card_name = itv->card->name;
+ itv->card_i2c = itv->card->i2c;
}
/* Precondition: the ivtv structure has been memset to 0. Only
@@ -819,79 +829,66 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
return 0;
}
-static void ivtv_request_module(struct ivtv *itv, const char *name)
+static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
+ const char *name, u32 id)
{
+ if ((hw & id) == 0)
+ return hw;
if (request_module(name) != 0) {
IVTV_ERR("Failed to load module %s\n", name);
- } else {
- IVTV_DEBUG_INFO("Loaded module %s\n", name);
+ return hw & ~id;
}
+ IVTV_DEBUG_INFO("Loaded module %s\n", name);
+ return hw;
}
static void ivtv_load_and_init_modules(struct ivtv *itv)
{
u32 hw = itv->card->hw_all;
- int i;
+ unsigned i;
/* load modules */
-#ifndef CONFIG_VIDEO_TUNER
- if (hw & IVTV_HW_TUNER) {
- if (itv->options.tuner == TUNER_XC2028) {
- IVTV_INFO("Xceive tuner not yet supported, only composite and S-Video inputs will be available\n");
- itv->tunerid = 1;
- }
- else {
- ivtv_request_module(itv, "tuner");
- }
+ if ((hw & IVTV_HW_TUNER) && itv->options.tuner == TUNER_XC2028) {
+ IVTV_INFO("Xceive tuner not yet supported, only composite\n");
+ IVTV_INFO("and S-Video inputs will be available\n");
+ hw &= ~IVTV_HW_TUNER;
}
+#ifndef CONFIG_VIDEO_TUNER
+ hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
#endif
#ifndef CONFIG_VIDEO_CX25840
- if (hw & IVTV_HW_CX25840)
- ivtv_request_module(itv, "cx25840");
+ hw = ivtv_request_module(itv, hw, "cx25840", IVTV_HW_CX25840);
#endif
#ifndef CONFIG_VIDEO_SAA711X
- if (hw & IVTV_HW_SAA711X)
- ivtv_request_module(itv, "saa7115");
+ hw = ivtv_request_module(itv, hw, "saa7115", IVTV_HW_SAA711X);
#endif
#ifndef CONFIG_VIDEO_SAA7127
- if (hw & IVTV_HW_SAA7127)
- ivtv_request_module(itv, "saa7127");
+ hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127);
#endif
- if (hw & IVTV_HW_SAA717X)
- ivtv_request_module(itv, "saa717x");
+ hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X);
#ifndef CONFIG_VIDEO_UPD64031A
- if (hw & IVTV_HW_UPD64031A)
- ivtv_request_module(itv, "upd64031a");
+ hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A);
#endif
#ifndef CONFIG_VIDEO_UPD64083
- if (hw & IVTV_HW_UPD6408X)
- ivtv_request_module(itv, "upd64083");
+ hw = ivtv_request_module(itv, hw, "upd64083", IVTV_HW_UPD6408X);
#endif
#ifndef CONFIG_VIDEO_MSP3400
- if (hw & IVTV_HW_MSP34XX)
- ivtv_request_module(itv, "msp3400");
+ hw = ivtv_request_module(itv, hw, "msp3400", IVTV_HW_MSP34XX);
#endif
#ifndef CONFIG_VIDEO_VP27SMPX
- if (hw & IVTV_HW_VP27SMPX)
- ivtv_request_module(itv, "vp27smpx");
+ hw = ivtv_request_module(itv, hw, "vp27smpx", IVTV_HW_VP27SMPX);
#endif
- if (hw & IVTV_HW_TVAUDIO)
- ivtv_request_module(itv, "tvaudio");
#ifndef CONFIG_VIDEO_WM8775
- if (hw & IVTV_HW_WM8775)
- ivtv_request_module(itv, "wm8775");
+ hw = ivtv_request_module(itv, hw, "wm8775", IVTV_HW_WM8775);
#endif
#ifndef CONFIG_VIDEO_WM8739
- if (hw & IVTV_HW_WM8739)
- ivtv_request_module(itv, "wm8739");
+ hw = ivtv_request_module(itv, hw, "wm8739", IVTV_HW_WM8739);
#endif
#ifndef CONFIG_VIDEO_CS53L32A
- if (hw & IVTV_HW_CS53L32A)
- ivtv_request_module(itv, "cs53l32a");
+ hw = ivtv_request_module(itv, hw, "cs53l32a", IVTV_HW_CS53L32A);
#endif
#ifndef CONFIG_VIDEO_M52790
- if (hw & IVTV_HW_M52790)
- ivtv_request_module(itv, "m52790");
+ hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
#endif
/* check which i2c devices are actually found */
@@ -900,11 +897,12 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
if (!(device & hw))
continue;
- if (device == IVTV_HW_GPIO) {
- /* GPIO is always available */
- itv->hw_flags |= IVTV_HW_GPIO;
+ if (device == IVTV_HW_GPIO || device == IVTV_HW_TVEEPROM) {
+ /* GPIO and TVEEPROM do not use i2c probing */
+ itv->hw_flags |= device;
continue;
}
+ ivtv_i2c_register(itv, i);
if (ivtv_i2c_hw_addr(itv, device) > 0)
itv->hw_flags |= device;
}
@@ -989,7 +987,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
- if (itv == 0) {
+ if (itv == NULL) {
spin_unlock(&ivtv_cards_lock);
return -ENOMEM;
}
@@ -1078,9 +1076,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active);
if (itv->card->hw_all & IVTV_HW_TVEEPROM) {
-#ifdef CONFIG_VIDEO_TVEEPROM_MODULE
- ivtv_request_module(itv, "tveeprom");
-#endif
/* Based on the model number the cardtype may be changed.
The PCI IDs are not always reliable. */
ivtv_process_eeprom(itv);
@@ -1153,7 +1148,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
if (itv->options.radio > 0)
itv->v4l2_cap |= V4L2_CAP_RADIO;
- if (itv->options.tuner > -1 && itv->tunerid == 0) {
+ if (itv->options.tuner > -1) {
struct tuner_setup setup;
setup.addr = ADDR_UNSET;
diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.h b/linux/drivers/media/video/ivtv/ivtv-driver.h
index 8b0074624..5b2bd0be0 100644
--- a/linux/drivers/media/video/ivtv/ivtv-driver.h
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.h
@@ -600,13 +600,13 @@ struct ivtv {
struct pci_dev *dev; /* PCI device */
const struct ivtv_card *card; /* card information */
const char *card_name; /* full name of the card */
+ const struct ivtv_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */
u8 has_cx23415; /* 1 if it is a cx23415 based card, 0 for cx23416 */
u8 pvr150_workaround; /* 1 if the cx25840 needs to workaround a PVR150 bug */
u8 nof_inputs; /* number of video inputs */
u8 nof_audio_inputs; /* number of audio inputs */
u32 v4l2_cap; /* V4L2 capabilities of card */
u32 hw_flags; /* hardware description of the board */
- int tunerid; /* userspace tuner ID for experimental Xceive tuner support */
v4l2_std_id tuner_std; /* the norm of the card's tuner (fixed) */
/* controlling video decoder function */
int (*video_dec_func)(struct ivtv *, unsigned int, void *);
diff --git a/linux/drivers/media/video/ivtv/ivtv-i2c.c b/linux/drivers/media/video/ivtv/ivtv-i2c.c
index 6c96bb9bc..d5df84421 100644
--- a/linux/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/linux/drivers/media/video/ivtv/ivtv-i2c.c
@@ -92,7 +92,8 @@
#define IVTV_TEA5767_I2C_ADDR 0x60
#define IVTV_UPD64031A_I2C_ADDR 0x12
#define IVTV_UPD64083_I2C_ADDR 0x5c
-#define IVTV_TDA985X_I2C_ADDR 0x5b
+#define IVTV_VP27SMPX_I2C_ADDR 0x5b
+#define IVTV_M52790_I2C_ADDR 0x48
/* This array should match the IVTV_HW_ defines */
static const u8 hw_driverids[] = {
@@ -105,7 +106,6 @@ static const u8 hw_driverids[] = {
I2C_DRIVERID_CS53L32A,
I2C_DRIVERID_TVEEPROM,
I2C_DRIVERID_SAA711X,
- I2C_DRIVERID_TVAUDIO,
I2C_DRIVERID_UPD64031A,
I2C_DRIVERID_UPD64083,
I2C_DRIVERID_SAA717X,
@@ -116,8 +116,28 @@ static const u8 hw_driverids[] = {
};
/* This array should match the IVTV_HW_ defines */
+static const u8 hw_addrs[] = {
+ IVTV_CX25840_I2C_ADDR,
+ IVTV_SAA7115_I2C_ADDR,
+ IVTV_SAA7127_I2C_ADDR,
+ IVTV_MSP3400_I2C_ADDR,
+ 0,
+ IVTV_WM8775_I2C_ADDR,
+ IVTV_CS53L32A_I2C_ADDR,
+ 0,
+ IVTV_SAA7115_I2C_ADDR,
+ IVTV_UPD64031A_I2C_ADDR,
+ IVTV_UPD64083_I2C_ADDR,
+ IVTV_SAA717x_I2C_ADDR,
+ IVTV_WM8739_I2C_ADDR,
+ IVTV_VP27SMPX_I2C_ADDR,
+ IVTV_M52790_I2C_ADDR,
+ 0 /* IVTV_HW_GPIO dummy driver ID */
+};
+
+/* This array should match the IVTV_HW_ defines */
static const char * const hw_drivernames[] = {
- "cx2584x",
+ "cx25840",
"saa7115",
"saa7127",
"msp3400",
@@ -125,8 +145,7 @@ static const char * const hw_drivernames[] = {
"wm8775",
"cs53l32a",
"tveeprom",
- "saa7114",
- "tvaudio",
+ "saa7115",
"upd64031a",
"upd64083",
"saa717x",
@@ -136,8 +155,62 @@ static const char * const hw_drivernames[] = {
"gpio",
};
+int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
+ struct i2c_board_info info;
+ struct i2c_client *c;
+ u8 id;
+ int i;
+
+ IVTV_DEBUG_I2C("i2c client register\n");
+ if (idx >= ARRAY_SIZE(hw_driverids) || hw_driverids[idx] == 0)
+ return -1;
+ id = hw_driverids[idx];
+ memset(&info, 0, sizeof(info));
+ strcpy(info.driver_name, hw_drivernames[idx]);
+ info.addr = hw_addrs[idx];
+ for (i = 0; itv->i2c_clients[i] && i < I2C_CLIENTS_MAX; i++) {}
+
+ if (i == I2C_CLIENTS_MAX) {
+ IVTV_ERR("insufficient room for new I2C client!\n");
+ return -ENOMEM;
+ }
+
+ if (id != I2C_DRIVERID_TUNER) {
+ c = i2c_new_device(&itv->i2c_adap, &info);
+ if (c->driver == NULL)
+ i2c_unregister_device(c);
+ else
+ itv->i2c_clients[i] = c;
+ return itv->i2c_clients[i] ? 0 : -ENODEV;
+ }
+
+ /* special tuner handling */
+ c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->radio);
+ if (c && c->driver == NULL)
+ i2c_unregister_device(c);
+ else if (c)
+ itv->i2c_clients[i++] = c;
+ c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->demod);
+ if (c && c->driver == NULL)
+ i2c_unregister_device(c);
+ else if (c)
+ itv->i2c_clients[i++] = c;
+ c = i2c_new_probed_device(&itv->i2c_adap, &info, itv->card_i2c->tv);
+ if (c && c->driver == NULL)
+ i2c_unregister_device(c);
+ else if (c)
+ itv->i2c_clients[i++] = c;
+ return 0;
+#else
+ return 0;
+#endif
+}
+
static int attach_inform(struct i2c_client *client)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
struct ivtv *itv = (struct ivtv *)i2c_get_adapdata(client->adapter);
int i;
@@ -151,6 +224,7 @@ static int attach_inform(struct i2c_client *client)
if (i == I2C_CLIENTS_MAX) {
IVTV_ERR("Insufficient room for new I2C client\n");
}
+#endif
return 0;
}
@@ -478,9 +552,11 @@ static struct i2c_adapter ivtv_i2c_adap_hw_template = {
.client_register = attach_inform,
.client_unregister = detach_inform,
.owner = THIS_MODULE,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
#ifdef I2C_ADAP_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG,
#endif
+#endif
};
static void ivtv_setscl_old(void *data, int state)
@@ -534,9 +610,11 @@ static struct i2c_adapter ivtv_i2c_adap_template = {
.client_register = attach_inform,
.client_unregister = detach_inform,
.owner = THIS_MODULE,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
#ifdef I2C_ADAP_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG,
#endif
+#endif
};
static const struct i2c_algo_bit_data ivtv_i2c_algo_template = {
@@ -561,12 +639,9 @@ int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg
IVTV_DEBUG_I2C("call_i2c_client addr=%02x\n", addr);
for (i = 0; i < I2C_CLIENTS_MAX; i++) {
client = itv->i2c_clients[i];
- if (client == NULL) {
- continue;
- }
- if (client->driver->command == NULL) {
+ if (client == NULL || client->driver == NULL ||
+ client->driver->command == NULL)
continue;
- }
if (addr == client->addr) {
retval = client->driver->command(client, cmd, arg);
return retval;
@@ -587,7 +662,7 @@ static int ivtv_i2c_id_addr(struct ivtv *itv, u32 id)
for (i = 0; i < I2C_CLIENTS_MAX; i++) {
client = itv->i2c_clients[i];
- if (client == NULL)
+ if (client == NULL || client->driver == NULL)
continue;
if (id == client->driver->id) {
retval = client->addr;
@@ -713,6 +788,16 @@ int __devinit init_ivtv_i2c(struct ivtv *itv)
{
IVTV_DEBUG_I2C("i2c init\n");
+ /* Sanity checks for the I2C hardware arrays. They must be the
+ * same size and GPIO must be the last entry.
+ */
+ if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) ||
+ ARRAY_SIZE(hw_drivernames) != ARRAY_SIZE(hw_addrs) ||
+ IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1)) ||
+ hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) {
+ IVTV_ERR("Mismatched I2C hardware arrays\n");
+ return -ENODEV;
+ }
if (itv->options.newi2c > 0) {
memcpy(&itv->i2c_adap, &ivtv_i2c_adap_hw_template,
sizeof(struct i2c_adapter));
diff --git a/linux/drivers/media/video/ivtv/ivtv-i2c.h b/linux/drivers/media/video/ivtv/ivtv-i2c.h
index de6a07442..7e8706b85 100644
--- a/linux/drivers/media/video/ivtv/ivtv-i2c.h
+++ b/linux/drivers/media/video/ivtv/ivtv-i2c.h
@@ -33,6 +33,7 @@ int ivtv_i2c_hw(struct ivtv *itv, u32 hw, unsigned int cmd, void *arg);
int ivtv_i2c_id(struct ivtv *itv, u32 id, unsigned int cmd, void *arg);
int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg);
void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg);
+int ivtv_i2c_register(struct ivtv *itv, unsigned idx);
/* init + register i2c algo-bit adapter */
int __devinit init_ivtv_i2c(struct ivtv *itv);
diff --git a/linux/drivers/media/video/ivtv/ivtv-ioctl.c b/linux/drivers/media/video/ivtv/ivtv-ioctl.c
index 39f20dfb8..87a83b8e3 100644
--- a/linux/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/linux/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -704,7 +704,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val & 0x02) {
- itv->video_dec_func(itv, cmd, 0);
+ itv->video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/linux/drivers/media/video/ivtv/ivtv-irq.c b/linux/drivers/media/video/ivtv/ivtv-irq.c
index 42f9b3402..46a5cbc62 100644
--- a/linux/drivers/media/video/ivtv/ivtv-irq.c
+++ b/linux/drivers/media/video/ivtv/ivtv-irq.c
@@ -210,7 +210,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
s->sg_pending[idx].dst = buf->dma_handle;
s->sg_pending[idx].src = offset;
s->sg_pending[idx].size = s->buf_size;
- buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
+ buf->bytesused = min(size, s->buf_size);
buf->dma_xfer_cnt = s->dma_xfer_cnt;
s->q_predma.bytesused += buf->bytesused;
@@ -742,7 +742,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
- itv->dma_data_req_size = data[2] >= 0x10000 ? 0x10000 : data[2];
+ itv->dma_data_req_size = min_t(u32, data[2], 0x10000);
itv->dma_data_req_offset = data[1];
s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/linux/drivers/media/video/ivtv/ivtv-streams.c b/linux/drivers/media/video/ivtv/ivtv-streams.c
index 3ca2a1a62..24d98ecf3 100644
--- a/linux/drivers/media/video/ivtv/ivtv-streams.c
+++ b/linux/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, &itv->i_flags);
/* Initialize Digitizer for Capture */
- itv->video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+ itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
- itv->video_dec_func(itv, VIDIOC_STREAMON, 0);
+ itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
/* begin_capture */
diff --git a/linux/drivers/media/video/ivtv/ivtv-version.h b/linux/drivers/media/video/ivtv/ivtv-version.h
index d050de2a7..0f1d4cc4b 100644
--- a/linux/drivers/media/video/ivtv/ivtv-version.h
+++ b/linux/drivers/media/video/ivtv/ivtv-version.h
@@ -22,7 +22,7 @@
#define IVTV_DRIVER_NAME "ivtv"
#define IVTV_DRIVER_VERSION_MAJOR 1
-#define IVTV_DRIVER_VERSION_MINOR 1
+#define IVTV_DRIVER_VERSION_MINOR 2
#define IVTV_DRIVER_VERSION_PATCHLEVEL 0
#define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL)
diff --git a/linux/drivers/media/video/ivtv/ivtvfb.c b/linux/drivers/media/video/ivtv/ivtvfb.c
index 1a73038ea..3b23fc05f 100644
--- a/linux/drivers/media/video/ivtv/ivtvfb.c
+++ b/linux/drivers/media/video/ivtv/ivtvfb.c
@@ -1057,7 +1057,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
- if (itv->osd_info == 0) {
+ if (itv->osd_info == NULL) {
IVTVFB_ERR("Failed to allocate memory for osd_info\n");
return -ENOMEM;
}
diff --git a/linux/drivers/media/video/m52790.c b/linux/drivers/media/video/m52790.c
index ebe089c6d..804ef3005 100644
--- a/linux/drivers/media/video/m52790.c
+++ b/linux/drivers/media/video/m52790.c
@@ -41,6 +41,7 @@ MODULE_DESCRIPTION("i2c device driver for m52790 A/V switch");
MODULE_AUTHOR("Hans Verkuil");
MODULE_LICENSE("GPL");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
static unsigned short normal_i2c[] = { 0x90 >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
@@ -48,6 +49,7 @@ static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
struct m52790_state {
u16 input;
diff --git a/linux/drivers/media/video/saa7127.c b/linux/drivers/media/video/saa7127.c
index 27d9cab97..8a7148114 100644
--- a/linux/drivers/media/video/saa7127.c
+++ b/linux/drivers/media/video/saa7127.c
@@ -78,6 +78,7 @@ MODULE_PARM(test_image, "i");
MODULE_PARM_DESC(debug, "debug level (0-2)");
MODULE_PARM_DESC(test_image, "test_image (0-1)");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
@@ -85,6 +86,7 @@ static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
/*
* SAA7127 registers
diff --git a/linux/drivers/media/video/saa7134/saa7134-cards.c b/linux/drivers/media/video/saa7134/saa7134-cards.c
index 85ed1ecae..e7aad2f61 100644
--- a/linux/drivers/media/video/saa7134/saa7134-cards.c
+++ b/linux/drivers/media/video/saa7134/saa7134-cards.c
@@ -4619,6 +4619,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
break;
case SAA7134_BOARD_AVERMEDIA_M102:
/* enable tuner */
+ dev->has_remote = SAA7134_REMOTE_GPIO;
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x8c040007, 0x8c040007);
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0c0007cd, 0x0c0007cd);
break;
diff --git a/linux/drivers/media/video/saa7134/saa7134-input.c b/linux/drivers/media/video/saa7134/saa7134-input.c
index b7392f65e..fa2d39781 100644
--- a/linux/drivers/media/video/saa7134/saa7134-input.c
+++ b/linux/drivers/media/video/saa7134/saa7134-input.c
@@ -260,6 +260,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
+ case SAA7134_BOARD_AVERMEDIA_M102:
ir_codes = ir_codes_avermedia;
mask_keycode = 0x0007C8;
mask_keydown = 0x000010;
diff --git a/linux/drivers/media/video/upd64031a.c b/linux/drivers/media/video/upd64031a.c
index 6cbd124c7..98bebcab3 100644
--- a/linux/drivers/media/video/upd64031a.c
+++ b/linux/drivers/media/video/upd64031a.c
@@ -54,6 +54,7 @@ MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug level (0-1)");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
static unsigned short normal_i2c[] = { 0x24 >> 1, 0x26 >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
@@ -61,6 +62,7 @@ static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
enum {
R00 = 0, R01, R02, R03, R04,
diff --git a/linux/drivers/media/video/upd64083.c b/linux/drivers/media/video/upd64083.c
index 34e99cfbb..2d5cb6e62 100644
--- a/linux/drivers/media/video/upd64083.c
+++ b/linux/drivers/media/video/upd64083.c
@@ -44,6 +44,7 @@ MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug level (0-1)");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
static unsigned short normal_i2c[] = { 0xb8 >> 1, 0xba >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
@@ -51,6 +52,7 @@ static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
enum {
R00 = 0, R01, R02, R03, R04,
diff --git a/linux/drivers/media/video/videobuf-core.c b/linux/drivers/media/video/videobuf-core.c
index be33909f9..a85b22147 100644
--- a/linux/drivers/media/video/videobuf-core.c
+++ b/linux/drivers/media/video/videobuf-core.c
@@ -23,29 +23,32 @@
#include "compat.h"
#define MAGIC_BUFFER 0x20070728
-#define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \
- { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); }
+#define MAGIC_CHECK(is, should) do { \
+ if (unlikely((is) != (should))) { \
+ printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \
+ BUG(); } } while (0)
-static int debug = 0;
+static int debug;
module_param(debug, int, 0644);
MODULE_DESCRIPTION("helper module to manage video4linux buffers");
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
MODULE_LICENSE("GPL");
-#define dprintk(level, fmt, arg...) if (debug >= level) \
- printk(KERN_DEBUG "vbuf: " fmt , ## arg)
+#define dprintk(level, fmt, arg...) do { \
+ if (debug >= level) \
+ printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0)
/* --------------------------------------------------------------------- */
#define CALL(q, f, arg...) \
- ( (q->int_ops->f)? q->int_ops->f(arg) : 0)
+ ((q->int_ops->f) ? q->int_ops->f(arg) : 0)
-void* videobuf_alloc(struct videobuf_queue* q)
+void *videobuf_alloc(struct videobuf_queue *q)
{
struct videobuf_buffer *vb;
- BUG_ON (q->msize<sizeof(*vb));
+ BUG_ON(q->msize < sizeof(*vb));
if (!q->int_ops || !q->int_ops->alloc) {
printk(KERN_ERR "No specific ops defined!\n");
@@ -67,7 +70,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
int retval = 0;
DECLARE_WAITQUEUE(wait, current);
- MAGIC_CHECK(vb->magic,MAGIC_BUFFER);
+ MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
add_wait_queue(&vb->done, &wait);
while (vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) {
if (non_blocking) {
@@ -76,11 +79,12 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
}
set_current_state(intr ? TASK_INTERRUPTIBLE
: TASK_UNINTERRUPTIBLE);
- if (vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED)
+ if (vb->state == VIDEOBUF_ACTIVE ||
+ vb->state == VIDEOBUF_QUEUED)
schedule();
set_current_state(TASK_RUNNING);
if (intr && signal_pending(current)) {
- dprintk(1,"buffer waiton: -EINTR\n");
+ dprintk(1, "buffer waiton: -EINTR\n");
retval = -EINTR;
break;
}
@@ -89,27 +93,27 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
return retval;
}
-int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
+int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf)
{
- MAGIC_CHECK(vb->magic,MAGIC_BUFFER);
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
- /* FIXME: This is required to avoid OOPS on some cases, since mmap_mapper()
- method should be called before _iolock.
+ /* FIXME: This is required to avoid OOPS on some cases,
+ since mmap_mapper() method should be called before _iolock.
On some cases, the mmap_mapper() is called only after scheduling.
However, this way is just too dirty! Better to wait for some event.
*/
schedule_timeout(HZ);
- return CALL(q,iolock,q,vb,fbuf);
+ return CALL(q, iolock, q, vb, fbuf);
}
/* --------------------------------------------------------------------- */
-void videobuf_queue_core_init(struct videobuf_queue* q,
+void videobuf_queue_core_init(struct videobuf_queue *q,
struct videobuf_queue_ops *ops,
void *dev,
spinlock_t *irqlock,
@@ -119,7 +123,7 @@ void videobuf_queue_core_init(struct videobuf_queue* q,
void *priv,
struct videobuf_qtype_ops *int_ops)
{
- memset(q,0,sizeof(*q));
+ memset(q, 0, sizeof(*q));
q->irqlock = irqlock;
q->dev = dev;
q->type = type;
@@ -130,13 +134,13 @@ void videobuf_queue_core_init(struct videobuf_queue* q,
q->int_ops = int_ops;
/* All buffer operations are mandatory */
- BUG_ON (!q->ops->buf_setup);
- BUG_ON (!q->ops->buf_prepare);
- BUG_ON (!q->ops->buf_queue);
- BUG_ON (!q->ops->buf_release);
+ BUG_ON(!q->ops->buf_setup);
+ BUG_ON(!q->ops->buf_prepare);
+ BUG_ON(!q->ops->buf_queue);
+ BUG_ON(!q->ops->buf_release);
/* Having implementations for abstract methods are mandatory */
- BUG_ON (!q->int_ops);
+ BUG_ON(!q->int_ops);
mutex_init(&q->lock);
INIT_LIST_HEAD(&q->stream);
@@ -147,33 +151,33 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
{
int i;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
if (q->streaming) {
- dprintk(1,"busy: streaming active\n");
+ dprintk(1, "busy: streaming active\n");
return 1;
}
if (q->reading) {
- dprintk(1,"busy: pending read #1\n");
+ dprintk(1, "busy: pending read #1\n");
return 1;
}
if (q->read_buf) {
- dprintk(1,"busy: pending read #2\n");
+ dprintk(1, "busy: pending read #2\n");
return 1;
}
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
if (q->bufs[i]->map) {
- dprintk(1,"busy: buffer #%d mapped\n",i);
+ dprintk(1, "busy: buffer #%d mapped\n", i);
return 1;
}
if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
- dprintk(1,"busy: buffer #%d queued\n",i);
+ dprintk(1, "busy: buffer #%d queued\n", i);
return 1;
}
if (q->bufs[i]->state == VIDEOBUF_ACTIVE) {
- dprintk(1,"busy: buffer #%d avtive\n",i);
+ dprintk(1, "busy: buffer #%d avtive\n", i);
return 1;
}
}
@@ -183,12 +187,12 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
/* Locking: Caller holds q->lock */
void videobuf_queue_cancel(struct videobuf_queue *q)
{
- unsigned long flags=0;
+ unsigned long flags = 0;
int i;
/* remove queued buffers from list */
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
+ spin_lock_irqsave(q->irqlock, flags);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
@@ -198,13 +202,13 @@ void videobuf_queue_cancel(struct videobuf_queue *q)
}
}
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
/* free all buffers + clear queue */
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
- q->ops->buf_release(q,q->bufs[i]);
+ q->ops->buf_release(q, q->bufs[i]);
}
INIT_LIST_HEAD(&q->stream);
}
@@ -234,8 +238,8 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
struct videobuf_buffer *vb, enum v4l2_buf_type type)
{
- MAGIC_CHECK(vb->magic,MAGIC_BUFFER);
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
b->index = vb->i;
b->type = type;
@@ -295,16 +299,16 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
if (!q)
return 0;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
- rc = CALL(q,mmap_free,q);
- if (rc<0)
+ rc = CALL(q, mmap_free, q);
+ if (rc < 0)
return rc;
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
- q->ops->buf_release(q,q->bufs[i]);
+ q->ops->buf_release(q, q->bufs[i]);
kfree(q->bufs[i]);
q->bufs[i] = NULL;
}
@@ -329,7 +333,7 @@ static int __videobuf_mmap_setup(struct videobuf_queue *q,
unsigned int i;
int err;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
err = __videobuf_mmap_free(q);
if (0 != err)
@@ -360,7 +364,7 @@ static int __videobuf_mmap_setup(struct videobuf_queue *q,
if (!i)
return -ENOMEM;
- dprintk(1,"mmap setup: %d buffers, %d bytes each\n",
+ dprintk(1, "mmap setup: %d buffers, %d bytes each\n",
i, bsize);
return i;
@@ -380,35 +384,35 @@ int videobuf_mmap_setup(struct videobuf_queue *q,
int videobuf_reqbufs(struct videobuf_queue *q,
struct v4l2_requestbuffers *req)
{
- unsigned int size,count;
+ unsigned int size, count;
int retval;
if (req->count < 1) {
- dprintk(1,"reqbufs: count invalid (%d)\n",req->count);
+ dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
return -EINVAL;
}
if (req->memory != V4L2_MEMORY_MMAP &&
req->memory != V4L2_MEMORY_USERPTR &&
req->memory != V4L2_MEMORY_OVERLAY) {
- dprintk(1,"reqbufs: memory type invalid\n");
+ dprintk(1, "reqbufs: memory type invalid\n");
return -EINVAL;
}
mutex_lock(&q->lock);
if (req->type != q->type) {
- dprintk(1,"reqbufs: queue type invalid\n");
+ dprintk(1, "reqbufs: queue type invalid\n");
retval = -EINVAL;
goto done;
}
if (q->streaming) {
- dprintk(1,"reqbufs: streaming already exists\n");
+ dprintk(1, "reqbufs: streaming already exists\n");
retval = -EBUSY;
goto done;
}
if (!list_empty(&q->stream)) {
- dprintk(1,"reqbufs: stream running\n");
+ dprintk(1, "reqbufs: stream running\n");
retval = -EBUSY;
goto done;
}
@@ -417,14 +421,14 @@ int videobuf_reqbufs(struct videobuf_queue *q,
if (count > VIDEO_MAX_FRAME)
count = VIDEO_MAX_FRAME;
size = 0;
- q->ops->buf_setup(q,&count,&size);
+ q->ops->buf_setup(q, &count, &size);
size = PAGE_ALIGN(size);
- dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
+ dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
count, size, (count*size)>>PAGE_SHIFT);
- retval = __videobuf_mmap_setup(q,count,size,req->memory);
+ retval = __videobuf_mmap_setup(q, count, size, req->memory);
if (retval < 0) {
- dprintk(1,"reqbufs: mmap setup returned %d\n",retval);
+ dprintk(1, "reqbufs: mmap setup returned %d\n", retval);
goto done;
}
@@ -441,19 +445,19 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
mutex_lock(&q->lock);
if (unlikely(b->type != q->type)) {
- dprintk(1,"querybuf: Wrong type.\n");
+ dprintk(1, "querybuf: Wrong type.\n");
goto done;
}
if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
- dprintk(1,"querybuf: index out of range.\n");
+ dprintk(1, "querybuf: index out of range.\n");
goto done;
}
if (unlikely(NULL == q->bufs[b->index])) {
- dprintk(1,"querybuf: buffer is null.\n");
+ dprintk(1, "querybuf: buffer is null.\n");
goto done;
}
- videobuf_status(q,b,q->bufs[b->index],q->type);
+ videobuf_status(q, b, q->bufs[b->index], q->type);
ret = 0;
done:
@@ -466,10 +470,10 @@ int videobuf_qbuf(struct videobuf_queue *q,
{
struct videobuf_buffer *buf;
enum v4l2_field field;
- unsigned long flags=0;
+ unsigned long flags = 0;
int retval;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
if (b->memory == V4L2_MEMORY_MMAP)
down_read(&current->mm->mmap_sem);
@@ -477,36 +481,36 @@ int videobuf_qbuf(struct videobuf_queue *q,
mutex_lock(&q->lock);
retval = -EBUSY;
if (q->reading) {
- dprintk(1,"qbuf: Reading running...\n");
+ dprintk(1, "qbuf: Reading running...\n");
goto done;
}
retval = -EINVAL;
if (b->type != q->type) {
- dprintk(1,"qbuf: Wrong type.\n");
+ dprintk(1, "qbuf: Wrong type.\n");
goto done;
}
if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
- dprintk(1,"qbuf: index out of range.\n");
+ dprintk(1, "qbuf: index out of range.\n");
goto done;
}
buf = q->bufs[b->index];
if (NULL == buf) {
- dprintk(1,"qbuf: buffer is null.\n");
+ dprintk(1, "qbuf: buffer is null.\n");
goto done;
}
- MAGIC_CHECK(buf->magic,MAGIC_BUFFER);
+ MAGIC_CHECK(buf->magic, MAGIC_BUFFER);
if (buf->memory != b->memory) {
- dprintk(1,"qbuf: memory type is wrong.\n");
+ dprintk(1, "qbuf: memory type is wrong.\n");
goto done;
}
if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) {
- dprintk(1,"qbuf: buffer is already queued or active.\n");
+ dprintk(1, "qbuf: buffer is already queued or active.\n");
goto done;
}
if (b->flags & V4L2_BUF_FLAG_INPUT) {
if (b->input >= q->inputs) {
- dprintk(1,"qbuf: wrong input.\n");
+ dprintk(1, "qbuf: wrong input.\n");
goto done;
}
buf->input = b->input;
@@ -517,44 +521,46 @@ int videobuf_qbuf(struct videobuf_queue *q,
switch (b->memory) {
case V4L2_MEMORY_MMAP:
if (0 == buf->baddr) {
- dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
+ dprintk(1, "qbuf: mmap requested "
+ "but buffer addr is zero!\n");
goto done;
}
break;
case V4L2_MEMORY_USERPTR:
if (b->length < buf->bsize) {
- dprintk(1,"qbuf: buffer length is not enough\n");
+ dprintk(1, "qbuf: buffer length is not enough\n");
goto done;
}
- if (VIDEOBUF_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
- q->ops->buf_release(q,buf);
+ if (VIDEOBUF_NEEDS_INIT != buf->state &&
+ buf->baddr != b->m.userptr)
+ q->ops->buf_release(q, buf);
buf->baddr = b->m.userptr;
break;
case V4L2_MEMORY_OVERLAY:
buf->boff = b->m.offset;
break;
default:
- dprintk(1,"qbuf: wrong memory type\n");
+ dprintk(1, "qbuf: wrong memory type\n");
goto done;
}
- dprintk(1,"qbuf: requesting next field\n");
+ dprintk(1, "qbuf: requesting next field\n");
field = videobuf_next_field(q);
- retval = q->ops->buf_prepare(q,buf,field);
+ retval = q->ops->buf_prepare(q, buf, field);
if (0 != retval) {
- dprintk(1,"qbuf: buffer_prepare returned %d\n",retval);
+ dprintk(1, "qbuf: buffer_prepare returned %d\n", retval);
goto done;
}
- list_add_tail(&buf->stream,&q->stream);
+ list_add_tail(&buf->stream, &q->stream);
if (q->streaming) {
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
- q->ops->buf_queue(q,buf);
+ spin_lock_irqsave(q->irqlock, flags);
+ q->ops->buf_queue(q, buf);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
}
- dprintk(1,"qbuf: succeded\n");
+ dprintk(1, "qbuf: succeded\n");
retval = 0;
done:
@@ -572,49 +578,49 @@ int videobuf_dqbuf(struct videobuf_queue *q,
struct videobuf_buffer *buf;
int retval;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
mutex_lock(&q->lock);
retval = -EBUSY;
if (q->reading) {
- dprintk(1,"dqbuf: Reading running...\n");
+ dprintk(1, "dqbuf: Reading running...\n");
goto done;
}
retval = -EINVAL;
if (b->type != q->type) {
- dprintk(1,"dqbuf: Wrong type.\n");
+ dprintk(1, "dqbuf: Wrong type.\n");
goto done;
}
if (list_empty(&q->stream)) {
- dprintk(1,"dqbuf: stream running\n");
+ dprintk(1, "dqbuf: stream running\n");
goto done;
}
buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
retval = videobuf_waiton(buf, nonblocking, 1);
if (retval < 0) {
- dprintk(1,"dqbuf: waiton returned %d\n",retval);
+ dprintk(1, "dqbuf: waiton returned %d\n", retval);
goto done;
}
switch (buf->state) {
case VIDEOBUF_ERROR:
- dprintk(1,"dqbuf: state is error\n");
+ dprintk(1, "dqbuf: state is error\n");
retval = -EIO;
- CALL(q,sync,q, buf);
+ CALL(q, sync, q, buf);
buf->state = VIDEOBUF_IDLE;
break;
case VIDEOBUF_DONE:
- dprintk(1,"dqbuf: state is done\n");
- CALL(q,sync,q, buf);
+ dprintk(1, "dqbuf: state is done\n");
+ CALL(q, sync, q, buf);
buf->state = VIDEOBUF_IDLE;
break;
default:
- dprintk(1,"dqbuf: state invalid\n");
+ dprintk(1, "dqbuf: state invalid\n");
retval = -EINVAL;
goto done;
}
list_del(&buf->stream);
- memset(b,0,sizeof(*b));
- videobuf_status(q,b,buf,q->type);
+ memset(b, 0, sizeof(*b));
+ videobuf_status(q, b, buf, q->type);
done:
mutex_unlock(&q->lock);
@@ -624,7 +630,7 @@ int videobuf_dqbuf(struct videobuf_queue *q,
int videobuf_streamon(struct videobuf_queue *q)
{
struct videobuf_buffer *buf;
- unsigned long flags=0;
+ unsigned long flags = 0;
int retval;
mutex_lock(&q->lock);
@@ -636,12 +642,12 @@ int videobuf_streamon(struct videobuf_queue *q)
goto done;
q->streaming = 1;
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
+ spin_lock_irqsave(q->irqlock, flags);
list_for_each_entry(buf, &q->stream, stream)
if (buf->state == VIDEOBUF_PREPARED)
- q->ops->buf_queue(q,buf);
+ q->ops->buf_queue(q, buf);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
done:
mutex_unlock(&q->lock);
@@ -677,10 +683,10 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
size_t count, loff_t *ppos)
{
enum v4l2_field field;
- unsigned long flags=0;
+ unsigned long flags = 0;
int retval;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
/* setup stuff */
q->read_buf = videobuf_alloc(q);
@@ -692,19 +698,19 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
q->read_buf->bsize = count;
field = videobuf_next_field(q);
- retval = q->ops->buf_prepare(q,q->read_buf,field);
+ retval = q->ops->buf_prepare(q, q->read_buf, field);
if (0 != retval)
goto done;
/* start capture & wait */
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
- q->ops->buf_queue(q,q->read_buf);
+ spin_lock_irqsave(q->irqlock, flags);
+ q->ops->buf_queue(q, q->read_buf);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
- retval = videobuf_waiton(q->read_buf,0,0);
+ spin_unlock_irqrestore(q->irqlock, flags);
+ retval = videobuf_waiton(q->read_buf, 0, 0);
if (0 == retval) {
- CALL(q,sync,q,q->read_buf);
+ CALL(q, sync, q, q->read_buf);
if (VIDEOBUF_ERROR == q->read_buf->state)
retval = -EIO;
else
@@ -713,7 +719,7 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
done:
/* cleanup */
- q->ops->buf_release(q,q->read_buf);
+ q->ops->buf_release(q, q->read_buf);
kfree(q->read_buf);
q->read_buf = NULL;
return retval;
@@ -724,21 +730,21 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
int nonblocking)
{
enum v4l2_field field;
- unsigned long flags=0;
+ unsigned long flags = 0;
unsigned size, nbufs;
int retval;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
mutex_lock(&q->lock);
nbufs = 1; size = 0;
- q->ops->buf_setup(q,&nbufs,&size);
+ q->ops->buf_setup(q, &nbufs, &size);
if (NULL == q->read_buf &&
count >= size &&
!nonblocking) {
- retval = videobuf_read_zerocopy(q,data,count,ppos);
+ retval = videobuf_read_zerocopy(q, data, count, ppos);
if (retval >= 0 || retval == -EIO)
/* ok, all done */
goto done;
@@ -750,25 +756,25 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
retval = -ENOMEM;
q->read_buf = videobuf_alloc(q);
- dprintk(1,"video alloc=0x%p\n", q->read_buf);
+ dprintk(1, "video alloc=0x%p\n", q->read_buf);
if (NULL == q->read_buf)
goto done;
q->read_buf->memory = V4L2_MEMORY_USERPTR;
q->read_buf->bsize = count; /* preferred size */
field = videobuf_next_field(q);
- retval = q->ops->buf_prepare(q,q->read_buf,field);
+ retval = q->ops->buf_prepare(q, q->read_buf, field);
if (0 != retval) {
- kfree (q->read_buf);
+ kfree(q->read_buf);
q->read_buf = NULL;
goto done;
}
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
+ spin_lock_irqsave(q->irqlock, flags);
- q->ops->buf_queue(q,q->read_buf);
+ q->ops->buf_queue(q, q->read_buf);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
q->read_off = 0;
}
@@ -777,11 +783,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
if (0 != retval)
goto done;
- CALL(q,sync,q,q->read_buf);
+ CALL(q, sync, q, q->read_buf);
if (VIDEOBUF_ERROR == q->read_buf->state) {
/* catch I/O errors */
- q->ops->buf_release(q,q->read_buf);
+ q->ops->buf_release(q, q->read_buf);
kfree(q->read_buf);
q->read_buf = NULL;
retval = -EIO;
@@ -789,14 +795,14 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
}
/* Copy to userspace */
- retval=CALL(q,video_copy_to_user,q,data,count,nonblocking);
- if (retval<0)
+ retval = CALL(q, video_copy_to_user, q, data, count, nonblocking);
+ if (retval < 0)
goto done;
q->read_off += retval;
if (q->read_off == q->read_buf->size) {
/* all data copied, cleanup */
- q->ops->buf_release(q,q->read_buf);
+ q->ops->buf_release(q, q->read_buf);
kfree(q->read_buf);
q->read_buf = NULL;
}
@@ -810,11 +816,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
int __videobuf_read_start(struct videobuf_queue *q)
{
enum v4l2_field field;
- unsigned long flags=0;
+ unsigned long flags = 0;
unsigned int count = 0, size = 0;
int err, i;
- q->ops->buf_setup(q,&count,&size);
+ q->ops->buf_setup(q, &count, &size);
if (count < 2)
count = 2;
if (count > VIDEO_MAX_FRAME)
@@ -829,17 +835,17 @@ int __videobuf_read_start(struct videobuf_queue *q)
for (i = 0; i < count; i++) {
field = videobuf_next_field(q);
- err = q->ops->buf_prepare(q,q->bufs[i],field);
+ err = q->ops->buf_prepare(q, q->bufs[i], field);
if (err)
return err;
list_add_tail(&q->bufs[i]->stream, &q->stream);
}
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
+ spin_lock_irqsave(q->irqlock, flags);
for (i = 0; i < count; i++)
- q->ops->buf_queue(q,q->bufs[i]);
+ q->ops->buf_queue(q, q->bufs[i]);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
q->reading = 1;
return 0;
}
@@ -900,11 +906,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
int vbihack, int nonblocking)
{
int rc, retval;
- unsigned long flags=0;
+ unsigned long flags = 0;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
- dprintk(2,"%s\n",__FUNCTION__);
+ dprintk(2, "%s\n", __FUNCTION__);
mutex_lock(&q->lock);
retval = -EBUSY;
if (q->streaming)
@@ -933,7 +939,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
}
if (q->read_buf->state == VIDEOBUF_DONE) {
- rc = CALL (q,copy_stream, q, data + retval, count,
+ rc = CALL(q, copy_stream, q, data + retval, count,
retval, vbihack, nonblocking);
if (rc < 0) {
retval = rc;
@@ -954,10 +960,10 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
list_add_tail(&q->read_buf->stream,
&q->stream);
if (q->irqlock)
- spin_lock_irqsave(q->irqlock,flags);
- q->ops->buf_queue(q,q->read_buf);
+ spin_lock_irqsave(q->irqlock, flags);
+ q->ops->buf_queue(q, q->read_buf);
if (q->irqlock)
- spin_unlock_irqrestore(q->irqlock,flags);
+ spin_unlock_irqrestore(q->irqlock, flags);
q->read_buf = NULL;
}
if (retval < 0)
@@ -1013,10 +1019,10 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
{
int retval;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
mutex_lock(&q->lock);
- retval=CALL(q,mmap_mapper,q,vma);
+ retval = CALL(q, mmap_mapper, q, vma);
mutex_unlock(&q->lock);
return retval;
@@ -1027,15 +1033,15 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
struct video_mbuf *mbuf, int count)
{
struct v4l2_requestbuffers req;
- int rc,i;
+ int rc, i;
- MAGIC_CHECK(q->int_ops->magic,MAGIC_QTYPE_OPS);
+ MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
- memset(&req,0,sizeof(req));
+ memset(&req, 0, sizeof(req));
req.type = q->type;
req.count = count;
req.memory = V4L2_MEMORY_MMAP;
- rc = videobuf_reqbufs(q,&req);
+ rc = videobuf_reqbufs(q, &req);
if (rc < 0)
return rc;
@@ -1080,9 +1086,3 @@ EXPORT_SYMBOL_GPL(videobuf_poll_stream);
EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
EXPORT_SYMBOL_GPL(videobuf_mmap_free);
EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/linux/drivers/media/video/videobuf-vmalloc.c b/linux/drivers/media/video/videobuf-vmalloc.c
index ceb4b54ac..84bb18565 100644
--- a/linux/drivers/media/video/videobuf-vmalloc.c
+++ b/linux/drivers/media/video/videobuf-vmalloc.c
@@ -52,7 +52,7 @@ videobuf_vm_open(struct vm_area_struct *vma)
{
struct videobuf_mapping *map = vma->vm_private_data;
- dprintk(2,"vm_open %p [count=%d,vma=%08lx-%08lx]\n",map,
+ dprintk(2,"vm_open %p [count=%u,vma=%08lx-%08lx]\n",map,
map->count,vma->vm_start,vma->vm_end);
map->count++;
@@ -65,7 +65,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
struct videobuf_queue *q = map->q;
int i;
- dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map,
+ dprintk(2,"vm_close %p [count=%u,vma=%08lx-%08lx]\n",map,
map->count,vma->vm_start,vma->vm_end);
map->count--;
@@ -222,7 +222,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
}
/* create mapping + update buffer list */
- map = q->bufs[first]->map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL);
+ map = q->bufs[first]->map = kzalloc(sizeof(struct videobuf_mapping),GFP_KERNEL);
if (NULL == map)
return -ENOMEM;
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
index 63b0c7aeb..02e44ab91 100644
--- a/linux/drivers/media/video/vivi.c
+++ b/linux/drivers/media/video/vivi.c
@@ -25,7 +25,7 @@
#include <linux/pci.h>
#include <linux/random.h>
#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
#include <linux/mutex.h>
#else
#include <asm/semaphore.h>
@@ -40,11 +40,11 @@
#include <linux/interrupt.h>
#include <media/videobuf-vmalloc.h>
#include <media/v4l2-common.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
#include <linux/kthread.h>
#endif
#include <linux/highmem.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
#include <linux/freezer.h>
#endif
@@ -53,21 +53,19 @@
#define WAKE_DENOMINATOR 1001
#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
-/* These timers are for 1 fps - used only for testing */
-//#define WAKE_DENOMINATOR 30 /* hack for testing purposes */
-//#define BUFFER_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
-
#include "font.h"
#define VIVI_MAJOR_VERSION 0
#define VIVI_MINOR_VERSION 4
#define VIVI_RELEASE 0
-#define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
+#define VIVI_VERSION \
+ KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
/* Declare static vars that will be used as parameters */
static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
static struct video_device vivi; /* Video device */
static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
+static int n_devs = 1; /* Number of virtual devices */
/* supported controls */
static struct v4l2_queryctrl vivi_qctrl[] = {
@@ -80,7 +78,7 @@ static struct v4l2_queryctrl vivi_qctrl[] = {
.default_value = 65535,
.flags = 0,
.type = V4L2_CTRL_TYPE_INTEGER,
- },{
+ }, {
.id = V4L2_CID_BRIGHTNESS,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Brightness",
@@ -121,7 +119,7 @@ static struct v4l2_queryctrl vivi_qctrl[] = {
static int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
-#define dprintk(level,fmt, arg...) \
+#define dprintk(level, fmt, arg...) \
do { \
if (vivi.debug >= (level)) \
printk(KERN_DEBUG "vivi: " fmt , ## arg); \
@@ -164,7 +162,7 @@ struct vivi_dmaqueue {
/* thread for generating video stream*/
struct task_struct *kthread;
wait_queue_head_t wq;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
struct semaphore *notify;
int rmmod:1;
#endif
@@ -178,7 +176,7 @@ static LIST_HEAD(vivi_devlist);
struct vivi_dev {
struct list_head vivi_devlist;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
struct mutex lock;
#else
struct semaphore lock;
@@ -187,13 +185,15 @@ struct vivi_dev {
int users;
/* various device info */
- struct video_device vfd;
+ struct video_device *vfd;
struct vivi_dmaqueue vidq;
/* Several counters */
- int h,m,s,us,jiffies;
+ int h, m, s, us, jiffies;
char timestr[13];
+
+ int mv_count; /* Controls bars movement */
};
struct vivi_fh {
@@ -201,7 +201,7 @@ struct vivi_fh {
/* video capture */
struct vivi_fmt *fmt;
- unsigned int width,height;
+ unsigned int width, height;
struct videobuf_queue vb_vidq;
enum v4l2_buf_type type;
@@ -220,109 +220,113 @@ enum colors {
GREEN,
MAGENTA,
RED,
- BLUE
+ BLUE,
+ BLACK,
};
static u8 bars[8][3] = {
/* R G B */
- {204,204,204}, /* white */
- {208,208, 0}, /* ambar */
- { 0,206,206}, /* cyan */
- { 0,239, 0}, /* green */
- {239, 0,239}, /* magenta */
- {205, 0, 0}, /* red */
- { 0, 0,255}, /* blue */
- { 0, 0, 0}
+ {204, 204, 204}, /* white */
+ {208, 208, 0}, /* ambar */
+ { 0, 206, 206}, /* cyan */
+ { 0, 239, 0}, /* green */
+ {239, 0, 239}, /* magenta */
+ {205, 0, 0}, /* red */
+ { 0, 0, 255}, /* blue */
+ { 0, 0, 0}, /* black */
};
-#define TO_Y(r,g,b) (((16829*r +33039*g +6416*b + 32768)>>16)+16)
+#define TO_Y(r, g, b) \
+ (((16829 * r + 33039 * g + 6416 * b + 32768) >> 16) + 16)
/* RGB to V(Cr) Color transform */
-#define TO_V(r,g,b) (((28784*r -24103*g -4681*b + 32768)>>16)+128)
+#define TO_V(r, g, b) \
+ (((28784 * r - 24103 * g - 4681 * b + 32768) >> 16) + 128)
/* RGB to U(Cb) Color transform */
-#define TO_U(r,g,b) (((-9714*r -19070*g +28784*b + 32768)>>16)+128)
+#define TO_U(r, g, b) \
+ (((-9714 * r - 19070 * g + 28784 * b + 32768) >> 16) + 128)
#define TSTAMP_MIN_Y 24
#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
#define TSTAMP_MIN_X 64
-static void gen_line(char *basep,int inipos,int wmax,
- int hmax, int line, int count, char *timestr)
+static void gen_line(char *basep, int inipos, int wmax,
+ int hmax, int line, int count, char *timestr)
{
- int w,i,j,pos=inipos,y;
- char *p,*s;
- u8 chr,r,g,b,color;
+ int w, i, j, y;
+ int pos = inipos;
+ char *p, *s;
+ u8 chr, r, g, b, color;
/* We will just duplicate the second pixel at the packet */
- wmax/=2;
+ wmax /= 2;
/* Generate a standard color bar pattern */
- for (w=0;w<wmax;w++) {
- int colorpos=((w+count)*8/(wmax+1)) % 8;
- r=bars[colorpos][0];
- g=bars[colorpos][1];
- b=bars[colorpos][2];
+ for (w = 0; w < wmax; w++) {
+ int colorpos = ((w + count) * 8/(wmax + 1)) % 8;
+ r = bars[colorpos][0];
+ g = bars[colorpos][1];
+ b = bars[colorpos][2];
- for (color=0;color<4;color++) {
- p=basep+pos;
+ for (color = 0; color < 4; color++) {
+ p = basep + pos;
switch (color) {
- case 0:
- case 2:
- *p=TO_Y(r,g,b); /* Luminance */
- break;
- case 1:
- *p=TO_U(r,g,b); /* Cb */
- break;
- case 3:
- *p=TO_V(r,g,b); /* Cr */
- break;
+ case 0:
+ case 2:
+ *p = TO_Y(r, g, b); /* Luma */
+ break;
+ case 1:
+ *p = TO_U(r, g, b); /* Cb */
+ break;
+ case 3:
+ *p = TO_V(r, g, b); /* Cr */
+ break;
}
pos++;
}
}
/* Checks if it is possible to show timestamp */
- if (TSTAMP_MAX_Y>=hmax)
+ if (TSTAMP_MAX_Y >= hmax)
goto end;
- if (TSTAMP_MIN_X+strlen(timestr)>=wmax)
+ if (TSTAMP_MIN_X + strlen(timestr) >= wmax)
goto end;
/* Print stream time */
- if (line>=TSTAMP_MIN_Y && line<=TSTAMP_MAX_Y) {
- j=TSTAMP_MIN_X;
- for (s=timestr;*s;s++) {
- chr=rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
- for (i=0;i<7;i++) {
- if (chr&1<<(7-i)) { /* Font color*/
- r=bars[BLUE][0];
- g=bars[BLUE][1];
- b=bars[BLUE][2];
- r=g=b=0;
- g=198;
- } else { /* Background color */
- r=bars[WHITE][0];
- g=bars[WHITE][1];
- b=bars[WHITE][2];
- r=g=b=0;
+ if (line >= TSTAMP_MIN_Y && line <= TSTAMP_MAX_Y) {
+ j = TSTAMP_MIN_X;
+ for (s = timestr; *s; s++) {
+ chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
+ for (i = 0; i < 7; i++) {
+ if (chr & 1 << (7 - i)) {
+ /* Font color*/
+ r = 0;
+ g = 198;
+ b = 0;
+ } else {
+ /* Background color */
+ r = bars[BLACK][0];
+ g = bars[BLACK][1];
+ b = bars[BLACK][2];
}
- pos=inipos+j*2;
- for (color=0;color<4;color++) {
- p=basep+pos;
+ pos = inipos + j * 2;
+ for (color = 0; color < 4; color++) {
+ p = basep + pos;
- y=TO_Y(r,g,b);
+ y = TO_Y(r, g, b);
switch (color) {
- case 0:
- case 2:
- *p=TO_Y(r,g,b); /* Luminance */
- break;
- case 1:
- *p=TO_U(r,g,b); /* Cb */
- break;
- case 3:
- *p=TO_V(r,g,b); /* Cr */
- break;
+ case 0:
+ case 2:
+ *p = TO_Y(r, g, b); /* Luma */
+ break;
+ case 1:
+ *p = TO_U(r, g, b); /* Cb */
+ break;
+ case 3:
+ *p = TO_V(r, g, b); /* Cr */
+ break;
}
pos++;
}
@@ -331,72 +335,57 @@ static void gen_line(char *basep,int inipos,int wmax,
}
}
-#if 0 /* This will require a different logic */
- /* Generate random noise */
- if (line>6*hmax/7) {
- if (line>6*hmax/7) {
- p=get_addr_pos(inipos+j/2,pages,to_addr);
-
-// get_random_bytes(buf+wmax-(wmax/7), wmax/7);
- kunmap_atomic(p, KM_BOUNCE_READ);
- }
- }
-
-#endif
-
end:
return;
}
-static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
+static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
{
- int h,pos=0;
+ int h , pos = 0;
int hmax = buf->vb.height;
int wmax = buf->vb.width;
struct timeval ts;
- char *tmpbuf = kmalloc(wmax*2,GFP_KERNEL);
- void *vbuf=videobuf_to_vmalloc (&buf->vb);
- /* FIXME: move to dev struct */
- static int mv_count=0;
+ char *tmpbuf = kmalloc(wmax * 2, GFP_KERNEL);
+ void *vbuf = videobuf_to_vmalloc(&buf->vb);
if (!tmpbuf)
return;
- for (h=0;h<hmax;h++) {
- gen_line(tmpbuf,0,wmax,hmax,h,mv_count,
+ for (h = 0; h < hmax; h++) {
+ gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count,
dev->timestr);
/* FIXME: replacing to __copy_to_user */
- if (copy_to_user(vbuf+pos,tmpbuf,wmax*2)!=0)
- dprintk(2,"vivifill copy_to_user failed.\n");
+ if (copy_to_user(vbuf + pos, tmpbuf, wmax * 2) != 0)
+ dprintk(2, "vivifill copy_to_user failed.\n");
pos += wmax*2;
}
- mv_count++;
+ dev->mv_count++;
kfree(tmpbuf);
/* Updates stream time */
- dev->us+=jiffies_to_usecs(jiffies-dev->jiffies);
- dev->jiffies=jiffies;
- if (dev->us>=1000000) {
- dev->us-=1000000;
+ dev->us += jiffies_to_usecs(jiffies-dev->jiffies);
+ dev->jiffies = jiffies;
+ if (dev->us >= 1000000) {
+ dev->us -= 1000000;
dev->s++;
- if (dev->s>=60) {
- dev->s-=60;
+ if (dev->s >= 60) {
+ dev->s -= 60;
dev->m++;
- if (dev->m>60) {
- dev->m-=60;
+ if (dev->m > 60) {
+ dev->m -= 60;
dev->h++;
- if (dev->h>24)
- dev->h-=24;
+ if (dev->h > 24)
+ dev->h -= 24;
}
}
}
- sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
- dev->h,dev->m,dev->s,(dev->us+500)/1000);
+ sprintf(dev->timestr, "%02d:%02d:%02d:%03d",
+ dev->h, dev->m, dev->s, (dev->us + 500) / 1000);
- dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
- (unsigned long)tmpbuf,pos);
+ dprintk(2, "vivifill at %s: Buffer 0x%08lx size= %d\n", dev->timestr,
+ (unsigned long)tmpbuf, pos);
/* Advice that buffer was filled */
buf->vb.state = VIDEOBUF_DONE;
@@ -413,14 +402,14 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q);
static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
{
struct vivi_buffer *buf;
- struct vivi_dev *dev= container_of(dma_q,struct vivi_dev,vidq);
+ struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq);
int bc;
/* Announces videobuf that all went ok */
for (bc = 0;; bc++) {
if (list_empty(&dma_q->active)) {
- dprintk(1,"No active queue to serve\n");
+ dprintk(1, "No active queue to serve\n");
break;
}
@@ -434,19 +423,20 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
}
do_gettimeofday(&buf->vb.ts);
- dprintk(2,"[%p/%d] wakeup\n",buf,buf->vb.i);
+ dprintk(2, "[%p/%d] wakeup\n", buf, buf->vb. i);
/* Fill buffer */
- vivi_fillbuff(dev,buf);
+ vivi_fillbuff(dev, buf);
if (list_empty(&dma_q->active)) {
del_timer(&dma_q->timeout);
} else {
- mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ mod_timer(&dma_q->timeout, jiffies + BUFFER_TIMEOUT);
}
}
if (bc != 1)
- dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
+ dprintk(1, "%s: %d buffers handled (should be 1)\n",
+ __FUNCTION__, bc);
}
static void vivi_sleep(struct vivi_dmaqueue *dma_q)
@@ -454,10 +444,10 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q)
int timeout;
DECLARE_WAITQUEUE(wait, current);
- dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+ dprintk(1, "%s dma_q=0x%08lx\n", __FUNCTION__, (unsigned long)dma_q);
add_wait_queue(&dma_q->wq, &wait);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
if (!(q->rmmod || signal_pending(current))) {
#else
if (!kthread_should_stop()) {
@@ -465,23 +455,31 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q)
dma_q->frame++;
/* Calculate time to wake up */
- timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
+ timeout = dma_q->ini_jiffies+
+ msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR * 1000)
+ / WAKE_DENOMINATOR) - jiffies;
if (timeout <= 0) {
- int old=dma_q->frame;
- dma_q->frame=(jiffies_to_msecs(jiffies-dma_q->ini_jiffies)*WAKE_DENOMINATOR)/(WAKE_NUMERATOR*1000)+1;
-
- timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
-
- dprintk(1,"underrun, losed %d frames. "
- "Now, frame is %d. Waking on %d jiffies\n",
- dma_q->frame-old,dma_q->frame,timeout);
+ int old = dma_q->frame;
+ dma_q->frame = (jiffies_to_msecs(jiffies -
+ dma_q->ini_jiffies) *
+ WAKE_DENOMINATOR) /
+ (WAKE_NUMERATOR * 1000) + 1;
+
+ timeout = dma_q->ini_jiffies+
+ msecs_to_jiffies((dma_q->frame *
+ WAKE_NUMERATOR * 1000)
+ / WAKE_DENOMINATOR) - jiffies;
+
+ dprintk(1, "underrun, losed %d frames. "
+ "Now, frame is %d. Waking on %d jiffies\n",
+ dma_q->frame-old, dma_q->frame, timeout);
} else
- dprintk(1,"will sleep for %i jiffies\n",timeout);
+ dprintk(1, "will sleep for %i jiffies\n", timeout);
vivi_thread_tick(dma_q);
- schedule_timeout_interruptible (timeout);
+ schedule_timeout_interruptible(timeout);
}
remove_wait_queue(&dma_q->wq, &wait);
@@ -490,9 +488,9 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q)
static int vivi_thread(void *data)
{
- struct vivi_dmaqueue *dma_q=data;
+ struct vivi_dmaqueue *dma_q = data;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
daemonize();
exit_files(current);
reparent_to_init();
@@ -506,7 +504,7 @@ static int vivi_thread(void *data)
if (dma_q->notify != NULL)
up(dma_q->notify);
#endif
- dprintk(1,"thread started\n");
+ dprintk(1, "thread started\n");
mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
set_freezable();
@@ -514,7 +512,7 @@ static int vivi_thread(void *data)
for (;;) {
vivi_sleep(dma_q);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
if (dma_q->rmmod || signal_pending(current))
#else
if (kthread_should_stop())
@@ -522,7 +520,7 @@ static int vivi_thread(void *data)
break;
}
dprintk(1, "thread: exit\n");
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
dma_q->kthread = NULL;
if (dma_q->notify != NULL)
@@ -533,12 +531,12 @@ static int vivi_thread(void *data)
static int vivi_start_thread(struct vivi_dmaqueue *dma_q)
{
- dma_q->frame=0;
- dma_q->ini_jiffies=jiffies;
+ dma_q->frame = 0;
+ dma_q->ini_jiffies = jiffies;
- dprintk(1,"%s\n",__FUNCTION__);
+ dprintk(1, "%s\n", __FUNCTION__);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
if (IS_ERR(dma_q->kthread)) {
@@ -553,7 +551,7 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q)
dma_q->rmmod = 0;
if (kernel_thread(vivi_thread, dma_q, 0) < 0) {
- printk (KERN_ERR "sdim: kernel_thread() failed\n");
+ printk(KERN_ERR "sdim: kernel_thread() failed\n");
return -EINVAL;
}
@@ -563,19 +561,18 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q)
/* Wakes thread */
wake_up_interruptible(&dma_q->wq);
- dprintk(1,"returning from %s\n",__FUNCTION__);
+ dprintk(1, "returning from %s\n", __FUNCTION__);
return 0;
}
static void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
{
- dprintk(1,"%s\n",__FUNCTION__);
+ dprintk(1, "%s\n", __FUNCTION__);
/* shutdown control thread */
if (dma_q->kthread) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
DECLARE_MUTEX_LOCKED(sem);
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+
/* shutdown control thread */
dma_q->notify = &sem;
dma_q->rmmod = 1;
@@ -586,7 +583,7 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
#else
kthread_stop(dma_q->kthread);
#endif
- dma_q->kthread=NULL;
+ dma_q->kthread = NULL;
}
}
@@ -594,16 +591,16 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
{
struct vivi_buffer *buf, *prev;
- dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+ dprintk(1, "%s dma_q=0x%08lx\n", __FUNCTION__, (unsigned long)dma_q);
if (!list_empty(&dma_q->active)) {
- buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue);
- dprintk(2,"restart_queue [%p/%d]: restart dma\n",
+ buf = list_entry(dma_q->active.next,
+ struct vivi_buffer, vb.queue);
+ dprintk(2, "restart_queue [%p/%d]: restart dma\n",
buf, buf->vb.i);
- dprintk(1,"Restarting video dma\n");
+ dprintk(1, "Restarting video dma\n");
vivi_stop_thread(dma_q);
-// vivi_start_thread(dma_q);
/* cancel all outstanding capture / vbi requests */
list_for_each_entry_safe(buf, prev, &dma_q->active, vb.queue) {
@@ -620,28 +617,29 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
for (;;) {
if (list_empty(&dma_q->queued))
return 0;
- buf = list_entry(dma_q->queued.next, struct vivi_buffer, vb.queue);
+ buf = list_entry(dma_q->queued.next,
+ struct vivi_buffer, vb.queue);
if (NULL == prev) {
list_del(&buf->vb.queue);
- list_add_tail(&buf->vb.queue,&dma_q->active);
+ list_add_tail(&buf->vb.queue, &dma_q->active);
- dprintk(1,"Restarting video dma\n");
+ dprintk(1, "Restarting video dma\n");
vivi_stop_thread(dma_q);
vivi_start_thread(dma_q);
buf->vb.state = VIDEOBUF_ACTIVE;
mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
- dprintk(2,"[%p/%d] restart_queue - first active\n",
- buf,buf->vb.i);
+ dprintk(2, "[%p/%d] restart_queue - first active\n",
+ buf, buf->vb.i);
} else if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_del(&buf->vb.queue);
- list_add_tail(&buf->vb.queue,&dma_q->active);
+ list_add_tail(&buf->vb.queue, &dma_q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
- dprintk(2,"[%p/%d] restart_queue - move to active\n",
- buf,buf->vb.i);
+ dprintk(2, "[%p/%d] restart_queue - move to active\n",
+ buf, buf->vb.i);
} else {
return 0;
}
@@ -651,16 +649,17 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
static void vivi_vid_timeout(unsigned long data)
{
- struct vivi_dev *dev = (struct vivi_dev*)data;
+ struct vivi_dev *dev = (struct vivi_dev *)data;
struct vivi_dmaqueue *vidq = &dev->vidq;
struct vivi_buffer *buf;
while (!list_empty(&vidq->active)) {
- buf = list_entry(vidq->active.next, struct vivi_buffer, vb.queue);
+ buf = list_entry(vidq->active.next,
+ struct vivi_buffer, vb.queue);
list_del(&buf->vb.queue);
buf->vb.state = VIDEOBUF_ERROR;
wake_up(&buf->vb.done);
- printk("vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
+ printk(KERN_INFO "vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
}
restart_video_queue(vidq);
@@ -682,19 +681,19 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
- dprintk(1,"%s, count=%d, size=%d\n",__FUNCTION__,*count, *size);
+ dprintk(1, "%s, count=%d, size=%d\n", __FUNCTION__, *count, *size);
return 0;
}
static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
{
- dprintk(1,"%s\n",__FUNCTION__);
+ dprintk(1, "%s\n", __FUNCTION__);
if (in_interrupt())
BUG();
- videobuf_waiton(&buf->vb,0,0);
+ videobuf_waiton(&buf->vb, 0, 0);
videobuf_vmalloc_free(&buf->vb);
buf->vb.state = VIDEOBUF_NEEDS_INIT;
}
@@ -706,10 +705,10 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
enum v4l2_field field)
{
struct vivi_fh *fh = vq->priv_data;
- struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb);
int rc, init_buffer = 0;
- dprintk(1,"%s, field=%d\n",__FUNCTION__,field);
+ dprintk(1, "%s, field=%d\n", __FUNCTION__, field);
BUG_ON(NULL == fh->fmt);
if (fh->width < 48 || fh->width > norm_maxw() ||
@@ -731,80 +730,78 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
}
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
- if (0 != (rc = videobuf_iolock(vq,&buf->vb,NULL)))
+ rc = videobuf_iolock(vq, &buf->vb, NULL);
+ if (rc < 0)
goto fail;
}
buf->vb.state = VIDEOBUF_PREPARED;
-#ifdef CONFIG_VIVI_SCATTER
- if (NULL == (buf->to_addr = kmalloc(sizeof(*buf->to_addr) * vb->dma.nr_pages,GFP_KERNEL))) {
- rc=-ENOMEM;
- goto fail;
- }
-#endif
return 0;
fail:
- free_buffer(vq,buf);
+ free_buffer(vq, buf);
return rc;
}
static void
buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
{
- struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
- struct vivi_fh *fh = vq->priv_data;
- struct vivi_dev *dev = fh->dev;
- struct vivi_dmaqueue *vidq = &dev->vidq;
+ struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb);
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_dev *dev = fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
struct vivi_buffer *prev;
if (!list_empty(&vidq->queued)) {
- dprintk(1,"adding vb queue=0x%08lx\n",(unsigned long)&buf->vb.queue);
- list_add_tail(&buf->vb.queue,&vidq->queued);
+ dprintk(1, "adding vb queue=0x%08lx\n",
+ (unsigned long)&buf->vb.queue);
+ list_add_tail(&buf->vb.queue, &vidq->queued);
buf->vb.state = VIDEOBUF_QUEUED;
- dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
+ dprintk(2, "[%p/%d] buffer_queue - append to queued\n",
buf, buf->vb.i);
} else if (list_empty(&vidq->active)) {
- list_add_tail(&buf->vb.queue,&vidq->active);
+ list_add_tail(&buf->vb.queue, &vidq->active);
buf->vb.state = VIDEOBUF_ACTIVE;
mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT);
- dprintk(2,"[%p/%d] buffer_queue - first active\n",
+ dprintk(2, "[%p/%d] buffer_queue - first active\n",
buf, buf->vb.i);
vivi_start_thread(vidq);
} else {
- prev = list_entry(vidq->active.prev, struct vivi_buffer, vb.queue);
+ prev = list_entry(vidq->active.prev,
+ struct vivi_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
- list_add_tail(&buf->vb.queue,&vidq->active);
+ list_add_tail(&buf->vb.queue, &vidq->active);
buf->vb.state = VIDEOBUF_ACTIVE;
- dprintk(2,"[%p/%d] buffer_queue - append to active\n",
+ dprintk(2, "[%p/%d] buffer_queue - append to active\n",
buf, buf->vb.i);
} else {
- list_add_tail(&buf->vb.queue,&vidq->queued);
+ list_add_tail(&buf->vb.queue, &vidq->queued);
buf->vb.state = VIDEOBUF_QUEUED;
- dprintk(2,"[%p/%d] buffer_queue - first queued\n",
+ dprintk(2, "[%p/%d] buffer_queue - first queued\n",
buf, buf->vb.i);
}
}
}
-static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+static void buffer_release(struct videobuf_queue *vq,
+ struct videobuf_buffer *vb)
{
- struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb);
struct vivi_fh *fh = vq->priv_data;
- struct vivi_dev *dev = (struct vivi_dev*)fh->dev;
+ struct vivi_dev *dev = (struct vivi_dev *)fh->dev;
struct vivi_dmaqueue *vidq = &dev->vidq;
- dprintk(1,"%s\n",__FUNCTION__);
+ dprintk(1, "%s\n", __FUNCTION__);
vivi_stop_thread(vidq);
- free_buffer(vq,buf);
+ free_buffer(vq, buf);
}
static struct videobuf_queue_ops vivi_video_qops = {
@@ -817,7 +814,7 @@ static struct videobuf_queue_ops vivi_video_qops = {
/* ------------------------------------------------------------------
IOCTL vidioc handling
------------------------------------------------------------------*/
-static int vidioc_querycap (struct file *file, void *priv,
+static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strcpy(cap->driver, "vivi");
@@ -829,21 +826,21 @@ static int vidioc_querycap (struct file *file, void *priv,
return 0;
}
-static int vidioc_enum_fmt_cap (struct file *file, void *priv,
+static int vidioc_enum_fmt_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
if (f->index > 0)
return -EINVAL;
- strlcpy(f->description,format.name,sizeof(f->description));
+ strlcpy(f->description, format.name, sizeof(f->description));
f->pixelformat = format.fourcc;
return 0;
}
-static int vidioc_g_fmt_cap (struct file *file, void *priv,
+static int vidioc_g_fmt_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
f->fmt.pix.width = fh->width;
f->fmt.pix.height = fh->height;
@@ -857,7 +854,7 @@ static int vidioc_g_fmt_cap (struct file *file, void *priv,
return (0);
}
-static int vidioc_try_fmt_cap (struct file *file, void *priv,
+static int vidioc_try_fmt_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct vivi_fmt *fmt;
@@ -865,18 +862,18 @@ static int vidioc_try_fmt_cap (struct file *file, void *priv,
unsigned int maxw, maxh;
if (format.fourcc != f->fmt.pix.pixelformat) {
- dprintk(1,"Fourcc format (0x%08x) invalid. Driver accepts "
- "only 0x%08x\n",f->fmt.pix.pixelformat,format.fourcc);
+ dprintk(1, "Fourcc format (0x%08x) invalid. Driver accepts "
+ "only 0x%08x\n", f->fmt.pix.pixelformat, format.fourcc);
return -EINVAL;
}
- fmt=&format;
+ fmt = &format;
field = f->fmt.pix.field;
if (field == V4L2_FIELD_ANY) {
- field=V4L2_FIELD_INTERLACED;
+ field = V4L2_FIELD_INTERLACED;
} else if (V4L2_FIELD_INTERLACED != field) {
- dprintk(1,"Field type invalid.\n");
+ dprintk(1, "Field type invalid.\n");
return -EINVAL;
}
@@ -902,11 +899,11 @@ static int vidioc_try_fmt_cap (struct file *file, void *priv,
}
/*FIXME: This seems to be generic enough to be at videodev2 */
-static int vidioc_s_fmt_cap (struct file *file, void *priv,
+static int vidioc_s_fmt_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct vivi_fh *fh=priv;
- int ret = vidioc_try_fmt_cap(file,fh,f);
+ struct vivi_fh *fh = priv;
+ int ret = vidioc_try_fmt_cap(file, fh, f);
if (ret < 0)
return (ret);
@@ -919,47 +916,48 @@ static int vidioc_s_fmt_cap (struct file *file, void *priv,
return (0);
}
-static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
+static int vidioc_reqbufs(struct file *file, void *priv,
+ struct v4l2_requestbuffers *p)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
return (videobuf_reqbufs(&fh->vb_vidq, p));
}
-static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)
+static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
return (videobuf_querybuf(&fh->vb_vidq, p));
}
-static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)
+static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
return (videobuf_qbuf(&fh->vb_vidq, p));
}
-static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
+static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
return (videobuf_dqbuf(&fh->vb_vidq, p,
file->f_flags & O_NONBLOCK));
}
#ifdef CONFIG_VIDEO_V4L1_COMPAT
-static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
+static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
- return videobuf_cgmbuf (&fh->vb_vidq, mbuf, 8);
+ return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8);
}
#endif
static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -971,7 +969,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{
- struct vivi_fh *fh=priv;
+ struct vivi_fh *fh = priv;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -981,13 +979,13 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
return videobuf_streamoff(&fh->vb_vidq);
}
-static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *i)
+static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i)
{
return 0;
}
/* only one input in this sample driver */
-static int vidioc_enum_input (struct file *file, void *priv,
+static int vidioc_enum_input(struct file *file, void *priv,
struct v4l2_input *inp)
{
if (inp->index != 0)
@@ -995,18 +993,18 @@ static int vidioc_enum_input (struct file *file, void *priv,
inp->type = V4L2_INPUT_TYPE_CAMERA;
inp->std = V4L2_STD_NTSC_M;
- strcpy(inp->name,"Camera");
+ strcpy(inp->name, "Camera");
return (0);
}
-static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
+static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
*i = 0;
return (0);
}
-static int vidioc_s_input (struct file *file, void *priv, unsigned int i)
+static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
if (i > 0)
return -EINVAL;
@@ -1015,8 +1013,8 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i)
}
/* --- controls ---------------------------------------------- */
-static int vidioc_queryctrl (struct file *file, void *priv,
- struct v4l2_queryctrl *qc)
+static int vidioc_queryctrl(struct file *file, void *priv,
+ struct v4l2_queryctrl *qc)
{
int i;
@@ -1030,33 +1028,31 @@ static int vidioc_queryctrl (struct file *file, void *priv,
return -EINVAL;
}
-static int vidioc_g_ctrl (struct file *file, void *priv,
- struct v4l2_control *ctrl)
+static int vidioc_g_ctrl(struct file *file, void *priv,
+ struct v4l2_control *ctrl)
{
int i;
for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
if (ctrl->id == vivi_qctrl[i].id) {
- ctrl->value=qctl_regs[i];
+ ctrl->value = qctl_regs[i];
return (0);
}
return -EINVAL;
}
-static int vidioc_s_ctrl (struct file *file, void *priv,
+static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctrl)
{
int i;
for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
if (ctrl->id == vivi_qctrl[i].id) {
- if (ctrl->value <
- vivi_qctrl[i].minimum
- || ctrl->value >
- vivi_qctrl[i].maximum) {
+ if (ctrl->value < vivi_qctrl[i].minimum
+ || ctrl->value > vivi_qctrl[i].maximum) {
return (-ERANGE);
}
- qctl_regs[i]=ctrl->value;
+ qctl_regs[i] = ctrl->value;
return (0);
}
return -EINVAL;
@@ -1075,22 +1071,14 @@ static int vivi_open(struct inode *inode, struct file *file)
struct vivi_fh *fh;
int i;
- printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
+ printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor);
list_for_each_entry(dev, &vivi_devlist, vivi_devlist)
- if (dev->vfd.minor == minor)
+ if (dev->vfd->minor == minor)
goto found;
return -ENODEV;
-found:
-
-#if 0 /* Avoids an oops at read() - seems to be semaphore related */
- if (dev->users) {
- printk(KERN_INFO "this driver can be opened only once (users=%d)\n",dev->users);
- return -EBUSY;
- }
-#endif
-
+found:
/* If more than one user, mutex should be added */
dev->users++;
@@ -1098,7 +1086,7 @@ found:
v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users);
/* allocate + initialize per filehandle data */
- fh = kzalloc(sizeof(*fh),GFP_KERNEL);
+ fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
dev->users--;
return -ENOMEM;
@@ -1114,27 +1102,21 @@ found:
/* Put all controls at a sane state */
for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
- qctl_regs[i] =vivi_qctrl[i].default_value;
-
- dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
- (unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
- dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
- dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
+ qctl_regs[i] = vivi_qctrl[i].default_value;
/* Resets frame counters */
- dev->h=0;
- dev->m=0;
- dev->s=0;
- dev->us=0;
- dev->jiffies=jiffies;
- sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
- dev->h,dev->m,dev->s,(dev->us+500)/1000);
+ dev->h = 0;
+ dev->m = 0;
+ dev->s = 0;
+ dev->us = 0;
+ dev->mv_count = 0;
+ dev->jiffies = jiffies;
+ sprintf(dev->timestr, "%02d:%02d:%02d:%03d",
+ dev->h, dev->m, dev->s, (dev->us + 500) / 1000);
videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops,
- NULL, NULL,
- fh->type,
- V4L2_FIELD_INTERLACED,
- sizeof(struct vivi_buffer),fh);
+ NULL, NULL, fh->type, V4L2_FIELD_INTERLACED,
+ sizeof(struct vivi_buffer), fh);
return 0;
}
@@ -1142,9 +1124,9 @@ found:
static ssize_t
vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
{
- struct vivi_fh *fh = file->private_data;
+ struct vivi_fh *fh = file->private_data;
- if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
return videobuf_read_stream(&fh->vb_vidq, data, count, ppos, 0,
file->f_flags & O_NONBLOCK);
}
@@ -1157,7 +1139,7 @@ vivi_poll(struct file *file, struct poll_table_struct *wait)
struct vivi_fh *fh = file->private_data;
struct videobuf_queue *q = &fh->vb_vidq;
- dprintk(1,"%s\n",__FUNCTION__);
+ dprintk(1, "%s\n", __FUNCTION__);
if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
return POLLERR;
@@ -1165,7 +1147,7 @@ vivi_poll(struct file *file, struct poll_table_struct *wait)
return videobuf_poll_stream(file, q, wait);
}
-static int vivi_release(struct inode *inode, struct file *file)
+static int vivi_close(struct inode *inode, struct file *file)
{
struct vivi_fh *fh = file->private_data;
struct vivi_dev *dev = fh->dev;
@@ -1177,26 +1159,46 @@ static int vivi_release(struct inode *inode, struct file *file)
videobuf_stop(&fh->vb_vidq);
videobuf_mmap_free(&fh->vb_vidq);
- kfree (fh);
+ kfree(fh);
dev->users--;
- printk(KERN_DEBUG "vivi: close called (minor=%d, users=%d)\n",minor,dev->users);
+ dprintk(1, "close called (minor=%d, users=%d)\n", minor, dev->users);
return 0;
}
-static int
-vivi_mmap(struct file *file, struct vm_area_struct * vma)
+static int vivi_release(void)
{
- struct vivi_fh *fh = file->private_data;
+ struct vivi_dev *dev;
+ struct list_head *list;
+
+ while (!list_empty(&vivi_devlist)) {
+ list = vivi_devlist.next;
+ list_del(list);
+ dev = list_entry(list, struct vivi_dev, vivi_devlist);
+
+ if (-1 != dev->vfd->minor)
+ video_unregister_device(dev->vfd);
+ else
+ video_device_release(dev->vfd);
+
+ kfree(dev);
+ }
+
+ return 0;
+}
+
+static int vivi_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ struct vivi_fh *fh = file->private_data;
int ret;
- dprintk (1,"mmap called, vma=0x%08lx\n",(unsigned long)vma);
+ dprintk(1, "mmap called, vma=0x%08lx\n", (unsigned long)vma);
- ret=videobuf_mmap_mapper(&fh->vb_vidq, vma);
+ ret = videobuf_mmap_mapper(&fh->vb_vidq, vma);
- dprintk (1,"vma start=0x%08lx, size=%ld, ret=%d\n",
+ dprintk(1, "vma start=0x%08lx, size=%ld, ret=%d\n",
(unsigned long)vma->vm_start,
(unsigned long)vma->vm_end-(unsigned long)vma->vm_start,
ret);
@@ -1207,7 +1209,7 @@ vivi_mmap(struct file *file, struct vm_area_struct * vma)
static const struct file_operations vivi_fops = {
.owner = THIS_MODULE,
.open = vivi_open,
- .release = vivi_release,
+ .release = vivi_close,
.read = vivi_read,
.poll = vivi_poll,
.ioctl = video_ioctl2, /* V4L2 ioctl handler */
@@ -1215,12 +1217,12 @@ static const struct file_operations vivi_fops = {
.llseek = no_llseek,
};
-static struct video_device vivi = {
+static struct video_device vivi_template = {
.name = "vivi",
.type = VID_TYPE_CAPTURE,
.fops = &vivi_fops,
.minor = -1,
-// .release = video_device_release,
+ .release = video_device_release,
.vidioc_querycap = vidioc_querycap,
.vidioc_enum_fmt_cap = vidioc_enum_fmt_cap,
@@ -1252,43 +1254,60 @@ static struct video_device vivi = {
static int __init vivi_init(void)
{
- int ret;
+ int ret = -ENOMEM, i;
struct vivi_dev *dev;
+ struct video_device *vfd;
- dev = kzalloc(sizeof(*dev),GFP_KERNEL);
- if (NULL == dev)
- return -ENOMEM;
- list_add_tail(&dev->vivi_devlist,&vivi_devlist);
+ for (i = 0; i < n_devs; i++) {
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (NULL == dev)
+ break;
- /* init video dma queues */
- INIT_LIST_HEAD(&dev->vidq.active);
- INIT_LIST_HEAD(&dev->vidq.queued);
- init_waitqueue_head(&dev->vidq.wq);
+ list_add_tail(&dev->vivi_devlist, &vivi_devlist);
- /* initialize locks */
- mutex_init(&dev->lock);
+ /* init video dma queues */
+ INIT_LIST_HEAD(&dev->vidq.active);
+ INIT_LIST_HEAD(&dev->vidq.queued);
+ init_waitqueue_head(&dev->vidq.wq);
- dev->vidq.timeout.function = vivi_vid_timeout;
- dev->vidq.timeout.data = (unsigned long)dev;
- init_timer(&dev->vidq.timeout);
+ /* initialize locks */
+ mutex_init(&dev->lock);
- ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
- printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
+ dev->vidq.timeout.function = vivi_vid_timeout;
+ dev->vidq.timeout.data = (unsigned long)dev;
+ init_timer(&dev->vidq.timeout);
+
+ vfd = video_device_alloc();
+ if (NULL == vfd)
+ break;
+
+ *vfd = vivi_template;
+
+ ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
+ if (ret < 0)
+ break;
+
+ snprintf(vfd->name, sizeof(vfd->name), "%s (%i)",
+ vivi_template.name, vfd->minor);
+
+ if (video_nr >= 0)
+ video_nr++;
+
+ dev->vfd = vfd;
+ }
+
+ if (ret < 0) {
+ vivi_release();
+ printk(KERN_INFO "Error %d while loading vivi driver\n", ret);
+ } else
+ printk(KERN_INFO "Video Technology Magazine Virtual Video "
+ "Capture Board successfully loaded.\n");
return ret;
}
static void __exit vivi_exit(void)
{
- struct vivi_dev *h;
- struct list_head *list;
-
- while (!list_empty(&vivi_devlist)) {
- list = vivi_devlist.next;
- list_del(list);
- h = list_entry(list, struct vivi_dev, vivi_devlist);
- kfree (h);
- }
- video_unregister_device(&vivi);
+ vivi_release();
}
module_init(vivi_init);
@@ -1299,10 +1318,13 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
MODULE_LICENSE("Dual BSD/GPL");
module_param(video_nr, int, 0);
+MODULE_PARM_DESC(video_nr, "video iminor start number");
-module_param_named(debug,vivi.debug, int, 0644);
-MODULE_PARM_DESC(debug,"activates debug info");
+module_param(n_devs, int, 0);
+MODULE_PARM_DESC(n_devs, "number of video devices to create");
-module_param(vid_limit,int,0644);
-MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
+module_param_named(debug, vivi.debug, int, 0644);
+MODULE_PARM_DESC(debug, "activates debug info");
+module_param(vid_limit, int, 0644);
+MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
diff --git a/linux/drivers/media/video/vp27smpx.c b/linux/drivers/media/video/vp27smpx.c
index 602d7da63..c7099c5fe 100644
--- a/linux/drivers/media/video/vp27smpx.c
+++ b/linux/drivers/media/video/vp27smpx.c
@@ -41,6 +41,7 @@ MODULE_DESCRIPTION("vp27smpx driver");
MODULE_AUTHOR("Hans Verkuil");
MODULE_LICENSE("GPL");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
static unsigned short normal_i2c[] = { 0xb6 >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
@@ -48,6 +49,7 @@ static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
/* ----------------------------------------------------------------------- */
diff --git a/linux/drivers/media/video/wm8739.c b/linux/drivers/media/video/wm8739.c
index a0a4ed3ba..36babfdb2 100644
--- a/linux/drivers/media/video/wm8739.c
+++ b/linux/drivers/media/video/wm8739.c
@@ -42,7 +42,6 @@ MODULE_AUTHOR("T. Adachi, Hans Verkuil");
MODULE_LICENSE("GPL");
static int debug;
-static unsigned short normal_i2c[] = { 0x34 >> 1, 0x36 >> 1, I2C_CLIENT_END };
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
module_param(debug, int, 0644);
@@ -52,11 +51,15 @@ MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug level (0-1)");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
+static unsigned short normal_i2c[] = { 0x34 >> 1, 0x36 >> 1, I2C_CLIENT_END };
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
#endif
I2C_CLIENT_INSMOD;
+#endif
/* ------------------------------------------------------------------------ */
diff --git a/linux/include/media/v4l2-i2c-drv.h b/linux/include/media/v4l2-i2c-drv.h
index 726120399..09e5f8de5 100644
--- a/linux/include/media/v4l2-i2c-drv.h
+++ b/linux/include/media/v4l2-i2c-drv.h
@@ -38,7 +38,6 @@ struct v4l2_i2c_driver_data {
};
static struct v4l2_i2c_driver_data v4l2_i2c_data;
-static struct i2c_client_address_data addr_data;
static struct i2c_driver v4l2_i2c_driver;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
@@ -59,6 +58,8 @@ static int __init v4l2_i2c_drv_init(void)
#else
+static struct i2c_client_address_data addr_data;
+
/* Bus-based I2C API is not present, add legacy code */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
diff --git a/v4l/Makefile b/v4l/Makefile
index 75e9c50ef..60bf0b317 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -43,6 +43,7 @@ default:: config-compat.h Makefile.media links oss
@echo Kernel build directory is $(OUTDIR)
$(MAKE) -C $(OUTDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules
./scripts/rmmod.pl check
+# $(MAKE) checkpatch
#################################################
# Object specific rules
@@ -395,6 +396,17 @@ push::
make -C .. push
#################################################
+# Consistency checks
+checkemacs::
+ scripts/check.pl
+
+checketerse::
+ scripts/check.pl -t
+
+checkpatch::
+ scripts/check.pl -c
+
+#################################################
# Help
help::
@cat ../INSTALL
diff --git a/v4l/scripts/check.pl b/v4l/scripts/check.pl
new file mode 100755
index 000000000..4958e281b
--- /dev/null
+++ b/v4l/scripts/check.pl
@@ -0,0 +1,118 @@
+#!/usr/bin/perl
+use Getopt::Std;
+use strict;
+
+my $c_syntax=0;
+my $fmt="--emacs";
+
+my %opt;
+
+sub usage ($)
+{
+ my $name = shift;
+ printf "Usage: %s [<args>] [<file>]\n".
+ "\t-c\tc style\n".
+ "\t-e\emacs style (default)\n".
+ "\t-t\terse style (default)\n".
+ "\t<file>\tfile name to open. If file not specified, uses hg diff\n\n", $name;
+
+ exit -1;
+}
+
+if (not getopts('cet',\%opt) or defined $opt{'h'}) {
+ usage($0);
+}
+
+my $cmd=shift;
+
+if ($opt{'c'}) {
+ $c_syntax=1;
+}
+
+if ($opt{'t'}) {
+ $fmt="--terse";
+ $c_syntax=0;
+}
+
+if ($cmd) {
+ $cmd="diff -upr /dev/null $cmd";
+} else {
+ $cmd="hg diff";
+}
+
+my $checkpatch=$ENV{CHECKPATCH};
+
+if (!$checkpatch) {
+ $checkpatch="/lib/modules/`uname -r`/build/scripts/checkpatch.pl";
+}
+
+my $cp_version;
+open IN,"$checkpatch|";
+while (<IN>) {
+ tr/A-Z/a-z/;
+ if (m/version\s*:\s*([\d\.]+)/) {
+ $cp_version = $1;
+ }
+}
+close IN;
+
+my $intree_checkpatch = "scripts/checkpatch.pl --no-tree";
+if (!open IN,"$intree_checkpatch|") {
+ $intree_checkpatch = "v4l/".$intree_checkpatch;
+ open IN,"$intree_checkpatch|";
+}
+while (<IN>) {
+ tr/A-Z/a-z/;
+ if (m/version\s*:\s*([\d\.]+)/) {
+ if ($1 > $cp_version) {
+ print "# WARNING: $checkpatch version $cp_version is\n"
+ ."# older than $intree_checkpatch version"
+ ." $1.\n# Using in-tree one.\n#\n";
+ $cp_version = $1;
+ $checkpatch = $intree_checkpatch;
+ }
+ }
+}
+close IN;
+
+open IN,"$cmd | $checkpatch -q --nosignoff $fmt -|";
+
+my $err="";
+my $errline="";
+my $file="";
+my $ln_numb;
+
+my $pwd=`pwd`;
+$pwd =~ s|/[^/]+\n$||;
+
+sub print_err()
+{
+ if ($err) {
+ printf STDERR "%s/%s: In '%s':\n", $pwd, $file, $errline;
+ printf STDERR "%s/%s:%d: %s\n", $pwd, $file, $ln_numb, $err;
+ $err="";
+ }
+}
+
+if ($c_syntax == 0) {
+ while (<IN>) {
+ s|^#[\d]+:\s*FILE:\s*|../|;
+ print "$_";
+ }
+} else {
+ while (<IN>) {
+ if (m/^\+(.*)\n/) {
+ $errline=$1;
+ } elsif (m/^\#\s*[\d]+\s*:\s*FILE:\s*([^\:]+)\:([\d]+)/) {
+ $file=$1;
+ $ln_numb=$2;
+ } elsif (m/^\-\s*\:\d+\:\s*(.*)\n/) {
+ print_err();
+ $err = $1;
+ $err =~ s/WARNING/warning/;
+ }
+# print "# $_";
+ }
+}
+close IN;
+print_err();
diff --git a/v4l/scripts/checkpatch.pl b/v4l/scripts/checkpatch.pl
index 7a3098b43..e64ef6704 100755
--- a/v4l/scripts/checkpatch.pl
+++ b/v4l/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
my $P = $0;
$P =~ s@.*/@@g;
-my $V = '0.11';
+my $V = '0.12';
use Getopt::Long qw(:config no_auto_abbrev);
@@ -19,8 +19,11 @@ my $chk_signoff = 1;
my $chk_patch = 1;
my $tst_type = 0;
my $emacs = 0;
+my $terse = 0;
my $file = 0;
my $check = 0;
+my $summary = 1;
+my $mailback = 0;
my $root;
GetOptions(
'q|quiet+' => \$quiet,
@@ -29,10 +32,13 @@ GetOptions(
'patch!' => \$chk_patch,
'test-type!' => \$tst_type,
'emacs!' => \$emacs,
+ 'terse!' => \$terse,
'file!' => \$file,
'subjective!' => \$check,
'strict!' => \$check,
'root=s' => \$root,
+ 'summary!' => \$summary,
+ 'mailback!' => \$mailback,
) or exit;
my $exit = 0;
@@ -42,6 +48,7 @@ if ($#ARGV < 0) {
print "version: $V\n";
print "options: -q => quiet\n";
print " --no-tree => run without a kernel tree\n";
+ print " --terse => one line per report\n";
print " --emacs => emacs compile window format\n";
print " --file => check a source file\n";
print " --strict => enable more subjective tests\n";
@@ -49,6 +56,11 @@ if ($#ARGV < 0) {
exit(1);
}
+if ($terse) {
+ $emacs = 1;
+ $quiet++;
+}
+
if ($tree) {
if (defined $root) {
if (!top_of_kernel_tree($root)) {
@@ -90,41 +102,6 @@ our $Attribute = qr{
__(?:mem|cpu|dev|)(?:initdata|init)
}x;
our $Inline = qr{inline|__always_inline|noinline};
-our $NonptrType = qr{
- \b
- (?:const\s+)?
- (?:unsigned\s+)?
- (?:
- void|
- char|
- short|
- int|
- long|
- unsigned|
- float|
- double|
- bool|
- long\s+int|
- long\s+long|
- long\s+long\s+int|
- (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
- struct\s+$Ident|
- union\s+$Ident|
- enum\s+$Ident|
- ${Ident}_t|
- ${Ident}_handler|
- ${Ident}_handler_fn
- )
- (?:\s+$Sparse)*
- \b
- }x;
-
-our $Type = qr{
- \b$NonptrType\b
- (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
- (?:\s+$Sparse|\s+$Attribute)*
- }x;
-our $Declare = qr{(?:$Storage\s+)?$Type};
our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
our $Lval = qr{$Ident(?:$Member)*};
@@ -136,7 +113,50 @@ our $Operators = qr{
&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/
}x;
-our $Bare = '';
+our $NonptrType;
+our $Type;
+our $Declare;
+
+our @typeList = (
+ qr{void},
+ qr{char},
+ qr{short},
+ qr{int},
+ qr{long},
+ qr{unsigned},
+ qr{float},
+ qr{double},
+ qr{bool},
+ qr{long\s+int},
+ qr{long\s+long},
+ qr{long\s+long\s+int},
+ qr{(?:__)?(?:u|s|be|le)(?:8|16|32|64)},
+ qr{struct\s+$Ident},
+ qr{union\s+$Ident},
+ qr{enum\s+$Ident},
+ qr{${Ident}_t},
+ qr{${Ident}_handler},
+ qr{${Ident}_handler_fn},
+);
+
+sub build_types {
+ my $all = "(?: \n" . join("|\n ", @typeList) . "\n)";
+ $NonptrType = qr{
+ \b
+ (?:const\s+)?
+ (?:unsigned\s+)?
+ $all
+ (?:\s+$Sparse|\s+const)*
+ \b
+ }x;
+ $Type = qr{
+ \b$NonptrType\b
+ (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
+ (?:\s+$Sparse|\s+$Attribute)*
+ }x;
+ $Declare = qr{(?:$Storage\s+)?$Type};
+}
+build_types();
$chk_signoff = 0 if ($file);
@@ -278,6 +298,81 @@ sub sanitise_line {
return $res;
}
+sub ctx_statement_block {
+ my ($linenr, $remain, $off) = @_;
+ my $line = $linenr - 1;
+ my $blk = '';
+ my $soff = $off;
+ my $coff = $off - 1;
+
+ my $type = '';
+ my $level = 0;
+ my $c;
+ my $len = 0;
+ while (1) {
+ #warn "CSB: blk<$blk>\n";
+ # If we are about to drop off the end, pull in more
+ # context.
+ if ($off >= $len) {
+ for (; $remain > 0; $line++) {
+ next if ($rawlines[$line] =~ /^-/);
+ $remain--;
+ $blk .= sanitise_line($rawlines[$line]) . "\n";
+ $len = length($blk);
+ $line++;
+ last;
+ }
+ # Bail if there is no further context.
+ #warn "CSB: blk<$blk> off<$off> len<$len>\n";
+ if ($off == $len) {
+ last;
+ }
+ }
+ $c = substr($blk, $off, 1);
+
+ #warn "CSB: c<$c> type<$type> level<$level>\n";
+ # Statement ends at the ';' or a close '}' at the
+ # outermost level.
+ if ($level == 0 && $c eq ';') {
+ last;
+ }
+
+ if (($type eq '' || $type eq '(') && $c eq '(') {
+ $level++;
+ $type = '(';
+ }
+ if ($type eq '(' && $c eq ')') {
+ $level--;
+ $type = ($level != 0)? '(' : '';
+
+ if ($level == 0 && $coff < $soff) {
+ $coff = $off;
+ }
+ }
+ if (($type eq '' || $type eq '{') && $c eq '{') {
+ $level++;
+ $type = '{';
+ }
+ if ($type eq '{' && $c eq '}') {
+ $level--;
+ $type = ($level != 0)? '{' : '';
+
+ if ($level == 0) {
+ last;
+ }
+ }
+ $off++;
+ }
+
+ my $statement = substr($blk, $soff, $off - $soff + 1);
+ my $condition = substr($blk, $soff, $coff - $soff + 1);
+
+ #warn "STATEMENT<$statement>\n";
+ #warn "CONDITION<$condition>\n";
+
+ return ($statement, $condition);
+}
+
sub ctx_block_get {
my ($linenr, $remain, $outer, $open, $close, $off) = @_;
my $line;
@@ -421,9 +516,6 @@ sub annotate_values {
my $paren = 0;
my @paren_type;
- # Include any user defined types we may have found as we went.
- my $type_match = "(?:$Type$Bare)";
-
while (length($cur)) {
print " <$type> " if ($debug);
if ($cur =~ /^(\s+)/o) {
@@ -433,7 +525,7 @@ sub annotate_values {
$type = 'N';
}
- } elsif ($cur =~ /^($type_match)/) {
+ } elsif ($cur =~ /^($Type)/) {
print "DECLARE($1)\n" if ($debug);
$type = 'T';
@@ -457,7 +549,7 @@ sub annotate_values {
}
$type = 'N';
- } elsif ($cur =~ /^(if|while|typeof)\b/o) {
+ } elsif ($cur =~ /^(if|while|typeof|for)\b/o) {
print "COND($1)\n" if ($debug);
$paren_type[$paren] = 'N';
$type = 'N';
@@ -515,11 +607,30 @@ sub annotate_values {
return $res;
}
+sub possible {
+ my ($possible) = @_;
+
+ #print "CHECK<$possible>\n";
+ if ($possible !~ /^(?:$Storage|$Type|DEFINE_\S+)$/ &&
+ $possible ne 'goto' && $possible ne 'return' &&
+ $possible ne 'struct' && $possible ne 'enum' &&
+ $possible ne 'case' && $possible ne 'else' &&
+ $possible ne 'typedef') {
+ #print "POSSIBLE<$possible>\n";
+ push(@typeList, $possible);
+ build_types();
+ }
+}
+
my $prefix = '';
my @report = ();
sub report {
- push(@report, $prefix . $_[0]);
+ my $line = $prefix . $_[0];
+
+ $line = (split('\n', $line))[0] . "\n" if ($terse);
+
+ push(@report, $line);
}
sub report_dump {
@report;
@@ -574,9 +685,6 @@ sub process {
my $prev_values = 'N';
- # Possible bare types.
- my @bare = ();
-
# Pre-scan the patch looking for any __setup documentation.
my @setup_docs = ();
my $setup_docs = 0;
@@ -631,21 +739,35 @@ sub process {
$realline++;
$realcnt-- if ($realcnt != 0);
- # track any sort of multi-line comment. Obviously if
- # the added text or context do not include the whole
- # comment we will not see it. Such is life.
- #
+ # Guestimate if this is a continuing comment. Run
+ # the context looking for a comment "edge". If this
+ # edge is a close comment then we must be in a comment
+ # at context start.
+ if ($linenr == $first_line) {
+ my $edge;
+ for (my $ln = $first_line; $ln < ($linenr + $realcnt); $ln++) {
+ ($edge) = ($lines[$ln - 1] =~ m@(/\*|\*/)@);
+ last if (defined $edge);
+ }
+ if (defined $edge && $edge eq '*/') {
+ $in_comment = 1;
+ }
+ }
+
# Guestimate if this is a continuing comment. If this
# is the start of a diff block and this line starts
# ' *' then it is very likely a comment.
if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
$in_comment = 1;
}
- if ($line =~ m@/\*@) {
- $in_comment = 1;
- }
- if ($line =~ m@\*/@) {
- $in_comment = 0;
+
+ # Find the last comment edge on _this_ line.
+ while (($line =~ m@(/\*|\*/)@g)) {
+ if ($1 eq '/*') {
+ $in_comment = 1;
+ } else {
+ $in_comment = 0;
+ }
}
# Measure the line length and indent.
@@ -687,7 +809,7 @@ sub process {
}
# Check for wrappage within a valid hunk of the file
- if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) {
+ if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
ERROR("patch seems to be corrupt (line wrapped?)\n" .
$herecurr) if (!$emitted_corrupt++);
}
@@ -727,6 +849,11 @@ sub process {
WARN("line over 80 characters\n" . $herecurr);
}
+# check for adding lines without a newline.
+ if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
+ WARN("adding a line without newline at end of file\n" . $herecurr);
+ }
+
# check we are in a valid source file *.[hc] if not then ignore this hunk
next if ($realfile !~ /\.[hc]$/);
@@ -752,30 +879,41 @@ sub process {
# Check for potential 'bare' types
if ($realcnt &&
- $line !~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?$Type\b/ &&
$line !~ /$Ident:\s*$/ &&
- $line !~ /^.\s*$Ident\s*\(/ &&
- # definitions in global scope can only start with types
- ($line =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?($Ident)\b/ ||
- # declarations always start with types
- $line =~ /^.\s*(?:$Storage\s+)?($Ident)\b\s*\**\s*$Ident\s*(?:;|=)/) ||
- # any (foo ... *) is a pointer cast, and foo is a type
- $line =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/) {
- my $possible = $1;
- if ($possible !~ /^(?:$Storage|$Type|DEFINE_\S+)$/ &&
- $possible ne 'goto' && $possible ne 'return' &&
- $possible ne 'struct' && $possible ne 'enum' &&
- $possible ne 'case' && $possible ne 'else' &&
- $possible ne 'typedef') {
- #print "POSSIBLE<$possible>\n";
- push(@bare, $possible);
- my $bare = join("|", @bare);
- $Bare = '|' . qr{
- \b(?:$bare)\b
- (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
- (?:\s+$Sparse)*
- }x;
+ ($line =~ /^.\s*$Ident\s*\(\*+\s*$Ident\)\s*\(/ ||
+ $line !~ /^.\s*$Ident\s*\(/)) {
+ # definitions in global scope can only start with types
+ if ($line =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/) {
+ possible($1);
+
+ # declarations always start with types
+ } elsif ($prev_values eq 'N' && $line =~ /^.\s*(?:$Storage\s+)?($Ident)\b\s*\**\s*$Ident\s*(?:;|=)/) {
+ possible($1);
+
+ # any (foo ... *) is a pointer cast, and foo is a type
+ } elsif ($line =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/) {
+ possible($1);
+ }
+
+ # Check for any sort of function declaration.
+ # int foo(something bar, other baz);
+ # void (*store_gdt)(x86_descr_ptr *);
+ if ($prev_values eq 'N' && $line =~ /^(.(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/) {
+ my ($name_len) = length($1);
+ my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, $name_len);
+ my $ctx = join("\n", @ctx);
+
+ $ctx =~ s/\n.//;
+ substr($ctx, 0, $name_len + 1) = '';
+ $ctx =~ s/\)[^\)]*$//;
+ for my $arg (split(/\s*,\s*/, $ctx)) {
+ if ($arg =~ /^(?:const\s+)?($Ident)(?:\s+$Sparse)*\s*\**\s*(:?\b$Ident)?$/ || $arg =~ /^($Ident)$/) {
+
+ possible($1);
+ }
+ }
}
+
}
#
@@ -935,6 +1073,10 @@ sub process {
# $clean = 0;
# }
+ if ($line =~ /\bLINUX_VERSION_CODE\b/) {
+ WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
+ }
+
# printk should use KERN_* levels. Note that follow on printk's on the
# same line do not need a level, so we use the current block context
# to try and find and validate the current printk. In summary the current
@@ -965,6 +1107,12 @@ sub process {
ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
}
+# open braces for enum, union and struct go on the same line.
+ if ($line =~ /^.\s*{/ &&
+ $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
+ ERROR("open brace '{' following $1 go on the same line\n" . $hereprev);
+ }
+
# check for spaces between functions and their parentheses.
while ($line =~ /($Ident)\s+\(/g) {
if ($1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case)$/ &&
@@ -1172,9 +1320,27 @@ sub process {
}
# Check for illegal assignment in if conditional.
- if ($line=~/\bif\s*\(.*[^<>!=]=[^=]/) {
- #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/);
- ERROR("do not use assignment in if condition\n" . $herecurr);
+ if ($line =~ /\bif\s*\(/) {
+ my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0);
+
+ if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) {
+ ERROR("do not use assignment in if condition ($c)\n" . $herecurr);
+ }
+
+ # Find out what is on the end of the line after the
+ # conditional.
+ substr($s, 0, length($c)) = '';
+ $s =~ s/\n.*//g;
+
+ if (length($c) && $s !~ /^\s*({|;|\/\*.*\*\/)?\s*\\*\s*$/) {
+ ERROR("trailing statements should be on next line\n" . $herecurr);
+ }
+ }
+
+# if and else should not have general statements after it
+ if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ &&
+ $1 !~ /^\s*(?:\sif|{|\\|$)/) {
+ ERROR("trailing statements should be on next line\n" . $herecurr);
}
# Check for }<nl>else {, these must be at the same
@@ -1205,12 +1371,6 @@ sub process {
}
}
-# if and else should not have general statements after it
- if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ &&
- $1 !~ /^\s*(?:\sif|{|\\|$)/) {
- ERROR("trailing statements should be on next line\n" . $herecurr);
- }
-
# multi-statement macros should be enclosed in a do while loop, grab the
# first statement and ensure its the whole macro if its not enclosed
# in a known goot container
@@ -1233,6 +1393,10 @@ sub process {
$off = length($1);
$ln--;
$cnt++;
+ while ($lines[$ln - 1] =~ /^-/) {
+ $ln--;
+ $cnt++;
+ }
}
my @ctx = ctx_statement($ln, $cnt, $off);
my $ctx_ln = $ln + $#ctx + 1;
@@ -1268,25 +1432,23 @@ sub process {
if ($lines[$nr - 1] =~ /{\s*$/) {
my ($lvl, @block) = ctx_block_level($nr, $cnt);
- my $stmt = join(' ', @block);
- $stmt =~ s/(^[^{]*){//;
+ my $stmt = join("\n", @block);
+ # Drop the diff line leader.
+ $stmt =~ s/\n./\n/g;
+ # Drop the code outside the block.
+ $stmt =~ s/(^[^{]*){\s*//;
my $before = $1;
- $stmt =~ s/}([^}]*$)//;
+ $stmt =~ s/\s*}([^}]*$)//;
my $after = $1;
#print "block<" . join(' ', @block) . "><" . scalar(@block) . ">\n";
#print "stmt<$stmt>\n\n";
- # Count the ;'s if there is fewer than two
- # then there can only be one statement,
- # if there is a brace inside we cannot
- # trivially detect if its one statement.
- # Also nested if's often require braces to
- # disambiguate the else binding so shhh there.
- my @semi = ($stmt =~ /;/g);
- push(@semi, "/**/") if ($stmt =~ m@/\*@);
- ##print "semi<" . scalar(@semi) . ">\n";
- if ($lvl == 0 && scalar(@semi) < 2 &&
+ # Count the newlines, if there is only one
+ # then the block should not have {}'s.
+ my @lines = ($stmt =~ /\n/g);
+ #print "lines<" . scalar(@lines) . ">\n";
+ if ($lvl == 0 && scalar(@lines) == 0 &&
$stmt !~ /{/ && $stmt !~ /\bif\b/ &&
$before !~ /}/ && $after !~ /{/) {
my $herectx = "$here\n" . join("\n", @control, @block[1 .. $#block]) . "\n";
@@ -1372,6 +1534,11 @@ sub process {
ERROR("inline keyword should sit between storage class and type\n" . $herecurr);
}
+# Check for __inline__ and __inline, prefer inline
+ if ($line =~ /\b(__inline__|__inline)\b/) {
+ WARN("plain inline is preferred over $1\n" . $herecurr);
+ }
+
# check for new externs in .c files.
if ($line =~ /^.\s*extern\s/ && ($realfile =~ /\.c$/)) {
WARN("externs should be avoided in .c files\n" . $herecurr);
@@ -1392,21 +1559,33 @@ sub process {
}
}
- if ($chk_patch && !$is_patch) {
+ # In mailback mode only produce a report in the negative, for
+ # things that appear to be patches.
+ if ($mailback && ($clean == 1 || !$is_patch)) {
+ exit(0);
+ }
+
+ # This is not a patch, and we are are in 'no-patch' mode so
+ # just keep quiet.
+ if (!$chk_patch && !$is_patch) {
+ exit(0);
+ }
+
+ if (!$is_patch) {
ERROR("Does not appear to be a unified-diff format patch\n");
}
if ($is_patch && $chk_signoff && $signoff == 0) {
ERROR("Missing Signed-off-by: line(s)\n");
}
- if ($clean == 0 && ($chk_patch || $is_patch)) {
- print report_dump();
- if ($quiet < 2) {
- print "total: $cnt_error errors, $cnt_warn warnings, " .
- (($check)? "$cnt_chk checks, " : "") .
- "$cnt_lines lines checked\n";
- }
+ print report_dump();
+ if ($summary) {
+ print "total: $cnt_error errors, $cnt_warn warnings, " .
+ (($check)? "$cnt_chk checks, " : "") .
+ "$cnt_lines lines checked\n";
+ print "\n" if ($quiet == 0);
}
+
if ($clean == 1 && $quiet == 0) {
print "Your patch has no obvious style problems and is ready for submission.\n"
}