diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 21:08:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 21:11:41 -0400 |
commit | 4ef4327b30957a16619ac7d47c749465e62de8c3 (patch) | |
tree | 5c80e853f0d9eadd01b2019d03d2432334393c5e | |
parent | 3989203290fba6fdf6bc4825fbf6526e1bf17977 (diff) | |
parent | a938b8c5be8fe5c28800c9cef4aa43d569aa57a8 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (120 commits)
cx231xx: Convert to snd_card_create()
V4L/DVB (11440): PWC: fix build error when CONFIG_INPUT=m
V4L/DVB (11439): UVC: uvc_status_cleanup(): undefined reference to `input_unregister_device'
V4L/DVB (11438): au0828: fix Kconfig dependance
V4L/DVB (11437): pvrusb2: Drop client_register/unregister stubs
V4L/DVB (11436): radio-mr800: convert to to v4l2_device
V4L/DVB (11435): dsbr100 radio: convert to to v4l2_device
V4L/DVB: zr364xx: remove unused #include <version.h>
V4L/DVB: usbvision: remove unused #include <version.h>
V4L/DVB (11427): gspca - m5602: Minor cleanups
V4L/DVB (11426): gspca - m5602: Don't touch hflip/vflip register on Read/Modify/Write
V4L/DVB (11425): gspca - m5602: Move the vflip quirk to probe stage.
V4L/DVB (11424): gspca - m5602-ov9650: Use the local ctrl cache. Adjust image on vflip.
V4L/DVB (11423): gspca - m5602-ov9650: Add a disconnect hook, setup a ctrl cache ctrl.
V4L/DVB (11422): gspca - m5602-ov9650: Replace a magic constant with a define
V4L/DVB (11421): gspca - m5602-ov9650: Synthesize modesetting.
V4L/DVB (11420): gspca - m5602: Improve error handling in the ov9650 driver
V4L/DVB (11419): gspca - m5602-ov9650: Don't read exposure data from COM1.
V4L/DVB (11418): gspca - m5602-ov9650: Auto white balancing is on by default
V4L/DVB (11417): gspca - m5602-ov9650: Autogain is on by default
...
200 files changed, 18702 insertions, 3343 deletions
diff --git a/Documentation/video4linux/pxa_camera.txt b/Documentation/video4linux/pxa_camera.txt new file mode 100644 index 000000000000..b1137f9a53eb --- /dev/null +++ b/Documentation/video4linux/pxa_camera.txt | |||
@@ -0,0 +1,125 @@ | |||
1 | PXA-Camera Host Driver | ||
2 | ====================== | ||
3 | |||
4 | Constraints | ||
5 | ----------- | ||
6 | a) Image size for YUV422P format | ||
7 | All YUV422P images are enforced to have width x height % 16 = 0. | ||
8 | This is due to DMA constraints, which transfers only planes of 8 byte | ||
9 | multiples. | ||
10 | |||
11 | |||
12 | Global video workflow | ||
13 | --------------------- | ||
14 | a) QCI stopped | ||
15 | Initialy, the QCI interface is stopped. | ||
16 | When a buffer is queued (pxa_videobuf_ops->buf_queue), the QCI starts. | ||
17 | |||
18 | b) QCI started | ||
19 | More buffers can be queued while the QCI is started without halting the | ||
20 | capture. The new buffers are "appended" at the tail of the DMA chain, and | ||
21 | smoothly captured one frame after the other. | ||
22 | |||
23 | Once a buffer is filled in the QCI interface, it is marked as "DONE" and | ||
24 | removed from the active buffers list. It can be then requeud or dequeued by | ||
25 | userland application. | ||
26 | |||
27 | Once the last buffer is filled in, the QCI interface stops. | ||
28 | |||
29 | |||
30 | DMA usage | ||
31 | --------- | ||
32 | a) DMA flow | ||
33 | - first buffer queued for capture | ||
34 | Once a first buffer is queued for capture, the QCI is started, but data | ||
35 | transfer is not started. On "End Of Frame" interrupt, the irq handler | ||
36 | starts the DMA chain. | ||
37 | - capture of one videobuffer | ||
38 | The DMA chain starts transfering data into videobuffer RAM pages. | ||
39 | When all pages are transfered, the DMA irq is raised on "ENDINTR" status | ||
40 | - finishing one videobuffer | ||
41 | The DMA irq handler marks the videobuffer as "done", and removes it from | ||
42 | the active running queue | ||
43 | Meanwhile, the next videobuffer (if there is one), is transfered by DMA | ||
44 | - finishing the last videobuffer | ||
45 | On the DMA irq of the last videobuffer, the QCI is stopped. | ||
46 | |||
47 | b) DMA prepared buffer will have this structure | ||
48 | |||
49 | +------------+-----+---------------+-----------------+ | ||
50 | | desc-sg[0] | ... | desc-sg[last] | finisher/linker | | ||
51 | +------------+-----+---------------+-----------------+ | ||
52 | |||
53 | This structure is pointed by dma->sg_cpu. | ||
54 | The descriptors are used as follows : | ||
55 | - desc-sg[i]: i-th descriptor, transfering the i-th sg | ||
56 | element to the video buffer scatter gather | ||
57 | - finisher: has ddadr=DADDR_STOP, dcmd=ENDIRQEN | ||
58 | - linker: has ddadr= desc-sg[0] of next video buffer, dcmd=0 | ||
59 | |||
60 | For the next schema, let's assume d0=desc-sg[0] .. dN=desc-sg[N], | ||
61 | "f" stands for finisher and "l" for linker. | ||
62 | A typical running chain is : | ||
63 | |||
64 | Videobuffer 1 Videobuffer 2 | ||
65 | +---------+----+---+ +----+----+----+---+ | ||
66 | | d0 | .. | dN | l | | d0 | .. | dN | f | | ||
67 | +---------+----+-|-+ ^----+----+----+---+ | ||
68 | | | | ||
69 | +----+ | ||
70 | |||
71 | After the chaining is finished, the chain looks like : | ||
72 | |||
73 | Videobuffer 1 Videobuffer 2 Videobuffer 3 | ||
74 | +---------+----+---+ +----+----+----+---+ +----+----+----+---+ | ||
75 | | d0 | .. | dN | l | | d0 | .. | dN | l | | d0 | .. | dN | f | | ||
76 | +---------+----+-|-+ ^----+----+----+-|-+ ^----+----+----+---+ | ||
77 | | | | | | ||
78 | +----+ +----+ | ||
79 | new_link | ||
80 | |||
81 | c) DMA hot chaining timeslice issue | ||
82 | |||
83 | As DMA chaining is done while DMA _is_ running, the linking may be done | ||
84 | while the DMA jumps from one Videobuffer to another. On the schema, that | ||
85 | would be a problem if the following sequence is encountered : | ||
86 | |||
87 | - DMA chain is Videobuffer1 + Videobuffer2 | ||
88 | - pxa_videobuf_queue() is called to queue Videobuffer3 | ||
89 | - DMA controller finishes Videobuffer2, and DMA stops | ||
90 | => | ||
91 | Videobuffer 1 Videobuffer 2 | ||
92 | +---------+----+---+ +----+----+----+---+ | ||
93 | | d0 | .. | dN | l | | d0 | .. | dN | f | | ||
94 | +---------+----+-|-+ ^----+----+----+-^-+ | ||
95 | | | | | ||
96 | +----+ +-- DMA DDADR loads DDADR_STOP | ||
97 | |||
98 | - pxa_dma_add_tail_buf() is called, the Videobuffer2 "finisher" is | ||
99 | replaced by a "linker" to Videobuffer3 (creation of new_link) | ||
100 | - pxa_videobuf_queue() finishes | ||
101 | - the DMA irq handler is called, which terminates Videobuffer2 | ||
102 | - Videobuffer3 capture is not scheduled on DMA chain (as it stopped !!!) | ||
103 | |||
104 | Videobuffer 1 Videobuffer 2 Videobuffer 3 | ||
105 | +---------+----+---+ +----+----+----+---+ +----+----+----+---+ | ||
106 | | d0 | .. | dN | l | | d0 | .. | dN | l | | d0 | .. | dN | f | | ||
107 | +---------+----+-|-+ ^----+----+----+-|-+ ^----+----+----+---+ | ||
108 | | | | | | ||
109 | +----+ +----+ | ||
110 | new_link | ||
111 | DMA DDADR still is DDADR_STOP | ||
112 | |||
113 | - pxa_camera_check_link_miss() is called | ||
114 | This checks if the DMA is finished and a buffer is still on the | ||
115 | pcdev->capture list. If that's the case, the capture will be restarted, | ||
116 | and Videobuffer3 is scheduled on DMA chain. | ||
117 | - the DMA irq handler finishes | ||
118 | |||
119 | Note: if DMA stops just after pxa_camera_check_link_miss() reads DDADR() | ||
120 | value, we have the guarantee that the DMA irq handler will be called back | ||
121 | when the DMA will finish the buffer, and pxa_camera_check_link_miss() will | ||
122 | be called again, to reschedule Videobuffer3. | ||
123 | |||
124 | -- | ||
125 | Author: Robert Jarzmik <robert.jarzmik@free.fr> | ||
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index a31177390e55..854808b67fae 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -90,7 +90,7 @@ up before calling v4l2_device_register then it will be untouched. If dev is | |||
90 | NULL, then you *must* setup v4l2_dev->name before calling v4l2_device_register. | 90 | NULL, then you *must* setup v4l2_dev->name before calling v4l2_device_register. |
91 | 91 | ||
92 | The first 'dev' argument is normally the struct device pointer of a pci_dev, | 92 | The first 'dev' argument is normally the struct device pointer of a pci_dev, |
93 | usb_device or platform_device. It is rare for dev to be NULL, but it happens | 93 | usb_interface or platform_device. It is rare for dev to be NULL, but it happens |
94 | with ISA devices or when one device creates multiple PCI devices, thus making | 94 | with ISA devices or when one device creates multiple PCI devices, thus making |
95 | it impossible to associate v4l2_dev with a particular parent. | 95 | it impossible to associate v4l2_dev with a particular parent. |
96 | 96 | ||
@@ -351,17 +351,6 @@ And this to go from an i2c_client to a v4l2_subdev struct: | |||
351 | 351 | ||
352 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | 352 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
353 | 353 | ||
354 | Finally you need to make a command function to make driver->command() | ||
355 | call the right subdev_ops functions: | ||
356 | |||
357 | static int subdev_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
358 | { | ||
359 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
360 | } | ||
361 | |||
362 | If driver->command is never used then you can leave this out. Eventually the | ||
363 | driver->command usage should be removed from v4l. | ||
364 | |||
365 | Make sure to call v4l2_device_unregister_subdev(sd) when the remove() callback | 354 | Make sure to call v4l2_device_unregister_subdev(sd) when the remove() callback |
366 | is called. This will unregister the sub-device from the bridge driver. It is | 355 | is called. This will unregister the sub-device from the bridge driver. It is |
367 | safe to call this even if the sub-device was never registered. | 356 | safe to call this even if the sub-device was never registered. |
@@ -375,14 +364,12 @@ from the remove() callback ensures that this is always done correctly. | |||
375 | 364 | ||
376 | The bridge driver also has some helper functions it can use: | 365 | The bridge driver also has some helper functions it can use: |
377 | 366 | ||
378 | struct v4l2_subdev *sd = v4l2_i2c_new_subdev(adapter, "module_foo", "chipid", 0x36); | 367 | struct v4l2_subdev *sd = v4l2_i2c_new_subdev(v4l2_dev, adapter, |
368 | "module_foo", "chipid", 0x36); | ||
379 | 369 | ||
380 | This loads the given module (can be NULL if no module needs to be loaded) and | 370 | This loads the given module (can be NULL if no module needs to be loaded) and |
381 | calls i2c_new_device() with the given i2c_adapter and chip/address arguments. | 371 | calls i2c_new_device() with the given i2c_adapter and chip/address arguments. |
382 | If all goes well, then it registers the subdev with the v4l2_device. It gets | 372 | If all goes well, then it registers the subdev with the v4l2_device. |
383 | the v4l2_device by calling i2c_get_adapdata(adapter), so you should make sure | ||
384 | to call i2c_set_adapdata(adapter, v4l2_device) when you setup the i2c_adapter | ||
385 | in your driver. | ||
386 | 373 | ||
387 | You can also use v4l2_i2c_new_probed_subdev() which is very similar to | 374 | You can also use v4l2_i2c_new_probed_subdev() which is very similar to |
388 | v4l2_i2c_new_subdev(), except that it has an array of possible I2C addresses | 375 | v4l2_i2c_new_subdev(), except that it has an array of possible I2C addresses |
diff --git a/MAINTAINERS b/MAINTAINERS index 9673cd28a69b..914f283dac08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1544,7 +1544,6 @@ S: Maintained | |||
1544 | DVB SUBSYSTEM AND DRIVERS | 1544 | DVB SUBSYSTEM AND DRIVERS |
1545 | P: LinuxTV.org Project | 1545 | P: LinuxTV.org Project |
1546 | M: linux-media@vger.kernel.org | 1546 | M: linux-media@vger.kernel.org |
1547 | L: linux-dvb@linuxtv.org (subscription required) | ||
1548 | W: http://linuxtv.org/ | 1547 | W: http://linuxtv.org/ |
1549 | T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/linux-2.6.git | 1548 | T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/linux-2.6.git |
1550 | S: Maintained | 1549 | S: Maintained |
diff --git a/arch/arm/mach-mx1/Makefile b/arch/arm/mach-mx1/Makefile index 82f1309568ef..7f86fe073ec6 100644 --- a/arch/arm/mach-mx1/Makefile +++ b/arch/arm/mach-mx1/Makefile | |||
@@ -6,6 +6,9 @@ | |||
6 | 6 | ||
7 | obj-y += generic.o clock.o devices.o | 7 | obj-y += generic.o clock.o devices.o |
8 | 8 | ||
9 | # Support for CMOS sensor interface | ||
10 | obj-$(CONFIG_MX1_VIDEO) += ksym_mx1.o mx1_camera_fiq.o | ||
11 | |||
9 | # Specific board support | 12 | # Specific board support |
10 | obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o | 13 | obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o |
11 | obj-$(CONFIG_MACH_SCB9328) += scb9328.o \ No newline at end of file | 14 | obj-$(CONFIG_MACH_SCB9328) += scb9328.o \ No newline at end of file |
diff --git a/arch/arm/mach-mx1/devices.c b/arch/arm/mach-mx1/devices.c index 97f42d96d7a1..76d1ffb48079 100644 --- a/arch/arm/mach-mx1/devices.c +++ b/arch/arm/mach-mx1/devices.c | |||
@@ -44,7 +44,7 @@ static struct resource imx_csi_resources[] = { | |||
44 | static u64 imx_csi_dmamask = 0xffffffffUL; | 44 | static u64 imx_csi_dmamask = 0xffffffffUL; |
45 | 45 | ||
46 | struct platform_device imx_csi_device = { | 46 | struct platform_device imx_csi_device = { |
47 | .name = "imx-csi", | 47 | .name = "mx1-camera", |
48 | .id = 0, /* This is used to put cameras on this interface */ | 48 | .id = 0, /* This is used to put cameras on this interface */ |
49 | .dev = { | 49 | .dev = { |
50 | .dma_mask = &imx_csi_dmamask, | 50 | .dma_mask = &imx_csi_dmamask, |
diff --git a/arch/arm/mach-mx1/ksym_mx1.c b/arch/arm/mach-mx1/ksym_mx1.c new file mode 100644 index 000000000000..b09ee12a4ff0 --- /dev/null +++ b/arch/arm/mach-mx1/ksym_mx1.c | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * Exported ksyms of ARCH_MX1 | ||
3 | * | ||
4 | * Copyright (C) 2008, Darius Augulis <augulis.darius@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/platform_device.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include <mach/mx1_camera.h> | ||
15 | |||
16 | /* IMX camera FIQ handler */ | ||
17 | EXPORT_SYMBOL(mx1_camera_sof_fiq_start); | ||
18 | EXPORT_SYMBOL(mx1_camera_sof_fiq_end); | ||
diff --git a/arch/arm/mach-mx1/mx1_camera_fiq.S b/arch/arm/mach-mx1/mx1_camera_fiq.S new file mode 100644 index 000000000000..9c69aa65bf17 --- /dev/null +++ b/arch/arm/mach-mx1/mx1_camera_fiq.S | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | ||
3 | * | ||
4 | * Based on linux/arch/arm/lib/floppydma.S | ||
5 | * Copyright (C) 1995, 1996 Russell King | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | #include <linux/linkage.h> | ||
12 | #include <asm/assembler.h> | ||
13 | |||
14 | .text | ||
15 | .global mx1_camera_sof_fiq_end | ||
16 | .global mx1_camera_sof_fiq_start | ||
17 | mx1_camera_sof_fiq_start: | ||
18 | @ enable dma | ||
19 | ldr r12, [r9] | ||
20 | orr r12, r12, #0x00000001 | ||
21 | str r12, [r9] | ||
22 | @ unmask DMA interrupt | ||
23 | ldr r12, [r8] | ||
24 | bic r12, r12, r13 | ||
25 | str r12, [r8] | ||
26 | @ disable SOF interrupt | ||
27 | ldr r12, [r10] | ||
28 | bic r12, r12, #0x00010000 | ||
29 | str r12, [r10] | ||
30 | @ clear SOF flag | ||
31 | mov r12, #0x00010000 | ||
32 | str r12, [r11] | ||
33 | @ return from FIQ | ||
34 | subs pc, lr, #4 | ||
35 | mx1_camera_sof_fiq_end: | ||
diff --git a/arch/arm/mach-mx3/clock.c b/arch/arm/mach-mx3/clock.c index ca46f4801c3d..9957a11533a4 100644 --- a/arch/arm/mach-mx3/clock.c +++ b/arch/arm/mach-mx3/clock.c | |||
@@ -533,7 +533,7 @@ static struct clk_lookup lookups[] __initdata = { | |||
533 | _REGISTER_CLOCK(NULL, "kpp", kpp_clk) | 533 | _REGISTER_CLOCK(NULL, "kpp", kpp_clk) |
534 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk1) | 534 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk1) |
535 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk2) | 535 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk2) |
536 | _REGISTER_CLOCK("mx3-camera.0", "csi", csi_clk) | 536 | _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk) |
537 | _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk) | 537 | _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk) |
538 | _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk) | 538 | _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk) |
539 | _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk) | 539 | _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk) |
diff --git a/arch/arm/plat-mxc/include/mach/memory.h b/arch/arm/plat-mxc/include/mach/memory.h index e0783e619580..eca37d09f3f8 100644 --- a/arch/arm/plat-mxc/include/mach/memory.h +++ b/arch/arm/plat-mxc/include/mach/memory.h | |||
@@ -24,4 +24,12 @@ | |||
24 | #define PHYS_OFFSET UL(0x80000000) | 24 | #define PHYS_OFFSET UL(0x80000000) |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #if defined(CONFIG_MX1_VIDEO) | ||
28 | /* | ||
29 | * Increase size of DMA-consistent memory region. | ||
30 | * This is required for i.MX camera driver to capture at least four VGA frames. | ||
31 | */ | ||
32 | #define CONSISTENT_DMA_SIZE SZ_4M | ||
33 | #endif /* CONFIG_MX1_VIDEO */ | ||
34 | |||
27 | #endif /* __ASM_ARCH_MXC_MEMORY_H__ */ | 35 | #endif /* __ASM_ARCH_MXC_MEMORY_H__ */ |
diff --git a/arch/arm/plat-mxc/include/mach/mx1_camera.h b/arch/arm/plat-mxc/include/mach/mx1_camera.h new file mode 100644 index 000000000000..4fd6c70314b4 --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/mx1_camera.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * mx1_camera.h - i.MX1/i.MXL camera driver header file | ||
3 | * | ||
4 | * Copyright (c) 2008, Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | ||
5 | * Copyright (C) 2009, Darius Augulis <augulis.darius@gmail.com> | ||
6 | * | ||
7 | * Based on PXA camera.h file: | ||
8 | * Copyright (C) 2003, Intel Corporation | ||
9 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #ifndef __ASM_ARCH_CAMERA_H_ | ||
17 | #define __ASM_ARCH_CAMERA_H_ | ||
18 | |||
19 | #define MX1_CAMERA_DATA_HIGH 1 | ||
20 | #define MX1_CAMERA_PCLK_RISING 2 | ||
21 | #define MX1_CAMERA_VSYNC_HIGH 4 | ||
22 | |||
23 | extern unsigned char mx1_camera_sof_fiq_start, mx1_camera_sof_fiq_end; | ||
24 | |||
25 | /** | ||
26 | * struct mx1_camera_pdata - i.MX1/i.MXL camera platform data | ||
27 | * @mclk_10khz: master clock frequency in 10kHz units | ||
28 | * @flags: MX1 camera platform flags | ||
29 | */ | ||
30 | struct mx1_camera_pdata { | ||
31 | unsigned long mclk_10khz; | ||
32 | unsigned long flags; | ||
33 | }; | ||
34 | |||
35 | #endif /* __ASM_ARCH_CAMERA_H_ */ | ||
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 6103caad1644..60955a70d880 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -294,7 +294,7 @@ config DVB_USB_DTV5100 | |||
294 | 294 | ||
295 | config DVB_USB_AF9015 | 295 | config DVB_USB_AF9015 |
296 | tristate "Afatech AF9015 DVB-T USB2.0 support" | 296 | tristate "Afatech AF9015 DVB-T USB2.0 support" |
297 | depends on DVB_USB && EXPERIMENTAL | 297 | depends on DVB_USB |
298 | select DVB_AF9013 | 298 | select DVB_AF9013 |
299 | select DVB_PLL if !DVB_FE_CUSTOMISE | 299 | select DVB_PLL if !DVB_FE_CUSTOMISE |
300 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE | 300 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE |
@@ -309,6 +309,6 @@ config DVB_USB_CE6230 | |||
309 | tristate "Intel CE6230 DVB-T USB2.0 support" | 309 | tristate "Intel CE6230 DVB-T USB2.0 support" |
310 | depends on DVB_USB && EXPERIMENTAL | 310 | depends on DVB_USB && EXPERIMENTAL |
311 | select DVB_ZL10353 | 311 | select DVB_ZL10353 |
312 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE | 312 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE |
313 | help | 313 | help |
314 | Say Y here to support the Intel CE6230 DVB-T USB2.0 receiver | 314 | Say Y here to support the Intel CE6230 DVB-T USB2.0 receiver |
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index f0ba8b07b84f..53bfc8e42fb9 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c | |||
@@ -782,17 +782,14 @@ static int af9015_read_config(struct usb_device *udev) | |||
782 | ARRAY_SIZE(af9015_ir_table_leadtek); | 782 | ARRAY_SIZE(af9015_ir_table_leadtek); |
783 | break; | 783 | break; |
784 | case USB_VID_VISIONPLUS: | 784 | case USB_VID_VISIONPLUS: |
785 | if (udev->descriptor.idProduct == | 785 | af9015_properties[i].rc_key_map = |
786 | cpu_to_le16(USB_PID_AZUREWAVE_AD_TU700)) { | 786 | af9015_rc_keys_twinhan; |
787 | af9015_properties[i].rc_key_map = | 787 | af9015_properties[i].rc_key_map_size = |
788 | af9015_rc_keys_twinhan; | 788 | ARRAY_SIZE(af9015_rc_keys_twinhan); |
789 | af9015_properties[i].rc_key_map_size = | 789 | af9015_config.ir_table = |
790 | ARRAY_SIZE(af9015_rc_keys_twinhan); | 790 | af9015_ir_table_twinhan; |
791 | af9015_config.ir_table = | 791 | af9015_config.ir_table_size = |
792 | af9015_ir_table_twinhan; | 792 | ARRAY_SIZE(af9015_ir_table_twinhan); |
793 | af9015_config.ir_table_size = | ||
794 | ARRAY_SIZE(af9015_ir_table_twinhan); | ||
795 | } | ||
796 | break; | 793 | break; |
797 | case USB_VID_KWORLD_2: | 794 | case USB_VID_KWORLD_2: |
798 | /* TODO: use correct rc keys */ | 795 | /* TODO: use correct rc keys */ |
@@ -833,6 +830,16 @@ static int af9015_read_config(struct usb_device *udev) | |||
833 | af9015_ir_table_msi; | 830 | af9015_ir_table_msi; |
834 | af9015_config.ir_table_size = | 831 | af9015_config.ir_table_size = |
835 | ARRAY_SIZE(af9015_ir_table_msi); | 832 | ARRAY_SIZE(af9015_ir_table_msi); |
833 | } else if (udev->descriptor.idProduct == | ||
834 | cpu_to_le16(USB_PID_TREKSTOR_DVBT)) { | ||
835 | af9015_properties[i].rc_key_map = | ||
836 | af9015_rc_keys_trekstor; | ||
837 | af9015_properties[i].rc_key_map_size = | ||
838 | ARRAY_SIZE(af9015_rc_keys_trekstor); | ||
839 | af9015_config.ir_table = | ||
840 | af9015_ir_table_trekstor; | ||
841 | af9015_config.ir_table_size = | ||
842 | ARRAY_SIZE(af9015_ir_table_trekstor); | ||
836 | } | 843 | } |
837 | break; | 844 | break; |
838 | case USB_VID_AVERMEDIA: | 845 | case USB_VID_AVERMEDIA: |
@@ -981,6 +988,21 @@ error: | |||
981 | if (ret) | 988 | if (ret) |
982 | err("eeprom read failed:%d", ret); | 989 | err("eeprom read failed:%d", ret); |
983 | 990 | ||
991 | /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM | ||
992 | content :-( Override some wrong values here. */ | ||
993 | if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA && | ||
994 | le16_to_cpu(udev->descriptor.idProduct) == USB_PID_AVERMEDIA_A850) { | ||
995 | deb_info("%s: AverMedia A850: overriding config\n", __func__); | ||
996 | /* disable dual mode */ | ||
997 | af9015_config.dual_mode = 0; | ||
998 | /* disable 2nd adapter */ | ||
999 | for (i = 0; i < af9015_properties_count; i++) | ||
1000 | af9015_properties[i].num_adapters = 1; | ||
1001 | |||
1002 | /* set correct IF */ | ||
1003 | af9015_af9013_config[0].tuner_if = 4570; | ||
1004 | } | ||
1005 | |||
984 | return ret; | 1006 | return ret; |
985 | } | 1007 | } |
986 | 1008 | ||
@@ -1237,6 +1259,9 @@ static struct usb_device_id af9015_usb_table[] = { | |||
1237 | /* 15 */{USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)}, | 1259 | /* 15 */{USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)}, |
1238 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)}, | 1260 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)}, |
1239 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)}, | 1261 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)}, |
1262 | {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)}, | ||
1263 | {USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)}, | ||
1264 | {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)}, | ||
1240 | {0}, | 1265 | {0}, |
1241 | }; | 1266 | }; |
1242 | MODULE_DEVICE_TABLE(usb, af9015_usb_table); | 1267 | MODULE_DEVICE_TABLE(usb, af9015_usb_table); |
@@ -1401,7 +1426,7 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1401 | 1426 | ||
1402 | .i2c_algo = &af9015_i2c_algo, | 1427 | .i2c_algo = &af9015_i2c_algo, |
1403 | 1428 | ||
1404 | .num_device_descs = 7, | 1429 | .num_device_descs = 9, |
1405 | .devices = { | 1430 | .devices = { |
1406 | { | 1431 | { |
1407 | .name = "Xtensions XD-380", | 1432 | .name = "Xtensions XD-380", |
@@ -1437,7 +1462,19 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1437 | .name = "KWorld USB DVB-T TV Stick II " \ | 1462 | .name = "KWorld USB DVB-T TV Stick II " \ |
1438 | "(VS-DVB-T 395U)", | 1463 | "(VS-DVB-T 395U)", |
1439 | .cold_ids = {&af9015_usb_table[16], | 1464 | .cold_ids = {&af9015_usb_table[16], |
1440 | &af9015_usb_table[17], NULL}, | 1465 | &af9015_usb_table[17], |
1466 | &af9015_usb_table[18], NULL}, | ||
1467 | .warm_ids = {NULL}, | ||
1468 | }, | ||
1469 | { | ||
1470 | .name = "TrekStor DVB-T USB Stick", | ||
1471 | .cold_ids = {&af9015_usb_table[19], NULL}, | ||
1472 | .warm_ids = {NULL}, | ||
1473 | }, | ||
1474 | { | ||
1475 | .name = "AverMedia AVerTV Volar Black HD " \ | ||
1476 | "(A850)", | ||
1477 | .cold_ids = {&af9015_usb_table[20], NULL}, | ||
1441 | .warm_ids = {NULL}, | 1478 | .warm_ids = {NULL}, |
1442 | }, | 1479 | }, |
1443 | } | 1480 | } |
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h index 00e25714662a..8d81a17c116d 100644 --- a/drivers/media/dvb/dvb-usb/af9015.h +++ b/drivers/media/dvb/dvb-usb/af9015.h | |||
@@ -64,14 +64,6 @@ | |||
64 | 64 | ||
65 | #define AF9015_EEPROM_OFFSET (AF9015_EEPROM_SAW_BW2 - AF9015_EEPROM_SAW_BW1) | 65 | #define AF9015_EEPROM_OFFSET (AF9015_EEPROM_SAW_BW2 - AF9015_EEPROM_SAW_BW1) |
66 | 66 | ||
67 | #define AF9015_GPIO_ON (1 << 0) | ||
68 | #define AF9015_GPIO_EN (1 << 1) | ||
69 | #define AF9015_GPIO_O (1 << 2) | ||
70 | #define AF9015_GPIO_I (1 << 3) | ||
71 | |||
72 | #define AF9015_GPIO_TUNER_ON (AF9015_GPIO_ON|AF9015_GPIO_EN) | ||
73 | #define AF9015_GPIO_TUNER_OFF (AF9015_GPIO_ON|AF9015_GPIO_EN|AF9015_GPIO_O) | ||
74 | |||
75 | struct req_t { | 67 | struct req_t { |
76 | u8 cmd; /* [0] */ | 68 | u8 cmd; /* [0] */ |
77 | /* seq */ /* [1] */ | 69 | /* seq */ /* [1] */ |
@@ -120,11 +112,11 @@ struct af9015_config { | |||
120 | 112 | ||
121 | enum af9015_remote { | 113 | enum af9015_remote { |
122 | AF9015_REMOTE_NONE = 0, | 114 | AF9015_REMOTE_NONE = 0, |
123 | AF9015_REMOTE_A_LINK_DTU_M, | 115 | /* 1 */ AF9015_REMOTE_A_LINK_DTU_M, |
124 | AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, | 116 | AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, |
125 | AF9015_REMOTE_MYGICTV_U718, | 117 | AF9015_REMOTE_MYGICTV_U718, |
126 | AF9015_REMOTE_DIGITTRADE_DVB_T, | 118 | AF9015_REMOTE_DIGITTRADE_DVB_T, |
127 | AF9015_REMOTE_AVERMEDIA_KS, | 119 | /* 5 */ AF9015_REMOTE_AVERMEDIA_KS, |
128 | }; | 120 | }; |
129 | 121 | ||
130 | /* Leadtek WinFast DTV Dongle Gold */ | 122 | /* Leadtek WinFast DTV Dongle Gold */ |
@@ -691,4 +683,67 @@ static u8 af9015_ir_table_digittrade[] = { | |||
691 | 0x00, 0xff, 0x1d, 0xe2, 0x40, 0x00, 0x00, | 683 | 0x00, 0xff, 0x1d, 0xe2, 0x40, 0x00, 0x00, |
692 | }; | 684 | }; |
693 | 685 | ||
686 | /* TREKSTOR DVB-T USB Stick */ | ||
687 | static struct dvb_usb_rc_key af9015_rc_keys_trekstor[] = { | ||
688 | { 0x07, 0x04, KEY_AGAIN }, /* Home */ | ||
689 | { 0x07, 0x05, KEY_MUTE }, /* Mute */ | ||
690 | { 0x07, 0x06, KEY_UP }, /* Up */ | ||
691 | { 0x07, 0x07, KEY_DOWN }, /* Down */ | ||
692 | { 0x07, 0x09, KEY_RIGHT }, /* Right */ | ||
693 | { 0x07, 0x0a, KEY_ENTER }, /* OK */ | ||
694 | { 0x07, 0x0b, KEY_FASTFORWARD }, /* Fast forward */ | ||
695 | { 0x07, 0x0c, KEY_REWIND }, /* Rewind */ | ||
696 | { 0x07, 0x0d, KEY_PLAY }, /* Play/Pause */ | ||
697 | { 0x07, 0x0e, KEY_VOLUMEUP }, /* Volume + */ | ||
698 | { 0x07, 0x0f, KEY_VOLUMEDOWN }, /* Volume - */ | ||
699 | { 0x07, 0x10, KEY_RECORD }, /* Record */ | ||
700 | { 0x07, 0x11, KEY_STOP }, /* Stop */ | ||
701 | { 0x07, 0x12, KEY_ZOOM }, /* TV */ | ||
702 | { 0x07, 0x13, KEY_EPG }, /* Info/EPG */ | ||
703 | { 0x07, 0x14, KEY_CHANNELDOWN }, /* Channel - */ | ||
704 | { 0x07, 0x15, KEY_CHANNELUP }, /* Channel + */ | ||
705 | { 0x07, 0x1e, KEY_1 }, | ||
706 | { 0x07, 0x1f, KEY_2 }, | ||
707 | { 0x07, 0x20, KEY_3 }, | ||
708 | { 0x07, 0x21, KEY_4 }, | ||
709 | { 0x07, 0x22, KEY_5 }, | ||
710 | { 0x07, 0x23, KEY_6 }, | ||
711 | { 0x07, 0x24, KEY_7 }, | ||
712 | { 0x07, 0x25, KEY_8 }, | ||
713 | { 0x07, 0x26, KEY_9 }, | ||
714 | { 0x07, 0x08, KEY_LEFT }, /* LEFT */ | ||
715 | { 0x07, 0x27, KEY_0 }, | ||
716 | }; | ||
717 | |||
718 | static u8 af9015_ir_table_trekstor[] = { | ||
719 | 0x00, 0xff, 0x86, 0x79, 0x04, 0x07, 0x00, | ||
720 | 0x00, 0xff, 0x85, 0x7a, 0x05, 0x07, 0x00, | ||
721 | 0x00, 0xff, 0x87, 0x78, 0x06, 0x07, 0x00, | ||
722 | 0x00, 0xff, 0x8c, 0x73, 0x07, 0x07, 0x00, | ||
723 | 0x00, 0xff, 0x89, 0x76, 0x09, 0x07, 0x00, | ||
724 | 0x00, 0xff, 0x88, 0x77, 0x0a, 0x07, 0x00, | ||
725 | 0x00, 0xff, 0x8a, 0x75, 0x0b, 0x07, 0x00, | ||
726 | 0x00, 0xff, 0x9e, 0x61, 0x0c, 0x07, 0x00, | ||
727 | 0x00, 0xff, 0x8d, 0x72, 0x0d, 0x07, 0x00, | ||
728 | 0x00, 0xff, 0x8b, 0x74, 0x0e, 0x07, 0x00, | ||
729 | 0x00, 0xff, 0x9b, 0x64, 0x0f, 0x07, 0x00, | ||
730 | 0x00, 0xff, 0x9d, 0x62, 0x10, 0x07, 0x00, | ||
731 | 0x00, 0xff, 0x8e, 0x71, 0x11, 0x07, 0x00, | ||
732 | 0x00, 0xff, 0x9c, 0x63, 0x12, 0x07, 0x00, | ||
733 | 0x00, 0xff, 0x8f, 0x70, 0x13, 0x07, 0x00, | ||
734 | 0x00, 0xff, 0x93, 0x6c, 0x14, 0x07, 0x00, | ||
735 | 0x00, 0xff, 0x97, 0x68, 0x15, 0x07, 0x00, | ||
736 | 0x00, 0xff, 0x92, 0x6d, 0x1e, 0x07, 0x00, | ||
737 | 0x00, 0xff, 0x96, 0x69, 0x1f, 0x07, 0x00, | ||
738 | 0x00, 0xff, 0x9a, 0x65, 0x20, 0x07, 0x00, | ||
739 | 0x00, 0xff, 0x91, 0x6e, 0x21, 0x07, 0x00, | ||
740 | 0x00, 0xff, 0x95, 0x6a, 0x22, 0x07, 0x00, | ||
741 | 0x00, 0xff, 0x99, 0x66, 0x23, 0x07, 0x00, | ||
742 | 0x00, 0xff, 0x90, 0x6f, 0x24, 0x07, 0x00, | ||
743 | 0x00, 0xff, 0x94, 0x6b, 0x25, 0x07, 0x00, | ||
744 | 0x00, 0xff, 0x98, 0x67, 0x26, 0x07, 0x00, | ||
745 | 0x00, 0xff, 0x9f, 0x60, 0x08, 0x07, 0x00, | ||
746 | 0x00, 0xff, 0x84, 0x7b, 0x27, 0x07, 0x00, | ||
747 | }; | ||
748 | |||
694 | #endif | 749 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/ce6230.c b/drivers/media/dvb/dvb-usb/ce6230.c index 5862820f109f..52badc00e673 100644 --- a/drivers/media/dvb/dvb-usb/ce6230.c +++ b/drivers/media/dvb/dvb-usb/ce6230.c | |||
@@ -250,6 +250,7 @@ static int ce6230_probe(struct usb_interface *intf, | |||
250 | 250 | ||
251 | static struct usb_device_id ce6230_table[] = { | 251 | static struct usb_device_id ce6230_table[] = { |
252 | { USB_DEVICE(USB_VID_INTEL, USB_PID_INTEL_CE9500) }, | 252 | { USB_DEVICE(USB_VID_INTEL, USB_PID_INTEL_CE9500) }, |
253 | { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A310) }, | ||
253 | { } /* Terminating entry */ | 254 | { } /* Terminating entry */ |
254 | }; | 255 | }; |
255 | MODULE_DEVICE_TABLE(usb, ce6230_table); | 256 | MODULE_DEVICE_TABLE(usb, ce6230_table); |
@@ -284,13 +285,18 @@ static struct dvb_usb_device_properties ce6230_properties = { | |||
284 | 285 | ||
285 | .i2c_algo = &ce6230_i2c_algo, | 286 | .i2c_algo = &ce6230_i2c_algo, |
286 | 287 | ||
287 | .num_device_descs = 1, | 288 | .num_device_descs = 2, |
288 | .devices = { | 289 | .devices = { |
289 | { | 290 | { |
290 | .name = "Intel CE9500 reference design", | 291 | .name = "Intel CE9500 reference design", |
291 | .cold_ids = {NULL}, | 292 | .cold_ids = {NULL}, |
292 | .warm_ids = {&ce6230_table[0], NULL}, | 293 | .warm_ids = {&ce6230_table[0], NULL}, |
293 | }, | 294 | }, |
295 | { | ||
296 | .name = "AVerMedia A310 USB 2.0 DVB-T tuner", | ||
297 | .cold_ids = {NULL}, | ||
298 | .warm_ids = {&ce6230_table[1], NULL}, | ||
299 | }, | ||
294 | } | 300 | } |
295 | }; | 301 | }; |
296 | 302 | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index dc7ea21cd139..f506c74119f3 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -65,6 +65,7 @@ | |||
65 | #define USB_PID_AFATECH_AF9005 0x9020 | 65 | #define USB_PID_AFATECH_AF9005 0x9020 |
66 | #define USB_PID_AFATECH_AF9015_9015 0x9015 | 66 | #define USB_PID_AFATECH_AF9015_9015 0x9015 |
67 | #define USB_PID_AFATECH_AF9015_9016 0x9016 | 67 | #define USB_PID_AFATECH_AF9015_9016 0x9016 |
68 | #define USB_PID_TREKSTOR_DVBT 0x901b | ||
68 | #define USB_VID_ALINK_DTU 0xf170 | 69 | #define USB_VID_ALINK_DTU 0xf170 |
69 | #define USB_PID_ANSONIC_DVBT_USB 0x6000 | 70 | #define USB_PID_ANSONIC_DVBT_USB 0x6000 |
70 | #define USB_PID_ANYSEE 0x861f | 71 | #define USB_PID_ANYSEE 0x861f |
@@ -102,6 +103,7 @@ | |||
102 | #define USB_PID_KWORLD_399U 0xe399 | 103 | #define USB_PID_KWORLD_399U 0xe399 |
103 | #define USB_PID_KWORLD_395U 0xe396 | 104 | #define USB_PID_KWORLD_395U 0xe396 |
104 | #define USB_PID_KWORLD_395U_2 0xe39b | 105 | #define USB_PID_KWORLD_395U_2 0xe39b |
106 | #define USB_PID_KWORLD_395U_3 0xe395 | ||
105 | #define USB_PID_KWORLD_PC160_2T 0xc160 | 107 | #define USB_PID_KWORLD_PC160_2T 0xc160 |
106 | #define USB_PID_KWORLD_VSTREAM_COLD 0x17de | 108 | #define USB_PID_KWORLD_VSTREAM_COLD 0x17de |
107 | #define USB_PID_KWORLD_VSTREAM_WARM 0x17df | 109 | #define USB_PID_KWORLD_VSTREAM_WARM 0x17df |
@@ -167,6 +169,8 @@ | |||
167 | #define USB_PID_AVERMEDIA_VOLAR_X 0xa815 | 169 | #define USB_PID_AVERMEDIA_VOLAR_X 0xa815 |
168 | #define USB_PID_AVERMEDIA_VOLAR_X_2 0x8150 | 170 | #define USB_PID_AVERMEDIA_VOLAR_X_2 0x8150 |
169 | #define USB_PID_AVERMEDIA_A309 0xa309 | 171 | #define USB_PID_AVERMEDIA_A309 0xa309 |
172 | #define USB_PID_AVERMEDIA_A310 0xa310 | ||
173 | #define USB_PID_AVERMEDIA_A850 0x850a | ||
170 | #define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 | 174 | #define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 |
171 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a | 175 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a |
172 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 | 176 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 |
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c index 12f7730184ad..32526f103b59 100644 --- a/drivers/media/dvb/firewire/firedtv-avc.c +++ b/drivers/media/dvb/firewire/firedtv-avc.c | |||
@@ -151,7 +151,7 @@ static void debug_fcp(const u8 *data, int length) | |||
151 | subunit_type = data[1] >> 3; | 151 | subunit_type = data[1] >> 3; |
152 | subunit_id = data[1] & 7; | 152 | subunit_id = data[1] & 7; |
153 | op = subunit_type == 0x1e || subunit_id == 5 ? ~0 : data[2]; | 153 | op = subunit_type == 0x1e || subunit_id == 5 ? ~0 : data[2]; |
154 | printk(KERN_INFO "%ssu=%x.%x l=%zu: %-8s - %s\n", | 154 | printk(KERN_INFO "%ssu=%x.%x l=%d: %-8s - %s\n", |
155 | prefix, subunit_type, subunit_id, length, | 155 | prefix, subunit_type, subunit_id, length, |
156 | debug_fcp_ctype(data[0]), | 156 | debug_fcp_ctype(data[0]), |
157 | debug_fcp_opcode(op, data, length)); | 157 | debug_fcp_opcode(op, data, length)); |
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index a486a7f81fa9..23e4cffeba38 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -513,6 +513,13 @@ config DVB_LGS8GL5 | |||
513 | help | 513 | help |
514 | A DMB-TH tuner module. Say Y when you want to support this frontend. | 514 | A DMB-TH tuner module. Say Y when you want to support this frontend. |
515 | 515 | ||
516 | config DVB_LGS8GXX | ||
517 | tristate "Legend Silicon LGS8913/LGS8GL5/LGS8GXX DMB-TH demodulator" | ||
518 | depends on DVB_CORE && I2C | ||
519 | default m if DVB_FE_CUSTOMISE | ||
520 | help | ||
521 | A DMB-TH tuner module. Say Y when you want to support this frontend. | ||
522 | |||
516 | comment "Tools to develop new frontends" | 523 | comment "Tools to develop new frontends" |
517 | 524 | ||
518 | config DVB_DUMMY_FE | 525 | config DVB_DUMMY_FE |
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 65a336aa1db6..bc2b00abd106 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -61,6 +61,7 @@ obj-$(CONFIG_DVB_TDA10048) += tda10048.o | |||
61 | obj-$(CONFIG_DVB_TUNER_CX24113) += cx24113.o | 61 | obj-$(CONFIG_DVB_TUNER_CX24113) += cx24113.o |
62 | obj-$(CONFIG_DVB_S5H1411) += s5h1411.o | 62 | obj-$(CONFIG_DVB_S5H1411) += s5h1411.o |
63 | obj-$(CONFIG_DVB_LGS8GL5) += lgs8gl5.o | 63 | obj-$(CONFIG_DVB_LGS8GL5) += lgs8gl5.o |
64 | obj-$(CONFIG_DVB_LGS8GXX) += lgs8gxx.o | ||
64 | obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o | 65 | obj-$(CONFIG_DVB_DUMMY_FE) += dvb_dummy_fe.o |
65 | obj-$(CONFIG_DVB_AF9013) += af9013.o | 66 | obj-$(CONFIG_DVB_AF9013) += af9013.o |
66 | obj-$(CONFIG_DVB_CX24116) += cx24116.o | 67 | obj-$(CONFIG_DVB_CX24116) += cx24116.o |
diff --git a/drivers/media/dvb/frontends/au8522_decoder.c b/drivers/media/dvb/frontends/au8522_decoder.c index d63e1527dc88..9e9a75576a1d 100644 --- a/drivers/media/dvb/frontends/au8522_decoder.c +++ b/drivers/media/dvb/frontends/au8522_decoder.c | |||
@@ -652,7 +652,7 @@ static int au8522_reset(struct v4l2_subdev *sd, u32 val) | |||
652 | } | 652 | } |
653 | 653 | ||
654 | static int au8522_s_video_routing(struct v4l2_subdev *sd, | 654 | static int au8522_s_video_routing(struct v4l2_subdev *sd, |
655 | const struct v4l2_routing *route) | 655 | u32 input, u32 output, u32 config) |
656 | { | 656 | { |
657 | struct au8522_state *state = to_state(sd); | 657 | struct au8522_state *state = to_state(sd); |
658 | 658 | ||
@@ -663,11 +663,11 @@ static int au8522_s_video_routing(struct v4l2_subdev *sd, | |||
663 | closed), and then came back to analog mode */ | 663 | closed), and then came back to analog mode */ |
664 | au8522_writereg(state, 0x106, 1); | 664 | au8522_writereg(state, 0x106, 1); |
665 | 665 | ||
666 | if (route->input == AU8522_COMPOSITE_CH1) { | 666 | if (input == AU8522_COMPOSITE_CH1) { |
667 | au8522_setup_cvbs_mode(state); | 667 | au8522_setup_cvbs_mode(state); |
668 | } else if (route->input == AU8522_SVIDEO_CH13) { | 668 | } else if (input == AU8522_SVIDEO_CH13) { |
669 | au8522_setup_svideo_mode(state); | 669 | au8522_setup_svideo_mode(state); |
670 | } else if (route->input == AU8522_COMPOSITE_CH4_SIF) { | 670 | } else if (input == AU8522_COMPOSITE_CH4_SIF) { |
671 | au8522_setup_cvbs_tuner_mode(state); | 671 | au8522_setup_cvbs_tuner_mode(state); |
672 | } else { | 672 | } else { |
673 | printk(KERN_ERR "au8522 mode not currently supported\n"); | 673 | printk(KERN_ERR "au8522 mode not currently supported\n"); |
@@ -677,10 +677,10 @@ static int au8522_s_video_routing(struct v4l2_subdev *sd, | |||
677 | } | 677 | } |
678 | 678 | ||
679 | static int au8522_s_audio_routing(struct v4l2_subdev *sd, | 679 | static int au8522_s_audio_routing(struct v4l2_subdev *sd, |
680 | const struct v4l2_routing *route) | 680 | u32 input, u32 output, u32 config) |
681 | { | 681 | { |
682 | struct au8522_state *state = to_state(sd); | 682 | struct au8522_state *state = to_state(sd); |
683 | set_audio_input(state, route->input); | 683 | set_audio_input(state, input); |
684 | return 0; | 684 | return 0; |
685 | } | 685 | } |
686 | 686 | ||
diff --git a/drivers/media/dvb/frontends/lgs8gxx.c b/drivers/media/dvb/frontends/lgs8gxx.c new file mode 100644 index 000000000000..f9785dfe735b --- /dev/null +++ b/drivers/media/dvb/frontends/lgs8gxx.c | |||
@@ -0,0 +1,816 @@ | |||
1 | /* | ||
2 | * Support for Legend Silicon DMB-TH demodulator | ||
3 | * LGS8913, LGS8GL5 | ||
4 | * experimental support LGS8G42, LGS8G52 | ||
5 | * | ||
6 | * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> | ||
7 | * Copyright (C) 2008 Sirius International (Hong Kong) Limited | ||
8 | * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <asm/div64.h> | ||
27 | |||
28 | #include "dvb_frontend.h" | ||
29 | |||
30 | #include "lgs8gxx.h" | ||
31 | #include "lgs8gxx_priv.h" | ||
32 | |||
33 | #define dprintk(args...) \ | ||
34 | do { \ | ||
35 | if (debug) \ | ||
36 | printk(KERN_DEBUG "lgs8gxx: " args); \ | ||
37 | } while (0) | ||
38 | |||
39 | static int debug; | ||
40 | static int fake_signal_str; | ||
41 | |||
42 | module_param(debug, int, 0644); | ||
43 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
44 | |||
45 | module_param(fake_signal_str, int, 0644); | ||
46 | MODULE_PARM_DESC(fake_signal_str, "fake signal strength for LGS8913." | ||
47 | "Signal strength calculation is slow.(default:off)."); | ||
48 | |||
49 | /* LGS8GXX internal helper functions */ | ||
50 | |||
51 | static int lgs8gxx_write_reg(struct lgs8gxx_state *priv, u8 reg, u8 data) | ||
52 | { | ||
53 | int ret; | ||
54 | u8 buf[] = { reg, data }; | ||
55 | struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 }; | ||
56 | |||
57 | msg.addr = priv->config->demod_address; | ||
58 | if (reg >= 0xC0) | ||
59 | msg.addr += 0x02; | ||
60 | |||
61 | if (debug >= 2) | ||
62 | printk(KERN_DEBUG "%s: reg=0x%02X, data=0x%02X\n", | ||
63 | __func__, reg, data); | ||
64 | |||
65 | ret = i2c_transfer(priv->i2c, &msg, 1); | ||
66 | |||
67 | if (ret != 1) | ||
68 | dprintk(KERN_DEBUG "%s: error reg=0x%x, data=0x%x, ret=%i\n", | ||
69 | __func__, reg, data, ret); | ||
70 | |||
71 | return (ret != 1) ? -1 : 0; | ||
72 | } | ||
73 | |||
74 | static int lgs8gxx_read_reg(struct lgs8gxx_state *priv, u8 reg, u8 *p_data) | ||
75 | { | ||
76 | int ret; | ||
77 | u8 dev_addr; | ||
78 | |||
79 | u8 b0[] = { reg }; | ||
80 | u8 b1[] = { 0 }; | ||
81 | struct i2c_msg msg[] = { | ||
82 | { .flags = 0, .buf = b0, .len = 1 }, | ||
83 | { .flags = I2C_M_RD, .buf = b1, .len = 1 }, | ||
84 | }; | ||
85 | |||
86 | dev_addr = priv->config->demod_address; | ||
87 | if (reg >= 0xC0) | ||
88 | dev_addr += 0x02; | ||
89 | msg[1].addr = msg[0].addr = dev_addr; | ||
90 | |||
91 | ret = i2c_transfer(priv->i2c, msg, 2); | ||
92 | if (ret != 2) { | ||
93 | dprintk(KERN_DEBUG "%s: error reg=0x%x, ret=%i\n", | ||
94 | __func__, reg, ret); | ||
95 | return -1; | ||
96 | } | ||
97 | |||
98 | *p_data = b1[0]; | ||
99 | if (debug >= 2) | ||
100 | printk(KERN_DEBUG "%s: reg=0x%02X, data=0x%02X\n", | ||
101 | __func__, reg, b1[0]); | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static int lgs8gxx_soft_reset(struct lgs8gxx_state *priv) | ||
106 | { | ||
107 | lgs8gxx_write_reg(priv, 0x02, 0x00); | ||
108 | msleep(1); | ||
109 | lgs8gxx_write_reg(priv, 0x02, 0x01); | ||
110 | msleep(100); | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | static int lgs8gxx_set_ad_mode(struct lgs8gxx_state *priv) | ||
116 | { | ||
117 | const struct lgs8gxx_config *config = priv->config; | ||
118 | u8 if_conf; | ||
119 | |||
120 | if_conf = 0x10; /* AGC output on; */ | ||
121 | |||
122 | if_conf |= | ||
123 | ((config->ext_adc) ? 0x80 : 0x00) | | ||
124 | ((config->if_neg_center) ? 0x04 : 0x00) | | ||
125 | ((config->if_freq == 0) ? 0x08 : 0x00) | /* Baseband */ | ||
126 | ((config->ext_adc && config->adc_signed) ? 0x02 : 0x00) | | ||
127 | ((config->ext_adc && config->if_neg_edge) ? 0x01 : 0x00); | ||
128 | |||
129 | if (config->ext_adc && | ||
130 | (config->prod == LGS8GXX_PROD_LGS8G52)) { | ||
131 | lgs8gxx_write_reg(priv, 0xBA, 0x40); | ||
132 | } | ||
133 | |||
134 | lgs8gxx_write_reg(priv, 0x07, if_conf); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static int lgs8gxx_set_if_freq(struct lgs8gxx_state *priv, u32 freq /*in kHz*/) | ||
140 | { | ||
141 | u64 val; | ||
142 | u32 v32; | ||
143 | u32 if_clk; | ||
144 | |||
145 | if_clk = priv->config->if_clk_freq; | ||
146 | |||
147 | val = freq; | ||
148 | if (freq != 0) { | ||
149 | val *= (u64)1 << 32; | ||
150 | if (if_clk != 0) | ||
151 | do_div(val, if_clk); | ||
152 | v32 = val & 0xFFFFFFFF; | ||
153 | dprintk("Set IF Freq to %dkHz\n", freq); | ||
154 | } else { | ||
155 | v32 = 0; | ||
156 | dprintk("Set IF Freq to baseband\n"); | ||
157 | } | ||
158 | dprintk("AFC_INIT_FREQ = 0x%08X\n", v32); | ||
159 | |||
160 | lgs8gxx_write_reg(priv, 0x09, 0xFF & (v32)); | ||
161 | lgs8gxx_write_reg(priv, 0x0A, 0xFF & (v32 >> 8)); | ||
162 | lgs8gxx_write_reg(priv, 0x0B, 0xFF & (v32 >> 16)); | ||
163 | lgs8gxx_write_reg(priv, 0x0C, 0xFF & (v32 >> 24)); | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | static int lgs8gxx_set_mode_auto(struct lgs8gxx_state *priv) | ||
169 | { | ||
170 | u8 t; | ||
171 | |||
172 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) | ||
173 | lgs8gxx_write_reg(priv, 0xC6, 0x01); | ||
174 | |||
175 | lgs8gxx_read_reg(priv, 0x7E, &t); | ||
176 | lgs8gxx_write_reg(priv, 0x7E, t | 0x01); | ||
177 | |||
178 | /* clear FEC self reset */ | ||
179 | lgs8gxx_read_reg(priv, 0xC5, &t); | ||
180 | lgs8gxx_write_reg(priv, 0xC5, t & 0xE0); | ||
181 | |||
182 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) { | ||
183 | /* FEC auto detect */ | ||
184 | lgs8gxx_write_reg(priv, 0xC1, 0x03); | ||
185 | |||
186 | lgs8gxx_read_reg(priv, 0x7C, &t); | ||
187 | t = (t & 0x8C) | 0x03; | ||
188 | lgs8gxx_write_reg(priv, 0x7C, t); | ||
189 | } | ||
190 | |||
191 | |||
192 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) { | ||
193 | /* BER test mode */ | ||
194 | lgs8gxx_read_reg(priv, 0xC3, &t); | ||
195 | t = (t & 0xEF) | 0x10; | ||
196 | lgs8gxx_write_reg(priv, 0xC3, t); | ||
197 | } | ||
198 | |||
199 | if (priv->config->prod == LGS8GXX_PROD_LGS8G52) | ||
200 | lgs8gxx_write_reg(priv, 0xD9, 0x40); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static int lgs8gxx_set_mode_manual(struct lgs8gxx_state *priv) | ||
206 | { | ||
207 | int ret = 0; | ||
208 | u8 t; | ||
209 | |||
210 | /* turn off auto-detect; manual settings */ | ||
211 | lgs8gxx_write_reg(priv, 0x7E, 0); | ||
212 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) | ||
213 | lgs8gxx_write_reg(priv, 0xC1, 0); | ||
214 | |||
215 | ret = lgs8gxx_read_reg(priv, 0xC5, &t); | ||
216 | t = (t & 0xE0) | 0x06; | ||
217 | lgs8gxx_write_reg(priv, 0xC5, t); | ||
218 | |||
219 | lgs8gxx_soft_reset(priv); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int lgs8gxx_is_locked(struct lgs8gxx_state *priv, u8 *locked) | ||
225 | { | ||
226 | int ret = 0; | ||
227 | u8 t; | ||
228 | |||
229 | ret = lgs8gxx_read_reg(priv, 0x4B, &t); | ||
230 | if (ret != 0) | ||
231 | return ret; | ||
232 | |||
233 | *locked = ((t & 0xC0) == 0xC0) ? 1 : 0; | ||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static int lgs8gxx_is_autodetect_finished(struct lgs8gxx_state *priv, | ||
238 | u8 *finished) | ||
239 | { | ||
240 | int ret = 0; | ||
241 | u8 t; | ||
242 | |||
243 | ret = lgs8gxx_read_reg(priv, 0xA4, &t); | ||
244 | if (ret != 0) | ||
245 | return ret; | ||
246 | |||
247 | *finished = ((t & 0x3) == 0x1) ? 1 : 0; | ||
248 | |||
249 | return 0; | ||
250 | } | ||
251 | |||
252 | static int lgs8gxx_autolock_gi(struct lgs8gxx_state *priv, u8 gi, u8 *locked) | ||
253 | { | ||
254 | int err; | ||
255 | u8 ad_fini = 0; | ||
256 | |||
257 | if (gi == GI_945) | ||
258 | dprintk("try GI 945\n"); | ||
259 | else if (gi == GI_595) | ||
260 | dprintk("try GI 595\n"); | ||
261 | else if (gi == GI_420) | ||
262 | dprintk("try GI 420\n"); | ||
263 | lgs8gxx_write_reg(priv, 0x04, gi); | ||
264 | lgs8gxx_soft_reset(priv); | ||
265 | msleep(50); | ||
266 | err = lgs8gxx_is_autodetect_finished(priv, &ad_fini); | ||
267 | if (err != 0) | ||
268 | return err; | ||
269 | if (ad_fini) { | ||
270 | err = lgs8gxx_is_locked(priv, locked); | ||
271 | if (err != 0) | ||
272 | return err; | ||
273 | } | ||
274 | |||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static int lgs8gxx_auto_detect(struct lgs8gxx_state *priv, | ||
279 | u8 *detected_param, u8 *gi) | ||
280 | { | ||
281 | int i, j; | ||
282 | int err = 0; | ||
283 | u8 locked = 0, tmp_gi; | ||
284 | |||
285 | dprintk("%s\n", __func__); | ||
286 | |||
287 | lgs8gxx_set_mode_auto(priv); | ||
288 | /* Guard Interval */ | ||
289 | lgs8gxx_write_reg(priv, 0x03, 00); | ||
290 | |||
291 | for (i = 0; i < 2; i++) { | ||
292 | for (j = 0; j < 2; j++) { | ||
293 | tmp_gi = GI_945; | ||
294 | err = lgs8gxx_autolock_gi(priv, GI_945, &locked); | ||
295 | if (err) | ||
296 | goto out; | ||
297 | if (locked) | ||
298 | goto locked; | ||
299 | } | ||
300 | for (j = 0; j < 2; j++) { | ||
301 | tmp_gi = GI_420; | ||
302 | err = lgs8gxx_autolock_gi(priv, GI_420, &locked); | ||
303 | if (err) | ||
304 | goto out; | ||
305 | if (locked) | ||
306 | goto locked; | ||
307 | } | ||
308 | tmp_gi = GI_595; | ||
309 | err = lgs8gxx_autolock_gi(priv, GI_595, &locked); | ||
310 | if (err) | ||
311 | goto out; | ||
312 | if (locked) | ||
313 | goto locked; | ||
314 | } | ||
315 | |||
316 | locked: | ||
317 | if ((err == 0) && (locked == 1)) { | ||
318 | u8 t; | ||
319 | |||
320 | lgs8gxx_read_reg(priv, 0xA2, &t); | ||
321 | *detected_param = t; | ||
322 | |||
323 | if (tmp_gi == GI_945) | ||
324 | dprintk("GI 945 locked\n"); | ||
325 | else if (tmp_gi == GI_595) | ||
326 | dprintk("GI 595 locked\n"); | ||
327 | else if (tmp_gi == GI_420) | ||
328 | dprintk("GI 420 locked\n"); | ||
329 | *gi = tmp_gi; | ||
330 | } | ||
331 | if (!locked) | ||
332 | err = -1; | ||
333 | |||
334 | out: | ||
335 | return err; | ||
336 | } | ||
337 | |||
338 | static void lgs8gxx_auto_lock(struct lgs8gxx_state *priv) | ||
339 | { | ||
340 | s8 err; | ||
341 | u8 gi = 0x2; | ||
342 | u8 detected_param = 0; | ||
343 | |||
344 | err = lgs8gxx_auto_detect(priv, &detected_param, &gi); | ||
345 | |||
346 | if (err != 0) { | ||
347 | dprintk("lgs8gxx_auto_detect failed\n"); | ||
348 | } | ||
349 | |||
350 | /* Apply detected parameters */ | ||
351 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) { | ||
352 | u8 inter_leave_len = detected_param & TIM_MASK ; | ||
353 | inter_leave_len = (inter_leave_len == TIM_LONG) ? 0x60 : 0x40; | ||
354 | detected_param &= CF_MASK | SC_MASK | LGS_FEC_MASK; | ||
355 | detected_param |= inter_leave_len; | ||
356 | } | ||
357 | lgs8gxx_write_reg(priv, 0x7D, detected_param); | ||
358 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) | ||
359 | lgs8gxx_write_reg(priv, 0xC0, detected_param); | ||
360 | /* lgs8gxx_soft_reset(priv); */ | ||
361 | |||
362 | /* Enter manual mode */ | ||
363 | lgs8gxx_set_mode_manual(priv); | ||
364 | |||
365 | switch (gi) { | ||
366 | case GI_945: | ||
367 | priv->curr_gi = 945; break; | ||
368 | case GI_595: | ||
369 | priv->curr_gi = 595; break; | ||
370 | case GI_420: | ||
371 | priv->curr_gi = 420; break; | ||
372 | default: | ||
373 | priv->curr_gi = 945; break; | ||
374 | } | ||
375 | } | ||
376 | |||
377 | static int lgs8gxx_set_mpeg_mode(struct lgs8gxx_state *priv, | ||
378 | u8 serial, u8 clk_pol, u8 clk_gated) | ||
379 | { | ||
380 | int ret = 0; | ||
381 | u8 t; | ||
382 | |||
383 | ret = lgs8gxx_read_reg(priv, 0xC2, &t); | ||
384 | if (ret != 0) | ||
385 | return ret; | ||
386 | |||
387 | t &= 0xF8; | ||
388 | t |= serial ? TS_SERIAL : TS_PARALLEL; | ||
389 | t |= clk_pol ? TS_CLK_INVERTED : TS_CLK_NORMAL; | ||
390 | t |= clk_gated ? TS_CLK_GATED : TS_CLK_FREERUN; | ||
391 | |||
392 | ret = lgs8gxx_write_reg(priv, 0xC2, t); | ||
393 | if (ret != 0) | ||
394 | return ret; | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | |||
400 | /* LGS8913 demod frontend functions */ | ||
401 | |||
402 | static int lgs8913_init(struct lgs8gxx_state *priv) | ||
403 | { | ||
404 | u8 t; | ||
405 | |||
406 | /* LGS8913 specific */ | ||
407 | lgs8gxx_write_reg(priv, 0xc1, 0x3); | ||
408 | |||
409 | lgs8gxx_read_reg(priv, 0x7c, &t); | ||
410 | lgs8gxx_write_reg(priv, 0x7c, (t&0x8c) | 0x3); | ||
411 | |||
412 | /* LGS8913 specific */ | ||
413 | lgs8gxx_read_reg(priv, 0xc3, &t); | ||
414 | lgs8gxx_write_reg(priv, 0xc3, t&0x10); | ||
415 | |||
416 | |||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static int lgs8gxx_init(struct dvb_frontend *fe) | ||
421 | { | ||
422 | struct lgs8gxx_state *priv = | ||
423 | (struct lgs8gxx_state *)fe->demodulator_priv; | ||
424 | const struct lgs8gxx_config *config = priv->config; | ||
425 | u8 data = 0; | ||
426 | s8 err; | ||
427 | dprintk("%s\n", __func__); | ||
428 | |||
429 | lgs8gxx_read_reg(priv, 0, &data); | ||
430 | dprintk("reg 0 = 0x%02X\n", data); | ||
431 | |||
432 | /* Setup MPEG output format */ | ||
433 | err = lgs8gxx_set_mpeg_mode(priv, config->serial_ts, | ||
434 | config->ts_clk_pol, | ||
435 | config->ts_clk_gated); | ||
436 | if (err != 0) | ||
437 | return -EIO; | ||
438 | |||
439 | if (config->prod == LGS8GXX_PROD_LGS8913) | ||
440 | lgs8913_init(priv); | ||
441 | lgs8gxx_set_if_freq(priv, priv->config->if_freq); | ||
442 | if (config->prod != LGS8GXX_PROD_LGS8913) | ||
443 | lgs8gxx_set_ad_mode(priv); | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static void lgs8gxx_release(struct dvb_frontend *fe) | ||
449 | { | ||
450 | struct lgs8gxx_state *state = fe->demodulator_priv; | ||
451 | dprintk("%s\n", __func__); | ||
452 | |||
453 | kfree(state); | ||
454 | } | ||
455 | |||
456 | |||
457 | static int lgs8gxx_write(struct dvb_frontend *fe, u8 *buf, int len) | ||
458 | { | ||
459 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
460 | |||
461 | if (len != 2) | ||
462 | return -EINVAL; | ||
463 | |||
464 | return lgs8gxx_write_reg(priv, buf[0], buf[1]); | ||
465 | } | ||
466 | |||
467 | static int lgs8gxx_set_fe(struct dvb_frontend *fe, | ||
468 | struct dvb_frontend_parameters *fe_params) | ||
469 | { | ||
470 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
471 | |||
472 | dprintk("%s\n", __func__); | ||
473 | |||
474 | /* set frequency */ | ||
475 | if (fe->ops.tuner_ops.set_params) { | ||
476 | fe->ops.tuner_ops.set_params(fe, fe_params); | ||
477 | if (fe->ops.i2c_gate_ctrl) | ||
478 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
479 | } | ||
480 | |||
481 | /* start auto lock */ | ||
482 | lgs8gxx_auto_lock(priv); | ||
483 | |||
484 | msleep(10); | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | static int lgs8gxx_get_fe(struct dvb_frontend *fe, | ||
490 | struct dvb_frontend_parameters *fe_params) | ||
491 | { | ||
492 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
493 | u8 t; | ||
494 | |||
495 | dprintk("%s\n", __func__); | ||
496 | |||
497 | /* TODO: get real readings from device */ | ||
498 | /* inversion status */ | ||
499 | fe_params->inversion = INVERSION_OFF; | ||
500 | |||
501 | /* bandwidth */ | ||
502 | fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; | ||
503 | |||
504 | |||
505 | lgs8gxx_read_reg(priv, 0x7D, &t); | ||
506 | fe_params->u.ofdm.code_rate_HP = FEC_AUTO; | ||
507 | fe_params->u.ofdm.code_rate_LP = FEC_AUTO; | ||
508 | |||
509 | /* constellation */ | ||
510 | switch (t & SC_MASK) { | ||
511 | case SC_QAM64: | ||
512 | fe_params->u.ofdm.constellation = QAM_64; | ||
513 | break; | ||
514 | case SC_QAM32: | ||
515 | fe_params->u.ofdm.constellation = QAM_32; | ||
516 | break; | ||
517 | case SC_QAM16: | ||
518 | fe_params->u.ofdm.constellation = QAM_16; | ||
519 | break; | ||
520 | case SC_QAM4: | ||
521 | case SC_QAM4NR: | ||
522 | fe_params->u.ofdm.constellation = QPSK; | ||
523 | break; | ||
524 | default: | ||
525 | fe_params->u.ofdm.constellation = QAM_64; | ||
526 | } | ||
527 | |||
528 | /* transmission mode */ | ||
529 | fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO; | ||
530 | |||
531 | /* guard interval */ | ||
532 | fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_AUTO; | ||
533 | |||
534 | /* hierarchy */ | ||
535 | fe_params->u.ofdm.hierarchy_information = HIERARCHY_NONE; | ||
536 | |||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | static | ||
541 | int lgs8gxx_get_tune_settings(struct dvb_frontend *fe, | ||
542 | struct dvb_frontend_tune_settings *fesettings) | ||
543 | { | ||
544 | /* FIXME: copy from tda1004x.c */ | ||
545 | fesettings->min_delay_ms = 800; | ||
546 | fesettings->step_size = 0; | ||
547 | fesettings->max_drift = 0; | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | static int lgs8gxx_read_status(struct dvb_frontend *fe, fe_status_t *fe_status) | ||
552 | { | ||
553 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
554 | s8 ret; | ||
555 | u8 t; | ||
556 | |||
557 | dprintk("%s\n", __func__); | ||
558 | |||
559 | ret = lgs8gxx_read_reg(priv, 0x4B, &t); | ||
560 | if (ret != 0) | ||
561 | return -EIO; | ||
562 | |||
563 | dprintk("Reg 0x4B: 0x%02X\n", t); | ||
564 | |||
565 | *fe_status = 0; | ||
566 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) { | ||
567 | if ((t & 0x40) == 0x40) | ||
568 | *fe_status |= FE_HAS_SIGNAL | FE_HAS_CARRIER; | ||
569 | if ((t & 0x80) == 0x80) | ||
570 | *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | | ||
571 | FE_HAS_LOCK; | ||
572 | } else { | ||
573 | if ((t & 0x80) == 0x80) | ||
574 | *fe_status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | | ||
575 | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | ||
576 | } | ||
577 | |||
578 | /* success */ | ||
579 | dprintk("%s: fe_status=0x%x\n", __func__, *fe_status); | ||
580 | return 0; | ||
581 | } | ||
582 | |||
583 | static int lgs8gxx_read_signal_agc(struct lgs8gxx_state *priv, u16 *signal) | ||
584 | { | ||
585 | u16 v; | ||
586 | u8 agc_lvl[2], cat; | ||
587 | |||
588 | dprintk("%s()\n", __func__); | ||
589 | lgs8gxx_read_reg(priv, 0x3F, &agc_lvl[0]); | ||
590 | lgs8gxx_read_reg(priv, 0x3E, &agc_lvl[1]); | ||
591 | |||
592 | v = agc_lvl[0]; | ||
593 | v <<= 8; | ||
594 | v |= agc_lvl[1]; | ||
595 | |||
596 | dprintk("agc_lvl: 0x%04X\n", v); | ||
597 | |||
598 | if (v < 0x100) | ||
599 | cat = 0; | ||
600 | else if (v < 0x190) | ||
601 | cat = 5; | ||
602 | else if (v < 0x2A8) | ||
603 | cat = 4; | ||
604 | else if (v < 0x381) | ||
605 | cat = 3; | ||
606 | else if (v < 0x400) | ||
607 | cat = 2; | ||
608 | else if (v == 0x400) | ||
609 | cat = 1; | ||
610 | else | ||
611 | cat = 0; | ||
612 | |||
613 | *signal = cat; | ||
614 | |||
615 | return 0; | ||
616 | } | ||
617 | |||
618 | static int lgs8913_read_signal_strength(struct lgs8gxx_state *priv, u16 *signal) | ||
619 | { | ||
620 | u8 t; s8 ret; | ||
621 | s16 max_strength = 0; | ||
622 | u8 str; | ||
623 | u16 i, gi = priv->curr_gi; | ||
624 | |||
625 | dprintk("%s\n", __func__); | ||
626 | |||
627 | ret = lgs8gxx_read_reg(priv, 0x4B, &t); | ||
628 | if (ret != 0) | ||
629 | return -EIO; | ||
630 | |||
631 | if (fake_signal_str) { | ||
632 | if ((t & 0xC0) == 0xC0) { | ||
633 | dprintk("Fake signal strength as 50\n"); | ||
634 | *signal = 0x32; | ||
635 | } else | ||
636 | *signal = 0; | ||
637 | return 0; | ||
638 | } | ||
639 | |||
640 | dprintk("gi = %d\n", gi); | ||
641 | for (i = 0; i < gi; i++) { | ||
642 | |||
643 | if ((i & 0xFF) == 0) | ||
644 | lgs8gxx_write_reg(priv, 0x84, 0x03 & (i >> 8)); | ||
645 | lgs8gxx_write_reg(priv, 0x83, i & 0xFF); | ||
646 | |||
647 | lgs8gxx_read_reg(priv, 0x94, &str); | ||
648 | if (max_strength < str) | ||
649 | max_strength = str; | ||
650 | } | ||
651 | |||
652 | *signal = max_strength; | ||
653 | dprintk("%s: signal=0x%02X\n", __func__, *signal); | ||
654 | |||
655 | lgs8gxx_read_reg(priv, 0x95, &t); | ||
656 | dprintk("%s: AVG Noise=0x%02X\n", __func__, t); | ||
657 | |||
658 | return 0; | ||
659 | } | ||
660 | |||
661 | static int lgs8gxx_read_signal_strength(struct dvb_frontend *fe, u16 *signal) | ||
662 | { | ||
663 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
664 | |||
665 | if (priv->config->prod == LGS8GXX_PROD_LGS8913) | ||
666 | return lgs8913_read_signal_strength(priv, signal); | ||
667 | else | ||
668 | return lgs8gxx_read_signal_agc(priv, signal); | ||
669 | } | ||
670 | |||
671 | static int lgs8gxx_read_snr(struct dvb_frontend *fe, u16 *snr) | ||
672 | { | ||
673 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
674 | u8 t; | ||
675 | *snr = 0; | ||
676 | |||
677 | lgs8gxx_read_reg(priv, 0x95, &t); | ||
678 | dprintk("AVG Noise=0x%02X\n", t); | ||
679 | *snr = 256 - t; | ||
680 | *snr <<= 8; | ||
681 | dprintk("snr=0x%x\n", *snr); | ||
682 | |||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | static int lgs8gxx_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | ||
687 | { | ||
688 | *ucblocks = 0; | ||
689 | dprintk("%s: ucblocks=0x%x\n", __func__, *ucblocks); | ||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | static int lgs8gxx_read_ber(struct dvb_frontend *fe, u32 *ber) | ||
694 | { | ||
695 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
696 | u8 r0, r1, r2, r3; | ||
697 | u32 total_cnt, err_cnt; | ||
698 | |||
699 | dprintk("%s\n", __func__); | ||
700 | |||
701 | lgs8gxx_write_reg(priv, 0xc6, 0x01); | ||
702 | lgs8gxx_write_reg(priv, 0xc6, 0x41); | ||
703 | lgs8gxx_write_reg(priv, 0xc6, 0x01); | ||
704 | |||
705 | msleep(200); | ||
706 | |||
707 | lgs8gxx_write_reg(priv, 0xc6, 0x81); | ||
708 | lgs8gxx_read_reg(priv, 0xd0, &r0); | ||
709 | lgs8gxx_read_reg(priv, 0xd1, &r1); | ||
710 | lgs8gxx_read_reg(priv, 0xd2, &r2); | ||
711 | lgs8gxx_read_reg(priv, 0xd3, &r3); | ||
712 | total_cnt = (r3 << 24) | (r2 << 16) | (r1 << 8) | (r0); | ||
713 | lgs8gxx_read_reg(priv, 0xd4, &r0); | ||
714 | lgs8gxx_read_reg(priv, 0xd5, &r1); | ||
715 | lgs8gxx_read_reg(priv, 0xd6, &r2); | ||
716 | lgs8gxx_read_reg(priv, 0xd7, &r3); | ||
717 | err_cnt = (r3 << 24) | (r2 << 16) | (r1 << 8) | (r0); | ||
718 | dprintk("error=%d total=%d\n", err_cnt, total_cnt); | ||
719 | |||
720 | if (total_cnt == 0) | ||
721 | *ber = 0; | ||
722 | else | ||
723 | *ber = err_cnt * 100 / total_cnt; | ||
724 | |||
725 | dprintk("%s: ber=0x%x\n", __func__, *ber); | ||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static int lgs8gxx_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | ||
730 | { | ||
731 | struct lgs8gxx_state *priv = fe->demodulator_priv; | ||
732 | |||
733 | if (priv->config->tuner_address == 0) | ||
734 | return 0; | ||
735 | if (enable) { | ||
736 | u8 v = 0x80 | priv->config->tuner_address; | ||
737 | return lgs8gxx_write_reg(priv, 0x01, v); | ||
738 | } | ||
739 | return lgs8gxx_write_reg(priv, 0x01, 0); | ||
740 | } | ||
741 | |||
742 | static struct dvb_frontend_ops lgs8gxx_ops = { | ||
743 | .info = { | ||
744 | .name = "Legend Silicon LGS8913/LGS8GXX DMB-TH", | ||
745 | .type = FE_OFDM, | ||
746 | .frequency_min = 474000000, | ||
747 | .frequency_max = 858000000, | ||
748 | .frequency_stepsize = 10000, | ||
749 | .caps = | ||
750 | FE_CAN_FEC_AUTO | | ||
751 | FE_CAN_QAM_AUTO | | ||
752 | FE_CAN_TRANSMISSION_MODE_AUTO | | ||
753 | FE_CAN_GUARD_INTERVAL_AUTO | ||
754 | }, | ||
755 | |||
756 | .release = lgs8gxx_release, | ||
757 | |||
758 | .init = lgs8gxx_init, | ||
759 | .write = lgs8gxx_write, | ||
760 | .i2c_gate_ctrl = lgs8gxx_i2c_gate_ctrl, | ||
761 | |||
762 | .set_frontend = lgs8gxx_set_fe, | ||
763 | .get_frontend = lgs8gxx_get_fe, | ||
764 | .get_tune_settings = lgs8gxx_get_tune_settings, | ||
765 | |||
766 | .read_status = lgs8gxx_read_status, | ||
767 | .read_ber = lgs8gxx_read_ber, | ||
768 | .read_signal_strength = lgs8gxx_read_signal_strength, | ||
769 | .read_snr = lgs8gxx_read_snr, | ||
770 | .read_ucblocks = lgs8gxx_read_ucblocks, | ||
771 | }; | ||
772 | |||
773 | struct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config, | ||
774 | struct i2c_adapter *i2c) | ||
775 | { | ||
776 | struct lgs8gxx_state *priv = NULL; | ||
777 | u8 data = 0; | ||
778 | |||
779 | dprintk("%s()\n", __func__); | ||
780 | |||
781 | if (config == NULL || i2c == NULL) | ||
782 | return NULL; | ||
783 | |||
784 | priv = kzalloc(sizeof(struct lgs8gxx_state), GFP_KERNEL); | ||
785 | if (priv == NULL) | ||
786 | goto error_out; | ||
787 | |||
788 | priv->config = config; | ||
789 | priv->i2c = i2c; | ||
790 | |||
791 | /* check if the demod is there */ | ||
792 | if (lgs8gxx_read_reg(priv, 0, &data) != 0) { | ||
793 | dprintk("%s lgs8gxx not found at i2c addr 0x%02X\n", | ||
794 | __func__, priv->config->demod_address); | ||
795 | goto error_out; | ||
796 | } | ||
797 | |||
798 | lgs8gxx_read_reg(priv, 1, &data); | ||
799 | |||
800 | memcpy(&priv->frontend.ops, &lgs8gxx_ops, | ||
801 | sizeof(struct dvb_frontend_ops)); | ||
802 | priv->frontend.demodulator_priv = priv; | ||
803 | |||
804 | return &priv->frontend; | ||
805 | |||
806 | error_out: | ||
807 | dprintk("%s() error_out\n", __func__); | ||
808 | kfree(priv); | ||
809 | return NULL; | ||
810 | |||
811 | } | ||
812 | EXPORT_SYMBOL(lgs8gxx_attach); | ||
813 | |||
814 | MODULE_DESCRIPTION("Legend Silicon LGS8913/LGS8GXX DMB-TH demodulator driver"); | ||
815 | MODULE_AUTHOR("David T. L. Wong <davidtlwong@gmail.com>"); | ||
816 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/lgs8gxx.h b/drivers/media/dvb/frontends/lgs8gxx.h new file mode 100644 index 000000000000..321d366a8307 --- /dev/null +++ b/drivers/media/dvb/frontends/lgs8gxx.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Support for Legend Silicon DMB-TH demodulator | ||
3 | * LGS8913, LGS8GL5 | ||
4 | * experimental support LGS8G42, LGS8G52 | ||
5 | * | ||
6 | * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> | ||
7 | * Copyright (C) 2008 Sirius International (Hong Kong) Limited | ||
8 | * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef __LGS8GXX_H__ | ||
27 | #define __LGS8GXX_H__ | ||
28 | |||
29 | #include <linux/dvb/frontend.h> | ||
30 | #include <linux/i2c.h> | ||
31 | |||
32 | #define LGS8GXX_PROD_LGS8913 0 | ||
33 | #define LGS8GXX_PROD_LGS8GL5 1 | ||
34 | #define LGS8GXX_PROD_LGS8G42 3 | ||
35 | #define LGS8GXX_PROD_LGS8G52 4 | ||
36 | #define LGS8GXX_PROD_LGS8G54 5 | ||
37 | |||
38 | struct lgs8gxx_config { | ||
39 | |||
40 | /* product type */ | ||
41 | u8 prod; | ||
42 | |||
43 | /* the demodulator's i2c address */ | ||
44 | u8 demod_address; | ||
45 | |||
46 | /* parallel or serial transport stream */ | ||
47 | u8 serial_ts; | ||
48 | |||
49 | /* transport stream polarity*/ | ||
50 | u8 ts_clk_pol; | ||
51 | |||
52 | /* transport stream clock gated by ts_valid */ | ||
53 | u8 ts_clk_gated; | ||
54 | |||
55 | /* A/D Clock frequency */ | ||
56 | u32 if_clk_freq; /* in kHz */ | ||
57 | |||
58 | /* IF frequency */ | ||
59 | u32 if_freq; /* in kHz */ | ||
60 | |||
61 | /*Use External ADC*/ | ||
62 | u8 ext_adc; | ||
63 | |||
64 | /*External ADC output two's complement*/ | ||
65 | u8 adc_signed; | ||
66 | |||
67 | /*Sample IF data at falling edge of IF_CLK*/ | ||
68 | u8 if_neg_edge; | ||
69 | |||
70 | /*IF use Negative center frequency*/ | ||
71 | u8 if_neg_center; | ||
72 | |||
73 | /* slave address and configuration of the tuner */ | ||
74 | u8 tuner_address; | ||
75 | }; | ||
76 | |||
77 | #if defined(CONFIG_DVB_LGS8GXX) || \ | ||
78 | (defined(CONFIG_DVB_LGS8GXX_MODULE) && defined(MODULE)) | ||
79 | extern struct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config, | ||
80 | struct i2c_adapter *i2c); | ||
81 | #else | ||
82 | static inline | ||
83 | struct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config, | ||
84 | struct i2c_adapter *i2c) { | ||
85 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
86 | return NULL; | ||
87 | } | ||
88 | #endif /* CONFIG_DVB_LGS8GXX */ | ||
89 | |||
90 | #endif /* __LGS8GXX_H__ */ | ||
diff --git a/drivers/media/dvb/frontends/lgs8gxx_priv.h b/drivers/media/dvb/frontends/lgs8gxx_priv.h new file mode 100644 index 000000000000..9776d30686dc --- /dev/null +++ b/drivers/media/dvb/frontends/lgs8gxx_priv.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Support for Legend Silicon DMB-TH demodulator | ||
3 | * LGS8913, LGS8GL5 | ||
4 | * experimental support LGS8G42, LGS8G52 | ||
5 | * | ||
6 | * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> | ||
7 | * Copyright (C) 2008 Sirius International (Hong Kong) Limited | ||
8 | * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef LGS8913_PRIV_H | ||
27 | #define LGS8913_PRIV_H | ||
28 | |||
29 | struct lgs8gxx_state { | ||
30 | struct i2c_adapter *i2c; | ||
31 | /* configuration settings */ | ||
32 | const struct lgs8gxx_config *config; | ||
33 | struct dvb_frontend frontend; | ||
34 | u16 curr_gi; /* current guard interval */ | ||
35 | }; | ||
36 | |||
37 | #define SC_MASK 0x1C /* Sub-Carrier Modulation Mask */ | ||
38 | #define SC_QAM64 0x10 /* 64QAM modulation */ | ||
39 | #define SC_QAM32 0x0C /* 32QAM modulation */ | ||
40 | #define SC_QAM16 0x08 /* 16QAM modulation */ | ||
41 | #define SC_QAM4NR 0x04 /* 4QAM modulation */ | ||
42 | #define SC_QAM4 0x00 /* 4QAM modulation */ | ||
43 | |||
44 | #define LGS_FEC_MASK 0x03 /* FEC Rate Mask */ | ||
45 | #define LGS_FEC_0_4 0x00 /* FEC Rate 0.4 */ | ||
46 | #define LGS_FEC_0_6 0x01 /* FEC Rate 0.6 */ | ||
47 | #define LGS_FEC_0_8 0x02 /* FEC Rate 0.8 */ | ||
48 | |||
49 | #define TIM_MASK 0x20 /* Time Interleave Length Mask */ | ||
50 | #define TIM_LONG 0x00 /* Time Interleave Length = 720 */ | ||
51 | #define TIM_MIDDLE 0x20 /* Time Interleave Length = 240 */ | ||
52 | |||
53 | #define CF_MASK 0x80 /* Control Frame Mask */ | ||
54 | #define CF_EN 0x80 /* Control Frame On */ | ||
55 | |||
56 | #define GI_MASK 0x03 /* Guard Interval Mask */ | ||
57 | #define GI_420 0x00 /* 1/9 Guard Interval */ | ||
58 | #define GI_595 0x01 /* */ | ||
59 | #define GI_945 0x02 /* 1/4 Guard Interval */ | ||
60 | |||
61 | |||
62 | #define TS_PARALLEL 0x00 /* Parallel TS Output a.k.a. SPI */ | ||
63 | #define TS_SERIAL 0x01 /* Serial TS Output a.k.a. SSI */ | ||
64 | #define TS_CLK_NORMAL 0x00 /* MPEG Clock Normal */ | ||
65 | #define TS_CLK_INVERTED 0x02 /* MPEG Clock Inverted */ | ||
66 | #define TS_CLK_GATED 0x00 /* MPEG clock gated */ | ||
67 | #define TS_CLK_FREERUN 0x04 /* MPEG clock free running*/ | ||
68 | |||
69 | |||
70 | #endif | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index cc54ed4efc48..613576202294 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -33,6 +33,9 @@ | |||
33 | 33 | ||
34 | History: | 34 | History: |
35 | 35 | ||
36 | Version 0.45: | ||
37 | Converted to v4l2_device. | ||
38 | |||
36 | Version 0.44: | 39 | Version 0.44: |
37 | Add suspend/resume functions, fix unplug of device, | 40 | Add suspend/resume functions, fix unplug of device, |
38 | a lot of cleanups and fixes by Alexey Klimov <klimov.linux@gmail.com> | 41 | a lot of cleanups and fixes by Alexey Klimov <klimov.linux@gmail.com> |
@@ -88,7 +91,7 @@ | |||
88 | #include <linux/slab.h> | 91 | #include <linux/slab.h> |
89 | #include <linux/input.h> | 92 | #include <linux/input.h> |
90 | #include <linux/videodev2.h> | 93 | #include <linux/videodev2.h> |
91 | #include <media/v4l2-common.h> | 94 | #include <media/v4l2-device.h> |
92 | #include <media/v4l2-ioctl.h> | 95 | #include <media/v4l2-ioctl.h> |
93 | #include <linux/usb.h> | 96 | #include <linux/usb.h> |
94 | 97 | ||
@@ -97,39 +100,8 @@ | |||
97 | */ | 100 | */ |
98 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 101 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
99 | 102 | ||
100 | #define DRIVER_VERSION "v0.44" | 103 | #define DRIVER_VERSION "v0.45" |
101 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 4) | 104 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 5) |
102 | |||
103 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
104 | { | ||
105 | .id = V4L2_CID_AUDIO_MUTE, | ||
106 | .name = "Mute", | ||
107 | .minimum = 0, | ||
108 | .maximum = 1, | ||
109 | .default_value = 1, | ||
110 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
111 | }, | ||
112 | /* HINT: the disabled controls are only here to satify kradio and such apps */ | ||
113 | { .id = V4L2_CID_AUDIO_VOLUME, | ||
114 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
115 | }, | ||
116 | { | ||
117 | .id = V4L2_CID_AUDIO_BALANCE, | ||
118 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
119 | }, | ||
120 | { | ||
121 | .id = V4L2_CID_AUDIO_BASS, | ||
122 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
123 | }, | ||
124 | { | ||
125 | .id = V4L2_CID_AUDIO_TREBLE, | ||
126 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
127 | }, | ||
128 | { | ||
129 | .id = V4L2_CID_AUDIO_LOUDNESS, | ||
130 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
131 | }, | ||
132 | }; | ||
133 | 105 | ||
134 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" | 106 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" |
135 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" | 107 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" |
@@ -167,6 +139,8 @@ module_param(radio_nr, int, 0); | |||
167 | struct dsbr100_device { | 139 | struct dsbr100_device { |
168 | struct usb_device *usbdev; | 140 | struct usb_device *usbdev; |
169 | struct video_device videodev; | 141 | struct video_device videodev; |
142 | struct v4l2_device v4l2_dev; | ||
143 | |||
170 | u8 *transfer_buffer; | 144 | u8 *transfer_buffer; |
171 | struct mutex lock; /* buffer locking */ | 145 | struct mutex lock; /* buffer locking */ |
172 | int curfreq; | 146 | int curfreq; |
@@ -384,6 +358,7 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf) | |||
384 | mutex_unlock(&radio->lock); | 358 | mutex_unlock(&radio->lock); |
385 | 359 | ||
386 | video_unregister_device(&radio->videodev); | 360 | video_unregister_device(&radio->videodev); |
361 | v4l2_device_disconnect(&radio->v4l2_dev); | ||
387 | } | 362 | } |
388 | 363 | ||
389 | 364 | ||
@@ -479,14 +454,11 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
479 | static int vidioc_queryctrl(struct file *file, void *priv, | 454 | static int vidioc_queryctrl(struct file *file, void *priv, |
480 | struct v4l2_queryctrl *qc) | 455 | struct v4l2_queryctrl *qc) |
481 | { | 456 | { |
482 | int i; | 457 | switch (qc->id) { |
483 | 458 | case V4L2_CID_AUDIO_MUTE: | |
484 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 459 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); |
485 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
486 | memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); | ||
487 | return 0; | ||
488 | } | ||
489 | } | 460 | } |
461 | |||
490 | return -EINVAL; | 462 | return -EINVAL; |
491 | } | 463 | } |
492 | 464 | ||
@@ -656,6 +628,7 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev) | |||
656 | { | 628 | { |
657 | struct dsbr100_device *radio = videodev_to_radio(videodev); | 629 | struct dsbr100_device *radio = videodev_to_radio(videodev); |
658 | 630 | ||
631 | v4l2_device_unregister(&radio->v4l2_dev); | ||
659 | kfree(radio->transfer_buffer); | 632 | kfree(radio->transfer_buffer); |
660 | kfree(radio); | 633 | kfree(radio); |
661 | } | 634 | } |
@@ -683,22 +656,15 @@ static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { | |||
683 | .vidioc_s_input = vidioc_s_input, | 656 | .vidioc_s_input = vidioc_s_input, |
684 | }; | 657 | }; |
685 | 658 | ||
686 | /* V4L2 interface */ | ||
687 | static struct video_device dsbr100_videodev_data = { | ||
688 | .name = "D-Link DSB-R 100", | ||
689 | .fops = &usb_dsbr100_fops, | ||
690 | .ioctl_ops = &usb_dsbr100_ioctl_ops, | ||
691 | .release = usb_dsbr100_video_device_release, | ||
692 | }; | ||
693 | |||
694 | /* check if the device is present and register with v4l and usb if it is */ | 659 | /* check if the device is present and register with v4l and usb if it is */ |
695 | static int usb_dsbr100_probe(struct usb_interface *intf, | 660 | static int usb_dsbr100_probe(struct usb_interface *intf, |
696 | const struct usb_device_id *id) | 661 | const struct usb_device_id *id) |
697 | { | 662 | { |
698 | struct dsbr100_device *radio; | 663 | struct dsbr100_device *radio; |
664 | struct v4l2_device *v4l2_dev; | ||
699 | int retval; | 665 | int retval; |
700 | 666 | ||
701 | radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL); | 667 | radio = kzalloc(sizeof(struct dsbr100_device), GFP_KERNEL); |
702 | 668 | ||
703 | if (!radio) | 669 | if (!radio) |
704 | return -ENOMEM; | 670 | return -ENOMEM; |
@@ -710,17 +676,35 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
710 | return -ENOMEM; | 676 | return -ENOMEM; |
711 | } | 677 | } |
712 | 678 | ||
679 | v4l2_dev = &radio->v4l2_dev; | ||
680 | |||
681 | retval = v4l2_device_register(&intf->dev, v4l2_dev); | ||
682 | if (retval < 0) { | ||
683 | v4l2_err(v4l2_dev, "couldn't register v4l2_device\n"); | ||
684 | kfree(radio->transfer_buffer); | ||
685 | kfree(radio); | ||
686 | return retval; | ||
687 | } | ||
688 | |||
689 | strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); | ||
690 | radio->videodev.v4l2_dev = v4l2_dev; | ||
691 | radio->videodev.fops = &usb_dsbr100_fops; | ||
692 | radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; | ||
693 | radio->videodev.release = usb_dsbr100_video_device_release; | ||
694 | |||
713 | mutex_init(&radio->lock); | 695 | mutex_init(&radio->lock); |
714 | radio->videodev = dsbr100_videodev_data; | ||
715 | 696 | ||
716 | radio->removed = 0; | 697 | radio->removed = 0; |
717 | radio->users = 0; | 698 | radio->users = 0; |
718 | radio->usbdev = interface_to_usbdev(intf); | 699 | radio->usbdev = interface_to_usbdev(intf); |
719 | radio->curfreq = FREQ_MIN * FREQ_MUL; | 700 | radio->curfreq = FREQ_MIN * FREQ_MUL; |
701 | |||
720 | video_set_drvdata(&radio->videodev, radio); | 702 | video_set_drvdata(&radio->videodev, radio); |
703 | |||
721 | retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); | 704 | retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); |
722 | if (retval < 0) { | 705 | if (retval < 0) { |
723 | dev_err(&intf->dev, "couldn't register video device\n"); | 706 | v4l2_err(v4l2_dev, "couldn't register video device\n"); |
707 | v4l2_device_unregister(v4l2_dev); | ||
724 | kfree(radio->transfer_buffer); | 708 | kfree(radio->transfer_buffer); |
725 | kfree(radio); | 709 | kfree(radio); |
726 | return -EIO; | 710 | return -EIO; |
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index ac82e33cb6fc..35edee009ba8 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
@@ -355,20 +355,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
355 | return a->index ? -EINVAL : 0; | 355 | return a->index ? -EINVAL : 0; |
356 | } | 356 | } |
357 | 357 | ||
358 | static int rtrack_open(struct file *file) | ||
359 | { | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int rtrack_release(struct file *file) | ||
364 | { | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static const struct v4l2_file_operations rtrack_fops = { | 358 | static const struct v4l2_file_operations rtrack_fops = { |
369 | .owner = THIS_MODULE, | 359 | .owner = THIS_MODULE, |
370 | .open = rtrack_open, | ||
371 | .release = rtrack_release, | ||
372 | .ioctl = video_ioctl2, | 360 | .ioctl = video_ioctl2, |
373 | }; | 361 | }; |
374 | 362 | ||
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 49299f7fd834..8daf809eb01a 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c | |||
@@ -318,20 +318,8 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
318 | return -EINVAL; | 318 | return -EINVAL; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int aztech_open(struct file *file) | ||
322 | { | ||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static int aztech_release(struct file *file) | ||
327 | { | ||
328 | return 0; | ||
329 | } | ||
330 | |||
331 | static const struct v4l2_file_operations aztech_fops = { | 321 | static const struct v4l2_file_operations aztech_fops = { |
332 | .owner = THIS_MODULE, | 322 | .owner = THIS_MODULE, |
333 | .open = aztech_open, | ||
334 | .release = aztech_release, | ||
335 | .ioctl = video_ioctl2, | 323 | .ioctl = video_ioctl2, |
336 | }; | 324 | }; |
337 | 325 | ||
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index 09265d25725e..c3f579de6e71 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c | |||
@@ -356,20 +356,8 @@ static struct pci_device_id gemtek_pci_id[] = | |||
356 | 356 | ||
357 | MODULE_DEVICE_TABLE(pci, gemtek_pci_id); | 357 | MODULE_DEVICE_TABLE(pci, gemtek_pci_id); |
358 | 358 | ||
359 | static int gemtek_pci_open(struct file *file) | ||
360 | { | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static int gemtek_pci_release(struct file *file) | ||
365 | { | ||
366 | return 0; | ||
367 | } | ||
368 | |||
369 | static const struct v4l2_file_operations gemtek_pci_fops = { | 359 | static const struct v4l2_file_operations gemtek_pci_fops = { |
370 | .owner = THIS_MODULE, | 360 | .owner = THIS_MODULE, |
371 | .open = gemtek_pci_open, | ||
372 | .release = gemtek_pci_release, | ||
373 | .ioctl = video_ioctl2, | 361 | .ioctl = video_ioctl2, |
374 | }; | 362 | }; |
375 | 363 | ||
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index 150464426d1d..73985f641f07 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c | |||
@@ -375,20 +375,9 @@ static int gemtek_probe(struct gemtek *gt) | |||
375 | /* | 375 | /* |
376 | * Video 4 Linux stuff. | 376 | * Video 4 Linux stuff. |
377 | */ | 377 | */ |
378 | static int gemtek_open(struct file *file) | ||
379 | { | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static int gemtek_release(struct file *file) | ||
384 | { | ||
385 | return 0; | ||
386 | } | ||
387 | 378 | ||
388 | static const struct v4l2_file_operations gemtek_fops = { | 379 | static const struct v4l2_file_operations gemtek_fops = { |
389 | .owner = THIS_MODULE, | 380 | .owner = THIS_MODULE, |
390 | .open = gemtek_open, | ||
391 | .release = gemtek_release, | ||
392 | .ioctl = video_ioctl2, | 381 | .ioctl = video_ioctl2, |
393 | }; | 382 | }; |
394 | 383 | ||
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 01a6d22950ad..64d737c35acf 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -292,20 +292,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
292 | return a->index ? -EINVAL : 0; | 292 | return a->index ? -EINVAL : 0; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int maestro_open(struct file *file) | ||
296 | { | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static int maestro_release(struct file *file) | ||
301 | { | ||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | static const struct v4l2_file_operations maestro_fops = { | 295 | static const struct v4l2_file_operations maestro_fops = { |
306 | .owner = THIS_MODULE, | 296 | .owner = THIS_MODULE, |
307 | .open = maestro_open, | ||
308 | .release = maestro_release, | ||
309 | .ioctl = video_ioctl2, | 297 | .ioctl = video_ioctl2, |
310 | }; | 298 | }; |
311 | 299 | ||
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 2606f0b30355..3da51fe8fb93 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -339,20 +339,8 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
339 | return -EINVAL; | 339 | return -EINVAL; |
340 | } | 340 | } |
341 | 341 | ||
342 | static int maxiradio_open(struct file *file) | ||
343 | { | ||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int maxiradio_release(struct file *file) | ||
348 | { | ||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static const struct v4l2_file_operations maxiradio_fops = { | 342 | static const struct v4l2_file_operations maxiradio_fops = { |
353 | .owner = THIS_MODULE, | 343 | .owner = THIS_MODULE, |
354 | .open = maxiradio_open, | ||
355 | .release = maxiradio_release, | ||
356 | .ioctl = video_ioctl2, | 344 | .ioctl = video_ioctl2, |
357 | }; | 345 | }; |
358 | 346 | ||
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index ded25bfb366e..cab19d05e02f 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c | |||
@@ -43,6 +43,7 @@ | |||
43 | * Douglas Schilling Landgraf <dougsland@gmail.com> and | 43 | * Douglas Schilling Landgraf <dougsland@gmail.com> and |
44 | * David Ellingsworth <david@identd.dyndns.org> | 44 | * David Ellingsworth <david@identd.dyndns.org> |
45 | * for discussion, help and support. | 45 | * for discussion, help and support. |
46 | * Version 0.11: Converted to v4l2_device. | ||
46 | * | 47 | * |
47 | * Many things to do: | 48 | * Many things to do: |
48 | * - Correct power managment of device (suspend & resume) | 49 | * - Correct power managment of device (suspend & resume) |
@@ -59,7 +60,7 @@ | |||
59 | #include <linux/slab.h> | 60 | #include <linux/slab.h> |
60 | #include <linux/input.h> | 61 | #include <linux/input.h> |
61 | #include <linux/videodev2.h> | 62 | #include <linux/videodev2.h> |
62 | #include <media/v4l2-common.h> | 63 | #include <media/v4l2-device.h> |
63 | #include <media/v4l2-ioctl.h> | 64 | #include <media/v4l2-ioctl.h> |
64 | #include <linux/usb.h> | 65 | #include <linux/usb.h> |
65 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 66 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
@@ -67,8 +68,8 @@ | |||
67 | /* driver and module definitions */ | 68 | /* driver and module definitions */ |
68 | #define DRIVER_AUTHOR "Alexey Klimov <klimov.linux@gmail.com>" | 69 | #define DRIVER_AUTHOR "Alexey Klimov <klimov.linux@gmail.com>" |
69 | #define DRIVER_DESC "AverMedia MR 800 USB FM radio driver" | 70 | #define DRIVER_DESC "AverMedia MR 800 USB FM radio driver" |
70 | #define DRIVER_VERSION "0.10" | 71 | #define DRIVER_VERSION "0.11" |
71 | #define RADIO_VERSION KERNEL_VERSION(0, 1, 0) | 72 | #define RADIO_VERSION KERNEL_VERSION(0, 1, 1) |
72 | 73 | ||
73 | MODULE_AUTHOR(DRIVER_AUTHOR); | 74 | MODULE_AUTHOR(DRIVER_AUTHOR); |
74 | MODULE_DESCRIPTION(DRIVER_DESC); | 75 | MODULE_DESCRIPTION(DRIVER_DESC); |
@@ -113,38 +114,6 @@ static int radio_nr = -1; | |||
113 | module_param(radio_nr, int, 0); | 114 | module_param(radio_nr, int, 0); |
114 | MODULE_PARM_DESC(radio_nr, "Radio Nr"); | 115 | MODULE_PARM_DESC(radio_nr, "Radio Nr"); |
115 | 116 | ||
116 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
117 | { | ||
118 | .id = V4L2_CID_AUDIO_MUTE, | ||
119 | .name = "Mute", | ||
120 | .minimum = 0, | ||
121 | .maximum = 1, | ||
122 | .step = 1, | ||
123 | .default_value = 1, | ||
124 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
125 | }, | ||
126 | /* HINT: the disabled controls are only here to satify kradio and such apps */ | ||
127 | { .id = V4L2_CID_AUDIO_VOLUME, | ||
128 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
129 | }, | ||
130 | { | ||
131 | .id = V4L2_CID_AUDIO_BALANCE, | ||
132 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
133 | }, | ||
134 | { | ||
135 | .id = V4L2_CID_AUDIO_BASS, | ||
136 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
137 | }, | ||
138 | { | ||
139 | .id = V4L2_CID_AUDIO_TREBLE, | ||
140 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
141 | }, | ||
142 | { | ||
143 | .id = V4L2_CID_AUDIO_LOUDNESS, | ||
144 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | static int usb_amradio_probe(struct usb_interface *intf, | 117 | static int usb_amradio_probe(struct usb_interface *intf, |
149 | const struct usb_device_id *id); | 118 | const struct usb_device_id *id); |
150 | static void usb_amradio_disconnect(struct usb_interface *intf); | 119 | static void usb_amradio_disconnect(struct usb_interface *intf); |
@@ -159,6 +128,7 @@ struct amradio_device { | |||
159 | /* reference to USB and video device */ | 128 | /* reference to USB and video device */ |
160 | struct usb_device *usbdev; | 129 | struct usb_device *usbdev; |
161 | struct video_device *videodev; | 130 | struct video_device *videodev; |
131 | struct v4l2_device v4l2_dev; | ||
162 | 132 | ||
163 | unsigned char *buffer; | 133 | unsigned char *buffer; |
164 | struct mutex lock; /* buffer locking */ | 134 | struct mutex lock; /* buffer locking */ |
@@ -329,6 +299,7 @@ static void usb_amradio_disconnect(struct usb_interface *intf) | |||
329 | 299 | ||
330 | usb_set_intfdata(intf, NULL); | 300 | usb_set_intfdata(intf, NULL); |
331 | video_unregister_device(radio->videodev); | 301 | video_unregister_device(radio->videodev); |
302 | v4l2_device_disconnect(&radio->v4l2_dev); | ||
332 | } | 303 | } |
333 | 304 | ||
334 | /* vidioc_querycap - query device capabilities */ | 305 | /* vidioc_querycap - query device capabilities */ |
@@ -463,14 +434,11 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
463 | static int vidioc_queryctrl(struct file *file, void *priv, | 434 | static int vidioc_queryctrl(struct file *file, void *priv, |
464 | struct v4l2_queryctrl *qc) | 435 | struct v4l2_queryctrl *qc) |
465 | { | 436 | { |
466 | int i; | 437 | switch (qc->id) { |
467 | 438 | case V4L2_CID_AUDIO_MUTE: | |
468 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 439 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); |
469 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
470 | memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); | ||
471 | return 0; | ||
472 | } | ||
473 | } | 440 | } |
441 | |||
474 | return -EINVAL; | 442 | return -EINVAL; |
475 | } | 443 | } |
476 | 444 | ||
@@ -671,34 +639,29 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { | |||
671 | .vidioc_s_input = vidioc_s_input, | 639 | .vidioc_s_input = vidioc_s_input, |
672 | }; | 640 | }; |
673 | 641 | ||
674 | static void usb_amradio_device_release(struct video_device *videodev) | 642 | static void usb_amradio_video_device_release(struct video_device *videodev) |
675 | { | 643 | { |
676 | struct amradio_device *radio = video_get_drvdata(videodev); | 644 | struct amradio_device *radio = video_get_drvdata(videodev); |
677 | 645 | ||
678 | /* we call v4l to free radio->videodev */ | 646 | /* we call v4l to free radio->videodev */ |
679 | video_device_release(videodev); | 647 | video_device_release(videodev); |
680 | 648 | ||
649 | v4l2_device_unregister(&radio->v4l2_dev); | ||
650 | |||
681 | /* free rest memory */ | 651 | /* free rest memory */ |
682 | kfree(radio->buffer); | 652 | kfree(radio->buffer); |
683 | kfree(radio); | 653 | kfree(radio); |
684 | } | 654 | } |
685 | 655 | ||
686 | /* V4L2 interface */ | ||
687 | static struct video_device amradio_videodev_template = { | ||
688 | .name = "AverMedia MR 800 USB FM Radio", | ||
689 | .fops = &usb_amradio_fops, | ||
690 | .ioctl_ops = &usb_amradio_ioctl_ops, | ||
691 | .release = usb_amradio_device_release, | ||
692 | }; | ||
693 | |||
694 | /* check if the device is present and register with v4l and usb if it is */ | 656 | /* check if the device is present and register with v4l and usb if it is */ |
695 | static int usb_amradio_probe(struct usb_interface *intf, | 657 | static int usb_amradio_probe(struct usb_interface *intf, |
696 | const struct usb_device_id *id) | 658 | const struct usb_device_id *id) |
697 | { | 659 | { |
698 | struct amradio_device *radio; | 660 | struct amradio_device *radio; |
661 | struct v4l2_device *v4l2_dev; | ||
699 | int retval; | 662 | int retval; |
700 | 663 | ||
701 | radio = kmalloc(sizeof(struct amradio_device), GFP_KERNEL); | 664 | radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL); |
702 | 665 | ||
703 | if (!radio) { | 666 | if (!radio) { |
704 | dev_err(&intf->dev, "kmalloc for amradio_device failed\n"); | 667 | dev_err(&intf->dev, "kmalloc for amradio_device failed\n"); |
@@ -713,6 +676,15 @@ static int usb_amradio_probe(struct usb_interface *intf, | |||
713 | return -ENOMEM; | 676 | return -ENOMEM; |
714 | } | 677 | } |
715 | 678 | ||
679 | v4l2_dev = &radio->v4l2_dev; | ||
680 | retval = v4l2_device_register(&intf->dev, v4l2_dev); | ||
681 | if (retval < 0) { | ||
682 | dev_err(&intf->dev, "couldn't register v4l2_device\n"); | ||
683 | kfree(radio->buffer); | ||
684 | kfree(radio); | ||
685 | return retval; | ||
686 | } | ||
687 | |||
716 | radio->videodev = video_device_alloc(); | 688 | radio->videodev = video_device_alloc(); |
717 | 689 | ||
718 | if (!radio->videodev) { | 690 | if (!radio->videodev) { |
@@ -722,8 +694,11 @@ static int usb_amradio_probe(struct usb_interface *intf, | |||
722 | return -ENOMEM; | 694 | return -ENOMEM; |
723 | } | 695 | } |
724 | 696 | ||
725 | memcpy(radio->videodev, &amradio_videodev_template, | 697 | strlcpy(radio->videodev->name, v4l2_dev->name, sizeof(radio->videodev->name)); |
726 | sizeof(amradio_videodev_template)); | 698 | radio->videodev->v4l2_dev = v4l2_dev; |
699 | radio->videodev->fops = &usb_amradio_fops; | ||
700 | radio->videodev->ioctl_ops = &usb_amradio_ioctl_ops; | ||
701 | radio->videodev->release = usb_amradio_video_device_release; | ||
727 | 702 | ||
728 | radio->removed = 0; | 703 | radio->removed = 0; |
729 | radio->users = 0; | 704 | radio->users = 0; |
@@ -734,10 +709,12 @@ static int usb_amradio_probe(struct usb_interface *intf, | |||
734 | mutex_init(&radio->lock); | 709 | mutex_init(&radio->lock); |
735 | 710 | ||
736 | video_set_drvdata(radio->videodev, radio); | 711 | video_set_drvdata(radio->videodev, radio); |
712 | |||
737 | retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); | 713 | retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); |
738 | if (retval < 0) { | 714 | if (retval < 0) { |
739 | dev_err(&intf->dev, "could not register video device\n"); | 715 | dev_err(&intf->dev, "could not register video device\n"); |
740 | video_device_release(radio->videodev); | 716 | video_device_release(radio->videodev); |
717 | v4l2_device_unregister(v4l2_dev); | ||
741 | kfree(radio->buffer); | 718 | kfree(radio->buffer); |
742 | kfree(radio); | 719 | kfree(radio); |
743 | return -EIO; | 720 | return -EIO; |
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index d1e6b01d4eca..9cb193fa6e33 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c | |||
@@ -260,20 +260,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
260 | return a->index ? -EINVAL : 0; | 260 | return a->index ? -EINVAL : 0; |
261 | } | 261 | } |
262 | 262 | ||
263 | static int rtrack2_open(struct file *file) | ||
264 | { | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int rtrack2_release(struct file *file) | ||
269 | { | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static const struct v4l2_file_operations rtrack2_fops = { | 263 | static const struct v4l2_file_operations rtrack2_fops = { |
274 | .owner = THIS_MODULE, | 264 | .owner = THIS_MODULE, |
275 | .open = rtrack2_open, | ||
276 | .release = rtrack2_release, | ||
277 | .ioctl = video_ioctl2, | 265 | .ioctl = video_ioctl2, |
278 | }; | 266 | }; |
279 | 267 | ||
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index f4784f0d1a88..1dba8f0832a0 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -260,20 +260,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
260 | return a->index ? -EINVAL : 0; | 260 | return a->index ? -EINVAL : 0; |
261 | } | 261 | } |
262 | 262 | ||
263 | static int fmi_open(struct file *file) | ||
264 | { | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int fmi_release(struct file *file) | ||
269 | { | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static const struct v4l2_file_operations fmi_fops = { | 263 | static const struct v4l2_file_operations fmi_fops = { |
274 | .owner = THIS_MODULE, | 264 | .owner = THIS_MODULE, |
275 | .open = fmi_open, | ||
276 | .release = fmi_release, | ||
277 | .ioctl = video_ioctl2, | 265 | .ioctl = video_ioctl2, |
278 | }; | 266 | }; |
279 | 267 | ||
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index 0ba9d88a80fc..c09ca8600ea1 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c | |||
@@ -377,20 +377,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
377 | return a->index ? -EINVAL : 0; | 377 | return a->index ? -EINVAL : 0; |
378 | } | 378 | } |
379 | 379 | ||
380 | static int fmr2_open(struct file *file) | ||
381 | { | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static int fmr2_release(struct file *file) | ||
386 | { | ||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | static const struct v4l2_file_operations fmr2_fops = { | 380 | static const struct v4l2_file_operations fmr2_fops = { |
391 | .owner = THIS_MODULE, | 381 | .owner = THIS_MODULE, |
392 | .open = fmr2_open, | ||
393 | .release = fmr2_release, | ||
394 | .ioctl = video_ioctl2, | 382 | .ioctl = video_ioctl2, |
395 | }; | 383 | }; |
396 | 384 | ||
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 713e242ba8b2..92c297796a9f 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -1686,7 +1686,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1686 | /* show some infos about the specific si470x device */ | 1686 | /* show some infos about the specific si470x device */ |
1687 | if (si470x_get_all_registers(radio) < 0) { | 1687 | if (si470x_get_all_registers(radio) < 0) { |
1688 | retval = -EIO; | 1688 | retval = -EIO; |
1689 | goto err_all; | 1689 | goto err_video; |
1690 | } | 1690 | } |
1691 | printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n", | 1691 | printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n", |
1692 | radio->registers[DEVICEID], radio->registers[CHIPID]); | 1692 | radio->registers[DEVICEID], radio->registers[CHIPID]); |
@@ -1694,7 +1694,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1694 | /* get software and hardware versions */ | 1694 | /* get software and hardware versions */ |
1695 | if (si470x_get_scratch_page_versions(radio) < 0) { | 1695 | if (si470x_get_scratch_page_versions(radio) < 0) { |
1696 | retval = -EIO; | 1696 | retval = -EIO; |
1697 | goto err_all; | 1697 | goto err_video; |
1698 | } | 1698 | } |
1699 | printk(KERN_INFO DRIVER_NAME | 1699 | printk(KERN_INFO DRIVER_NAME |
1700 | ": software version %d, hardware version %d\n", | 1700 | ": software version %d, hardware version %d\n", |
@@ -1727,7 +1727,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1727 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); | 1727 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); |
1728 | if (!radio->buffer) { | 1728 | if (!radio->buffer) { |
1729 | retval = -EIO; | 1729 | retval = -EIO; |
1730 | goto err_all; | 1730 | goto err_video; |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | /* rds buffer configuration */ | 1733 | /* rds buffer configuration */ |
@@ -1749,8 +1749,9 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1749 | 1749 | ||
1750 | return 0; | 1750 | return 0; |
1751 | err_all: | 1751 | err_all: |
1752 | video_device_release(radio->videodev); | ||
1753 | kfree(radio->buffer); | 1752 | kfree(radio->buffer); |
1753 | err_video: | ||
1754 | video_device_release(radio->videodev); | ||
1754 | err_radio: | 1755 | err_radio: |
1755 | kfree(radio); | 1756 | kfree(radio); |
1756 | err_initial: | 1757 | err_initial: |
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index 5b007f5c74b2..699db9acaaf7 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c | |||
@@ -332,20 +332,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
332 | return a->index ? -EINVAL : 0; | 332 | return a->index ? -EINVAL : 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | static int terratec_open(struct file *file) | ||
336 | { | ||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static int terratec_release(struct file *file) | ||
341 | { | ||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static const struct v4l2_file_operations terratec_fops = { | 335 | static const struct v4l2_file_operations terratec_fops = { |
346 | .owner = THIS_MODULE, | 336 | .owner = THIS_MODULE, |
347 | .open = terratec_open, | ||
348 | .release = terratec_release, | ||
349 | .ioctl = video_ioctl2, | 337 | .ioctl = video_ioctl2, |
350 | }; | 338 | }; |
351 | 339 | ||
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c index d1be6492a07b..6f9ecc359356 100644 --- a/drivers/media/radio/radio-trust.c +++ b/drivers/media/radio/radio-trust.c | |||
@@ -338,20 +338,8 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
338 | return a->index ? -EINVAL : 0; | 338 | return a->index ? -EINVAL : 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | static int trust_open(struct file *file) | ||
342 | { | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static int trust_release(struct file *file) | ||
347 | { | ||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static const struct v4l2_file_operations trust_fops = { | 341 | static const struct v4l2_file_operations trust_fops = { |
352 | .owner = THIS_MODULE, | 342 | .owner = THIS_MODULE, |
353 | .open = trust_open, | ||
354 | .release = trust_release, | ||
355 | .ioctl = video_ioctl2, | 343 | .ioctl = video_ioctl2, |
356 | }; | 344 | }; |
357 | 345 | ||
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c index 92d923c7f360..3a98f1399495 100644 --- a/drivers/media/radio/radio-typhoon.c +++ b/drivers/media/radio/radio-typhoon.c | |||
@@ -314,20 +314,8 @@ static int vidioc_log_status(struct file *file, void *priv) | |||
314 | return 0; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | static int typhoon_open(struct file *file) | ||
318 | { | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static int typhoon_release(struct file *file) | ||
323 | { | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static const struct v4l2_file_operations typhoon_fops = { | 317 | static const struct v4l2_file_operations typhoon_fops = { |
328 | .owner = THIS_MODULE, | 318 | .owner = THIS_MODULE, |
329 | .open = typhoon_open, | ||
330 | .release = typhoon_release, | ||
331 | .ioctl = video_ioctl2, | 319 | .ioctl = video_ioctl2, |
332 | }; | 320 | }; |
333 | 321 | ||
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 1f85f2024dc0..80e98b6422fe 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -370,21 +370,9 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
370 | return a->index ? -EINVAL : 0; | 370 | return a->index ? -EINVAL : 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | static int zoltrix_open(struct file *file) | ||
374 | { | ||
375 | return 0; | ||
376 | } | ||
377 | |||
378 | static int zoltrix_release(struct file *file) | ||
379 | { | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static const struct v4l2_file_operations zoltrix_fops = | 373 | static const struct v4l2_file_operations zoltrix_fops = |
384 | { | 374 | { |
385 | .owner = THIS_MODULE, | 375 | .owner = THIS_MODULE, |
386 | .open = zoltrix_open, | ||
387 | .release = zoltrix_release, | ||
388 | .ioctl = video_ioctl2, | 376 | .ioctl = video_ioctl2, |
389 | }; | 377 | }; |
390 | 378 | ||
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 76bad5819592..9d48da2fb013 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -746,6 +746,18 @@ config SOC_CAMERA_OV772X | |||
746 | help | 746 | help |
747 | This is a ov772x camera driver | 747 | This is a ov772x camera driver |
748 | 748 | ||
749 | config MX1_VIDEO | ||
750 | bool | ||
751 | |||
752 | config VIDEO_MX1 | ||
753 | tristate "i.MX1/i.MXL CMOS Sensor Interface driver" | ||
754 | depends on VIDEO_DEV && ARCH_MX1 && SOC_CAMERA | ||
755 | select FIQ | ||
756 | select VIDEOBUF_DMA_CONTIG | ||
757 | select MX1_VIDEO | ||
758 | ---help--- | ||
759 | This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface | ||
760 | |||
749 | config VIDEO_MX3 | 761 | config VIDEO_MX3 |
750 | tristate "i.MX3x Camera Sensor Interface driver" | 762 | tristate "i.MX3x Camera Sensor Interface driver" |
751 | depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA | 763 | depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA |
@@ -795,6 +807,8 @@ source "drivers/media/video/hdpvr/Kconfig" | |||
795 | 807 | ||
796 | source "drivers/media/video/em28xx/Kconfig" | 808 | source "drivers/media/video/em28xx/Kconfig" |
797 | 809 | ||
810 | source "drivers/media/video/cx231xx/Kconfig" | ||
811 | |||
798 | source "drivers/media/video/usbvision/Kconfig" | 812 | source "drivers/media/video/usbvision/Kconfig" |
799 | 813 | ||
800 | source "drivers/media/video/usbvideo/Kconfig" | 814 | source "drivers/media/video/usbvideo/Kconfig" |
@@ -904,5 +918,4 @@ config USB_S2255 | |||
904 | This driver can be compiled as a module, called s2255drv. | 918 | This driver can be compiled as a module, called s2255drv. |
905 | 919 | ||
906 | endif # V4L_USB_DRIVERS | 920 | endif # V4L_USB_DRIVERS |
907 | |||
908 | endif # VIDEO_CAPTURE_DRIVERS | 921 | endif # VIDEO_CAPTURE_DRIVERS |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index b9046744463b..3f1a0350a569 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -10,7 +10,7 @@ stkwebcam-objs := stk-webcam.o stk-sensor.o | |||
10 | 10 | ||
11 | omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o | 11 | omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o |
12 | 12 | ||
13 | videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o | 13 | videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o |
14 | 14 | ||
15 | obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o | 15 | obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o |
16 | ifeq ($(CONFIG_COMPAT),y) | 16 | ifeq ($(CONFIG_COMPAT),y) |
@@ -67,6 +67,7 @@ obj-$(CONFIG_VIDEO_MEYE) += meye.o | |||
67 | obj-$(CONFIG_VIDEO_SAA7134) += saa7134/ | 67 | obj-$(CONFIG_VIDEO_SAA7134) += saa7134/ |
68 | obj-$(CONFIG_VIDEO_CX88) += cx88/ | 68 | obj-$(CONFIG_VIDEO_CX88) += cx88/ |
69 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ | 69 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ |
70 | obj-$(CONFIG_VIDEO_CX231XX) += cx231xx/ | ||
70 | obj-$(CONFIG_VIDEO_USBVISION) += usbvision/ | 71 | obj-$(CONFIG_VIDEO_USBVISION) += usbvision/ |
71 | obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o | 72 | obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o |
72 | obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o | 73 | obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o |
@@ -133,6 +134,7 @@ obj-$(CONFIG_VIDEO_CX18) += cx18/ | |||
133 | obj-$(CONFIG_VIDEO_VIVI) += vivi.o | 134 | obj-$(CONFIG_VIDEO_VIVI) += vivi.o |
134 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ | 135 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ |
135 | 136 | ||
137 | obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o | ||
136 | obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o | 138 | obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o |
137 | obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o | 139 | obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o |
138 | obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o | 140 | obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 873c30a41bd7..97b003449c91 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -219,18 +219,19 @@ static int adv7170_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static int adv7170_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 222 | static int adv7170_s_routing(struct v4l2_subdev *sd, |
223 | u32 input, u32 output, u32 config) | ||
223 | { | 224 | { |
224 | struct adv7170 *encoder = to_adv7170(sd); | 225 | struct adv7170 *encoder = to_adv7170(sd); |
225 | 226 | ||
226 | /* RJ: route->input = 0: input is from decoder | 227 | /* RJ: input = 0: input is from decoder |
227 | route->input = 1: input is from ZR36060 | 228 | input = 1: input is from ZR36060 |
228 | route->input = 2: color bar */ | 229 | input = 2: color bar */ |
229 | 230 | ||
230 | v4l2_dbg(1, debug, sd, "set input from %s\n", | 231 | v4l2_dbg(1, debug, sd, "set input from %s\n", |
231 | route->input == 0 ? "decoder" : "ZR36060"); | 232 | input == 0 ? "decoder" : "ZR36060"); |
232 | 233 | ||
233 | switch (route->input) { | 234 | switch (input) { |
234 | case 0: | 235 | case 0: |
235 | adv7170_write(sd, 0x01, 0x20); | 236 | adv7170_write(sd, 0x01, 0x20); |
236 | adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */ | 237 | adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */ |
@@ -250,11 +251,11 @@ static int adv7170_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing * | |||
250 | break; | 251 | break; |
251 | 252 | ||
252 | default: | 253 | default: |
253 | v4l2_dbg(1, debug, sd, "illegal input: %d\n", route->input); | 254 | v4l2_dbg(1, debug, sd, "illegal input: %d\n", input); |
254 | return -EINVAL; | 255 | return -EINVAL; |
255 | } | 256 | } |
256 | v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[route->input]); | 257 | v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]); |
257 | encoder->input = route->input; | 258 | encoder->input = input; |
258 | return 0; | 259 | return 0; |
259 | } | 260 | } |
260 | 261 | ||
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index ff1210303295..cf8c06c85ded 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -237,15 +237,16 @@ static int adv7175_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
237 | return 0; | 237 | return 0; |
238 | } | 238 | } |
239 | 239 | ||
240 | static int adv7175_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 240 | static int adv7175_s_routing(struct v4l2_subdev *sd, |
241 | u32 input, u32 output, u32 config) | ||
241 | { | 242 | { |
242 | struct adv7175 *encoder = to_adv7175(sd); | 243 | struct adv7175 *encoder = to_adv7175(sd); |
243 | 244 | ||
244 | /* RJ: route->input = 0: input is from decoder | 245 | /* RJ: input = 0: input is from decoder |
245 | route->input = 1: input is from ZR36060 | 246 | input = 1: input is from ZR36060 |
246 | route->input = 2: color bar */ | 247 | input = 2: color bar */ |
247 | 248 | ||
248 | switch (route->input) { | 249 | switch (input) { |
249 | case 0: | 250 | case 0: |
250 | adv7175_write(sd, 0x01, 0x00); | 251 | adv7175_write(sd, 0x01, 0x00); |
251 | 252 | ||
@@ -288,11 +289,11 @@ static int adv7175_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing * | |||
288 | break; | 289 | break; |
289 | 290 | ||
290 | default: | 291 | default: |
291 | v4l2_dbg(1, debug, sd, "illegal input: %d\n", route->input); | 292 | v4l2_dbg(1, debug, sd, "illegal input: %d\n", input); |
292 | return -EINVAL; | 293 | return -EINVAL; |
293 | } | 294 | } |
294 | v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[route->input]); | 295 | v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]); |
295 | encoder->input = route->input; | 296 | encoder->input = input; |
296 | return 0; | 297 | return 0; |
297 | } | 298 | } |
298 | 299 | ||
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig index 05cdf494dfb0..0c3a5ba0e857 100644 --- a/drivers/media/video/au0828/Kconfig +++ b/drivers/media/video/au0828/Kconfig | |||
@@ -4,6 +4,7 @@ config VIDEO_AU0828 | |||
4 | depends on I2C && INPUT && DVB_CORE && USB && VIDEO_V4L2 | 4 | depends on I2C && INPUT && DVB_CORE && USB && VIDEO_V4L2 |
5 | select I2C_ALGOBIT | 5 | select I2C_ALGOBIT |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
7 | select VIDEOBUF_VMALLOC | ||
7 | select DVB_AU8522 if !DVB_FE_CUSTOMISE | 8 | select DVB_AU8522 if !DVB_FE_CUSTOMISE |
8 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE | 9 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE |
9 | select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE | 10 | select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE |
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index 1aabaa7e55bb..053bbe8c8e3a 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c | |||
@@ -46,6 +46,7 @@ struct au0828_board au0828_boards[] = { | |||
46 | .name = "Hauppauge HVR850", | 46 | .name = "Hauppauge HVR850", |
47 | .tuner_type = TUNER_XC5000, | 47 | .tuner_type = TUNER_XC5000, |
48 | .tuner_addr = 0x61, | 48 | .tuner_addr = 0x61, |
49 | .i2c_clk_divider = AU0828_I2C_CLK_30KHZ, | ||
49 | .input = { | 50 | .input = { |
50 | { | 51 | { |
51 | .type = AU0828_VMUX_TELEVISION, | 52 | .type = AU0828_VMUX_TELEVISION, |
@@ -70,6 +71,13 @@ struct au0828_board au0828_boards[] = { | |||
70 | .name = "Hauppauge HVR950Q", | 71 | .name = "Hauppauge HVR950Q", |
71 | .tuner_type = TUNER_XC5000, | 72 | .tuner_type = TUNER_XC5000, |
72 | .tuner_addr = 0x61, | 73 | .tuner_addr = 0x61, |
74 | /* The au0828 hardware i2c implementation does not properly | ||
75 | support the xc5000's i2c clock stretching. So we need to | ||
76 | lower the clock frequency enough where the 15us clock | ||
77 | stretch fits inside of a normal clock cycle, or else the | ||
78 | au0828 fails to set the STOP bit. A 30 KHz clock puts the | ||
79 | clock pulse width at 18us */ | ||
80 | .i2c_clk_divider = AU0828_I2C_CLK_30KHZ, | ||
73 | .input = { | 81 | .input = { |
74 | { | 82 | { |
75 | .type = AU0828_VMUX_TELEVISION, | 83 | .type = AU0828_VMUX_TELEVISION, |
@@ -94,16 +102,19 @@ struct au0828_board au0828_boards[] = { | |||
94 | .name = "Hauppauge HVR950Q rev xxF8", | 102 | .name = "Hauppauge HVR950Q rev xxF8", |
95 | .tuner_type = UNSET, | 103 | .tuner_type = UNSET, |
96 | .tuner_addr = ADDR_UNSET, | 104 | .tuner_addr = ADDR_UNSET, |
105 | .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, | ||
97 | }, | 106 | }, |
98 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { | 107 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { |
99 | .name = "DViCO FusionHDTV USB", | 108 | .name = "DViCO FusionHDTV USB", |
100 | .tuner_type = UNSET, | 109 | .tuner_type = UNSET, |
101 | .tuner_addr = ADDR_UNSET, | 110 | .tuner_addr = ADDR_UNSET, |
111 | .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, | ||
102 | }, | 112 | }, |
103 | [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { | 113 | [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { |
104 | .name = "Hauppauge Woodbury", | 114 | .name = "Hauppauge Woodbury", |
105 | .tuner_type = UNSET, | 115 | .tuner_type = UNSET, |
106 | .tuner_addr = ADDR_UNSET, | 116 | .tuner_addr = ADDR_UNSET, |
117 | .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, | ||
107 | }, | 118 | }, |
108 | }; | 119 | }; |
109 | 120 | ||
@@ -200,8 +211,8 @@ void au0828_card_setup(struct au0828_dev *dev) | |||
200 | /* Load the analog demodulator driver (note this would need to | 211 | /* Load the analog demodulator driver (note this would need to |
201 | be abstracted out if we ever need to support a different | 212 | be abstracted out if we ever need to support a different |
202 | demod) */ | 213 | demod) */ |
203 | sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "au8522", "au8522", | 214 | sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
204 | 0x8e >> 1); | 215 | "au8522", "au8522", 0x8e >> 1); |
205 | if (sd == NULL) | 216 | if (sd == NULL) |
206 | printk(KERN_ERR "analog subdev registration failed\n"); | 217 | printk(KERN_ERR "analog subdev registration failed\n"); |
207 | } | 218 | } |
@@ -209,8 +220,8 @@ void au0828_card_setup(struct au0828_dev *dev) | |||
209 | /* Setup tuners */ | 220 | /* Setup tuners */ |
210 | if (dev->board.tuner_type != TUNER_ABSENT) { | 221 | if (dev->board.tuner_type != TUNER_ABSENT) { |
211 | /* Load the tuner module, which does the attach */ | 222 | /* Load the tuner module, which does the attach */ |
212 | sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner", | 223 | sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
213 | dev->board.tuner_addr); | 224 | "tuner", "tuner", dev->board.tuner_addr); |
214 | if (sd == NULL) | 225 | if (sd == NULL) |
215 | printk(KERN_ERR "tuner subdev registration fail\n"); | 226 | printk(KERN_ERR "tuner subdev registration fail\n"); |
216 | 227 | ||
diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c index 8c761d164442..4cee0b92eeee 100644 --- a/drivers/media/video/au0828/au0828-core.c +++ b/drivers/media/video/au0828/au0828-core.c | |||
@@ -36,8 +36,6 @@ int au0828_debug; | |||
36 | module_param_named(debug, au0828_debug, int, 0644); | 36 | module_param_named(debug, au0828_debug, int, 0644); |
37 | MODULE_PARM_DESC(debug, "enable debug messages"); | 37 | MODULE_PARM_DESC(debug, "enable debug messages"); |
38 | 38 | ||
39 | static atomic_t au0828_instance = ATOMIC_INIT(0); | ||
40 | |||
41 | #define _AU0828_BULKPIPE 0x03 | 39 | #define _AU0828_BULKPIPE 0x03 |
42 | #define _BULKPIPESIZE 0xffff | 40 | #define _BULKPIPESIZE 0xffff |
43 | 41 | ||
@@ -169,7 +167,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface) | |||
169 | static int au0828_usb_probe(struct usb_interface *interface, | 167 | static int au0828_usb_probe(struct usb_interface *interface, |
170 | const struct usb_device_id *id) | 168 | const struct usb_device_id *id) |
171 | { | 169 | { |
172 | int ifnum, retval, i; | 170 | int ifnum, retval; |
173 | struct au0828_dev *dev; | 171 | struct au0828_dev *dev; |
174 | struct usb_device *usbdev = interface_to_usbdev(interface); | 172 | struct usb_device *usbdev = interface_to_usbdev(interface); |
175 | 173 | ||
@@ -197,10 +195,7 @@ static int au0828_usb_probe(struct usb_interface *interface, | |||
197 | usb_set_intfdata(interface, dev); | 195 | usb_set_intfdata(interface, dev); |
198 | 196 | ||
199 | /* Create the v4l2_device */ | 197 | /* Create the v4l2_device */ |
200 | i = atomic_inc_return(&au0828_instance) - 1; | 198 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
201 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d", | ||
202 | "au0828", i); | ||
203 | retval = v4l2_device_register(&dev->usbdev->dev, &dev->v4l2_dev); | ||
204 | if (retval) { | 199 | if (retval) { |
205 | printk(KERN_ERR "%s() v4l2_device_register failed\n", | 200 | printk(KERN_ERR "%s() v4l2_device_register failed\n", |
206 | __func__); | 201 | __func__); |
diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c index f9a958d0aef1..13e494365e70 100644 --- a/drivers/media/video/au0828/au0828-i2c.c +++ b/drivers/media/video/au0828/au0828-i2c.c | |||
@@ -39,13 +39,15 @@ MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | |||
39 | static inline int i2c_slave_did_write_ack(struct i2c_adapter *i2c_adap) | 39 | static inline int i2c_slave_did_write_ack(struct i2c_adapter *i2c_adap) |
40 | { | 40 | { |
41 | struct au0828_dev *dev = i2c_adap->algo_data; | 41 | struct au0828_dev *dev = i2c_adap->algo_data; |
42 | return au0828_read(dev, REG_201) & 0x08 ? 0 : 1; | 42 | return au0828_read(dev, AU0828_I2C_STATUS_201) & |
43 | AU0828_I2C_STATUS_NO_WRITE_ACK ? 0 : 1; | ||
43 | } | 44 | } |
44 | 45 | ||
45 | static inline int i2c_slave_did_read_ack(struct i2c_adapter *i2c_adap) | 46 | static inline int i2c_slave_did_read_ack(struct i2c_adapter *i2c_adap) |
46 | { | 47 | { |
47 | struct au0828_dev *dev = i2c_adap->algo_data; | 48 | struct au0828_dev *dev = i2c_adap->algo_data; |
48 | return au0828_read(dev, REG_201) & 0x02 ? 0 : 1; | 49 | return au0828_read(dev, AU0828_I2C_STATUS_201) & |
50 | AU0828_I2C_STATUS_NO_READ_ACK ? 0 : 1; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) | 53 | static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) |
@@ -67,7 +69,8 @@ static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) | |||
67 | static inline int i2c_is_read_busy(struct i2c_adapter *i2c_adap) | 69 | static inline int i2c_is_read_busy(struct i2c_adapter *i2c_adap) |
68 | { | 70 | { |
69 | struct au0828_dev *dev = i2c_adap->algo_data; | 71 | struct au0828_dev *dev = i2c_adap->algo_data; |
70 | return au0828_read(dev, REG_201) & 0x01 ? 0 : 1; | 72 | return au0828_read(dev, AU0828_I2C_STATUS_201) & |
73 | AU0828_I2C_STATUS_READ_DONE ? 0 : 1; | ||
71 | } | 74 | } |
72 | 75 | ||
73 | static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) | 76 | static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) |
@@ -89,7 +92,8 @@ static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) | |||
89 | static inline int i2c_is_write_done(struct i2c_adapter *i2c_adap) | 92 | static inline int i2c_is_write_done(struct i2c_adapter *i2c_adap) |
90 | { | 93 | { |
91 | struct au0828_dev *dev = i2c_adap->algo_data; | 94 | struct au0828_dev *dev = i2c_adap->algo_data; |
92 | return au0828_read(dev, REG_201) & 0x04 ? 1 : 0; | 95 | return au0828_read(dev, AU0828_I2C_STATUS_201) & |
96 | AU0828_I2C_STATUS_WRITE_DONE ? 1 : 0; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) | 99 | static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) |
@@ -111,7 +115,8 @@ static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) | |||
111 | static inline int i2c_is_busy(struct i2c_adapter *i2c_adap) | 115 | static inline int i2c_is_busy(struct i2c_adapter *i2c_adap) |
112 | { | 116 | { |
113 | struct au0828_dev *dev = i2c_adap->algo_data; | 117 | struct au0828_dev *dev = i2c_adap->algo_data; |
114 | return au0828_read(dev, REG_201) & 0x10 ? 1 : 0; | 118 | return au0828_read(dev, AU0828_I2C_STATUS_201) & |
119 | AU0828_I2C_STATUS_BUSY ? 1 : 0; | ||
115 | } | 120 | } |
116 | 121 | ||
117 | static int i2c_wait_done(struct i2c_adapter *i2c_adap) | 122 | static int i2c_wait_done(struct i2c_adapter *i2c_adap) |
@@ -139,19 +144,14 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
139 | 144 | ||
140 | dprintk(4, "%s()\n", __func__); | 145 | dprintk(4, "%s()\n", __func__); |
141 | 146 | ||
142 | au0828_write(dev, REG_2FF, 0x01); | 147 | au0828_write(dev, AU0828_I2C_MULTIBYTE_MODE_2FF, 0x01); |
143 | 148 | ||
144 | /* FIXME: There is a problem with i2c communications with xc5000 that | 149 | /* Set the I2C clock */ |
145 | requires us to slow down the i2c clock until we have a better | 150 | au0828_write(dev, AU0828_I2C_CLK_DIVIDER_202, |
146 | strategy (such as using the secondary i2c bus to do firmware | 151 | dev->board.i2c_clk_divider); |
147 | loading */ | ||
148 | if ((msg->addr << 1) == 0xc2) | ||
149 | au0828_write(dev, REG_202, 0x40); | ||
150 | else | ||
151 | au0828_write(dev, REG_202, 0x07); | ||
152 | 152 | ||
153 | /* Hardware needs 8 bit addresses */ | 153 | /* Hardware needs 8 bit addresses */ |
154 | au0828_write(dev, REG_203, msg->addr << 1); | 154 | au0828_write(dev, AU0828_I2C_DEST_ADDR_203, msg->addr << 1); |
155 | 155 | ||
156 | dprintk(4, "SEND: %02x\n", msg->addr); | 156 | dprintk(4, "SEND: %02x\n", msg->addr); |
157 | 157 | ||
@@ -163,7 +163,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
163 | actual bytes to the bus, just do a read check. This is | 163 | actual bytes to the bus, just do a read check. This is |
164 | consistent with how I saw i2c device checking done in the | 164 | consistent with how I saw i2c device checking done in the |
165 | USB trace of the Windows driver */ | 165 | USB trace of the Windows driver */ |
166 | au0828_write(dev, REG_200, 0x20); | 166 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
167 | AU0828_I2C_TRIGGER_READ); | ||
168 | |||
167 | if (!i2c_wait_done(i2c_adap)) | 169 | if (!i2c_wait_done(i2c_adap)) |
168 | return -EIO; | 170 | return -EIO; |
169 | 171 | ||
@@ -177,7 +179,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
177 | 179 | ||
178 | dprintk(4, " %02x\n", msg->buf[i]); | 180 | dprintk(4, " %02x\n", msg->buf[i]); |
179 | 181 | ||
180 | au0828_write(dev, REG_205, msg->buf[i]); | 182 | au0828_write(dev, AU0828_I2C_WRITE_FIFO_205, msg->buf[i]); |
181 | 183 | ||
182 | strobe++; | 184 | strobe++; |
183 | i++; | 185 | i++; |
@@ -186,9 +188,12 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
186 | 188 | ||
187 | /* Strobe the byte into the bus */ | 189 | /* Strobe the byte into the bus */ |
188 | if (i < msg->len) | 190 | if (i < msg->len) |
189 | au0828_write(dev, REG_200, 0x41); | 191 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
192 | AU0828_I2C_TRIGGER_WRITE | | ||
193 | AU0828_I2C_TRIGGER_HOLD); | ||
190 | else | 194 | else |
191 | au0828_write(dev, REG_200, 0x01); | 195 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
196 | AU0828_I2C_TRIGGER_WRITE); | ||
192 | 197 | ||
193 | /* Reset strobe trigger */ | 198 | /* Reset strobe trigger */ |
194 | strobe = 0; | 199 | strobe = 0; |
@@ -216,25 +221,22 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
216 | 221 | ||
217 | dprintk(4, "%s()\n", __func__); | 222 | dprintk(4, "%s()\n", __func__); |
218 | 223 | ||
219 | au0828_write(dev, REG_2FF, 0x01); | 224 | au0828_write(dev, AU0828_I2C_MULTIBYTE_MODE_2FF, 0x01); |
220 | 225 | ||
221 | /* FIXME: There is a problem with i2c communications with xc5000 that | 226 | /* Set the I2C clock */ |
222 | requires us to slow down the i2c clock until we have a better | 227 | au0828_write(dev, AU0828_I2C_CLK_DIVIDER_202, |
223 | strategy (such as using the secondary i2c bus to do firmware | 228 | dev->board.i2c_clk_divider); |
224 | loading */ | ||
225 | if ((msg->addr << 1) == 0xc2) | ||
226 | au0828_write(dev, REG_202, 0x40); | ||
227 | else | ||
228 | au0828_write(dev, REG_202, 0x07); | ||
229 | 229 | ||
230 | /* Hardware needs 8 bit addresses */ | 230 | /* Hardware needs 8 bit addresses */ |
231 | au0828_write(dev, REG_203, msg->addr << 1); | 231 | au0828_write(dev, AU0828_I2C_DEST_ADDR_203, msg->addr << 1); |
232 | 232 | ||
233 | dprintk(4, " RECV:\n"); | 233 | dprintk(4, " RECV:\n"); |
234 | 234 | ||
235 | /* Deal with i2c_scan */ | 235 | /* Deal with i2c_scan */ |
236 | if (msg->len == 0) { | 236 | if (msg->len == 0) { |
237 | au0828_write(dev, REG_200, 0x20); | 237 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
238 | AU0828_I2C_TRIGGER_READ); | ||
239 | |||
238 | if (i2c_wait_read_ack(i2c_adap)) | 240 | if (i2c_wait_read_ack(i2c_adap)) |
239 | return -EIO; | 241 | return -EIO; |
240 | return 0; | 242 | return 0; |
@@ -245,14 +247,18 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
245 | i++; | 247 | i++; |
246 | 248 | ||
247 | if (i < msg->len) | 249 | if (i < msg->len) |
248 | au0828_write(dev, REG_200, 0x60); | 250 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
251 | AU0828_I2C_TRIGGER_READ | | ||
252 | AU0828_I2C_TRIGGER_HOLD); | ||
249 | else | 253 | else |
250 | au0828_write(dev, REG_200, 0x20); | 254 | au0828_write(dev, AU0828_I2C_TRIGGER_200, |
255 | AU0828_I2C_TRIGGER_READ); | ||
251 | 256 | ||
252 | if (!i2c_wait_read_done(i2c_adap)) | 257 | if (!i2c_wait_read_done(i2c_adap)) |
253 | return -EIO; | 258 | return -EIO; |
254 | 259 | ||
255 | msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; | 260 | msg->buf[i-1] = au0828_read(dev, AU0828_I2C_READ_FIFO_209) & |
261 | 0xff; | ||
256 | 262 | ||
257 | dprintk(4, " %02x\n", msg->buf[i-1]); | 263 | dprintk(4, " %02x\n", msg->buf[i-1]); |
258 | } | 264 | } |
diff --git a/drivers/media/video/au0828/au0828-reg.h b/drivers/media/video/au0828/au0828-reg.h index b15e4a3b6fc0..c39f3d2b721e 100644 --- a/drivers/media/video/au0828/au0828-reg.h +++ b/drivers/media/video/au0828/au0828-reg.h | |||
@@ -30,15 +30,36 @@ | |||
30 | #define AU0828_SENSORCTRL_100 0x100 | 30 | #define AU0828_SENSORCTRL_100 0x100 |
31 | #define AU0828_SENSORCTRL_VBI_103 0x103 | 31 | #define AU0828_SENSORCTRL_VBI_103 0x103 |
32 | 32 | ||
33 | #define REG_200 0x200 | 33 | /* I2C registers */ |
34 | #define REG_201 0x201 | 34 | #define AU0828_I2C_TRIGGER_200 0x200 |
35 | #define REG_202 0x202 | 35 | #define AU0828_I2C_STATUS_201 0x201 |
36 | #define REG_203 0x203 | 36 | #define AU0828_I2C_CLK_DIVIDER_202 0x202 |
37 | #define REG_205 0x205 | 37 | #define AU0828_I2C_DEST_ADDR_203 0x203 |
38 | #define REG_209 0x209 | 38 | #define AU0828_I2C_WRITE_FIFO_205 0x205 |
39 | #define REG_2FF 0x2ff | 39 | #define AU0828_I2C_READ_FIFO_209 0x209 |
40 | #define AU0828_I2C_MULTIBYTE_MODE_2FF 0x2ff | ||
40 | 41 | ||
41 | /* Audio registers */ | 42 | /* Audio registers */ |
42 | #define AU0828_AUDIOCTRL_50C 0x50C | 43 | #define AU0828_AUDIOCTRL_50C 0x50C |
43 | 44 | ||
44 | #define REG_600 0x600 | 45 | #define REG_600 0x600 |
46 | |||
47 | /*********************************************************************/ | ||
48 | /* Here are constants for values associated with the above registers */ | ||
49 | |||
50 | /* I2C Trigger (Reg 0x200) */ | ||
51 | #define AU0828_I2C_TRIGGER_WRITE 0x01 | ||
52 | #define AU0828_I2C_TRIGGER_READ 0x20 | ||
53 | #define AU0828_I2C_TRIGGER_HOLD 0x40 | ||
54 | |||
55 | /* I2C Status (Reg 0x201) */ | ||
56 | #define AU0828_I2C_STATUS_READ_DONE 0x01 | ||
57 | #define AU0828_I2C_STATUS_NO_READ_ACK 0x02 | ||
58 | #define AU0828_I2C_STATUS_WRITE_DONE 0x04 | ||
59 | #define AU0828_I2C_STATUS_NO_WRITE_ACK 0x08 | ||
60 | #define AU0828_I2C_STATUS_BUSY 0x10 | ||
61 | |||
62 | /* I2C Clock Divider (Reg 0x202) */ | ||
63 | #define AU0828_I2C_CLK_250KHZ 0x07 | ||
64 | #define AU0828_I2C_CLK_100KHZ 0x14 | ||
65 | #define AU0828_I2C_CLK_30KHZ 0x40 | ||
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c index f7ad4958b94e..27bedc6c7791 100644 --- a/drivers/media/video/au0828/au0828-video.c +++ b/drivers/media/video/au0828/au0828-video.c | |||
@@ -1100,7 +1100,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm) | |||
1100 | have to make the au0828 bridge adjust the size of its capture | 1100 | have to make the au0828 bridge adjust the size of its capture |
1101 | buffer, which is currently hardcoded at 720x480 */ | 1101 | buffer, which is currently hardcoded at 720x480 */ |
1102 | 1102 | ||
1103 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_std, *norm); | 1103 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, *norm); |
1104 | return 0; | 1104 | return 0; |
1105 | } | 1105 | } |
1106 | 1106 | ||
@@ -1154,7 +1154,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) | |||
1154 | struct au0828_fh *fh = priv; | 1154 | struct au0828_fh *fh = priv; |
1155 | struct au0828_dev *dev = fh->dev; | 1155 | struct au0828_dev *dev = fh->dev; |
1156 | int i; | 1156 | int i; |
1157 | struct v4l2_routing route; | ||
1158 | 1157 | ||
1159 | dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__, | 1158 | dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__, |
1160 | index); | 1159 | index); |
@@ -1180,9 +1179,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) | |||
1180 | break; | 1179 | break; |
1181 | } | 1180 | } |
1182 | 1181 | ||
1183 | route.input = AUVI_INPUT(index).vmux; | 1182 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, |
1184 | route.output = 0; | 1183 | AUVI_INPUT(index).vmux, 0, 0); |
1185 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, &route); | ||
1186 | 1184 | ||
1187 | for (i = 0; i < AU0828_MAX_INPUT; i++) { | 1185 | for (i = 0; i < AU0828_MAX_INPUT; i++) { |
1188 | int enable = 0; | 1186 | int enable = 0; |
@@ -1205,8 +1203,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) | |||
1205 | } | 1203 | } |
1206 | } | 1204 | } |
1207 | 1205 | ||
1208 | route.input = AUVI_INPUT(index).amux; | 1206 | v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, |
1209 | v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, &route); | 1207 | AUVI_INPUT(index).amux, 0, 0); |
1210 | return 0; | 1208 | return 0; |
1211 | } | 1209 | } |
1212 | 1210 | ||
diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h index 6ed1a6129731..b977915efbd0 100644 --- a/drivers/media/video/au0828/au0828.h +++ b/drivers/media/video/au0828/au0828.h | |||
@@ -81,6 +81,7 @@ struct au0828_board { | |||
81 | char *name; | 81 | char *name; |
82 | unsigned int tuner_type; | 82 | unsigned int tuner_type; |
83 | unsigned char tuner_addr; | 83 | unsigned char tuner_addr; |
84 | unsigned char i2c_clk_divider; | ||
84 | struct au0828_input input[AU0828_MAX_INPUT]; | 85 | struct au0828_input input[AU0828_MAX_INPUT]; |
85 | 86 | ||
86 | }; | 87 | }; |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index df4516d8dcab..f9330e3529c3 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -292,21 +292,22 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std) | |||
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 295 | static int bt819_s_routing(struct v4l2_subdev *sd, |
296 | u32 input, u32 output, u32 config) | ||
296 | { | 297 | { |
297 | struct bt819 *decoder = to_bt819(sd); | 298 | struct bt819 *decoder = to_bt819(sd); |
298 | 299 | ||
299 | v4l2_dbg(1, debug, sd, "set input %x\n", route->input); | 300 | v4l2_dbg(1, debug, sd, "set input %x\n", input); |
300 | 301 | ||
301 | if (route->input < 0 || route->input > 7) | 302 | if (input < 0 || input > 7) |
302 | return -EINVAL; | 303 | return -EINVAL; |
303 | 304 | ||
304 | if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL) | 305 | if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL) |
305 | v4l2_err(sd, "no notify found!\n"); | 306 | v4l2_err(sd, "no notify found!\n"); |
306 | 307 | ||
307 | if (decoder->input != route->input) { | 308 | if (decoder->input != input) { |
308 | v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0); | 309 | v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0); |
309 | decoder->input = route->input; | 310 | decoder->input = input; |
310 | /* select mode */ | 311 | /* select mode */ |
311 | if (decoder->input == 0) { | 312 | if (decoder->input == 0) { |
312 | bt819_setbit(decoder, 0x0b, 6, 0); | 313 | bt819_setbit(decoder, 0x0b, 6, 0); |
@@ -444,9 +445,6 @@ static const struct v4l2_subdev_core_ops bt819_core_ops = { | |||
444 | .g_ctrl = bt819_g_ctrl, | 445 | .g_ctrl = bt819_g_ctrl, |
445 | .s_ctrl = bt819_s_ctrl, | 446 | .s_ctrl = bt819_s_ctrl, |
446 | .queryctrl = bt819_queryctrl, | 447 | .queryctrl = bt819_queryctrl, |
447 | }; | ||
448 | |||
449 | static const struct v4l2_subdev_tuner_ops bt819_tuner_ops = { | ||
450 | .s_std = bt819_s_std, | 448 | .s_std = bt819_s_std, |
451 | }; | 449 | }; |
452 | 450 | ||
@@ -459,7 +457,6 @@ static const struct v4l2_subdev_video_ops bt819_video_ops = { | |||
459 | 457 | ||
460 | static const struct v4l2_subdev_ops bt819_ops = { | 458 | static const struct v4l2_subdev_ops bt819_ops = { |
461 | .core = &bt819_core_ops, | 459 | .core = &bt819_core_ops, |
462 | .tuner = &bt819_tuner_ops, | ||
463 | .video = &bt819_video_ops, | 460 | .video = &bt819_video_ops, |
464 | }; | 461 | }; |
465 | 462 | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 78db39503947..d0b4d4925ff8 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -142,16 +142,17 @@ static int bt856_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | 144 | ||
145 | static int bt856_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 145 | static int bt856_s_routing(struct v4l2_subdev *sd, |
146 | u32 input, u32 output, u32 config) | ||
146 | { | 147 | { |
147 | struct bt856 *encoder = to_bt856(sd); | 148 | struct bt856 *encoder = to_bt856(sd); |
148 | 149 | ||
149 | v4l2_dbg(1, debug, sd, "set input %d\n", route->input); | 150 | v4l2_dbg(1, debug, sd, "set input %d\n", input); |
150 | 151 | ||
151 | /* We only have video bus. | 152 | /* We only have video bus. |
152 | * route->input= 0: input is from bt819 | 153 | * input= 0: input is from bt819 |
153 | * route->input= 1: input is from ZR36060 */ | 154 | * input= 1: input is from ZR36060 */ |
154 | switch (route->input) { | 155 | switch (input) { |
155 | case 0: | 156 | case 0: |
156 | bt856_setbit(encoder, 0xde, 4, 0); | 157 | bt856_setbit(encoder, 0xde, 4, 0); |
157 | bt856_setbit(encoder, 0xde, 3, 1); | 158 | bt856_setbit(encoder, 0xde, 3, 1); |
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c index 350cae4b02c3..af7e3a5bac9f 100644 --- a/drivers/media/video/bt866.c +++ b/drivers/media/video/bt866.c | |||
@@ -99,7 +99,8 @@ static int bt866_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
99 | return 0; | 99 | return 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 102 | static int bt866_s_routing(struct v4l2_subdev *sd, |
103 | u32 input, u32 output, u32 config) | ||
103 | { | 104 | { |
104 | static const __u8 init[] = { | 105 | static const __u8 init[] = { |
105 | 0xc8, 0xcc, /* CRSCALE */ | 106 | 0xc8, 0xcc, /* CRSCALE */ |
@@ -137,7 +138,7 @@ static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro | |||
137 | 138 | ||
138 | val = encoder->reg[0xdc]; | 139 | val = encoder->reg[0xdc]; |
139 | 140 | ||
140 | if (route->input == 0) | 141 | if (input == 0) |
141 | val |= 0x40; /* CBSWAP */ | 142 | val |= 0x40; /* CBSWAP */ |
142 | else | 143 | else |
143 | val &= ~0x40; /* !CBSWAP */ | 144 | val &= ~0x40; /* !CBSWAP */ |
@@ -145,15 +146,15 @@ static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro | |||
145 | bt866_write(encoder, 0xdc, val); | 146 | bt866_write(encoder, 0xdc, val); |
146 | 147 | ||
147 | val = encoder->reg[0xcc]; | 148 | val = encoder->reg[0xcc]; |
148 | if (route->input == 2) | 149 | if (input == 2) |
149 | val |= 0x01; /* OSDBAR */ | 150 | val |= 0x01; /* OSDBAR */ |
150 | else | 151 | else |
151 | val &= ~0x01; /* !OSDBAR */ | 152 | val &= ~0x01; /* !OSDBAR */ |
152 | bt866_write(encoder, 0xcc, val); | 153 | bt866_write(encoder, 0xcc, val); |
153 | 154 | ||
154 | v4l2_dbg(1, debug, sd, "set input %d\n", route->input); | 155 | v4l2_dbg(1, debug, sd, "set input %d\n", input); |
155 | 156 | ||
156 | switch (route->input) { | 157 | switch (input) { |
157 | case 0: | 158 | case 0: |
158 | case 1: | 159 | case 1: |
159 | case 2: | 160 | case 2: |
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index b9c3ba51fb86..fdb4adff3d28 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c | |||
@@ -3324,17 +3324,6 @@ void __devinit bttv_init_card1(struct bttv *btv) | |||
3324 | /* initialization part two -- after registering i2c bus */ | 3324 | /* initialization part two -- after registering i2c bus */ |
3325 | void __devinit bttv_init_card2(struct bttv *btv) | 3325 | void __devinit bttv_init_card2(struct bttv *btv) |
3326 | { | 3326 | { |
3327 | static const unsigned short tvaudio_addrs[] = { | ||
3328 | I2C_ADDR_TDA8425 >> 1, | ||
3329 | I2C_ADDR_TEA6300 >> 1, | ||
3330 | I2C_ADDR_TEA6420 >> 1, | ||
3331 | I2C_ADDR_TDA9840 >> 1, | ||
3332 | I2C_ADDR_TDA985x_L >> 1, | ||
3333 | I2C_ADDR_TDA985x_H >> 1, | ||
3334 | I2C_ADDR_TDA9874 >> 1, | ||
3335 | I2C_ADDR_PIC16C54 >> 1, | ||
3336 | I2C_CLIENT_END | ||
3337 | }; | ||
3338 | int addr=ADDR_UNSET; | 3327 | int addr=ADDR_UNSET; |
3339 | 3328 | ||
3340 | btv->tuner_type = UNSET; | 3329 | btv->tuner_type = UNSET; |
@@ -3512,12 +3501,15 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3512 | 3501 | ||
3513 | /* Load tuner module before issuing tuner config call! */ | 3502 | /* Load tuner module before issuing tuner config call! */ |
3514 | if (bttv_tvcards[btv->c.type].has_radio) | 3503 | if (bttv_tvcards[btv->c.type].has_radio) |
3515 | v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3504 | v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3516 | "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO)); | 3505 | &btv->c.i2c_adap, "tuner", "tuner", |
3517 | v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner", | 3506 | v4l2_i2c_tuner_addrs(ADDRS_RADIO)); |
3518 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 3507 | v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3519 | v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner", | 3508 | &btv->c.i2c_adap, "tuner", "tuner", |
3520 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD)); | 3509 | v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); |
3510 | v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, | ||
3511 | &btv->c.i2c_adap, "tuner", "tuner", | ||
3512 | v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD)); | ||
3521 | 3513 | ||
3522 | tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; | 3514 | tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; |
3523 | tun_setup.type = btv->tuner_type; | 3515 | tun_setup.type = btv->tuner_type; |
@@ -3570,8 +3562,8 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3570 | }; | 3562 | }; |
3571 | struct v4l2_subdev *sd; | 3563 | struct v4l2_subdev *sd; |
3572 | 3564 | ||
3573 | sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3565 | sd = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3574 | "saa6588", "saa6588", addrs); | 3566 | &btv->c.i2c_adap, "saa6588", "saa6588", addrs); |
3575 | btv->has_saa6588 = (sd != NULL); | 3567 | btv->has_saa6588 = (sd != NULL); |
3576 | } | 3568 | } |
3577 | 3569 | ||
@@ -3595,8 +3587,8 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3595 | I2C_CLIENT_END | 3587 | I2C_CLIENT_END |
3596 | }; | 3588 | }; |
3597 | 3589 | ||
3598 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3590 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3599 | "msp3400", "msp3400", addrs); | 3591 | &btv->c.i2c_adap, "msp3400", "msp3400", addrs); |
3600 | if (btv->sd_msp34xx) | 3592 | if (btv->sd_msp34xx) |
3601 | return; | 3593 | return; |
3602 | goto no_audio; | 3594 | goto no_audio; |
@@ -3609,16 +3601,16 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3609 | I2C_CLIENT_END | 3601 | I2C_CLIENT_END |
3610 | }; | 3602 | }; |
3611 | 3603 | ||
3612 | if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3604 | if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3613 | "tda7432", "tda7432", addrs)) | 3605 | &btv->c.i2c_adap, "tda7432", "tda7432", addrs)) |
3614 | return; | 3606 | return; |
3615 | goto no_audio; | 3607 | goto no_audio; |
3616 | } | 3608 | } |
3617 | 3609 | ||
3618 | case 3: { | 3610 | case 3: { |
3619 | /* The user specified that we should probe for tvaudio */ | 3611 | /* The user specified that we should probe for tvaudio */ |
3620 | btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3612 | btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3621 | "tvaudio", "tvaudio", tvaudio_addrs); | 3613 | &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs()); |
3622 | if (btv->sd_tvaudio) | 3614 | if (btv->sd_tvaudio) |
3623 | return; | 3615 | return; |
3624 | goto no_audio; | 3616 | goto no_audio; |
@@ -3637,21 +3629,13 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3637 | it really is a msp3400, so it will return NULL when the device | 3629 | it really is a msp3400, so it will return NULL when the device |
3638 | found is really something else (e.g. a tea6300). */ | 3630 | found is really something else (e.g. a tea6300). */ |
3639 | if (!bttv_tvcards[btv->c.type].no_msp34xx) { | 3631 | if (!bttv_tvcards[btv->c.type].no_msp34xx) { |
3640 | static const unsigned short addrs[] = { | 3632 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev_addr(&btv->c.v4l2_dev, |
3641 | I2C_ADDR_MSP3400 >> 1, | 3633 | &btv->c.i2c_adap, "msp3400", "msp3400", |
3642 | I2C_CLIENT_END | 3634 | I2C_ADDR_MSP3400 >> 1); |
3643 | }; | ||
3644 | |||
3645 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | ||
3646 | "msp3400", "msp3400", addrs); | ||
3647 | } else if (bttv_tvcards[btv->c.type].msp34xx_alt) { | 3635 | } else if (bttv_tvcards[btv->c.type].msp34xx_alt) { |
3648 | static const unsigned short addrs[] = { | 3636 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev_addr(&btv->c.v4l2_dev, |
3649 | I2C_ADDR_MSP3400_ALT >> 1, | 3637 | &btv->c.i2c_adap, "msp3400", "msp3400", |
3650 | I2C_CLIENT_END | 3638 | I2C_ADDR_MSP3400_ALT >> 1); |
3651 | }; | ||
3652 | |||
3653 | btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | ||
3654 | "msp3400", "msp3400", addrs); | ||
3655 | } | 3639 | } |
3656 | 3640 | ||
3657 | /* If we found a msp34xx, then we're done. */ | 3641 | /* If we found a msp34xx, then we're done. */ |
@@ -3665,14 +3649,14 @@ void __devinit bttv_init_card2(struct bttv *btv) | |||
3665 | I2C_CLIENT_END | 3649 | I2C_CLIENT_END |
3666 | }; | 3650 | }; |
3667 | 3651 | ||
3668 | if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3652 | if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3669 | "tda7432", "tda7432", addrs)) | 3653 | &btv->c.i2c_adap, "tda7432", "tda7432", addrs)) |
3670 | return; | 3654 | return; |
3671 | } | 3655 | } |
3672 | 3656 | ||
3673 | /* Now see if we can find one of the tvaudio devices. */ | 3657 | /* Now see if we can find one of the tvaudio devices. */ |
3674 | btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, | 3658 | btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev, |
3675 | "tvaudio", "tvaudio", tvaudio_addrs); | 3659 | &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs()); |
3676 | if (btv->sd_tvaudio) | 3660 | if (btv->sd_tvaudio) |
3677 | return; | 3661 | return; |
3678 | 3662 | ||
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 7a8ca0d8356f..74f619d6cc93 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -1198,7 +1198,7 @@ audio_mux(struct bttv *btv, int input, int mute) | |||
1198 | ctrl.value = btv->mute; | 1198 | ctrl.value = btv->mute; |
1199 | bttv_call_all(btv, core, s_ctrl, &ctrl); | 1199 | bttv_call_all(btv, core, s_ctrl, &ctrl); |
1200 | if (btv->sd_msp34xx) { | 1200 | if (btv->sd_msp34xx) { |
1201 | struct v4l2_routing route; | 1201 | u32 in; |
1202 | 1202 | ||
1203 | /* Note: the inputs tuner/radio/extern/intern are translated | 1203 | /* Note: the inputs tuner/radio/extern/intern are translated |
1204 | to msp routings. This assumes common behavior for all msp3400 | 1204 | to msp routings. This assumes common behavior for all msp3400 |
@@ -1207,11 +1207,11 @@ audio_mux(struct bttv *btv, int input, int mute) | |||
1207 | For now this is sufficient. */ | 1207 | For now this is sufficient. */ |
1208 | switch (input) { | 1208 | switch (input) { |
1209 | case TVAUDIO_INPUT_RADIO: | 1209 | case TVAUDIO_INPUT_RADIO: |
1210 | route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, | 1210 | in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, |
1211 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | 1211 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); |
1212 | break; | 1212 | break; |
1213 | case TVAUDIO_INPUT_EXTERN: | 1213 | case TVAUDIO_INPUT_EXTERN: |
1214 | route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, | 1214 | in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, |
1215 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | 1215 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); |
1216 | break; | 1216 | break; |
1217 | case TVAUDIO_INPUT_INTERN: | 1217 | case TVAUDIO_INPUT_INTERN: |
@@ -1220,7 +1220,7 @@ audio_mux(struct bttv *btv, int input, int mute) | |||
1220 | input is the BTTV_BOARD_AVERMEDIA98. I wonder how | 1220 | input is the BTTV_BOARD_AVERMEDIA98. I wonder how |
1221 | that was tested. My guess is that the whole INTERN | 1221 | that was tested. My guess is that the whole INTERN |
1222 | input does not work. */ | 1222 | input does not work. */ |
1223 | route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, | 1223 | in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, |
1224 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | 1224 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); |
1225 | break; | 1225 | break; |
1226 | case TVAUDIO_INPUT_TUNER: | 1226 | case TVAUDIO_INPUT_TUNER: |
@@ -1229,21 +1229,18 @@ audio_mux(struct bttv *btv, int input, int mute) | |||
1229 | is the only difference between the VOODOOTV_FM | 1229 | is the only difference between the VOODOOTV_FM |
1230 | and VOODOOTV_200 */ | 1230 | and VOODOOTV_200 */ |
1231 | if (btv->c.type == BTTV_BOARD_VOODOOTV_200) | 1231 | if (btv->c.type == BTTV_BOARD_VOODOOTV_200) |
1232 | route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \ | 1232 | in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \ |
1233 | MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER); | 1233 | MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER); |
1234 | else | 1234 | else |
1235 | route.input = MSP_INPUT_DEFAULT; | 1235 | in = MSP_INPUT_DEFAULT; |
1236 | break; | 1236 | break; |
1237 | } | 1237 | } |
1238 | route.output = MSP_OUTPUT_DEFAULT; | 1238 | v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, |
1239 | v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, &route); | 1239 | in, MSP_OUTPUT_DEFAULT, 0); |
1240 | } | 1240 | } |
1241 | if (btv->sd_tvaudio) { | 1241 | if (btv->sd_tvaudio) { |
1242 | struct v4l2_routing route; | 1242 | v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, |
1243 | 1243 | input, 0, 0); | |
1244 | route.input = input; | ||
1245 | route.output = 0; | ||
1246 | v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, &route); | ||
1247 | } | 1244 | } |
1248 | return 0; | 1245 | return 0; |
1249 | } | 1246 | } |
@@ -1329,7 +1326,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm) | |||
1329 | break; | 1326 | break; |
1330 | } | 1327 | } |
1331 | id = tvnorm->v4l2_id; | 1328 | id = tvnorm->v4l2_id; |
1332 | bttv_call_all(btv, tuner, s_std, id); | 1329 | bttv_call_all(btv, core, s_std, id); |
1333 | 1330 | ||
1334 | return 0; | 1331 | return 0; |
1335 | } | 1332 | } |
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h index 96498489199d..a1d0e9c9f286 100644 --- a/drivers/media/video/bt8xx/bttvp.h +++ b/drivers/media/video/bt8xx/bttvp.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #define _BTTVP_H_ | 26 | #define _BTTVP_H_ |
27 | 27 | ||
28 | #include <linux/version.h> | 28 | #include <linux/version.h> |
29 | #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,17) | 29 | #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,18) |
30 | 30 | ||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index 7abe94d9fb4c..5f582726985d 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c | |||
@@ -1954,7 +1954,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, | |||
1954 | goto out_freeirq; | 1954 | goto out_freeirq; |
1955 | 1955 | ||
1956 | cam->sensor_addr = 0x42; | 1956 | cam->sensor_addr = 0x42; |
1957 | cam->sensor = v4l2_i2c_new_subdev(&cam->i2c_adapter, | 1957 | cam->sensor = v4l2_i2c_new_subdev(&cam->v4l2_dev, &cam->i2c_adapter, |
1958 | "ov7670", "ov7670", cam->sensor_addr); | 1958 | "ov7670", "ov7670", cam->sensor_addr); |
1959 | if (cam->sensor == NULL) { | 1959 | if (cam->sensor == NULL) { |
1960 | ret = -ENODEV; | 1960 | ret = -ENODEV; |
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c index 9714059ee949..57dc1704b6c0 100644 --- a/drivers/media/video/cs5345.c +++ b/drivers/media/video/cs5345.c | |||
@@ -53,14 +53,15 @@ static inline int cs5345_read(struct v4l2_subdev *sd, u8 reg) | |||
53 | return i2c_smbus_read_byte_data(client, reg); | 53 | return i2c_smbus_read_byte_data(client, reg); |
54 | } | 54 | } |
55 | 55 | ||
56 | static int cs5345_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 56 | static int cs5345_s_routing(struct v4l2_subdev *sd, |
57 | u32 input, u32 output, u32 config) | ||
57 | { | 58 | { |
58 | if ((route->input & 0xf) > 6) { | 59 | if ((input & 0xf) > 6) { |
59 | v4l2_err(sd, "Invalid input %d.\n", route->input); | 60 | v4l2_err(sd, "Invalid input %d.\n", input); |
60 | return -EINVAL; | 61 | return -EINVAL; |
61 | } | 62 | } |
62 | cs5345_write(sd, 0x09, route->input & 0xf); | 63 | cs5345_write(sd, 0x09, input & 0xf); |
63 | cs5345_write(sd, 0x05, route->input & 0xf0); | 64 | cs5345_write(sd, 0x05, input & 0xf0); |
64 | return 0; | 65 | return 0; |
65 | } | 66 | } |
66 | 67 | ||
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index 5aeb066857a7..80bca8df9fbf 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c | |||
@@ -58,17 +58,18 @@ static int cs53l32a_read(struct v4l2_subdev *sd, u8 reg) | |||
58 | return i2c_smbus_read_byte_data(client, reg); | 58 | return i2c_smbus_read_byte_data(client, reg); |
59 | } | 59 | } |
60 | 60 | ||
61 | static int cs53l32a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 61 | static int cs53l32a_s_routing(struct v4l2_subdev *sd, |
62 | u32 input, u32 output, u32 config) | ||
62 | { | 63 | { |
63 | /* There are 2 physical inputs, but the second input can be | 64 | /* There are 2 physical inputs, but the second input can be |
64 | placed in two modes, the first mode bypasses the PGA (gain), | 65 | placed in two modes, the first mode bypasses the PGA (gain), |
65 | the second goes through the PGA. Hence there are three | 66 | the second goes through the PGA. Hence there are three |
66 | possible inputs to choose from. */ | 67 | possible inputs to choose from. */ |
67 | if (route->input > 2) { | 68 | if (input > 2) { |
68 | v4l2_err(sd, "Invalid input %d.\n", route->input); | 69 | v4l2_err(sd, "Invalid input %d.\n", input); |
69 | return -EINVAL; | 70 | return -EINVAL; |
70 | } | 71 | } |
71 | cs53l32a_write(sd, 0x01, 0x01 + (route->input << 4)); | 72 | cs53l32a_write(sd, 0x01, 0x01 + (input << 4)); |
72 | return 0; | 73 | return 0; |
73 | } | 74 | } |
74 | 75 | ||
diff --git a/drivers/media/video/cx18/cx18-audio.c b/drivers/media/video/cx18/cx18-audio.c index bb5c5165dd5f..1519e91c677a 100644 --- a/drivers/media/video/cx18/cx18-audio.c +++ b/drivers/media/video/cx18/cx18-audio.c | |||
@@ -33,7 +33,6 @@ | |||
33 | int cx18_audio_set_io(struct cx18 *cx) | 33 | int cx18_audio_set_io(struct cx18 *cx) |
34 | { | 34 | { |
35 | const struct cx18_card_audio_input *in; | 35 | const struct cx18_card_audio_input *in; |
36 | struct v4l2_routing route; | ||
37 | u32 val; | 36 | u32 val; |
38 | int err; | 37 | int err; |
39 | 38 | ||
@@ -44,13 +43,11 @@ int cx18_audio_set_io(struct cx18 *cx) | |||
44 | in = &cx->card->audio_inputs[cx->audio_input]; | 43 | in = &cx->card->audio_inputs[cx->audio_input]; |
45 | 44 | ||
46 | /* handle muxer chips */ | 45 | /* handle muxer chips */ |
47 | route.input = in->muxer_input; | 46 | v4l2_subdev_call(cx->sd_extmux, audio, s_routing, |
48 | route.output = 0; | 47 | in->audio_input, 0, 0); |
49 | v4l2_subdev_call(cx->sd_extmux, audio, s_routing, &route); | ||
50 | 48 | ||
51 | route.input = in->audio_input; | ||
52 | err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl, | 49 | err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl, |
53 | audio, s_routing, &route); | 50 | audio, s_routing, in->audio_input, 0, 0); |
54 | if (err) | 51 | if (err) |
55 | return err; | 52 | return err; |
56 | 53 | ||
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c index f4dd9d78eb3d..cf2bd888a429 100644 --- a/drivers/media/video/cx18/cx18-av-core.c +++ b/drivers/media/video/cx18/cx18-av-core.c | |||
@@ -203,43 +203,42 @@ static int cx18_av_reset(struct v4l2_subdev *sd, u32 val) | |||
203 | 203 | ||
204 | static int cx18_av_init(struct v4l2_subdev *sd, u32 val) | 204 | static int cx18_av_init(struct v4l2_subdev *sd, u32 val) |
205 | { | 205 | { |
206 | struct cx18_av_state *state = to_cx18_av_state(sd); | ||
207 | struct cx18 *cx = v4l2_get_subdevdata(sd); | 206 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
208 | 207 | ||
209 | switch (val) { | 208 | /* |
210 | case CX18_AV_INIT_PLLS: | 209 | * The crystal freq used in calculations in this driver will be |
211 | /* | 210 | * 28.636360 MHz. |
212 | * The crystal freq used in calculations in this driver will be | 211 | * Aim to run the PLLs' VCOs near 400 MHz to minimze errors. |
213 | * 28.636360 MHz. | 212 | */ |
214 | * Aim to run the PLLs' VCOs near 400 MHz to minimze errors. | ||
215 | */ | ||
216 | 213 | ||
217 | /* | 214 | /* |
218 | * VDCLK Integer = 0x0f, Post Divider = 0x04 | 215 | * VDCLK Integer = 0x0f, Post Divider = 0x04 |
219 | * AIMCLK Integer = 0x0e, Post Divider = 0x16 | 216 | * AIMCLK Integer = 0x0e, Post Divider = 0x16 |
220 | */ | 217 | */ |
221 | cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f); | 218 | cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f); |
222 | 219 | ||
223 | /* VDCLK Fraction = 0x2be2fe */ | 220 | /* VDCLK Fraction = 0x2be2fe */ |
224 | /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */ | 221 | /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */ |
225 | cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe); | 222 | cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe); |
226 | 223 | ||
227 | /* AIMCLK Fraction = 0x05227ad */ | 224 | /* AIMCLK Fraction = 0x05227ad */ |
228 | /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/ | 225 | /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/ |
229 | cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad); | 226 | cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad); |
230 | 227 | ||
231 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */ | 228 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */ |
232 | cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56); | 229 | cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56); |
233 | break; | 230 | return 0; |
231 | } | ||
234 | 232 | ||
235 | case CX18_AV_INIT_NORMAL: | 233 | static int cx18_av_load_fw(struct v4l2_subdev *sd) |
236 | default: | 234 | { |
237 | if (!state->is_initialized) { | 235 | struct cx18_av_state *state = to_cx18_av_state(sd); |
238 | /* initialize on first use */ | 236 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
239 | state->is_initialized = 1; | 237 | |
240 | cx18_av_initialize(cx); | 238 | if (!state->is_initialized) { |
241 | } | 239 | /* initialize on first use */ |
242 | break; | 240 | state->is_initialized = 1; |
241 | cx18_av_initialize(cx); | ||
243 | } | 242 | } |
244 | return 0; | 243 | return 0; |
245 | } | 244 | } |
@@ -548,19 +547,19 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | |||
548 | } | 547 | } |
549 | 548 | ||
550 | static int cx18_av_s_video_routing(struct v4l2_subdev *sd, | 549 | static int cx18_av_s_video_routing(struct v4l2_subdev *sd, |
551 | const struct v4l2_routing *route) | 550 | u32 input, u32 output, u32 config) |
552 | { | 551 | { |
553 | struct cx18_av_state *state = to_cx18_av_state(sd); | 552 | struct cx18_av_state *state = to_cx18_av_state(sd); |
554 | struct cx18 *cx = v4l2_get_subdevdata(sd); | 553 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
555 | return set_input(cx, route->input, state->aud_input); | 554 | return set_input(cx, input, state->aud_input); |
556 | } | 555 | } |
557 | 556 | ||
558 | static int cx18_av_s_audio_routing(struct v4l2_subdev *sd, | 557 | static int cx18_av_s_audio_routing(struct v4l2_subdev *sd, |
559 | const struct v4l2_routing *route) | 558 | u32 input, u32 output, u32 config) |
560 | { | 559 | { |
561 | struct cx18_av_state *state = to_cx18_av_state(sd); | 560 | struct cx18_av_state *state = to_cx18_av_state(sd); |
562 | struct cx18 *cx = v4l2_get_subdevdata(sd); | 561 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
563 | return set_input(cx, state->vid_input, route->input); | 562 | return set_input(cx, state->vid_input, input); |
564 | } | 563 | } |
565 | 564 | ||
566 | static int cx18_av_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | 565 | static int cx18_av_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) |
@@ -1185,10 +1184,12 @@ static const struct v4l2_subdev_core_ops cx18_av_general_ops = { | |||
1185 | .g_chip_ident = cx18_av_g_chip_ident, | 1184 | .g_chip_ident = cx18_av_g_chip_ident, |
1186 | .log_status = cx18_av_log_status, | 1185 | .log_status = cx18_av_log_status, |
1187 | .init = cx18_av_init, | 1186 | .init = cx18_av_init, |
1187 | .load_fw = cx18_av_load_fw, | ||
1188 | .reset = cx18_av_reset, | 1188 | .reset = cx18_av_reset, |
1189 | .queryctrl = cx18_av_queryctrl, | 1189 | .queryctrl = cx18_av_queryctrl, |
1190 | .g_ctrl = cx18_av_g_ctrl, | 1190 | .g_ctrl = cx18_av_g_ctrl, |
1191 | .s_ctrl = cx18_av_s_ctrl, | 1191 | .s_ctrl = cx18_av_s_ctrl, |
1192 | .s_std = cx18_av_s_std, | ||
1192 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1193 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1193 | .g_register = cx18_av_g_register, | 1194 | .g_register = cx18_av_g_register, |
1194 | .s_register = cx18_av_s_register, | 1195 | .s_register = cx18_av_s_register, |
@@ -1200,7 +1201,6 @@ static const struct v4l2_subdev_tuner_ops cx18_av_tuner_ops = { | |||
1200 | .s_frequency = cx18_av_s_frequency, | 1201 | .s_frequency = cx18_av_s_frequency, |
1201 | .g_tuner = cx18_av_g_tuner, | 1202 | .g_tuner = cx18_av_g_tuner, |
1202 | .s_tuner = cx18_av_s_tuner, | 1203 | .s_tuner = cx18_av_s_tuner, |
1203 | .s_std = cx18_av_s_std, | ||
1204 | }; | 1204 | }; |
1205 | 1205 | ||
1206 | static const struct v4l2_subdev_audio_ops cx18_av_audio_ops = { | 1206 | static const struct v4l2_subdev_audio_ops cx18_av_audio_ops = { |
diff --git a/drivers/media/video/cx18/cx18-av-core.h b/drivers/media/video/cx18/cx18-av-core.h index c458120e8c90..9b84a0c58e0e 100644 --- a/drivers/media/video/cx18/cx18-av-core.h +++ b/drivers/media/video/cx18/cx18-av-core.h | |||
@@ -328,11 +328,6 @@ static inline struct cx18_av_state *to_cx18_av_state(struct v4l2_subdev *sd) | |||
328 | return container_of(sd, struct cx18_av_state, sd); | 328 | return container_of(sd, struct cx18_av_state, sd); |
329 | } | 329 | } |
330 | 330 | ||
331 | enum cx18_av_subdev_init_arg { | ||
332 | CX18_AV_INIT_NORMAL = 0, | ||
333 | CX18_AV_INIT_PLLS = 1, | ||
334 | }; | ||
335 | |||
336 | /* ----------------------------------------------------------------------- */ | 331 | /* ----------------------------------------------------------------------- */ |
337 | /* cx18_av-core.c */ | 332 | /* cx18_av-core.c */ |
338 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); | 333 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); |
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 210c68aaae00..49b1c3d7b1a8 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -810,7 +810,7 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, | |||
810 | CX18_ERR("Could not register A/V decoder subdevice\n"); | 810 | CX18_ERR("Could not register A/V decoder subdevice\n"); |
811 | goto free_map; | 811 | goto free_map; |
812 | } | 812 | } |
813 | cx18_call_hw(cx, CX18_HW_418_AV, core, init, (u32) CX18_AV_INIT_PLLS); | 813 | cx18_call_hw(cx, CX18_HW_418_AV, core, init, 0); |
814 | 814 | ||
815 | /* Initialize GPIO Reset Controller to do chip resets during i2c init */ | 815 | /* Initialize GPIO Reset Controller to do chip resets during i2c init */ |
816 | if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { | 816 | if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { |
@@ -1028,7 +1028,7 @@ int cx18_init_on_first_open(struct cx18 *cx) | |||
1028 | cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); | 1028 | cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); |
1029 | 1029 | ||
1030 | /* Init the A/V decoder, if it hasn't been already */ | 1030 | /* Init the A/V decoder, if it hasn't been already */ |
1031 | v4l2_subdev_call(cx->sd_av, core, init, (u32) CX18_AV_INIT_NORMAL); | 1031 | v4l2_subdev_call(cx->sd_av, core, load_fw); |
1032 | 1032 | ||
1033 | vf.tuner = 0; | 1033 | vf.tuner = 0; |
1034 | vf.type = V4L2_TUNER_ANALOG_TV; | 1034 | vf.type = V4L2_TUNER_ANALOG_TV; |
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 4d7d6d5a7f86..b3889c0b2697 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
@@ -608,7 +608,7 @@ int cx18_v4l2_close(struct file *filp) | |||
608 | /* Mark that the radio is no longer in use */ | 608 | /* Mark that the radio is no longer in use */ |
609 | clear_bit(CX18_F_I_RADIO_USER, &cx->i_flags); | 609 | clear_bit(CX18_F_I_RADIO_USER, &cx->i_flags); |
610 | /* Switch tuner to TV */ | 610 | /* Switch tuner to TV */ |
611 | cx18_call_all(cx, tuner, s_std, cx->std); | 611 | cx18_call_all(cx, core, s_std, cx->std); |
612 | /* Select correct audio input (i.e. TV tuner or Line in) */ | 612 | /* Select correct audio input (i.e. TV tuner or Line in) */ |
613 | cx18_audio_set_io(cx); | 613 | cx18_audio_set_io(cx); |
614 | if (atomic_read(&cx->ana_capturing) > 0) { | 614 | if (atomic_read(&cx->ana_capturing) > 0) { |
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c index 5518d1424f8f..86a204b5448e 100644 --- a/drivers/media/video/cx18/cx18-gpio.c +++ b/drivers/media/video/cx18/cx18-gpio.c | |||
@@ -156,12 +156,12 @@ static int gpiomux_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) | |||
156 | } | 156 | } |
157 | 157 | ||
158 | static int gpiomux_s_audio_routing(struct v4l2_subdev *sd, | 158 | static int gpiomux_s_audio_routing(struct v4l2_subdev *sd, |
159 | const struct v4l2_routing *route) | 159 | u32 input, u32 output, u32 config) |
160 | { | 160 | { |
161 | struct cx18 *cx = v4l2_get_subdevdata(sd); | 161 | struct cx18 *cx = v4l2_get_subdevdata(sd); |
162 | u32 data; | 162 | u32 data; |
163 | 163 | ||
164 | switch (route->input) { | 164 | switch (input) { |
165 | case 0: | 165 | case 0: |
166 | data = cx->card->gpio_audio_input.tuner; | 166 | data = cx->card->gpio_audio_input.tuner; |
167 | break; | 167 | break; |
@@ -180,10 +180,10 @@ static int gpiomux_s_audio_routing(struct v4l2_subdev *sd, | |||
180 | 180 | ||
181 | static const struct v4l2_subdev_core_ops gpiomux_core_ops = { | 181 | static const struct v4l2_subdev_core_ops gpiomux_core_ops = { |
182 | .log_status = gpiomux_log_status, | 182 | .log_status = gpiomux_log_status, |
183 | .s_std = gpiomux_s_std, | ||
183 | }; | 184 | }; |
184 | 185 | ||
185 | static const struct v4l2_subdev_tuner_ops gpiomux_tuner_ops = { | 186 | static const struct v4l2_subdev_tuner_ops gpiomux_tuner_ops = { |
186 | .s_std = gpiomux_s_std, | ||
187 | .s_radio = gpiomux_s_radio, | 187 | .s_radio = gpiomux_s_radio, |
188 | }; | 188 | }; |
189 | 189 | ||
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index d092643faf46..b9b7064a2be8 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -100,16 +100,16 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx) | |||
100 | 100 | ||
101 | if (hw == CX18_HW_TUNER) { | 101 | if (hw == CX18_HW_TUNER) { |
102 | /* special tuner group handling */ | 102 | /* special tuner group handling */ |
103 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 103 | sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev, |
104 | cx->card_i2c->radio); | 104 | adap, mod, type, cx->card_i2c->radio); |
105 | if (sd != NULL) | 105 | if (sd != NULL) |
106 | sd->grp_id = hw; | 106 | sd->grp_id = hw; |
107 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 107 | sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev, |
108 | cx->card_i2c->demod); | 108 | adap, mod, type, cx->card_i2c->demod); |
109 | if (sd != NULL) | 109 | if (sd != NULL) |
110 | sd->grp_id = hw; | 110 | sd->grp_id = hw; |
111 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 111 | sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev, |
112 | cx->card_i2c->tv); | 112 | adap, mod, type, cx->card_i2c->tv); |
113 | if (sd != NULL) | 113 | if (sd != NULL) |
114 | sd->grp_id = hw; | 114 | sd->grp_id = hw; |
115 | return sd != NULL ? 0 : -1; | 115 | return sd != NULL ? 0 : -1; |
@@ -120,7 +120,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx) | |||
120 | return -1; | 120 | return -1; |
121 | 121 | ||
122 | /* It's an I2C device other than an analog tuner */ | 122 | /* It's an I2C device other than an analog tuner */ |
123 | sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]); | 123 | sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, mod, type, hw_addrs[idx]); |
124 | if (sd != NULL) | 124 | if (sd != NULL) |
125 | sd->grp_id = hw; | 125 | sd->grp_id = hw; |
126 | return sd != NULL ? 0 : -1; | 126 | return sd != NULL ? 0 : -1; |
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index e4c9e3d8bacd..d7b1921e6666 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c | |||
@@ -705,7 +705,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std) | |||
705 | (unsigned long long) cx->std); | 705 | (unsigned long long) cx->std); |
706 | 706 | ||
707 | /* Tuner */ | 707 | /* Tuner */ |
708 | cx18_call_all(cx, tuner, s_std, cx->std); | 708 | cx18_call_all(cx, core, s_std, cx->std); |
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | 711 | ||
@@ -926,16 +926,6 @@ static long cx18_default(struct file *file, void *fh, int cmd, void *arg) | |||
926 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | 926 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
927 | 927 | ||
928 | switch (cmd) { | 928 | switch (cmd) { |
929 | case VIDIOC_INT_S_AUDIO_ROUTING: { | ||
930 | struct v4l2_routing *route = arg; | ||
931 | |||
932 | CX18_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING(%d, %d)\n", | ||
933 | route->input, route->output); | ||
934 | cx18_call_hw(cx, cx->card->hw_audio_ctrl, audio, s_routing, | ||
935 | route); | ||
936 | break; | ||
937 | } | ||
938 | |||
939 | case VIDIOC_INT_RESET: { | 929 | case VIDIOC_INT_RESET: { |
940 | u32 val = *(u32 *)arg; | 930 | u32 val = *(u32 *)arg; |
941 | 931 | ||
diff --git a/drivers/media/video/cx18/cx18-video.c b/drivers/media/video/cx18/cx18-video.c index 6fdadedf17a8..6dc84aac8f44 100644 --- a/drivers/media/video/cx18/cx18-video.c +++ b/drivers/media/video/cx18/cx18-video.c | |||
@@ -25,20 +25,8 @@ | |||
25 | 25 | ||
26 | void cx18_video_set_io(struct cx18 *cx) | 26 | void cx18_video_set_io(struct cx18 *cx) |
27 | { | 27 | { |
28 | struct v4l2_routing route; | ||
29 | int inp = cx->active_input; | 28 | int inp = cx->active_input; |
30 | u32 type; | ||
31 | 29 | ||
32 | route.input = cx->card->video_inputs[inp].video_input; | 30 | v4l2_subdev_call(cx->sd_av, video, s_routing, |
33 | route.output = 0; | 31 | cx->card->video_inputs[inp].video_input, 0, 0); |
34 | v4l2_subdev_call(cx->sd_av, video, s_routing, &route); | ||
35 | |||
36 | type = cx->card->video_inputs[inp].video_type; | ||
37 | |||
38 | if (type == CX18_CARD_INPUT_VID_TUNER) | ||
39 | route.input = 0; /* Tuner */ | ||
40 | else if (type < CX18_CARD_INPUT_COMPOSITE1) | ||
41 | route.input = 2; /* S-Video */ | ||
42 | else | ||
43 | route.input = 1; /* Composite */ | ||
44 | } | 32 | } |
diff --git a/drivers/media/video/cx231xx/Kconfig b/drivers/media/video/cx231xx/Kconfig new file mode 100644 index 000000000000..91156546a07a --- /dev/null +++ b/drivers/media/video/cx231xx/Kconfig | |||
@@ -0,0 +1,35 @@ | |||
1 | config VIDEO_CX231XX | ||
2 | tristate "Conexant cx231xx USB video capture support" | ||
3 | depends on VIDEO_DEV && I2C && INPUT | ||
4 | select VIDEO_TUNER | ||
5 | select VIDEO_TVEEPROM | ||
6 | select VIDEO_IR | ||
7 | select VIDEOBUF_VMALLOC | ||
8 | select VIDEO_CX25840 | ||
9 | select VIDEO_CX231XX_ALSA | ||
10 | |||
11 | ---help--- | ||
12 | This is a video4linux driver for Conexant 231xx USB based TV cards. | ||
13 | |||
14 | To compile this driver as a module, choose M here: the | ||
15 | module will be called cx231xx | ||
16 | |||
17 | config VIDEO_CX231XX_ALSA | ||
18 | tristate "Conexant Cx231xx ALSA audio module" | ||
19 | depends on VIDEO_CX231XX && SND | ||
20 | select SND_PCM | ||
21 | |||
22 | ---help--- | ||
23 | This is an ALSA driver for Cx231xx USB based TV cards. | ||
24 | |||
25 | To compile this driver as a module, choose M here: the | ||
26 | module will be called cx231xx-alsa | ||
27 | |||
28 | config VIDEO_CX231XX_DVB | ||
29 | tristate "DVB/ATSC Support for Cx231xx based TV cards" | ||
30 | depends on VIDEO_CX231XX && DVB_CORE | ||
31 | select VIDEOBUF_DVB | ||
32 | select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMISE | ||
33 | ---help--- | ||
34 | This adds support for DVB cards based on the | ||
35 | Conexant cx231xx chips. | ||
diff --git a/drivers/media/video/cx231xx/Makefile b/drivers/media/video/cx231xx/Makefile new file mode 100644 index 000000000000..755dd0ce65ff --- /dev/null +++ b/drivers/media/video/cx231xx/Makefile | |||
@@ -0,0 +1,14 @@ | |||
1 | cx231xx-objs := cx231xx-video.o cx231xx-i2c.o cx231xx-cards.o cx231xx-core.o \ | ||
2 | cx231xx-avcore.o cx231xx-pcb-cfg.o cx231xx-vbi.o | ||
3 | |||
4 | cx231xx-alsa-objs := cx231xx-audio.o | ||
5 | |||
6 | obj-$(CONFIG_VIDEO_CX231XX) += cx231xx.o | ||
7 | obj-$(CONFIG_VIDEO_CX231XX_ALSA) += cx231xx-alsa.o | ||
8 | obj-$(CONFIG_VIDEO_CX231XX_DVB) += cx231xx-dvb.o | ||
9 | |||
10 | EXTRA_CFLAGS += -Idrivers/media/video | ||
11 | EXTRA_CFLAGS += -Idrivers/media/common/tuners | ||
12 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | ||
13 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | ||
14 | |||
diff --git a/drivers/media/video/cx231xx/cx231xx-audio.c b/drivers/media/video/cx231xx/cx231xx-audio.c new file mode 100644 index 000000000000..7793d60966db --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-audio.c | |||
@@ -0,0 +1,586 @@ | |||
1 | /* | ||
2 | * Conexant Cx231xx audio extension | ||
3 | * | ||
4 | * Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | * Based on em28xx driver | ||
6 | * | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/usb.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/sound.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/soundcard.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <linux/vmalloc.h> | ||
31 | #include <linux/proc_fs.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <sound/core.h> | ||
34 | #include <sound/pcm.h> | ||
35 | #include <sound/pcm_params.h> | ||
36 | #include <sound/info.h> | ||
37 | #include <sound/initval.h> | ||
38 | #include <sound/control.h> | ||
39 | #include <media/v4l2-common.h> | ||
40 | #include "cx231xx.h" | ||
41 | |||
42 | static int debug; | ||
43 | module_param(debug, int, 0644); | ||
44 | MODULE_PARM_DESC(debug, "activates debug info"); | ||
45 | |||
46 | #define dprintk(fmt, arg...) do { \ | ||
47 | if (debug) \ | ||
48 | printk(KERN_INFO "cx231xx-audio %s: " fmt, \ | ||
49 | __func__, ##arg); \ | ||
50 | } while (0) | ||
51 | |||
52 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | ||
53 | |||
54 | static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) | ||
55 | { | ||
56 | int i; | ||
57 | |||
58 | dprintk("Stopping isoc\n"); | ||
59 | |||
60 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
61 | if (dev->adev.urb[i]) { | ||
62 | if (!irqs_disabled()) | ||
63 | usb_kill_urb(dev->adev.urb[i]); | ||
64 | else | ||
65 | usb_unlink_urb(dev->adev.urb[i]); | ||
66 | |||
67 | usb_free_urb(dev->adev.urb[i]); | ||
68 | dev->adev.urb[i] = NULL; | ||
69 | |||
70 | kfree(dev->adev.transfer_buffer[i]); | ||
71 | dev->adev.transfer_buffer[i] = NULL; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static void cx231xx_audio_isocirq(struct urb *urb) | ||
79 | { | ||
80 | struct cx231xx *dev = urb->context; | ||
81 | int i; | ||
82 | unsigned int oldptr; | ||
83 | int period_elapsed = 0; | ||
84 | int status; | ||
85 | unsigned char *cp; | ||
86 | unsigned int stride; | ||
87 | struct snd_pcm_substream *substream; | ||
88 | struct snd_pcm_runtime *runtime; | ||
89 | |||
90 | switch (urb->status) { | ||
91 | case 0: /* success */ | ||
92 | case -ETIMEDOUT: /* NAK */ | ||
93 | break; | ||
94 | case -ECONNRESET: /* kill */ | ||
95 | case -ENOENT: | ||
96 | case -ESHUTDOWN: | ||
97 | return; | ||
98 | default: /* error */ | ||
99 | dprintk("urb completition error %d.\n", urb->status); | ||
100 | break; | ||
101 | } | ||
102 | |||
103 | if (dev->adev.capture_pcm_substream) { | ||
104 | substream = dev->adev.capture_pcm_substream; | ||
105 | runtime = substream->runtime; | ||
106 | stride = runtime->frame_bits >> 3; | ||
107 | |||
108 | for (i = 0; i < urb->number_of_packets; i++) { | ||
109 | int length = urb->iso_frame_desc[i].actual_length / | ||
110 | stride; | ||
111 | cp = (unsigned char *)urb->transfer_buffer + | ||
112 | urb->iso_frame_desc[i].offset; | ||
113 | |||
114 | if (!length) | ||
115 | continue; | ||
116 | |||
117 | oldptr = dev->adev.hwptr_done_capture; | ||
118 | if (oldptr + length >= runtime->buffer_size) { | ||
119 | unsigned int cnt; | ||
120 | |||
121 | cnt = runtime->buffer_size - oldptr; | ||
122 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
123 | cnt * stride); | ||
124 | memcpy(runtime->dma_area, cp + cnt * stride, | ||
125 | length * stride - cnt * stride); | ||
126 | } else { | ||
127 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
128 | length * stride); | ||
129 | } | ||
130 | |||
131 | snd_pcm_stream_lock(substream); | ||
132 | |||
133 | dev->adev.hwptr_done_capture += length; | ||
134 | if (dev->adev.hwptr_done_capture >= | ||
135 | runtime->buffer_size) | ||
136 | dev->adev.hwptr_done_capture -= | ||
137 | runtime->buffer_size; | ||
138 | |||
139 | dev->adev.capture_transfer_done += length; | ||
140 | if (dev->adev.capture_transfer_done >= | ||
141 | runtime->period_size) { | ||
142 | dev->adev.capture_transfer_done -= | ||
143 | runtime->period_size; | ||
144 | period_elapsed = 1; | ||
145 | } | ||
146 | snd_pcm_stream_unlock(substream); | ||
147 | } | ||
148 | if (period_elapsed) | ||
149 | snd_pcm_period_elapsed(substream); | ||
150 | } | ||
151 | urb->status = 0; | ||
152 | |||
153 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
154 | if (status < 0) { | ||
155 | cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", | ||
156 | status); | ||
157 | } | ||
158 | return; | ||
159 | } | ||
160 | |||
161 | static int cx231xx_init_audio_isoc(struct cx231xx *dev) | ||
162 | { | ||
163 | int i, errCode; | ||
164 | int sb_size; | ||
165 | |||
166 | cx231xx_info("%s: Starting AUDIO transfers\n", __func__); | ||
167 | |||
168 | sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size; | ||
169 | |||
170 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
171 | struct urb *urb; | ||
172 | int j, k; | ||
173 | |||
174 | dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); | ||
175 | if (!dev->adev.transfer_buffer[i]) | ||
176 | return -ENOMEM; | ||
177 | |||
178 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); | ||
179 | urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); | ||
180 | if (!urb) { | ||
181 | cx231xx_errdev("usb_alloc_urb failed!\n"); | ||
182 | for (j = 0; j < i; j++) { | ||
183 | usb_free_urb(dev->adev.urb[j]); | ||
184 | kfree(dev->adev.transfer_buffer[j]); | ||
185 | } | ||
186 | return -ENOMEM; | ||
187 | } | ||
188 | |||
189 | urb->dev = dev->udev; | ||
190 | urb->context = dev; | ||
191 | urb->pipe = usb_rcvisocpipe(dev->udev, | ||
192 | dev->adev.end_point_addr); | ||
193 | urb->transfer_flags = URB_ISO_ASAP; | ||
194 | urb->transfer_buffer = dev->adev.transfer_buffer[i]; | ||
195 | urb->interval = 1; | ||
196 | urb->complete = cx231xx_audio_isocirq; | ||
197 | urb->number_of_packets = CX231XX_NUM_AUDIO_PACKETS; | ||
198 | urb->transfer_buffer_length = sb_size; | ||
199 | |||
200 | for (j = k = 0; j < CX231XX_NUM_AUDIO_PACKETS; | ||
201 | j++, k += dev->adev.max_pkt_size) { | ||
202 | urb->iso_frame_desc[j].offset = k; | ||
203 | urb->iso_frame_desc[j].length = dev->adev.max_pkt_size; | ||
204 | } | ||
205 | dev->adev.urb[i] = urb; | ||
206 | } | ||
207 | |||
208 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
209 | errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); | ||
210 | if (errCode < 0) { | ||
211 | cx231xx_isoc_audio_deinit(dev); | ||
212 | return errCode; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | return errCode; | ||
217 | } | ||
218 | |||
219 | static int cx231xx_cmd(struct cx231xx *dev, int cmd, int arg) | ||
220 | { | ||
221 | dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON) ? | ||
222 | "stop" : "start"); | ||
223 | |||
224 | switch (cmd) { | ||
225 | case CX231XX_CAPTURE_STREAM_EN: | ||
226 | if (dev->adev.capture_stream == STREAM_OFF && arg == 1) { | ||
227 | dev->adev.capture_stream = STREAM_ON; | ||
228 | cx231xx_init_audio_isoc(dev); | ||
229 | } else if (dev->adev.capture_stream == STREAM_ON && arg == 0) { | ||
230 | dev->adev.capture_stream = STREAM_OFF; | ||
231 | cx231xx_isoc_audio_deinit(dev); | ||
232 | } else { | ||
233 | cx231xx_errdev("An underrun very likely occurred. " | ||
234 | "Ignoring it.\n"); | ||
235 | } | ||
236 | return 0; | ||
237 | default: | ||
238 | return -EINVAL; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, | ||
243 | size_t size) | ||
244 | { | ||
245 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
246 | |||
247 | dprintk("Allocating vbuffer\n"); | ||
248 | if (runtime->dma_area) { | ||
249 | if (runtime->dma_bytes > size) | ||
250 | return 0; | ||
251 | |||
252 | vfree(runtime->dma_area); | ||
253 | } | ||
254 | runtime->dma_area = vmalloc(size); | ||
255 | if (!runtime->dma_area) | ||
256 | return -ENOMEM; | ||
257 | |||
258 | runtime->dma_bytes = size; | ||
259 | |||
260 | return 0; | ||
261 | } | ||
262 | |||
263 | static struct snd_pcm_hardware snd_cx231xx_hw_capture = { | ||
264 | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
265 | SNDRV_PCM_INFO_MMAP | | ||
266 | SNDRV_PCM_INFO_INTERLEAVED | | ||
267 | SNDRV_PCM_INFO_MMAP_VALID, | ||
268 | |||
269 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
270 | |||
271 | .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT, | ||
272 | |||
273 | .rate_min = 48000, | ||
274 | .rate_max = 48000, | ||
275 | .channels_min = 2, | ||
276 | .channels_max = 2, | ||
277 | .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ | ||
278 | .period_bytes_min = 64, /* 12544/2, */ | ||
279 | .period_bytes_max = 12544, | ||
280 | .periods_min = 2, | ||
281 | .periods_max = 98, /* 12544, */ | ||
282 | }; | ||
283 | |||
284 | static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) | ||
285 | { | ||
286 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
287 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
288 | int ret = 0; | ||
289 | |||
290 | dprintk("opening device and trying to acquire exclusive lock\n"); | ||
291 | |||
292 | if (!dev) { | ||
293 | cx231xx_errdev("BUG: cx231xx can't find device struct." | ||
294 | " Can't proceed with open\n"); | ||
295 | return -ENODEV; | ||
296 | } | ||
297 | |||
298 | /* Sets volume, mute, etc */ | ||
299 | dev->mute = 0; | ||
300 | |||
301 | /* set alternate setting for audio interface */ | ||
302 | /* 1 - 48000 samples per sec */ | ||
303 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1); | ||
304 | if (ret < 0) { | ||
305 | cx231xx_errdev("failed to set alternate setting !\n"); | ||
306 | |||
307 | return ret; | ||
308 | } | ||
309 | |||
310 | /* inform hardware to start streaming */ | ||
311 | ret = cx231xx_capture_start(dev, 1, Audio); | ||
312 | |||
313 | runtime->hw = snd_cx231xx_hw_capture; | ||
314 | |||
315 | mutex_lock(&dev->lock); | ||
316 | dev->adev.users++; | ||
317 | mutex_unlock(&dev->lock); | ||
318 | |||
319 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
320 | dev->adev.capture_pcm_substream = substream; | ||
321 | runtime->private_data = dev; | ||
322 | |||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | ||
327 | { | ||
328 | int ret; | ||
329 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
330 | |||
331 | dprintk("closing device\n"); | ||
332 | |||
333 | /* set alternate setting for audio interface */ | ||
334 | /* 1 - 48000 samples per sec */ | ||
335 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); | ||
336 | if (ret < 0) { | ||
337 | cx231xx_errdev("failed to set alternate setting !\n"); | ||
338 | |||
339 | return ret; | ||
340 | } | ||
341 | |||
342 | /* inform hardware to start streaming */ | ||
343 | ret = cx231xx_capture_start(dev, 0, Audio); | ||
344 | |||
345 | dev->mute = 1; | ||
346 | mutex_lock(&dev->lock); | ||
347 | dev->adev.users--; | ||
348 | mutex_unlock(&dev->lock); | ||
349 | |||
350 | if (dev->adev.users == 0 && dev->adev.shutdown == 1) { | ||
351 | dprintk("audio users: %d\n", dev->adev.users); | ||
352 | dprintk("disabling audio stream!\n"); | ||
353 | dev->adev.shutdown = 0; | ||
354 | dprintk("released lock\n"); | ||
355 | cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, 0); | ||
356 | } | ||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, | ||
361 | struct snd_pcm_hw_params *hw_params) | ||
362 | { | ||
363 | unsigned int channels, rate, format; | ||
364 | int ret; | ||
365 | |||
366 | dprintk("Setting capture parameters\n"); | ||
367 | |||
368 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | ||
369 | params_buffer_bytes(hw_params)); | ||
370 | format = params_format(hw_params); | ||
371 | rate = params_rate(hw_params); | ||
372 | channels = params_channels(hw_params); | ||
373 | |||
374 | /* TODO: set up cx231xx audio chip to deliver the correct audio format, | ||
375 | current default is 48000hz multiplexed => 96000hz mono | ||
376 | which shouldn't matter since analogue TV only supports mono */ | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static int snd_cx231xx_hw_capture_free(struct snd_pcm_substream *substream) | ||
381 | { | ||
382 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
383 | |||
384 | dprintk("Stop capture, if needed\n"); | ||
385 | |||
386 | if (dev->adev.capture_stream == STREAM_ON) | ||
387 | cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, CX231XX_STOP_AUDIO); | ||
388 | |||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static int snd_cx231xx_prepare(struct snd_pcm_substream *substream) | ||
393 | { | ||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream, | ||
398 | int cmd) | ||
399 | { | ||
400 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
401 | int retval; | ||
402 | |||
403 | dprintk("Should %s capture\n", (cmd == SNDRV_PCM_TRIGGER_START) ? | ||
404 | "start" : "stop"); | ||
405 | |||
406 | spin_lock(&dev->adev.slock); | ||
407 | switch (cmd) { | ||
408 | case SNDRV_PCM_TRIGGER_START: | ||
409 | cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, | ||
410 | CX231XX_START_AUDIO); | ||
411 | retval = 0; | ||
412 | break; | ||
413 | case SNDRV_PCM_TRIGGER_STOP: | ||
414 | cx231xx_cmd(dev, CX231XX_CAPTURE_STREAM_EN, CX231XX_STOP_AUDIO); | ||
415 | retval = 0; | ||
416 | break; | ||
417 | default: | ||
418 | retval = -EINVAL; | ||
419 | } | ||
420 | |||
421 | spin_unlock(&dev->adev.slock); | ||
422 | return retval; | ||
423 | } | ||
424 | |||
425 | static snd_pcm_uframes_t snd_cx231xx_capture_pointer(struct snd_pcm_substream | ||
426 | *substream) | ||
427 | { | ||
428 | struct cx231xx *dev; | ||
429 | unsigned long flags; | ||
430 | snd_pcm_uframes_t hwptr_done; | ||
431 | |||
432 | dev = snd_pcm_substream_chip(substream); | ||
433 | |||
434 | spin_lock_irqsave(&dev->adev.slock, flags); | ||
435 | hwptr_done = dev->adev.hwptr_done_capture; | ||
436 | spin_unlock_irqrestore(&dev->adev.slock, flags); | ||
437 | |||
438 | return hwptr_done; | ||
439 | } | ||
440 | |||
441 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
442 | unsigned long offset) | ||
443 | { | ||
444 | void *pageptr = subs->runtime->dma_area + offset; | ||
445 | |||
446 | return vmalloc_to_page(pageptr); | ||
447 | } | ||
448 | |||
449 | static struct snd_pcm_ops snd_cx231xx_pcm_capture = { | ||
450 | .open = snd_cx231xx_capture_open, | ||
451 | .close = snd_cx231xx_pcm_close, | ||
452 | .ioctl = snd_pcm_lib_ioctl, | ||
453 | .hw_params = snd_cx231xx_hw_capture_params, | ||
454 | .hw_free = snd_cx231xx_hw_capture_free, | ||
455 | .prepare = snd_cx231xx_prepare, | ||
456 | .trigger = snd_cx231xx_capture_trigger, | ||
457 | .pointer = snd_cx231xx_capture_pointer, | ||
458 | .page = snd_pcm_get_vmalloc_page, | ||
459 | }; | ||
460 | |||
461 | static int cx231xx_audio_init(struct cx231xx *dev) | ||
462 | { | ||
463 | struct cx231xx_audio *adev = &dev->adev; | ||
464 | struct snd_pcm *pcm; | ||
465 | struct snd_card *card; | ||
466 | static int devnr; | ||
467 | int err; | ||
468 | struct usb_interface *uif; | ||
469 | int i, isoc_pipe = 0; | ||
470 | |||
471 | if (dev->has_alsa_audio != 1) { | ||
472 | /* This device does not support the extension (in this case | ||
473 | the device is expecting the snd-usb-audio module or | ||
474 | doesn't have analog audio support at all) */ | ||
475 | return 0; | ||
476 | } | ||
477 | |||
478 | cx231xx_info("cx231xx-audio.c: probing for cx231xx " | ||
479 | "non standard usbaudio\n"); | ||
480 | |||
481 | err = snd_card_create(index[devnr], "Cx231xx Audio", THIS_MODULE, | ||
482 | 0, &card); | ||
483 | if (err < 0) | ||
484 | return err; | ||
485 | |||
486 | spin_lock_init(&adev->slock); | ||
487 | err = snd_pcm_new(card, "Cx231xx Audio", 0, 0, 1, &pcm); | ||
488 | if (err < 0) { | ||
489 | snd_card_free(card); | ||
490 | return err; | ||
491 | } | ||
492 | |||
493 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
494 | &snd_cx231xx_pcm_capture); | ||
495 | pcm->info_flags = 0; | ||
496 | pcm->private_data = dev; | ||
497 | strcpy(pcm->name, "Conexant cx231xx Capture"); | ||
498 | strcpy(card->driver, "Conexant cx231xx Audio"); | ||
499 | strcpy(card->shortname, "Cx231xx Audio"); | ||
500 | strcpy(card->longname, "Conexant cx231xx Audio"); | ||
501 | |||
502 | err = snd_card_register(card); | ||
503 | if (err < 0) { | ||
504 | snd_card_free(card); | ||
505 | return err; | ||
506 | } | ||
507 | adev->sndcard = card; | ||
508 | adev->udev = dev->udev; | ||
509 | |||
510 | /* compute alternate max packet sizes for Audio */ | ||
511 | uif = | ||
512 | dev->udev->actconfig->interface[dev->current_pcb_config. | ||
513 | hs_config_info[0].interface_info. | ||
514 | audio_index + 1]; | ||
515 | |||
516 | adev->end_point_addr = | ||
517 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
518 | bEndpointAddress); | ||
519 | |||
520 | adev->num_alt = uif->num_altsetting; | ||
521 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
522 | adev->end_point_addr, adev->num_alt); | ||
523 | adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); | ||
524 | |||
525 | if (adev->alt_max_pkt_size == NULL) { | ||
526 | cx231xx_errdev("out of memory!\n"); | ||
527 | return -ENOMEM; | ||
528 | } | ||
529 | |||
530 | for (i = 0; i < adev->num_alt; i++) { | ||
531 | u16 tmp = | ||
532 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | ||
533 | wMaxPacketSize); | ||
534 | adev->alt_max_pkt_size[i] = | ||
535 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
536 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
537 | adev->alt_max_pkt_size[i]); | ||
538 | } | ||
539 | |||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | static int cx231xx_audio_fini(struct cx231xx *dev) | ||
544 | { | ||
545 | if (dev == NULL) | ||
546 | return 0; | ||
547 | |||
548 | if (dev->has_alsa_audio != 1) { | ||
549 | /* This device does not support the extension (in this case | ||
550 | the device is expecting the snd-usb-audio module or | ||
551 | doesn't have analog audio support at all) */ | ||
552 | return 0; | ||
553 | } | ||
554 | |||
555 | if (dev->adev.sndcard) { | ||
556 | snd_card_free(dev->adev.sndcard); | ||
557 | kfree(dev->adev.alt_max_pkt_size); | ||
558 | dev->adev.sndcard = NULL; | ||
559 | } | ||
560 | |||
561 | return 0; | ||
562 | } | ||
563 | |||
564 | static struct cx231xx_ops audio_ops = { | ||
565 | .id = CX231XX_AUDIO, | ||
566 | .name = "Cx231xx Audio Extension", | ||
567 | .init = cx231xx_audio_init, | ||
568 | .fini = cx231xx_audio_fini, | ||
569 | }; | ||
570 | |||
571 | static int __init cx231xx_alsa_register(void) | ||
572 | { | ||
573 | return cx231xx_register_extension(&audio_ops); | ||
574 | } | ||
575 | |||
576 | static void __exit cx231xx_alsa_unregister(void) | ||
577 | { | ||
578 | cx231xx_unregister_extension(&audio_ops); | ||
579 | } | ||
580 | |||
581 | MODULE_LICENSE("GPL"); | ||
582 | MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); | ||
583 | MODULE_DESCRIPTION("Cx231xx Audio driver"); | ||
584 | |||
585 | module_init(cx231xx_alsa_register); | ||
586 | module_exit(cx231xx_alsa_unregister); | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c new file mode 100644 index 000000000000..1be3881be991 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c | |||
@@ -0,0 +1,2581 @@ | |||
1 | /* | ||
2 | cx231xx_avcore.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program contains the specific code to control the avdecoder chip and | ||
8 | other related usb control functions for cx231xx based chipset. | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/bitmap.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | ||
32 | #include <linux/version.h> | ||
33 | #include <linux/mm.h> | ||
34 | #include <linux/mutex.h> | ||
35 | |||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-ioctl.h> | ||
38 | #include <media/v4l2-chip-ident.h> | ||
39 | |||
40 | #include "cx231xx.h" | ||
41 | |||
42 | /****************************************************************************** | ||
43 | -: BLOCK ARRANGEMENT :- | ||
44 | I2S block ----------------------| | ||
45 | [I2S audio] | | ||
46 | | | ||
47 | Analog Front End --> Direct IF -|-> Cx25840 --> Audio | ||
48 | [video & audio] | [Audio] | ||
49 | | | ||
50 | |-> Cx25840 --> Video | ||
51 | [Video] | ||
52 | |||
53 | *******************************************************************************/ | ||
54 | |||
55 | /****************************************************************************** | ||
56 | * A F E - B L O C K C O N T R O L functions * | ||
57 | * [ANALOG FRONT END] * | ||
58 | ******************************************************************************/ | ||
59 | static int afe_write_byte(struct cx231xx *dev, u16 saddr, u8 data) | ||
60 | { | ||
61 | return cx231xx_write_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
62 | saddr, 2, data, 1); | ||
63 | } | ||
64 | |||
65 | static int afe_read_byte(struct cx231xx *dev, u16 saddr, u8 *data) | ||
66 | { | ||
67 | int status; | ||
68 | u32 temp = 0; | ||
69 | |||
70 | status = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
71 | saddr, 2, &temp, 1); | ||
72 | *data = (u8) temp; | ||
73 | return status; | ||
74 | } | ||
75 | |||
76 | int cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count) | ||
77 | { | ||
78 | int status = 0; | ||
79 | u8 temp = 0; | ||
80 | u8 afe_power_status = 0; | ||
81 | int i = 0; | ||
82 | |||
83 | /* super block initialize */ | ||
84 | temp = (u8) (ref_count & 0xff); | ||
85 | status = afe_write_byte(dev, SUP_BLK_TUNE2, temp); | ||
86 | if (status < 0) | ||
87 | return status; | ||
88 | |||
89 | status = afe_read_byte(dev, SUP_BLK_TUNE2, &afe_power_status); | ||
90 | if (status < 0) | ||
91 | return status; | ||
92 | |||
93 | temp = (u8) ((ref_count & 0x300) >> 8); | ||
94 | temp |= 0x40; | ||
95 | status = afe_write_byte(dev, SUP_BLK_TUNE1, temp); | ||
96 | if (status < 0) | ||
97 | return status; | ||
98 | |||
99 | status = afe_write_byte(dev, SUP_BLK_PLL2, 0x0f); | ||
100 | if (status < 0) | ||
101 | return status; | ||
102 | |||
103 | /* enable pll */ | ||
104 | while (afe_power_status != 0x18) { | ||
105 | status = afe_write_byte(dev, SUP_BLK_PWRDN, 0x18); | ||
106 | if (status < 0) { | ||
107 | cx231xx_info( | ||
108 | ": Init Super Block failed in send cmd\n"); | ||
109 | break; | ||
110 | } | ||
111 | |||
112 | status = afe_read_byte(dev, SUP_BLK_PWRDN, &afe_power_status); | ||
113 | afe_power_status &= 0xff; | ||
114 | if (status < 0) { | ||
115 | cx231xx_info( | ||
116 | ": Init Super Block failed in receive cmd\n"); | ||
117 | break; | ||
118 | } | ||
119 | i++; | ||
120 | if (i == 10) { | ||
121 | cx231xx_info( | ||
122 | ": Init Super Block force break in loop !!!!\n"); | ||
123 | status = -1; | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | |||
128 | if (status < 0) | ||
129 | return status; | ||
130 | |||
131 | /* start tuning filter */ | ||
132 | status = afe_write_byte(dev, SUP_BLK_TUNE3, 0x40); | ||
133 | if (status < 0) | ||
134 | return status; | ||
135 | |||
136 | msleep(5); | ||
137 | |||
138 | /* exit tuning */ | ||
139 | status = afe_write_byte(dev, SUP_BLK_TUNE3, 0x00); | ||
140 | |||
141 | return status; | ||
142 | } | ||
143 | |||
144 | int cx231xx_afe_init_channels(struct cx231xx *dev) | ||
145 | { | ||
146 | int status = 0; | ||
147 | |||
148 | /* power up all 3 channels, clear pd_buffer */ | ||
149 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, 0x00); | ||
150 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, 0x00); | ||
151 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, 0x00); | ||
152 | |||
153 | /* Enable quantizer calibration */ | ||
154 | status = afe_write_byte(dev, ADC_COM_QUANT, 0x02); | ||
155 | |||
156 | /* channel initialize, force modulator (fb) reset */ | ||
157 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH1, 0x17); | ||
158 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH2, 0x17); | ||
159 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH3, 0x17); | ||
160 | |||
161 | /* start quantilizer calibration */ | ||
162 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH1, 0x10); | ||
163 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH2, 0x10); | ||
164 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH3, 0x10); | ||
165 | msleep(5); | ||
166 | |||
167 | /* exit modulator (fb) reset */ | ||
168 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH1, 0x07); | ||
169 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH2, 0x07); | ||
170 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH3, 0x07); | ||
171 | |||
172 | /* enable the pre_clamp in each channel for single-ended input */ | ||
173 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH1, 0xf0); | ||
174 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH2, 0xf0); | ||
175 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH3, 0xf0); | ||
176 | |||
177 | /* use diode instead of resistor, so set term_en to 0, res_en to 0 */ | ||
178 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
179 | ADC_QGAIN_RES_TRM_CH1, 3, 7, 0x00); | ||
180 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
181 | ADC_QGAIN_RES_TRM_CH2, 3, 7, 0x00); | ||
182 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
183 | ADC_QGAIN_RES_TRM_CH3, 3, 7, 0x00); | ||
184 | |||
185 | /* dynamic element matching off */ | ||
186 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH1, 0x03); | ||
187 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH2, 0x03); | ||
188 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH3, 0x03); | ||
189 | |||
190 | return status; | ||
191 | } | ||
192 | |||
193 | int cx231xx_afe_setup_AFE_for_baseband(struct cx231xx *dev) | ||
194 | { | ||
195 | u8 c_value = 0; | ||
196 | int status = 0; | ||
197 | |||
198 | status = afe_read_byte(dev, ADC_PWRDN_CLAMP_CH2, &c_value); | ||
199 | c_value &= (~(0x50)); | ||
200 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, c_value); | ||
201 | |||
202 | return status; | ||
203 | } | ||
204 | |||
205 | /* | ||
206 | The Analog Front End in Cx231xx has 3 channels. These | ||
207 | channels are used to share between different inputs | ||
208 | like tuner, s-video and composite inputs. | ||
209 | |||
210 | channel 1 ----- pin 1 to pin4(in reg is 1-4) | ||
211 | channel 2 ----- pin 5 to pin8(in reg is 5-8) | ||
212 | channel 3 ----- pin 9 to pin 12(in reg is 9-11) | ||
213 | */ | ||
214 | int cx231xx_afe_set_input_mux(struct cx231xx *dev, u32 input_mux) | ||
215 | { | ||
216 | u8 ch1_setting = (u8) input_mux; | ||
217 | u8 ch2_setting = (u8) (input_mux >> 8); | ||
218 | u8 ch3_setting = (u8) (input_mux >> 16); | ||
219 | int status = 0; | ||
220 | u8 value = 0; | ||
221 | |||
222 | if (ch1_setting != 0) { | ||
223 | status = afe_read_byte(dev, ADC_INPUT_CH1, &value); | ||
224 | value &= (!INPUT_SEL_MASK); | ||
225 | value |= (ch1_setting - 1) << 4; | ||
226 | value &= 0xff; | ||
227 | status = afe_write_byte(dev, ADC_INPUT_CH1, value); | ||
228 | } | ||
229 | |||
230 | if (ch2_setting != 0) { | ||
231 | status = afe_read_byte(dev, ADC_INPUT_CH2, &value); | ||
232 | value &= (!INPUT_SEL_MASK); | ||
233 | value |= (ch2_setting - 1) << 4; | ||
234 | value &= 0xff; | ||
235 | status = afe_write_byte(dev, ADC_INPUT_CH2, value); | ||
236 | } | ||
237 | |||
238 | /* For ch3_setting, the value to put in the register is | ||
239 | 7 less than the input number */ | ||
240 | if (ch3_setting != 0) { | ||
241 | status = afe_read_byte(dev, ADC_INPUT_CH3, &value); | ||
242 | value &= (!INPUT_SEL_MASK); | ||
243 | value |= (ch3_setting - 1) << 4; | ||
244 | value &= 0xff; | ||
245 | status = afe_write_byte(dev, ADC_INPUT_CH3, value); | ||
246 | } | ||
247 | |||
248 | return status; | ||
249 | } | ||
250 | |||
251 | int cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode) | ||
252 | { | ||
253 | int status = 0; | ||
254 | |||
255 | /* | ||
256 | * FIXME: We need to implement the AFE code for LOW IF and for HI IF. | ||
257 | * Currently, only baseband works. | ||
258 | */ | ||
259 | |||
260 | switch (mode) { | ||
261 | case AFE_MODE_LOW_IF: | ||
262 | /* SetupAFEforLowIF(); */ | ||
263 | break; | ||
264 | case AFE_MODE_BASEBAND: | ||
265 | status = cx231xx_afe_setup_AFE_for_baseband(dev); | ||
266 | break; | ||
267 | case AFE_MODE_EU_HI_IF: | ||
268 | /* SetupAFEforEuHiIF(); */ | ||
269 | break; | ||
270 | case AFE_MODE_US_HI_IF: | ||
271 | /* SetupAFEforUsHiIF(); */ | ||
272 | break; | ||
273 | case AFE_MODE_JAPAN_HI_IF: | ||
274 | /* SetupAFEforJapanHiIF(); */ | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | if ((mode != dev->afe_mode) && | ||
279 | (dev->video_input == CX231XX_VMUX_TELEVISION)) | ||
280 | status = cx231xx_afe_adjust_ref_count(dev, | ||
281 | CX231XX_VMUX_TELEVISION); | ||
282 | |||
283 | dev->afe_mode = mode; | ||
284 | |||
285 | return status; | ||
286 | } | ||
287 | |||
288 | int cx231xx_afe_update_power_control(struct cx231xx *dev, | ||
289 | enum AV_MODE avmode) | ||
290 | { | ||
291 | u8 afe_power_status = 0; | ||
292 | int status = 0; | ||
293 | |||
294 | switch (dev->model) { | ||
295 | case CX231XX_BOARD_CNXT_RDE_250: | ||
296 | case CX231XX_BOARD_CNXT_RDU_250: | ||
297 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { | ||
298 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
299 | FLD_PWRDN_ENABLE_PLL)) { | ||
300 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
301 | FLD_PWRDN_TUNING_BIAS | | ||
302 | FLD_PWRDN_ENABLE_PLL); | ||
303 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
304 | &afe_power_status); | ||
305 | if (status < 0) | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
310 | 0x00); | ||
311 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
312 | 0x00); | ||
313 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
314 | 0x00); | ||
315 | } else if (avmode == POLARIS_AVMODE_DIGITAL) { | ||
316 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
317 | 0x70); | ||
318 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
319 | 0x70); | ||
320 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
321 | 0x70); | ||
322 | |||
323 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
324 | &afe_power_status); | ||
325 | afe_power_status |= FLD_PWRDN_PD_BANDGAP | | ||
326 | FLD_PWRDN_PD_BIAS | | ||
327 | FLD_PWRDN_PD_TUNECK; | ||
328 | status |= afe_write_byte(dev, SUP_BLK_PWRDN, | ||
329 | afe_power_status); | ||
330 | } else if (avmode == POLARIS_AVMODE_ENXTERNAL_AV) { | ||
331 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
332 | FLD_PWRDN_ENABLE_PLL)) { | ||
333 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
334 | FLD_PWRDN_TUNING_BIAS | | ||
335 | FLD_PWRDN_ENABLE_PLL); | ||
336 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
337 | &afe_power_status); | ||
338 | if (status < 0) | ||
339 | break; | ||
340 | } | ||
341 | |||
342 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
343 | 0x00); | ||
344 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
345 | 0x00); | ||
346 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
347 | 0x00); | ||
348 | } else { | ||
349 | cx231xx_info("Invalid AV mode input\n"); | ||
350 | status = -1; | ||
351 | } | ||
352 | break; | ||
353 | default: | ||
354 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { | ||
355 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
356 | FLD_PWRDN_ENABLE_PLL)) { | ||
357 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
358 | FLD_PWRDN_TUNING_BIAS | | ||
359 | FLD_PWRDN_ENABLE_PLL); | ||
360 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
361 | &afe_power_status); | ||
362 | if (status < 0) | ||
363 | break; | ||
364 | } | ||
365 | |||
366 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
367 | 0x40); | ||
368 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
369 | 0x40); | ||
370 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
371 | 0x00); | ||
372 | } else if (avmode == POLARIS_AVMODE_DIGITAL) { | ||
373 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
374 | 0x70); | ||
375 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
376 | 0x70); | ||
377 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
378 | 0x70); | ||
379 | |||
380 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
381 | &afe_power_status); | ||
382 | afe_power_status |= FLD_PWRDN_PD_BANDGAP | | ||
383 | FLD_PWRDN_PD_BIAS | | ||
384 | FLD_PWRDN_PD_TUNECK; | ||
385 | status |= afe_write_byte(dev, SUP_BLK_PWRDN, | ||
386 | afe_power_status); | ||
387 | } else if (avmode == POLARIS_AVMODE_ENXTERNAL_AV) { | ||
388 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
389 | FLD_PWRDN_ENABLE_PLL)) { | ||
390 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
391 | FLD_PWRDN_TUNING_BIAS | | ||
392 | FLD_PWRDN_ENABLE_PLL); | ||
393 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
394 | &afe_power_status); | ||
395 | if (status < 0) | ||
396 | break; | ||
397 | } | ||
398 | |||
399 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
400 | 0x00); | ||
401 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
402 | 0x00); | ||
403 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
404 | 0x40); | ||
405 | } else { | ||
406 | cx231xx_info("Invalid AV mode input\n"); | ||
407 | status = -1; | ||
408 | } | ||
409 | } /* switch */ | ||
410 | |||
411 | return status; | ||
412 | } | ||
413 | |||
414 | int cx231xx_afe_adjust_ref_count(struct cx231xx *dev, u32 video_input) | ||
415 | { | ||
416 | u8 input_mode = 0; | ||
417 | u8 ntf_mode = 0; | ||
418 | int status = 0; | ||
419 | |||
420 | dev->video_input = video_input; | ||
421 | |||
422 | if (video_input == CX231XX_VMUX_TELEVISION) { | ||
423 | status = afe_read_byte(dev, ADC_INPUT_CH3, &input_mode); | ||
424 | status = afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH3, | ||
425 | &ntf_mode); | ||
426 | } else { | ||
427 | status = afe_read_byte(dev, ADC_INPUT_CH1, &input_mode); | ||
428 | status = afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH1, | ||
429 | &ntf_mode); | ||
430 | } | ||
431 | |||
432 | input_mode = (ntf_mode & 0x3) | ((input_mode & 0x6) << 1); | ||
433 | |||
434 | switch (input_mode) { | ||
435 | case SINGLE_ENDED: | ||
436 | dev->afe_ref_count = 0x23C; | ||
437 | break; | ||
438 | case LOW_IF: | ||
439 | dev->afe_ref_count = 0x24C; | ||
440 | break; | ||
441 | case EU_IF: | ||
442 | dev->afe_ref_count = 0x258; | ||
443 | break; | ||
444 | case US_IF: | ||
445 | dev->afe_ref_count = 0x260; | ||
446 | break; | ||
447 | default: | ||
448 | break; | ||
449 | } | ||
450 | |||
451 | status = cx231xx_afe_init_super_block(dev, dev->afe_ref_count); | ||
452 | |||
453 | return status; | ||
454 | } | ||
455 | |||
456 | /****************************************************************************** | ||
457 | * V I D E O / A U D I O D E C O D E R C O N T R O L functions * | ||
458 | ******************************************************************************/ | ||
459 | static int vid_blk_write_byte(struct cx231xx *dev, u16 saddr, u8 data) | ||
460 | { | ||
461 | return cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
462 | saddr, 2, data, 1); | ||
463 | } | ||
464 | |||
465 | static int vid_blk_read_byte(struct cx231xx *dev, u16 saddr, u8 *data) | ||
466 | { | ||
467 | int status; | ||
468 | u32 temp = 0; | ||
469 | |||
470 | status = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
471 | saddr, 2, &temp, 1); | ||
472 | *data = (u8) temp; | ||
473 | return status; | ||
474 | } | ||
475 | |||
476 | static int vid_blk_write_word(struct cx231xx *dev, u16 saddr, u32 data) | ||
477 | { | ||
478 | return cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
479 | saddr, 2, data, 4); | ||
480 | } | ||
481 | |||
482 | static int vid_blk_read_word(struct cx231xx *dev, u16 saddr, u32 *data) | ||
483 | { | ||
484 | return cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
485 | saddr, 2, data, 4); | ||
486 | } | ||
487 | |||
488 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | ||
489 | { | ||
490 | int status = 0; | ||
491 | |||
492 | switch (INPUT(input)->type) { | ||
493 | case CX231XX_VMUX_COMPOSITE1: | ||
494 | case CX231XX_VMUX_SVIDEO: | ||
495 | if ((dev->current_pcb_config.type == USB_BUS_POWER) && | ||
496 | (dev->power_mode != POLARIS_AVMODE_ENXTERNAL_AV)) { | ||
497 | /* External AV */ | ||
498 | status = cx231xx_set_power_mode(dev, | ||
499 | POLARIS_AVMODE_ENXTERNAL_AV); | ||
500 | if (status < 0) { | ||
501 | cx231xx_errdev("%s: set_power_mode : Failed to" | ||
502 | " set Power - errCode [%d]!\n", | ||
503 | __func__, status); | ||
504 | return status; | ||
505 | } | ||
506 | } | ||
507 | status = cx231xx_set_decoder_video_input(dev, | ||
508 | INPUT(input)->type, | ||
509 | INPUT(input)->vmux); | ||
510 | break; | ||
511 | case CX231XX_VMUX_TELEVISION: | ||
512 | case CX231XX_VMUX_CABLE: | ||
513 | if ((dev->current_pcb_config.type == USB_BUS_POWER) && | ||
514 | (dev->power_mode != POLARIS_AVMODE_ANALOGT_TV)) { | ||
515 | /* Tuner */ | ||
516 | status = cx231xx_set_power_mode(dev, | ||
517 | POLARIS_AVMODE_ANALOGT_TV); | ||
518 | if (status < 0) { | ||
519 | cx231xx_errdev("%s: set_power_mode:Failed" | ||
520 | " to set Power - errCode [%d]!\n", | ||
521 | __func__, status); | ||
522 | return status; | ||
523 | } | ||
524 | } | ||
525 | status = cx231xx_set_decoder_video_input(dev, | ||
526 | CX231XX_VMUX_COMPOSITE1, | ||
527 | INPUT(input)->vmux); | ||
528 | break; | ||
529 | default: | ||
530 | cx231xx_errdev("%s: set_power_mode : Unknown Input %d !\n", | ||
531 | __func__, INPUT(input)->type); | ||
532 | break; | ||
533 | } | ||
534 | |||
535 | /* save the selection */ | ||
536 | dev->video_input = input; | ||
537 | |||
538 | return status; | ||
539 | } | ||
540 | |||
541 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, | ||
542 | u8 pin_type, u8 input) | ||
543 | { | ||
544 | int status = 0; | ||
545 | u32 value = 0; | ||
546 | |||
547 | if (pin_type != dev->video_input) { | ||
548 | status = cx231xx_afe_adjust_ref_count(dev, pin_type); | ||
549 | if (status < 0) { | ||
550 | cx231xx_errdev("%s: adjust_ref_count :Failed to set" | ||
551 | "AFE input mux - errCode [%d]!\n", | ||
552 | __func__, status); | ||
553 | return status; | ||
554 | } | ||
555 | } | ||
556 | |||
557 | /* call afe block to set video inputs */ | ||
558 | status = cx231xx_afe_set_input_mux(dev, input); | ||
559 | if (status < 0) { | ||
560 | cx231xx_errdev("%s: set_input_mux :Failed to set" | ||
561 | " AFE input mux - errCode [%d]!\n", | ||
562 | __func__, status); | ||
563 | return status; | ||
564 | } | ||
565 | |||
566 | switch (pin_type) { | ||
567 | case CX231XX_VMUX_COMPOSITE1: | ||
568 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
569 | value |= (0 << 13) | (1 << 4); | ||
570 | value &= ~(1 << 5); | ||
571 | |||
572 | /* set [24:23] [22:15] to 0 */ | ||
573 | value &= (~(0x1ff8000)); | ||
574 | /* set FUNC_MODE[24:23] = 2 IF_MOD[22:15] = 0 */ | ||
575 | value |= 0x1000000; | ||
576 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
577 | |||
578 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
579 | value |= (1 << 7); | ||
580 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
581 | |||
582 | /* Set vip 1.1 output mode */ | ||
583 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
584 | VID_BLK_I2C_ADDRESS, | ||
585 | OUT_CTRL1, | ||
586 | FLD_OUT_MODE, | ||
587 | OUT_MODE_VIP11); | ||
588 | |||
589 | /* Tell DIF object to go to baseband mode */ | ||
590 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
591 | if (status < 0) { | ||
592 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
593 | " mode- errCode [%d]!\n", | ||
594 | __func__, status); | ||
595 | return status; | ||
596 | } | ||
597 | |||
598 | /* Read the DFE_CTRL1 register */ | ||
599 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
600 | |||
601 | /* enable the VBI_GATE_EN */ | ||
602 | value |= FLD_VBI_GATE_EN; | ||
603 | |||
604 | /* Enable the auto-VGA enable */ | ||
605 | value |= FLD_VGA_AUTO_EN; | ||
606 | |||
607 | /* Write it back */ | ||
608 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
609 | |||
610 | /* Disable auto config of registers */ | ||
611 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
612 | VID_BLK_I2C_ADDRESS, | ||
613 | MODE_CTRL, FLD_ACFG_DIS, | ||
614 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
615 | |||
616 | /* Set CVBS input mode */ | ||
617 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
618 | VID_BLK_I2C_ADDRESS, | ||
619 | MODE_CTRL, FLD_INPUT_MODE, | ||
620 | cx231xx_set_field(FLD_INPUT_MODE, INPUT_MODE_CVBS_0)); | ||
621 | break; | ||
622 | case CX231XX_VMUX_SVIDEO: | ||
623 | /* Disable the use of DIF */ | ||
624 | |||
625 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
626 | |||
627 | /* set [24:23] [22:15] to 0 */ | ||
628 | value &= (~(0x1ff8000)); | ||
629 | /* set FUNC_MODE[24:23] = 2 | ||
630 | IF_MOD[22:15] = 0 DCR_BYP_CH2[4:4] = 1; */ | ||
631 | value |= 0x1000010; | ||
632 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
633 | |||
634 | /* Tell DIF object to go to baseband mode */ | ||
635 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
636 | if (status < 0) { | ||
637 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
638 | " mode- errCode [%d]!\n", | ||
639 | __func__, status); | ||
640 | return status; | ||
641 | } | ||
642 | |||
643 | /* Read the DFE_CTRL1 register */ | ||
644 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
645 | |||
646 | /* enable the VBI_GATE_EN */ | ||
647 | value |= FLD_VBI_GATE_EN; | ||
648 | |||
649 | /* Enable the auto-VGA enable */ | ||
650 | value |= FLD_VGA_AUTO_EN; | ||
651 | |||
652 | /* Write it back */ | ||
653 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
654 | |||
655 | /* Disable auto config of registers */ | ||
656 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
657 | VID_BLK_I2C_ADDRESS, | ||
658 | MODE_CTRL, FLD_ACFG_DIS, | ||
659 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
660 | |||
661 | /* Set YC input mode */ | ||
662 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
663 | VID_BLK_I2C_ADDRESS, | ||
664 | MODE_CTRL, | ||
665 | FLD_INPUT_MODE, | ||
666 | cx231xx_set_field(FLD_INPUT_MODE, INPUT_MODE_YC_1)); | ||
667 | |||
668 | /* Chroma to ADC2 */ | ||
669 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
670 | value |= FLD_CHROMA_IN_SEL; /* set the chroma in select */ | ||
671 | |||
672 | /* Clear VGA_SEL_CH2 and VGA_SEL_CH3 (bits 7 and 8) | ||
673 | This sets them to use video | ||
674 | rather than audio. Only one of the two will be in use. */ | ||
675 | value &= ~(FLD_VGA_SEL_CH2 | FLD_VGA_SEL_CH3); | ||
676 | |||
677 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
678 | |||
679 | status = cx231xx_afe_set_mode(dev, AFE_MODE_BASEBAND); | ||
680 | break; | ||
681 | case CX231XX_VMUX_TELEVISION: | ||
682 | case CX231XX_VMUX_CABLE: | ||
683 | default: | ||
684 | switch (dev->model) { | ||
685 | case CX231XX_BOARD_CNXT_RDE_250: | ||
686 | case CX231XX_BOARD_CNXT_RDU_250: | ||
687 | /* Disable the use of DIF */ | ||
688 | |||
689 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
690 | value |= (0 << 13) | (1 << 4); | ||
691 | value &= ~(1 << 5); | ||
692 | |||
693 | /* set [24:23] [22:15] to 0 */ | ||
694 | value &= (~(0x1FF8000)); | ||
695 | /* set FUNC_MODE[24:23] = 2 IF_MOD[22:15] = 0 */ | ||
696 | value |= 0x1000000; | ||
697 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
698 | |||
699 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
700 | value |= (1 << 7); | ||
701 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
702 | |||
703 | /* Set vip 1.1 output mode */ | ||
704 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
705 | VID_BLK_I2C_ADDRESS, | ||
706 | OUT_CTRL1, FLD_OUT_MODE, | ||
707 | OUT_MODE_VIP11); | ||
708 | |||
709 | /* Tell DIF object to go to baseband mode */ | ||
710 | status = cx231xx_dif_set_standard(dev, | ||
711 | DIF_USE_BASEBAND); | ||
712 | if (status < 0) { | ||
713 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
714 | " mode- errCode [%d]!\n", | ||
715 | __func__, status); | ||
716 | return status; | ||
717 | } | ||
718 | |||
719 | /* Read the DFE_CTRL1 register */ | ||
720 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
721 | |||
722 | /* enable the VBI_GATE_EN */ | ||
723 | value |= FLD_VBI_GATE_EN; | ||
724 | |||
725 | /* Enable the auto-VGA enable */ | ||
726 | value |= FLD_VGA_AUTO_EN; | ||
727 | |||
728 | /* Write it back */ | ||
729 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
730 | |||
731 | /* Disable auto config of registers */ | ||
732 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
733 | VID_BLK_I2C_ADDRESS, | ||
734 | MODE_CTRL, FLD_ACFG_DIS, | ||
735 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
736 | |||
737 | /* Set CVBS input mode */ | ||
738 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
739 | VID_BLK_I2C_ADDRESS, | ||
740 | MODE_CTRL, FLD_INPUT_MODE, | ||
741 | cx231xx_set_field(FLD_INPUT_MODE, | ||
742 | INPUT_MODE_CVBS_0)); | ||
743 | break; | ||
744 | default: | ||
745 | /* Enable the DIF for the tuner */ | ||
746 | |||
747 | /* Reinitialize the DIF */ | ||
748 | status = cx231xx_dif_set_standard(dev, dev->norm); | ||
749 | if (status < 0) { | ||
750 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
751 | " mode- errCode [%d]!\n", | ||
752 | __func__, status); | ||
753 | return status; | ||
754 | } | ||
755 | |||
756 | /* Make sure bypass is cleared */ | ||
757 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &value); | ||
758 | |||
759 | /* Clear the bypass bit */ | ||
760 | value &= ~FLD_DIF_DIF_BYPASS; | ||
761 | |||
762 | /* Enable the use of the DIF block */ | ||
763 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, value); | ||
764 | |||
765 | /* Read the DFE_CTRL1 register */ | ||
766 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
767 | |||
768 | /* Disable the VBI_GATE_EN */ | ||
769 | value &= ~FLD_VBI_GATE_EN; | ||
770 | |||
771 | /* Enable the auto-VGA enable, AGC, and | ||
772 | set the skip count to 2 */ | ||
773 | value |= FLD_VGA_AUTO_EN | FLD_AGC_AUTO_EN | 0x00200000; | ||
774 | |||
775 | /* Write it back */ | ||
776 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
777 | |||
778 | /* Wait until AGC locks up */ | ||
779 | msleep(1); | ||
780 | |||
781 | /* Disable the auto-VGA enable AGC */ | ||
782 | value &= ~(FLD_VGA_AUTO_EN); | ||
783 | |||
784 | /* Write it back */ | ||
785 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
786 | |||
787 | /* Enable Polaris B0 AGC output */ | ||
788 | status = vid_blk_read_word(dev, PIN_CTRL, &value); | ||
789 | value |= (FLD_OEF_AGC_RF) | | ||
790 | (FLD_OEF_AGC_IFVGA) | | ||
791 | (FLD_OEF_AGC_IF); | ||
792 | status = vid_blk_write_word(dev, PIN_CTRL, value); | ||
793 | |||
794 | /* Set vip 1.1 output mode */ | ||
795 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
796 | VID_BLK_I2C_ADDRESS, | ||
797 | OUT_CTRL1, FLD_OUT_MODE, | ||
798 | OUT_MODE_VIP11); | ||
799 | |||
800 | /* Disable auto config of registers */ | ||
801 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
802 | VID_BLK_I2C_ADDRESS, | ||
803 | MODE_CTRL, FLD_ACFG_DIS, | ||
804 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
805 | |||
806 | /* Set CVBS input mode */ | ||
807 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
808 | VID_BLK_I2C_ADDRESS, | ||
809 | MODE_CTRL, FLD_INPUT_MODE, | ||
810 | cx231xx_set_field(FLD_INPUT_MODE, | ||
811 | INPUT_MODE_CVBS_0)); | ||
812 | |||
813 | /* Set some bits in AFE_CTRL so that channel 2 or 3 | ||
814 | * is ready to receive audio */ | ||
815 | /* Clear clamp for channels 2 and 3 (bit 16-17) */ | ||
816 | /* Clear droop comp (bit 19-20) */ | ||
817 | /* Set VGA_SEL (for audio control) (bit 7-8) */ | ||
818 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
819 | |||
820 | value |= FLD_VGA_SEL_CH3 | FLD_VGA_SEL_CH2; | ||
821 | |||
822 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
823 | break; | ||
824 | |||
825 | } | ||
826 | break; | ||
827 | } | ||
828 | |||
829 | /* Set raw VBI mode */ | ||
830 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
831 | VID_BLK_I2C_ADDRESS, | ||
832 | OUT_CTRL1, FLD_VBIHACTRAW_EN, | ||
833 | cx231xx_set_field(FLD_VBIHACTRAW_EN, 1)); | ||
834 | |||
835 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
836 | if (value & 0x02) { | ||
837 | value |= (1 << 19); | ||
838 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
839 | } | ||
840 | |||
841 | return status; | ||
842 | } | ||
843 | |||
844 | /* | ||
845 | * Handle any video-mode specific overrides that are different | ||
846 | * on a per video standards basis after touching the MODE_CTRL | ||
847 | * register which resets many values for autodetect | ||
848 | */ | ||
849 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | ||
850 | { | ||
851 | int status = 0; | ||
852 | |||
853 | cx231xx_info("do_mode_ctrl_overrides : 0x%x\n", | ||
854 | (unsigned int)dev->norm); | ||
855 | |||
856 | /* Change the DFE_CTRL3 bp_percent to fix flagging */ | ||
857 | status = vid_blk_write_word(dev, DFE_CTRL3, 0xCD3F0280); | ||
858 | |||
859 | if (dev->norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) { | ||
860 | cx231xx_info("do_mode_ctrl_overrides NTSC\n"); | ||
861 | |||
862 | /* Move the close caption lines out of active video, | ||
863 | adjust the active video start point */ | ||
864 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
865 | VID_BLK_I2C_ADDRESS, | ||
866 | VERT_TIM_CTRL, | ||
867 | FLD_VBLANK_CNT, 0x18); | ||
868 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
869 | VID_BLK_I2C_ADDRESS, | ||
870 | VERT_TIM_CTRL, | ||
871 | FLD_VACTIVE_CNT, | ||
872 | 0x1E6000); | ||
873 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
874 | VID_BLK_I2C_ADDRESS, | ||
875 | VERT_TIM_CTRL, | ||
876 | FLD_V656BLANK_CNT, | ||
877 | 0x1E000000); | ||
878 | |||
879 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
880 | VID_BLK_I2C_ADDRESS, | ||
881 | HORIZ_TIM_CTRL, | ||
882 | FLD_HBLANK_CNT, | ||
883 | cx231xx_set_field | ||
884 | (FLD_HBLANK_CNT, 0x79)); | ||
885 | } else if (dev->norm & V4L2_STD_SECAM) { | ||
886 | cx231xx_info("do_mode_ctrl_overrides SECAM\n"); | ||
887 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
888 | VID_BLK_I2C_ADDRESS, | ||
889 | VERT_TIM_CTRL, | ||
890 | FLD_VBLANK_CNT, 0x24); | ||
891 | /* Adjust the active video horizontal start point */ | ||
892 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
893 | VID_BLK_I2C_ADDRESS, | ||
894 | HORIZ_TIM_CTRL, | ||
895 | FLD_HBLANK_CNT, | ||
896 | cx231xx_set_field | ||
897 | (FLD_HBLANK_CNT, 0x85)); | ||
898 | } else { | ||
899 | cx231xx_info("do_mode_ctrl_overrides PAL\n"); | ||
900 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
901 | VID_BLK_I2C_ADDRESS, | ||
902 | VERT_TIM_CTRL, | ||
903 | FLD_VBLANK_CNT, 0x24); | ||
904 | /* Adjust the active video horizontal start point */ | ||
905 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
906 | VID_BLK_I2C_ADDRESS, | ||
907 | HORIZ_TIM_CTRL, | ||
908 | FLD_HBLANK_CNT, | ||
909 | cx231xx_set_field | ||
910 | (FLD_HBLANK_CNT, 0x85)); | ||
911 | } | ||
912 | |||
913 | return status; | ||
914 | } | ||
915 | |||
916 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input) | ||
917 | { | ||
918 | int status = 0; | ||
919 | enum AUDIO_INPUT ainput = AUDIO_INPUT_LINE; | ||
920 | |||
921 | switch (INPUT(input)->amux) { | ||
922 | case CX231XX_AMUX_VIDEO: | ||
923 | ainput = AUDIO_INPUT_TUNER_TV; | ||
924 | break; | ||
925 | case CX231XX_AMUX_LINE_IN: | ||
926 | status = cx231xx_i2s_blk_set_audio_input(dev, input); | ||
927 | ainput = AUDIO_INPUT_LINE; | ||
928 | break; | ||
929 | default: | ||
930 | break; | ||
931 | } | ||
932 | |||
933 | status = cx231xx_set_audio_decoder_input(dev, ainput); | ||
934 | |||
935 | return status; | ||
936 | } | ||
937 | |||
938 | int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | ||
939 | enum AUDIO_INPUT audio_input) | ||
940 | { | ||
941 | u32 dwval; | ||
942 | int status; | ||
943 | u8 gen_ctrl; | ||
944 | u32 value = 0; | ||
945 | |||
946 | /* Put it in soft reset */ | ||
947 | status = vid_blk_read_byte(dev, GENERAL_CTL, &gen_ctrl); | ||
948 | gen_ctrl |= 1; | ||
949 | status = vid_blk_write_byte(dev, GENERAL_CTL, gen_ctrl); | ||
950 | |||
951 | switch (audio_input) { | ||
952 | case AUDIO_INPUT_LINE: | ||
953 | /* setup AUD_IO control from Merlin paralle output */ | ||
954 | value = cx231xx_set_field(FLD_AUD_CHAN1_SRC, | ||
955 | AUD_CHAN_SRC_PARALLEL); | ||
956 | status = vid_blk_write_word(dev, AUD_IO_CTRL, value); | ||
957 | |||
958 | /* setup input to Merlin, SRC2 connect to AC97 | ||
959 | bypass upsample-by-2, slave mode, sony mode, left justify | ||
960 | adr 091c, dat 01000000 */ | ||
961 | status = vid_blk_read_word(dev, AC97_CTL, &dwval); | ||
962 | |||
963 | status = vid_blk_write_word(dev, AC97_CTL, | ||
964 | (dwval | FLD_AC97_UP2X_BYPASS)); | ||
965 | |||
966 | /* select the parallel1 and SRC3 */ | ||
967 | status = vid_blk_write_word(dev, BAND_OUT_SEL, | ||
968 | cx231xx_set_field(FLD_SRC3_IN_SEL, 0x0) | | ||
969 | cx231xx_set_field(FLD_SRC3_CLK_SEL, 0x0) | | ||
970 | cx231xx_set_field(FLD_PARALLEL1_SRC_SEL, 0x0)); | ||
971 | |||
972 | /* unmute all, AC97 in, independence mode | ||
973 | adr 08d0, data 0x00063073 */ | ||
974 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063073); | ||
975 | |||
976 | /* set AVC maximum threshold, adr 08d4, dat ffff0024 */ | ||
977 | status = vid_blk_read_word(dev, PATH1_VOL_CTL, &dwval); | ||
978 | status = vid_blk_write_word(dev, PATH1_VOL_CTL, | ||
979 | (dwval | FLD_PATH1_AVC_THRESHOLD)); | ||
980 | |||
981 | /* set SC maximum threshold, adr 08ec, dat ffffb3a3 */ | ||
982 | status = vid_blk_read_word(dev, PATH1_SC_CTL, &dwval); | ||
983 | status = vid_blk_write_word(dev, PATH1_SC_CTL, | ||
984 | (dwval | FLD_PATH1_SC_THRESHOLD)); | ||
985 | break; | ||
986 | |||
987 | case AUDIO_INPUT_TUNER_TV: | ||
988 | default: | ||
989 | |||
990 | /* Setup SRC sources and clocks */ | ||
991 | status = vid_blk_write_word(dev, BAND_OUT_SEL, | ||
992 | cx231xx_set_field(FLD_SRC6_IN_SEL, 0x00) | | ||
993 | cx231xx_set_field(FLD_SRC6_CLK_SEL, 0x01) | | ||
994 | cx231xx_set_field(FLD_SRC5_IN_SEL, 0x00) | | ||
995 | cx231xx_set_field(FLD_SRC5_CLK_SEL, 0x02) | | ||
996 | cx231xx_set_field(FLD_SRC4_IN_SEL, 0x02) | | ||
997 | cx231xx_set_field(FLD_SRC4_CLK_SEL, 0x03) | | ||
998 | cx231xx_set_field(FLD_SRC3_IN_SEL, 0x00) | | ||
999 | cx231xx_set_field(FLD_SRC3_CLK_SEL, 0x00) | | ||
1000 | cx231xx_set_field(FLD_BASEBAND_BYPASS_CTL, 0x00) | | ||
1001 | cx231xx_set_field(FLD_AC97_SRC_SEL, 0x03) | | ||
1002 | cx231xx_set_field(FLD_I2S_SRC_SEL, 0x00) | | ||
1003 | cx231xx_set_field(FLD_PARALLEL2_SRC_SEL, 0x02) | | ||
1004 | cx231xx_set_field(FLD_PARALLEL1_SRC_SEL, 0x01)); | ||
1005 | |||
1006 | /* Setup the AUD_IO control */ | ||
1007 | status = vid_blk_write_word(dev, AUD_IO_CTRL, | ||
1008 | cx231xx_set_field(FLD_I2S_PORT_DIR, 0x00) | | ||
1009 | cx231xx_set_field(FLD_I2S_OUT_SRC, 0x00) | | ||
1010 | cx231xx_set_field(FLD_AUD_CHAN3_SRC, 0x00) | | ||
1011 | cx231xx_set_field(FLD_AUD_CHAN2_SRC, 0x00) | | ||
1012 | cx231xx_set_field(FLD_AUD_CHAN1_SRC, 0x03)); | ||
1013 | |||
1014 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F063870); | ||
1015 | |||
1016 | /* setAudioStandard(_audio_standard); */ | ||
1017 | |||
1018 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063870); | ||
1019 | switch (dev->model) { | ||
1020 | case CX231XX_BOARD_CNXT_RDE_250: | ||
1021 | case CX231XX_BOARD_CNXT_RDU_250: | ||
1022 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1023 | VID_BLK_I2C_ADDRESS, | ||
1024 | CHIP_CTRL, | ||
1025 | FLD_SIF_EN, | ||
1026 | cx231xx_set_field(FLD_SIF_EN, 1)); | ||
1027 | break; | ||
1028 | default: | ||
1029 | break; | ||
1030 | } | ||
1031 | break; | ||
1032 | |||
1033 | case AUDIO_INPUT_TUNER_FM: | ||
1034 | /* use SIF for FM radio | ||
1035 | setupFM(); | ||
1036 | setAudioStandard(_audio_standard); | ||
1037 | */ | ||
1038 | break; | ||
1039 | |||
1040 | case AUDIO_INPUT_MUTE: | ||
1041 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F011012); | ||
1042 | break; | ||
1043 | } | ||
1044 | |||
1045 | /* Take it out of soft reset */ | ||
1046 | status = vid_blk_read_byte(dev, GENERAL_CTL, &gen_ctrl); | ||
1047 | gen_ctrl &= ~1; | ||
1048 | status = vid_blk_write_byte(dev, GENERAL_CTL, gen_ctrl); | ||
1049 | |||
1050 | return status; | ||
1051 | } | ||
1052 | |||
1053 | /* Set resolution of the video */ | ||
1054 | int cx231xx_resolution_set(struct cx231xx *dev) | ||
1055 | { | ||
1056 | int width, height; | ||
1057 | u32 hscale, vscale; | ||
1058 | int status = 0; | ||
1059 | |||
1060 | width = dev->width; | ||
1061 | height = dev->height; | ||
1062 | |||
1063 | get_scale(dev, width, height, &hscale, &vscale); | ||
1064 | |||
1065 | /* set horzontal scale */ | ||
1066 | status = vid_blk_write_word(dev, HSCALE_CTRL, hscale); | ||
1067 | |||
1068 | /* set vertical scale */ | ||
1069 | status = vid_blk_write_word(dev, VSCALE_CTRL, vscale); | ||
1070 | |||
1071 | return status; | ||
1072 | } | ||
1073 | |||
1074 | /****************************************************************************** | ||
1075 | * C H I P Specific C O N T R O L functions * | ||
1076 | ******************************************************************************/ | ||
1077 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev) | ||
1078 | { | ||
1079 | u32 value; | ||
1080 | int status = 0; | ||
1081 | |||
1082 | status = vid_blk_read_word(dev, PIN_CTRL, &value); | ||
1083 | value |= (~dev->board.ctl_pin_status_mask); | ||
1084 | status = vid_blk_write_word(dev, PIN_CTRL, value); | ||
1085 | |||
1086 | return status; | ||
1087 | } | ||
1088 | |||
1089 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | ||
1090 | u8 analog_or_digital) | ||
1091 | { | ||
1092 | int status = 0; | ||
1093 | |||
1094 | /* first set the direction to output */ | ||
1095 | status = cx231xx_set_gpio_direction(dev, | ||
1096 | dev->board. | ||
1097 | agc_analog_digital_select_gpio, 1); | ||
1098 | |||
1099 | /* 0 - demod ; 1 - Analog mode */ | ||
1100 | status = cx231xx_set_gpio_value(dev, | ||
1101 | dev->board.agc_analog_digital_select_gpio, | ||
1102 | analog_or_digital); | ||
1103 | |||
1104 | return status; | ||
1105 | } | ||
1106 | |||
1107 | int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex) | ||
1108 | { | ||
1109 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1110 | int status = 0; | ||
1111 | |||
1112 | cx231xx_info("Changing the i2c port for tuner to %d\n", I2CIndex); | ||
1113 | |||
1114 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | ||
1115 | PWR_CTL_EN, value, 4); | ||
1116 | if (status < 0) | ||
1117 | return status; | ||
1118 | |||
1119 | if (I2CIndex == I2C_1) { | ||
1120 | if (value[0] & I2C_DEMOD_EN) { | ||
1121 | value[0] &= ~I2C_DEMOD_EN; | ||
1122 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1123 | PWR_CTL_EN, value, 4); | ||
1124 | } | ||
1125 | } else { | ||
1126 | if (!(value[0] & I2C_DEMOD_EN)) { | ||
1127 | value[0] |= I2C_DEMOD_EN; | ||
1128 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1129 | PWR_CTL_EN, value, 4); | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | return status; | ||
1134 | |||
1135 | } | ||
1136 | |||
1137 | /****************************************************************************** | ||
1138 | * D I F - B L O C K C O N T R O L functions * | ||
1139 | ******************************************************************************/ | ||
1140 | int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | ||
1141 | u32 function_mode, u32 standard) | ||
1142 | { | ||
1143 | int status = 0; | ||
1144 | |||
1145 | if (mode == V4L2_TUNER_RADIO) { | ||
1146 | /* C2HH */ | ||
1147 | /* lo if big signal */ | ||
1148 | status = cx231xx_reg_mask_write(dev, | ||
1149 | VID_BLK_I2C_ADDRESS, 32, | ||
1150 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1151 | /* FUNC_MODE = DIF */ | ||
1152 | status = cx231xx_reg_mask_write(dev, | ||
1153 | VID_BLK_I2C_ADDRESS, 32, | ||
1154 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, function_mode); | ||
1155 | /* IF_MODE */ | ||
1156 | status = cx231xx_reg_mask_write(dev, | ||
1157 | VID_BLK_I2C_ADDRESS, 32, | ||
1158 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xFF); | ||
1159 | /* no inv */ | ||
1160 | status = cx231xx_reg_mask_write(dev, | ||
1161 | VID_BLK_I2C_ADDRESS, 32, | ||
1162 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1163 | } else if (standard != DIF_USE_BASEBAND) { | ||
1164 | if (standard & V4L2_STD_MN) { | ||
1165 | /* lo if big signal */ | ||
1166 | status = cx231xx_reg_mask_write(dev, | ||
1167 | VID_BLK_I2C_ADDRESS, 32, | ||
1168 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1169 | /* FUNC_MODE = DIF */ | ||
1170 | status = cx231xx_reg_mask_write(dev, | ||
1171 | VID_BLK_I2C_ADDRESS, 32, | ||
1172 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1173 | function_mode); | ||
1174 | /* IF_MODE */ | ||
1175 | status = cx231xx_reg_mask_write(dev, | ||
1176 | VID_BLK_I2C_ADDRESS, 32, | ||
1177 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xb); | ||
1178 | /* no inv */ | ||
1179 | status = cx231xx_reg_mask_write(dev, | ||
1180 | VID_BLK_I2C_ADDRESS, 32, | ||
1181 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1182 | /* 0x124, AUD_CHAN1_SRC = 0x3 */ | ||
1183 | status = cx231xx_reg_mask_write(dev, | ||
1184 | VID_BLK_I2C_ADDRESS, 32, | ||
1185 | AUD_IO_CTRL, 0, 31, 0x00000003); | ||
1186 | } else if ((standard == V4L2_STD_PAL_I) | | ||
1187 | (standard & V4L2_STD_SECAM)) { | ||
1188 | /* C2HH setup */ | ||
1189 | /* lo if big signal */ | ||
1190 | status = cx231xx_reg_mask_write(dev, | ||
1191 | VID_BLK_I2C_ADDRESS, 32, | ||
1192 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1193 | /* FUNC_MODE = DIF */ | ||
1194 | status = cx231xx_reg_mask_write(dev, | ||
1195 | VID_BLK_I2C_ADDRESS, 32, | ||
1196 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1197 | function_mode); | ||
1198 | /* IF_MODE */ | ||
1199 | status = cx231xx_reg_mask_write(dev, | ||
1200 | VID_BLK_I2C_ADDRESS, 32, | ||
1201 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xF); | ||
1202 | /* no inv */ | ||
1203 | status = cx231xx_reg_mask_write(dev, | ||
1204 | VID_BLK_I2C_ADDRESS, 32, | ||
1205 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1206 | } else { | ||
1207 | /* default PAL BG */ | ||
1208 | /* C2HH setup */ | ||
1209 | /* lo if big signal */ | ||
1210 | status = cx231xx_reg_mask_write(dev, | ||
1211 | VID_BLK_I2C_ADDRESS, 32, | ||
1212 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1213 | /* FUNC_MODE = DIF */ | ||
1214 | status = cx231xx_reg_mask_write(dev, | ||
1215 | VID_BLK_I2C_ADDRESS, 32, | ||
1216 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1217 | function_mode); | ||
1218 | /* IF_MODE */ | ||
1219 | status = cx231xx_reg_mask_write(dev, | ||
1220 | VID_BLK_I2C_ADDRESS, 32, | ||
1221 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xE); | ||
1222 | /* no inv */ | ||
1223 | status = cx231xx_reg_mask_write(dev, | ||
1224 | VID_BLK_I2C_ADDRESS, 32, | ||
1225 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1229 | return status; | ||
1230 | } | ||
1231 | |||
1232 | int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard) | ||
1233 | { | ||
1234 | int status = 0; | ||
1235 | u32 dif_misc_ctrl_value = 0; | ||
1236 | u32 func_mode = 0; | ||
1237 | |||
1238 | cx231xx_info("%s: setStandard to %x\n", __func__, standard); | ||
1239 | |||
1240 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &dif_misc_ctrl_value); | ||
1241 | if (standard != DIF_USE_BASEBAND) | ||
1242 | dev->norm = standard; | ||
1243 | |||
1244 | switch (dev->model) { | ||
1245 | case CX231XX_BOARD_CNXT_RDE_250: | ||
1246 | case CX231XX_BOARD_CNXT_RDU_250: | ||
1247 | func_mode = 0x03; | ||
1248 | break; | ||
1249 | default: | ||
1250 | func_mode = 0x01; | ||
1251 | } | ||
1252 | |||
1253 | status = cx231xx_dif_configure_C2HH_for_low_IF(dev, dev->active_mode, | ||
1254 | func_mode, standard); | ||
1255 | |||
1256 | if (standard == DIF_USE_BASEBAND) { /* base band */ | ||
1257 | /* There is a different SRC_PHASE_INC value | ||
1258 | for baseband vs. DIF */ | ||
1259 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, 0xDF7DF83); | ||
1260 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1261 | &dif_misc_ctrl_value); | ||
1262 | dif_misc_ctrl_value |= FLD_DIF_DIF_BYPASS; | ||
1263 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1264 | dif_misc_ctrl_value); | ||
1265 | } else if (standard & V4L2_STD_PAL_D) { | ||
1266 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1267 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1268 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1269 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1270 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1271 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1272 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1273 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1274 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1275 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
1276 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1277 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
1278 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1279 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
1280 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1281 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
1282 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1283 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1284 | 0x26001700); | ||
1285 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1286 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1287 | 0x00002660); | ||
1288 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1289 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1290 | 0x72500800); | ||
1291 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1292 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1293 | 0x27000100); | ||
1294 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1295 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3934EA); | ||
1296 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1297 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1298 | 0x00000000); | ||
1299 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1300 | DIF_SRC_PHASE_INC, 0, 31, | ||
1301 | 0x1befbf06); | ||
1302 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1303 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1304 | 0x000035e8); | ||
1305 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1306 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1307 | /* Save the Spec Inversion value */ | ||
1308 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1309 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1310 | } else if (standard & V4L2_STD_PAL_I) { | ||
1311 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1312 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1313 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1314 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1315 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1316 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1317 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1318 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1319 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1320 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
1321 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1322 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
1323 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1324 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
1325 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1326 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
1327 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1328 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1329 | 0x26001700); | ||
1330 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1331 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1332 | 0x00002660); | ||
1333 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1334 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1335 | 0x72500800); | ||
1336 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1337 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1338 | 0x27000100); | ||
1339 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1340 | DIF_AV_SEP_CTRL, 0, 31, 0x5F39A934); | ||
1341 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1342 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1343 | 0x00000000); | ||
1344 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1345 | DIF_SRC_PHASE_INC, 0, 31, | ||
1346 | 0x1befbf06); | ||
1347 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1348 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1349 | 0x000035e8); | ||
1350 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1351 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1352 | /* Save the Spec Inversion value */ | ||
1353 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1354 | dif_misc_ctrl_value |= 0x3a033F11; | ||
1355 | } else if (standard & V4L2_STD_PAL_M) { | ||
1356 | /* improved Low Frequency Phase Noise */ | ||
1357 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0xFF01FF0C); | ||
1358 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xbd038c85); | ||
1359 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1db4640a); | ||
1360 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
1361 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C1380); | ||
1362 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
1363 | 0x26001700); | ||
1364 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
1365 | 0x00002660); | ||
1366 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
1367 | 0x72500800); | ||
1368 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
1369 | 0x27000100); | ||
1370 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, 0x012c405d); | ||
1371 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
1372 | 0x009f50c1); | ||
1373 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
1374 | 0x1befbf06); | ||
1375 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
1376 | 0x000035e8); | ||
1377 | status = vid_blk_write_word(dev, DIF_SOFT_RST_CTRL_REVB, | ||
1378 | 0x00000000); | ||
1379 | /* Save the Spec Inversion value */ | ||
1380 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1381 | dif_misc_ctrl_value |= 0x3A0A3F10; | ||
1382 | } else if (standard & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) { | ||
1383 | /* improved Low Frequency Phase Noise */ | ||
1384 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0xFF01FF0C); | ||
1385 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xbd038c85); | ||
1386 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1db4640a); | ||
1387 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
1388 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C1380); | ||
1389 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
1390 | 0x26001700); | ||
1391 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
1392 | 0x00002660); | ||
1393 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
1394 | 0x72500800); | ||
1395 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
1396 | 0x27000100); | ||
1397 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, | ||
1398 | 0x012c405d); | ||
1399 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
1400 | 0x009f50c1); | ||
1401 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
1402 | 0x1befbf06); | ||
1403 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
1404 | 0x000035e8); | ||
1405 | status = vid_blk_write_word(dev, DIF_SOFT_RST_CTRL_REVB, | ||
1406 | 0x00000000); | ||
1407 | /* Save the Spec Inversion value */ | ||
1408 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1409 | dif_misc_ctrl_value = 0x3A093F10; | ||
1410 | } else if (standard & | ||
1411 | (V4L2_STD_SECAM_B | V4L2_STD_SECAM_D | V4L2_STD_SECAM_G | | ||
1412 | V4L2_STD_SECAM_K | V4L2_STD_SECAM_K1)) { | ||
1413 | |||
1414 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1415 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1416 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1417 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1418 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1419 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1420 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1421 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1422 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1423 | DIF_AGC_IF_REF, 0, 31, 0x888C0380); | ||
1424 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1425 | DIF_AGC_CTRL_IF, 0, 31, 0xe0262600); | ||
1426 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1427 | DIF_AGC_CTRL_INT, 0, 31, 0xc2171700); | ||
1428 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1429 | DIF_AGC_CTRL_RF, 0, 31, 0xc2262600); | ||
1430 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1431 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1432 | 0x26001700); | ||
1433 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1434 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1435 | 0x00002660); | ||
1436 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1437 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1438 | 0x27000100); | ||
1439 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1440 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530ec); | ||
1441 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1442 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1443 | 0x00000000); | ||
1444 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1445 | DIF_SRC_PHASE_INC, 0, 31, | ||
1446 | 0x1befbf06); | ||
1447 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1448 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1449 | 0x000035e8); | ||
1450 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1451 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1452 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1453 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1454 | 0xf4000000); | ||
1455 | |||
1456 | /* Save the Spec Inversion value */ | ||
1457 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1458 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1459 | } else if (standard & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) { | ||
1460 | /* Is it SECAM_L1? */ | ||
1461 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1462 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1463 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1464 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1465 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1466 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1467 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1468 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1469 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1470 | DIF_AGC_IF_REF, 0, 31, 0x888C0380); | ||
1471 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1472 | DIF_AGC_CTRL_IF, 0, 31, 0xe0262600); | ||
1473 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1474 | DIF_AGC_CTRL_INT, 0, 31, 0xc2171700); | ||
1475 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1476 | DIF_AGC_CTRL_RF, 0, 31, 0xc2262600); | ||
1477 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1478 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1479 | 0x26001700); | ||
1480 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1481 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1482 | 0x00002660); | ||
1483 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1484 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1485 | 0x27000100); | ||
1486 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1487 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530ec); | ||
1488 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1489 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1490 | 0x00000000); | ||
1491 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1492 | DIF_SRC_PHASE_INC, 0, 31, | ||
1493 | 0x1befbf06); | ||
1494 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1495 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1496 | 0x000035e8); | ||
1497 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1498 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1499 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1500 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1501 | 0xf2560000); | ||
1502 | |||
1503 | /* Save the Spec Inversion value */ | ||
1504 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1505 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1506 | |||
1507 | } else if (standard & V4L2_STD_NTSC_M) { | ||
1508 | /* V4L2_STD_NTSC_M (75 IRE Setup) Or | ||
1509 | V4L2_STD_NTSC_M_JP (Japan, 0 IRE Setup) */ | ||
1510 | |||
1511 | /* For NTSC the centre frequency of video coming out of | ||
1512 | sidewinder is around 7.1MHz or 3.6MHz depending on the | ||
1513 | spectral inversion. so for a non spectrally inverted channel | ||
1514 | the pll freq word is 0x03420c49 | ||
1515 | */ | ||
1516 | |||
1517 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0x6503BC0C); | ||
1518 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xBD038C85); | ||
1519 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1DB4640A); | ||
1520 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
1521 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C0380); | ||
1522 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
1523 | 0x26001700); | ||
1524 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
1525 | 0x00002660); | ||
1526 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
1527 | 0x04000800); | ||
1528 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
1529 | 0x27000100); | ||
1530 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, 0x01296e1f); | ||
1531 | |||
1532 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
1533 | 0x009f50c1); | ||
1534 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
1535 | 0x1befbf06); | ||
1536 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
1537 | 0x000035e8); | ||
1538 | |||
1539 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_IF, 0xC2262600); | ||
1540 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_INT, | ||
1541 | 0xC2262600); | ||
1542 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_RF, 0xC2262600); | ||
1543 | |||
1544 | /* Save the Spec Inversion value */ | ||
1545 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1546 | dif_misc_ctrl_value |= 0x3a003F10; | ||
1547 | } else { | ||
1548 | /* default PAL BG */ | ||
1549 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1550 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1551 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1552 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1553 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1554 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1555 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1556 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1557 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1558 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
1559 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1560 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
1561 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1562 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
1563 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1564 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
1565 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1566 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1567 | 0x26001700); | ||
1568 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1569 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1570 | 0x00002660); | ||
1571 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1572 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1573 | 0x72500800); | ||
1574 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1575 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1576 | 0x27000100); | ||
1577 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1578 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530EC); | ||
1579 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1580 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1581 | 0x00A653A8); | ||
1582 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1583 | DIF_SRC_PHASE_INC, 0, 31, | ||
1584 | 0x1befbf06); | ||
1585 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1586 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1587 | 0x000035e8); | ||
1588 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1589 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1590 | /* Save the Spec Inversion value */ | ||
1591 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1592 | dif_misc_ctrl_value |= 0x3a013F11; | ||
1593 | } | ||
1594 | |||
1595 | /* The AGC values should be the same for all standards, | ||
1596 | AUD_SRC_SEL[19] should always be disabled */ | ||
1597 | dif_misc_ctrl_value &= ~FLD_DIF_AUD_SRC_SEL; | ||
1598 | |||
1599 | /* It is still possible to get Set Standard calls even when we | ||
1600 | are in FM mode. | ||
1601 | This is done to override the value for FM. */ | ||
1602 | if (dev->active_mode == V4L2_TUNER_RADIO) | ||
1603 | dif_misc_ctrl_value = 0x7a080000; | ||
1604 | |||
1605 | /* Write the calculated value for misc ontrol register */ | ||
1606 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, dif_misc_ctrl_value); | ||
1607 | |||
1608 | return status; | ||
1609 | } | ||
1610 | |||
1611 | int cx231xx_tuner_pre_channel_change(struct cx231xx *dev) | ||
1612 | { | ||
1613 | int status = 0; | ||
1614 | u32 dwval; | ||
1615 | |||
1616 | /* Set the RF and IF k_agc values to 3 */ | ||
1617 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | ||
1618 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); | ||
1619 | dwval |= 0x33000000; | ||
1620 | |||
1621 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); | ||
1622 | |||
1623 | return status; | ||
1624 | } | ||
1625 | |||
1626 | int cx231xx_tuner_post_channel_change(struct cx231xx *dev) | ||
1627 | { | ||
1628 | int status = 0; | ||
1629 | u32 dwval; | ||
1630 | |||
1631 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for | ||
1632 | * SECAM L/B/D standards */ | ||
1633 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | ||
1634 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); | ||
1635 | |||
1636 | if (dev->norm & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_B | | ||
1637 | V4L2_STD_SECAM_D)) | ||
1638 | dwval |= 0x88000000; | ||
1639 | else | ||
1640 | dwval |= 0x44000000; | ||
1641 | |||
1642 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); | ||
1643 | |||
1644 | return status; | ||
1645 | } | ||
1646 | |||
1647 | /****************************************************************************** | ||
1648 | * I 2 S - B L O C K C O N T R O L functions * | ||
1649 | ******************************************************************************/ | ||
1650 | int cx231xx_i2s_blk_initialize(struct cx231xx *dev) | ||
1651 | { | ||
1652 | int status = 0; | ||
1653 | u32 value; | ||
1654 | |||
1655 | status = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1656 | CH_PWR_CTRL1, 1, &value, 1); | ||
1657 | /* enables clock to delta-sigma and decimation filter */ | ||
1658 | value |= 0x80; | ||
1659 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1660 | CH_PWR_CTRL1, 1, value, 1); | ||
1661 | /* power up all channel */ | ||
1662 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1663 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
1664 | |||
1665 | return status; | ||
1666 | } | ||
1667 | |||
1668 | int cx231xx_i2s_blk_update_power_control(struct cx231xx *dev, | ||
1669 | enum AV_MODE avmode) | ||
1670 | { | ||
1671 | int status = 0; | ||
1672 | u32 value = 0; | ||
1673 | |||
1674 | if (avmode != POLARIS_AVMODE_ENXTERNAL_AV) { | ||
1675 | status = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1676 | CH_PWR_CTRL2, 1, &value, 1); | ||
1677 | value |= 0xfe; | ||
1678 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1679 | CH_PWR_CTRL2, 1, value, 1); | ||
1680 | } else { | ||
1681 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1682 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
1683 | } | ||
1684 | |||
1685 | return status; | ||
1686 | } | ||
1687 | |||
1688 | /* set i2s_blk for audio input types */ | ||
1689 | int cx231xx_i2s_blk_set_audio_input(struct cx231xx *dev, u8 audio_input) | ||
1690 | { | ||
1691 | int status = 0; | ||
1692 | |||
1693 | switch (audio_input) { | ||
1694 | case CX231XX_AMUX_LINE_IN: | ||
1695 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1696 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
1697 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1698 | CH_PWR_CTRL1, 1, 0x80, 1); | ||
1699 | break; | ||
1700 | case CX231XX_AMUX_VIDEO: | ||
1701 | default: | ||
1702 | break; | ||
1703 | } | ||
1704 | |||
1705 | dev->ctl_ainput = audio_input; | ||
1706 | |||
1707 | return status; | ||
1708 | } | ||
1709 | |||
1710 | /****************************************************************************** | ||
1711 | * P O W E R C O N T R O L functions * | ||
1712 | ******************************************************************************/ | ||
1713 | int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | ||
1714 | { | ||
1715 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1716 | u32 tmp = 0; | ||
1717 | int status = 0; | ||
1718 | |||
1719 | if (dev->power_mode != mode) | ||
1720 | dev->power_mode = mode; | ||
1721 | else { | ||
1722 | cx231xx_info(" setPowerMode::mode = %d, No Change req.\n", | ||
1723 | mode); | ||
1724 | return 0; | ||
1725 | } | ||
1726 | |||
1727 | cx231xx_info(" setPowerMode::mode = %d\n", mode); | ||
1728 | |||
1729 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | ||
1730 | 4); | ||
1731 | if (status < 0) | ||
1732 | return status; | ||
1733 | |||
1734 | tmp = *((u32 *) value); | ||
1735 | |||
1736 | switch (mode) { | ||
1737 | case POLARIS_AVMODE_ENXTERNAL_AV: | ||
1738 | |||
1739 | tmp &= (~PWR_MODE_MASK); | ||
1740 | |||
1741 | tmp |= PWR_AV_EN; | ||
1742 | value[0] = (u8) tmp; | ||
1743 | value[1] = (u8) (tmp >> 8); | ||
1744 | value[2] = (u8) (tmp >> 16); | ||
1745 | value[3] = (u8) (tmp >> 24); | ||
1746 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1747 | PWR_CTL_EN, value, 4); | ||
1748 | msleep(PWR_SLEEP_INTERVAL); | ||
1749 | |||
1750 | tmp |= PWR_ISO_EN; | ||
1751 | value[0] = (u8) tmp; | ||
1752 | value[1] = (u8) (tmp >> 8); | ||
1753 | value[2] = (u8) (tmp >> 16); | ||
1754 | value[3] = (u8) (tmp >> 24); | ||
1755 | status = | ||
1756 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, | ||
1757 | value, 4); | ||
1758 | msleep(PWR_SLEEP_INTERVAL); | ||
1759 | |||
1760 | tmp |= POLARIS_AVMODE_ENXTERNAL_AV; | ||
1761 | value[0] = (u8) tmp; | ||
1762 | value[1] = (u8) (tmp >> 8); | ||
1763 | value[2] = (u8) (tmp >> 16); | ||
1764 | value[3] = (u8) (tmp >> 24); | ||
1765 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1766 | PWR_CTL_EN, value, 4); | ||
1767 | |||
1768 | /* reset state of xceive tuner */ | ||
1769 | dev->xc_fw_load_done = 0; | ||
1770 | break; | ||
1771 | |||
1772 | case POLARIS_AVMODE_ANALOGT_TV: | ||
1773 | |||
1774 | tmp &= (~PWR_DEMOD_EN); | ||
1775 | tmp |= (I2C_DEMOD_EN); | ||
1776 | value[0] = (u8) tmp; | ||
1777 | value[1] = (u8) (tmp >> 8); | ||
1778 | value[2] = (u8) (tmp >> 16); | ||
1779 | value[3] = (u8) (tmp >> 24); | ||
1780 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1781 | PWR_CTL_EN, value, 4); | ||
1782 | msleep(PWR_SLEEP_INTERVAL); | ||
1783 | |||
1784 | if (!(tmp & PWR_TUNER_EN)) { | ||
1785 | tmp |= (PWR_TUNER_EN); | ||
1786 | value[0] = (u8) tmp; | ||
1787 | value[1] = (u8) (tmp >> 8); | ||
1788 | value[2] = (u8) (tmp >> 16); | ||
1789 | value[3] = (u8) (tmp >> 24); | ||
1790 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1791 | PWR_CTL_EN, value, 4); | ||
1792 | msleep(PWR_SLEEP_INTERVAL); | ||
1793 | } | ||
1794 | |||
1795 | if (!(tmp & PWR_AV_EN)) { | ||
1796 | tmp |= PWR_AV_EN; | ||
1797 | value[0] = (u8) tmp; | ||
1798 | value[1] = (u8) (tmp >> 8); | ||
1799 | value[2] = (u8) (tmp >> 16); | ||
1800 | value[3] = (u8) (tmp >> 24); | ||
1801 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1802 | PWR_CTL_EN, value, 4); | ||
1803 | msleep(PWR_SLEEP_INTERVAL); | ||
1804 | } | ||
1805 | if (!(tmp & PWR_ISO_EN)) { | ||
1806 | tmp |= PWR_ISO_EN; | ||
1807 | value[0] = (u8) tmp; | ||
1808 | value[1] = (u8) (tmp >> 8); | ||
1809 | value[2] = (u8) (tmp >> 16); | ||
1810 | value[3] = (u8) (tmp >> 24); | ||
1811 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1812 | PWR_CTL_EN, value, 4); | ||
1813 | msleep(PWR_SLEEP_INTERVAL); | ||
1814 | } | ||
1815 | |||
1816 | if (!(tmp & POLARIS_AVMODE_ANALOGT_TV)) { | ||
1817 | tmp |= POLARIS_AVMODE_ANALOGT_TV; | ||
1818 | value[0] = (u8) tmp; | ||
1819 | value[1] = (u8) (tmp >> 8); | ||
1820 | value[2] = (u8) (tmp >> 16); | ||
1821 | value[3] = (u8) (tmp >> 24); | ||
1822 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1823 | PWR_CTL_EN, value, 4); | ||
1824 | msleep(PWR_SLEEP_INTERVAL); | ||
1825 | } | ||
1826 | |||
1827 | if ((dev->model == CX231XX_BOARD_CNXT_RDE_250) || | ||
1828 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | ||
1829 | /* tuner path to channel 1 from port 3 */ | ||
1830 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
1831 | |||
1832 | if (dev->cx231xx_reset_analog_tuner) | ||
1833 | dev->cx231xx_reset_analog_tuner(dev); | ||
1834 | } | ||
1835 | break; | ||
1836 | |||
1837 | case POLARIS_AVMODE_DIGITAL: | ||
1838 | if (!(tmp & PWR_TUNER_EN)) { | ||
1839 | tmp |= (PWR_TUNER_EN); | ||
1840 | value[0] = (u8) tmp; | ||
1841 | value[1] = (u8) (tmp >> 8); | ||
1842 | value[2] = (u8) (tmp >> 16); | ||
1843 | value[3] = (u8) (tmp >> 24); | ||
1844 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1845 | PWR_CTL_EN, value, 4); | ||
1846 | msleep(PWR_SLEEP_INTERVAL); | ||
1847 | } | ||
1848 | if (!(tmp & PWR_AV_EN)) { | ||
1849 | tmp |= PWR_AV_EN; | ||
1850 | value[0] = (u8) tmp; | ||
1851 | value[1] = (u8) (tmp >> 8); | ||
1852 | value[2] = (u8) (tmp >> 16); | ||
1853 | value[3] = (u8) (tmp >> 24); | ||
1854 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1855 | PWR_CTL_EN, value, 4); | ||
1856 | msleep(PWR_SLEEP_INTERVAL); | ||
1857 | } | ||
1858 | if (!(tmp & PWR_ISO_EN)) { | ||
1859 | tmp |= PWR_ISO_EN; | ||
1860 | value[0] = (u8) tmp; | ||
1861 | value[1] = (u8) (tmp >> 8); | ||
1862 | value[2] = (u8) (tmp >> 16); | ||
1863 | value[3] = (u8) (tmp >> 24); | ||
1864 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1865 | PWR_CTL_EN, value, 4); | ||
1866 | msleep(PWR_SLEEP_INTERVAL); | ||
1867 | } | ||
1868 | |||
1869 | tmp |= POLARIS_AVMODE_DIGITAL | I2C_DEMOD_EN; | ||
1870 | value[0] = (u8) tmp; | ||
1871 | value[1] = (u8) (tmp >> 8); | ||
1872 | value[2] = (u8) (tmp >> 16); | ||
1873 | value[3] = (u8) (tmp >> 24); | ||
1874 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1875 | PWR_CTL_EN, value, 4); | ||
1876 | msleep(PWR_SLEEP_INTERVAL); | ||
1877 | |||
1878 | if (!(tmp & PWR_DEMOD_EN)) { | ||
1879 | tmp |= PWR_DEMOD_EN; | ||
1880 | value[0] = (u8) tmp; | ||
1881 | value[1] = (u8) (tmp >> 8); | ||
1882 | value[2] = (u8) (tmp >> 16); | ||
1883 | value[3] = (u8) (tmp >> 24); | ||
1884 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1885 | PWR_CTL_EN, value, 4); | ||
1886 | msleep(PWR_SLEEP_INTERVAL); | ||
1887 | } | ||
1888 | |||
1889 | if ((dev->model == CX231XX_BOARD_CNXT_RDE_250) || | ||
1890 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | ||
1891 | /* tuner path to channel 1 from port 3 */ | ||
1892 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
1893 | |||
1894 | if (dev->cx231xx_reset_analog_tuner) | ||
1895 | dev->cx231xx_reset_analog_tuner(dev); | ||
1896 | } | ||
1897 | break; | ||
1898 | |||
1899 | default: | ||
1900 | break; | ||
1901 | } | ||
1902 | |||
1903 | msleep(PWR_SLEEP_INTERVAL); | ||
1904 | |||
1905 | /* For power saving, only enable Pwr_resetout_n | ||
1906 | when digital TV is selected. */ | ||
1907 | if (mode == POLARIS_AVMODE_DIGITAL) { | ||
1908 | tmp |= PWR_RESETOUT_EN; | ||
1909 | value[0] = (u8) tmp; | ||
1910 | value[1] = (u8) (tmp >> 8); | ||
1911 | value[2] = (u8) (tmp >> 16); | ||
1912 | value[3] = (u8) (tmp >> 24); | ||
1913 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1914 | PWR_CTL_EN, value, 4); | ||
1915 | msleep(PWR_SLEEP_INTERVAL); | ||
1916 | } | ||
1917 | |||
1918 | /* update power control for afe */ | ||
1919 | status = cx231xx_afe_update_power_control(dev, mode); | ||
1920 | |||
1921 | /* update power control for i2s_blk */ | ||
1922 | status = cx231xx_i2s_blk_update_power_control(dev, mode); | ||
1923 | |||
1924 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | ||
1925 | 4); | ||
1926 | cx231xx_info(" The data of PWR_CTL_EN register 0x74" | ||
1927 | "=0x%0x,0x%0x,0x%0x,0x%0x\n", | ||
1928 | value[0], value[1], value[2], value[3]); | ||
1929 | |||
1930 | return status; | ||
1931 | } | ||
1932 | |||
1933 | int cx231xx_power_suspend(struct cx231xx *dev) | ||
1934 | { | ||
1935 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1936 | u32 tmp = 0; | ||
1937 | int status = 0; | ||
1938 | |||
1939 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
1940 | value, 4); | ||
1941 | if (status > 0) | ||
1942 | return status; | ||
1943 | |||
1944 | tmp = *((u32 *) value); | ||
1945 | tmp &= (~PWR_MODE_MASK); | ||
1946 | |||
1947 | value[0] = (u8) tmp; | ||
1948 | value[1] = (u8) (tmp >> 8); | ||
1949 | value[2] = (u8) (tmp >> 16); | ||
1950 | value[3] = (u8) (tmp >> 24); | ||
1951 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, | ||
1952 | value, 4); | ||
1953 | |||
1954 | return status; | ||
1955 | } | ||
1956 | |||
1957 | /****************************************************************************** | ||
1958 | * S T R E A M C O N T R O L functions * | ||
1959 | ******************************************************************************/ | ||
1960 | int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask) | ||
1961 | { | ||
1962 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
1963 | u32 tmp = 0; | ||
1964 | int status = 0; | ||
1965 | |||
1966 | cx231xx_info("cx231xx_start_stream():: ep_mask = %x\n", ep_mask); | ||
1967 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | ||
1968 | value, 4); | ||
1969 | if (status < 0) | ||
1970 | return status; | ||
1971 | |||
1972 | tmp = *((u32 *) value); | ||
1973 | tmp |= ep_mask; | ||
1974 | value[0] = (u8) tmp; | ||
1975 | value[1] = (u8) (tmp >> 8); | ||
1976 | value[2] = (u8) (tmp >> 16); | ||
1977 | value[3] = (u8) (tmp >> 24); | ||
1978 | |||
1979 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, EP_MODE_SET, | ||
1980 | value, 4); | ||
1981 | |||
1982 | return status; | ||
1983 | } | ||
1984 | |||
1985 | int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask) | ||
1986 | { | ||
1987 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
1988 | u32 tmp = 0; | ||
1989 | int status = 0; | ||
1990 | |||
1991 | cx231xx_info("cx231xx_stop_stream():: ep_mask = %x\n", ep_mask); | ||
1992 | status = | ||
1993 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, value, 4); | ||
1994 | if (status < 0) | ||
1995 | return status; | ||
1996 | |||
1997 | tmp = *((u32 *) value); | ||
1998 | tmp &= (~ep_mask); | ||
1999 | value[0] = (u8) tmp; | ||
2000 | value[1] = (u8) (tmp >> 8); | ||
2001 | value[2] = (u8) (tmp >> 16); | ||
2002 | value[3] = (u8) (tmp >> 24); | ||
2003 | |||
2004 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, EP_MODE_SET, | ||
2005 | value, 4); | ||
2006 | |||
2007 | return status; | ||
2008 | } | ||
2009 | |||
2010 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | ||
2011 | { | ||
2012 | int status = 0; | ||
2013 | |||
2014 | if (dev->udev->speed == USB_SPEED_HIGH) { | ||
2015 | switch (media_type) { | ||
2016 | case 81: /* audio */ | ||
2017 | cx231xx_info("%s: Audio enter HANC\n", __func__); | ||
2018 | status = | ||
2019 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); | ||
2020 | break; | ||
2021 | |||
2022 | case 2: /* vbi */ | ||
2023 | cx231xx_info("%s: set vanc registers\n", __func__); | ||
2024 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); | ||
2025 | break; | ||
2026 | |||
2027 | case 3: /* sliced cc */ | ||
2028 | cx231xx_info("%s: set hanc registers\n", __func__); | ||
2029 | status = | ||
2030 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); | ||
2031 | break; | ||
2032 | |||
2033 | case 0: /* video */ | ||
2034 | cx231xx_info("%s: set video registers\n", __func__); | ||
2035 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | ||
2036 | break; | ||
2037 | |||
2038 | case 4: /* ts1 */ | ||
2039 | cx231xx_info("%s: set ts1 registers\n", __func__); | ||
2040 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | ||
2041 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); | ||
2042 | break; | ||
2043 | case 6: /* ts1 parallel mode */ | ||
2044 | cx231xx_info("%s: set ts1 parrallel mode registers\n", | ||
2045 | __func__); | ||
2046 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | ||
2047 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); | ||
2048 | break; | ||
2049 | } | ||
2050 | } else { | ||
2051 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | ||
2052 | } | ||
2053 | |||
2054 | return status; | ||
2055 | } | ||
2056 | |||
2057 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type) | ||
2058 | { | ||
2059 | int rc; | ||
2060 | u32 ep_mask = -1; | ||
2061 | struct pcb_config *pcb_config; | ||
2062 | |||
2063 | /* get EP for media type */ | ||
2064 | pcb_config = (struct pcb_config *)&dev->current_pcb_config; | ||
2065 | |||
2066 | if (pcb_config->config_num == 1) { | ||
2067 | switch (media_type) { | ||
2068 | case 0: /* Video */ | ||
2069 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ | ||
2070 | break; | ||
2071 | case 1: /* Audio */ | ||
2072 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ | ||
2073 | break; | ||
2074 | case 2: /* Vbi */ | ||
2075 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ | ||
2076 | break; | ||
2077 | case 3: /* Sliced_cc */ | ||
2078 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ | ||
2079 | break; | ||
2080 | case 4: /* ts1 */ | ||
2081 | case 6: /* ts1 parallel mode */ | ||
2082 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ | ||
2083 | break; | ||
2084 | case 5: /* ts2 */ | ||
2085 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ | ||
2086 | break; | ||
2087 | } | ||
2088 | |||
2089 | } else if (pcb_config->config_num > 1) { | ||
2090 | switch (media_type) { | ||
2091 | case 0: /* Video */ | ||
2092 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ | ||
2093 | break; | ||
2094 | case 1: /* Audio */ | ||
2095 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ | ||
2096 | break; | ||
2097 | case 2: /* Vbi */ | ||
2098 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ | ||
2099 | break; | ||
2100 | case 3: /* Sliced_cc */ | ||
2101 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ | ||
2102 | break; | ||
2103 | case 4: /* ts1 */ | ||
2104 | case 6: /* ts1 parallel mode */ | ||
2105 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ | ||
2106 | break; | ||
2107 | case 5: /* ts2 */ | ||
2108 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ | ||
2109 | break; | ||
2110 | } | ||
2111 | |||
2112 | } | ||
2113 | |||
2114 | if (start) { | ||
2115 | rc = cx231xx_initialize_stream_xfer(dev, media_type); | ||
2116 | |||
2117 | if (rc < 0) | ||
2118 | return rc; | ||
2119 | |||
2120 | /* enable video capture */ | ||
2121 | if (ep_mask > 0) | ||
2122 | rc = cx231xx_start_stream(dev, ep_mask); | ||
2123 | } else { | ||
2124 | /* disable video capture */ | ||
2125 | if (ep_mask > 0) | ||
2126 | rc = cx231xx_stop_stream(dev, ep_mask); | ||
2127 | } | ||
2128 | |||
2129 | if (dev->mode == CX231XX_ANALOG_MODE) | ||
2130 | ;/* do any in Analog mode */ | ||
2131 | else | ||
2132 | ;/* do any in digital mode */ | ||
2133 | |||
2134 | return rc; | ||
2135 | } | ||
2136 | EXPORT_SYMBOL_GPL(cx231xx_capture_start); | ||
2137 | |||
2138 | /***************************************************************************** | ||
2139 | * G P I O B I T control functions * | ||
2140 | ******************************************************************************/ | ||
2141 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val) | ||
2142 | { | ||
2143 | int status = 0; | ||
2144 | |||
2145 | status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 0); | ||
2146 | |||
2147 | return status; | ||
2148 | } | ||
2149 | |||
2150 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val) | ||
2151 | { | ||
2152 | int status = 0; | ||
2153 | |||
2154 | status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 1); | ||
2155 | |||
2156 | return status; | ||
2157 | } | ||
2158 | |||
2159 | /* | ||
2160 | * cx231xx_set_gpio_direction | ||
2161 | * Sets the direction of the GPIO pin to input or output | ||
2162 | * | ||
2163 | * Parameters : | ||
2164 | * pin_number : The GPIO Pin number to program the direction for | ||
2165 | * from 0 to 31 | ||
2166 | * pin_value : The Direction of the GPIO Pin under reference. | ||
2167 | * 0 = Input direction | ||
2168 | * 1 = Output direction | ||
2169 | */ | ||
2170 | int cx231xx_set_gpio_direction(struct cx231xx *dev, | ||
2171 | int pin_number, int pin_value) | ||
2172 | { | ||
2173 | int status = 0; | ||
2174 | u32 value = 0; | ||
2175 | |||
2176 | /* Check for valid pin_number - if 32 , bail out */ | ||
2177 | if (pin_number >= 32) | ||
2178 | return -EINVAL; | ||
2179 | |||
2180 | /* input */ | ||
2181 | if (pin_value == 0) | ||
2182 | value = dev->gpio_dir & (~(1 << pin_number)); /* clear */ | ||
2183 | else | ||
2184 | value = dev->gpio_dir | (1 << pin_number); | ||
2185 | |||
2186 | status = cx231xx_set_gpio_bit(dev, value, (u8 *) &dev->gpio_val); | ||
2187 | |||
2188 | /* cache the value for future */ | ||
2189 | dev->gpio_dir = value; | ||
2190 | |||
2191 | return status; | ||
2192 | } | ||
2193 | |||
2194 | /* | ||
2195 | * cx231xx_set_gpio_value | ||
2196 | * Sets the value of the GPIO pin to Logic high or low. The Pin under | ||
2197 | * reference should ALREADY BE SET IN OUTPUT MODE !!!!!!!!! | ||
2198 | * | ||
2199 | * Parameters : | ||
2200 | * pin_number : The GPIO Pin number to program the direction for | ||
2201 | * pin_value : The value of the GPIO Pin under reference. | ||
2202 | * 0 = set it to 0 | ||
2203 | * 1 = set it to 1 | ||
2204 | */ | ||
2205 | int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value) | ||
2206 | { | ||
2207 | int status = 0; | ||
2208 | u32 value = 0; | ||
2209 | |||
2210 | /* Check for valid pin_number - if 0xFF , bail out */ | ||
2211 | if (pin_number >= 32) | ||
2212 | return -EINVAL; | ||
2213 | |||
2214 | /* first do a sanity check - if the Pin is not output, make it output */ | ||
2215 | if ((dev->gpio_dir & (1 << pin_number)) == 0x00) { | ||
2216 | /* It was in input mode */ | ||
2217 | value = dev->gpio_dir | (1 << pin_number); | ||
2218 | dev->gpio_dir = value; | ||
2219 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2220 | (u8 *) &dev->gpio_val); | ||
2221 | value = 0; | ||
2222 | } | ||
2223 | |||
2224 | if (pin_value == 0) | ||
2225 | value = dev->gpio_val & (~(1 << pin_number)); | ||
2226 | else | ||
2227 | value = dev->gpio_val | (1 << pin_number); | ||
2228 | |||
2229 | /* store the value */ | ||
2230 | dev->gpio_val = value; | ||
2231 | |||
2232 | /* toggle bit0 of GP_IO */ | ||
2233 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2234 | |||
2235 | return status; | ||
2236 | } | ||
2237 | |||
2238 | /***************************************************************************** | ||
2239 | * G P I O I2C related functions * | ||
2240 | ******************************************************************************/ | ||
2241 | int cx231xx_gpio_i2c_start(struct cx231xx *dev) | ||
2242 | { | ||
2243 | int status = 0; | ||
2244 | |||
2245 | /* set SCL to output 1 ; set SDA to output 1 */ | ||
2246 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2247 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2248 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2249 | dev->gpio_val |= 1 << dev->board.tuner_sda_gpio; | ||
2250 | |||
2251 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2252 | if (status < 0) | ||
2253 | return -EINVAL; | ||
2254 | |||
2255 | /* set SCL to output 1; set SDA to output 0 */ | ||
2256 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2257 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2258 | |||
2259 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2260 | if (status < 0) | ||
2261 | return -EINVAL; | ||
2262 | |||
2263 | /* set SCL to output 0; set SDA to output 0 */ | ||
2264 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2265 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2266 | |||
2267 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2268 | if (status < 0) | ||
2269 | return -EINVAL; | ||
2270 | |||
2271 | return status; | ||
2272 | } | ||
2273 | |||
2274 | int cx231xx_gpio_i2c_end(struct cx231xx *dev) | ||
2275 | { | ||
2276 | int status = 0; | ||
2277 | |||
2278 | /* set SCL to output 0; set SDA to output 0 */ | ||
2279 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2280 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2281 | |||
2282 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2283 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2284 | |||
2285 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2286 | if (status < 0) | ||
2287 | return -EINVAL; | ||
2288 | |||
2289 | /* set SCL to output 1; set SDA to output 0 */ | ||
2290 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2291 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2292 | |||
2293 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2294 | if (status < 0) | ||
2295 | return -EINVAL; | ||
2296 | |||
2297 | /* set SCL to input ,release SCL cable control | ||
2298 | set SDA to input ,release SDA cable control */ | ||
2299 | dev->gpio_dir &= ~(1 << dev->board.tuner_scl_gpio); | ||
2300 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2301 | |||
2302 | status = | ||
2303 | cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2304 | if (status < 0) | ||
2305 | return -EINVAL; | ||
2306 | |||
2307 | return status; | ||
2308 | } | ||
2309 | |||
2310 | int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data) | ||
2311 | { | ||
2312 | int status = 0; | ||
2313 | u8 i; | ||
2314 | |||
2315 | /* set SCL to output ; set SDA to output */ | ||
2316 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2317 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2318 | |||
2319 | for (i = 0; i < 8; i++) { | ||
2320 | if (((data << i) & 0x80) == 0) { | ||
2321 | /* set SCL to output 0; set SDA to output 0 */ | ||
2322 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2323 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2324 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2325 | (u8 *)&dev->gpio_val); | ||
2326 | |||
2327 | /* set SCL to output 1; set SDA to output 0 */ | ||
2328 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2329 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2330 | (u8 *)&dev->gpio_val); | ||
2331 | |||
2332 | /* set SCL to output 0; set SDA to output 0 */ | ||
2333 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2334 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2335 | (u8 *)&dev->gpio_val); | ||
2336 | } else { | ||
2337 | /* set SCL to output 0; set SDA to output 1 */ | ||
2338 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2339 | dev->gpio_val |= 1 << dev->board.tuner_sda_gpio; | ||
2340 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2341 | (u8 *)&dev->gpio_val); | ||
2342 | |||
2343 | /* set SCL to output 1; set SDA to output 1 */ | ||
2344 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2345 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2346 | (u8 *)&dev->gpio_val); | ||
2347 | |||
2348 | /* set SCL to output 0; set SDA to output 1 */ | ||
2349 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2350 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2351 | (u8 *)&dev->gpio_val); | ||
2352 | } | ||
2353 | } | ||
2354 | return status; | ||
2355 | } | ||
2356 | |||
2357 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 * buf) | ||
2358 | { | ||
2359 | u8 value = 0; | ||
2360 | int status = 0; | ||
2361 | u32 gpio_logic_value = 0; | ||
2362 | u8 i; | ||
2363 | |||
2364 | /* read byte */ | ||
2365 | for (i = 0; i < 8; i++) { /* send write I2c addr */ | ||
2366 | |||
2367 | /* set SCL to output 0; set SDA to input */ | ||
2368 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2369 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2370 | (u8 *)&dev->gpio_val); | ||
2371 | |||
2372 | /* set SCL to output 1; set SDA to input */ | ||
2373 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2374 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2375 | (u8 *)&dev->gpio_val); | ||
2376 | |||
2377 | /* get SDA data bit */ | ||
2378 | gpio_logic_value = dev->gpio_val; | ||
2379 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, | ||
2380 | (u8 *)&dev->gpio_val); | ||
2381 | if ((dev->gpio_val & (1 << dev->board.tuner_sda_gpio)) != 0) | ||
2382 | value |= (1 << (8 - i - 1)); | ||
2383 | |||
2384 | dev->gpio_val = gpio_logic_value; | ||
2385 | } | ||
2386 | |||
2387 | /* set SCL to output 0,finish the read latest SCL signal. | ||
2388 | !!!set SDA to input, never to modify SDA direction at | ||
2389 | the same times */ | ||
2390 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2391 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2392 | |||
2393 | /* store the value */ | ||
2394 | *buf = value & 0xff; | ||
2395 | |||
2396 | return status; | ||
2397 | } | ||
2398 | |||
2399 | int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev) | ||
2400 | { | ||
2401 | int status = 0; | ||
2402 | u32 gpio_logic_value = 0; | ||
2403 | int nCnt = 10; | ||
2404 | int nInit = nCnt; | ||
2405 | |||
2406 | /* clock stretch; set SCL to input; set SDA to input; | ||
2407 | get SCL value till SCL = 1 */ | ||
2408 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2409 | dev->gpio_dir &= ~(1 << dev->board.tuner_scl_gpio); | ||
2410 | |||
2411 | gpio_logic_value = dev->gpio_val; | ||
2412 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2413 | |||
2414 | do { | ||
2415 | msleep(2); | ||
2416 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, | ||
2417 | (u8 *)&dev->gpio_val); | ||
2418 | nCnt--; | ||
2419 | } while (((dev->gpio_val & | ||
2420 | (1 << dev->board.tuner_scl_gpio)) == 0) && | ||
2421 | (nCnt > 0)); | ||
2422 | |||
2423 | if (nCnt == 0) | ||
2424 | cx231xx_info("No ACK after %d msec -GPIO I2C failed!", | ||
2425 | nInit * 10); | ||
2426 | |||
2427 | /* readAck | ||
2428 | throuth clock stretch ,slave has given a SCL signal, | ||
2429 | so the SDA data can be directly read. */ | ||
2430 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2431 | |||
2432 | if ((dev->gpio_val & 1 << dev->board.tuner_sda_gpio) == 0) { | ||
2433 | dev->gpio_val = gpio_logic_value; | ||
2434 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2435 | status = 0; | ||
2436 | } else { | ||
2437 | dev->gpio_val = gpio_logic_value; | ||
2438 | dev->gpio_val |= (1 << dev->board.tuner_sda_gpio); | ||
2439 | } | ||
2440 | |||
2441 | /* read SDA end, set the SCL to output 0, after this operation, | ||
2442 | SDA direction can be changed. */ | ||
2443 | dev->gpio_val = gpio_logic_value; | ||
2444 | dev->gpio_dir |= (1 << dev->board.tuner_scl_gpio); | ||
2445 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2446 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2447 | |||
2448 | return status; | ||
2449 | } | ||
2450 | |||
2451 | int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev) | ||
2452 | { | ||
2453 | int status = 0; | ||
2454 | |||
2455 | /* set SDA to ouput */ | ||
2456 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2457 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2458 | |||
2459 | /* set SCL = 0 (output); set SDA = 0 (output) */ | ||
2460 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2461 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2462 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2463 | |||
2464 | /* set SCL = 1 (output); set SDA = 0 (output) */ | ||
2465 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2466 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2467 | |||
2468 | /* set SCL = 0 (output); set SDA = 0 (output) */ | ||
2469 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2470 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2471 | |||
2472 | /* set SDA to input,and then the slave will read data from SDA. */ | ||
2473 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2474 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2475 | |||
2476 | return status; | ||
2477 | } | ||
2478 | |||
2479 | int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev) | ||
2480 | { | ||
2481 | int status = 0; | ||
2482 | |||
2483 | /* set scl to output ; set sda to input */ | ||
2484 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2485 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2486 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2487 | |||
2488 | /* set scl to output 0; set sda to input */ | ||
2489 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2490 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2491 | |||
2492 | /* set scl to output 1; set sda to input */ | ||
2493 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2494 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2495 | |||
2496 | return status; | ||
2497 | } | ||
2498 | |||
2499 | /***************************************************************************** | ||
2500 | * G P I O I2C related functions * | ||
2501 | ******************************************************************************/ | ||
2502 | /* cx231xx_gpio_i2c_read | ||
2503 | * Function to read data from gpio based I2C interface | ||
2504 | */ | ||
2505 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len) | ||
2506 | { | ||
2507 | int status = 0; | ||
2508 | int i = 0; | ||
2509 | |||
2510 | /* get the lock */ | ||
2511 | mutex_lock(&dev->gpio_i2c_lock); | ||
2512 | |||
2513 | /* start */ | ||
2514 | status = cx231xx_gpio_i2c_start(dev); | ||
2515 | |||
2516 | /* write dev_addr */ | ||
2517 | status = cx231xx_gpio_i2c_write_byte(dev, (dev_addr << 1) + 1); | ||
2518 | |||
2519 | /* readAck */ | ||
2520 | status = cx231xx_gpio_i2c_read_ack(dev); | ||
2521 | |||
2522 | /* read data */ | ||
2523 | for (i = 0; i < len; i++) { | ||
2524 | /* read data */ | ||
2525 | buf[i] = 0; | ||
2526 | status = cx231xx_gpio_i2c_read_byte(dev, &buf[i]); | ||
2527 | |||
2528 | if ((i + 1) != len) { | ||
2529 | /* only do write ack if we more length */ | ||
2530 | status = cx231xx_gpio_i2c_write_ack(dev); | ||
2531 | } | ||
2532 | } | ||
2533 | |||
2534 | /* write NAK - inform reads are complete */ | ||
2535 | status = cx231xx_gpio_i2c_write_nak(dev); | ||
2536 | |||
2537 | /* write end */ | ||
2538 | status = cx231xx_gpio_i2c_end(dev); | ||
2539 | |||
2540 | /* release the lock */ | ||
2541 | mutex_unlock(&dev->gpio_i2c_lock); | ||
2542 | |||
2543 | return status; | ||
2544 | } | ||
2545 | |||
2546 | /* cx231xx_gpio_i2c_write | ||
2547 | * Function to write data to gpio based I2C interface | ||
2548 | */ | ||
2549 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len) | ||
2550 | { | ||
2551 | int status = 0; | ||
2552 | int i = 0; | ||
2553 | |||
2554 | /* get the lock */ | ||
2555 | mutex_lock(&dev->gpio_i2c_lock); | ||
2556 | |||
2557 | /* start */ | ||
2558 | status = cx231xx_gpio_i2c_start(dev); | ||
2559 | |||
2560 | /* write dev_addr */ | ||
2561 | status = cx231xx_gpio_i2c_write_byte(dev, dev_addr << 1); | ||
2562 | |||
2563 | /* read Ack */ | ||
2564 | status = cx231xx_gpio_i2c_read_ack(dev); | ||
2565 | |||
2566 | for (i = 0; i < len; i++) { | ||
2567 | /* Write data */ | ||
2568 | status = cx231xx_gpio_i2c_write_byte(dev, buf[i]); | ||
2569 | |||
2570 | /* read Ack */ | ||
2571 | status = cx231xx_gpio_i2c_read_ack(dev); | ||
2572 | } | ||
2573 | |||
2574 | /* write End */ | ||
2575 | status = cx231xx_gpio_i2c_end(dev); | ||
2576 | |||
2577 | /* release the lock */ | ||
2578 | mutex_unlock(&dev->gpio_i2c_lock); | ||
2579 | |||
2580 | return 0; | ||
2581 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c new file mode 100644 index 000000000000..c8a32b1b5381 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -0,0 +1,914 @@ | |||
1 | /* | ||
2 | cx231xx-cards.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <linux/usb.h> | ||
28 | #include <media/tuner.h> | ||
29 | #include <media/tveeprom.h> | ||
30 | #include <media/v4l2-common.h> | ||
31 | #include <media/v4l2-chip-ident.h> | ||
32 | |||
33 | #include <media/cx25840.h> | ||
34 | #include "xc5000.h" | ||
35 | |||
36 | #include "cx231xx.h" | ||
37 | |||
38 | static int tuner = -1; | ||
39 | module_param(tuner, int, 0444); | ||
40 | MODULE_PARM_DESC(tuner, "tuner type"); | ||
41 | |||
42 | static unsigned int disable_ir; | ||
43 | module_param(disable_ir, int, 0444); | ||
44 | MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); | ||
45 | |||
46 | /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */ | ||
47 | static unsigned long cx231xx_devused; | ||
48 | |||
49 | /* | ||
50 | * Reset sequences for analog/digital modes | ||
51 | */ | ||
52 | |||
53 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { | ||
54 | {0x03, 0x01, 10}, | ||
55 | {0x03, 0x00, 30}, | ||
56 | {0x03, 0x01, 10}, | ||
57 | {-1, -1, -1}, | ||
58 | }; | ||
59 | |||
60 | /* | ||
61 | * Board definitions | ||
62 | */ | ||
63 | struct cx231xx_board cx231xx_boards[] = { | ||
64 | [CX231XX_BOARD_UNKNOWN] = { | ||
65 | .name = "Unknown CX231xx video grabber", | ||
66 | .tuner_type = TUNER_ABSENT, | ||
67 | .input = {{ | ||
68 | .type = CX231XX_VMUX_TELEVISION, | ||
69 | .vmux = CX231XX_VIN_3_1, | ||
70 | .amux = CX231XX_AMUX_VIDEO, | ||
71 | .gpio = 0, | ||
72 | }, { | ||
73 | .type = CX231XX_VMUX_COMPOSITE1, | ||
74 | .vmux = CX231XX_VIN_2_1, | ||
75 | .amux = CX231XX_AMUX_LINE_IN, | ||
76 | .gpio = 0, | ||
77 | }, { | ||
78 | .type = CX231XX_VMUX_SVIDEO, | ||
79 | .vmux = CX231XX_VIN_1_1 | | ||
80 | (CX231XX_VIN_1_2 << 8) | | ||
81 | CX25840_SVIDEO_ON, | ||
82 | .amux = CX231XX_AMUX_LINE_IN, | ||
83 | .gpio = 0, | ||
84 | } | ||
85 | }, | ||
86 | }, | ||
87 | [CX231XX_BOARD_CNXT_RDE_250] = { | ||
88 | .name = "Conexant Hybrid TV - RDE250", | ||
89 | .tuner_type = TUNER_XC5000, | ||
90 | .tuner_addr = 0x61, | ||
91 | .tuner_gpio = RDE250_XCV_TUNER, | ||
92 | .tuner_sif_gpio = 0x05, | ||
93 | .tuner_scl_gpio = 0x1a, | ||
94 | .tuner_sda_gpio = 0x1b, | ||
95 | .decoder = CX231XX_AVDECODER, | ||
96 | .demod_xfer_mode = 0, | ||
97 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
98 | .agc_analog_digital_select_gpio = 0x0c, | ||
99 | .gpio_pin_status_mask = 0x4001000, | ||
100 | .tuner_i2c_master = 1, | ||
101 | .demod_i2c_master = 2, | ||
102 | .has_dvb = 1, | ||
103 | .demod_addr = 0x02, | ||
104 | .norm = V4L2_STD_PAL, | ||
105 | |||
106 | .input = {{ | ||
107 | .type = CX231XX_VMUX_TELEVISION, | ||
108 | .vmux = CX231XX_VIN_3_1, | ||
109 | .amux = CX231XX_AMUX_VIDEO, | ||
110 | .gpio = 0, | ||
111 | }, { | ||
112 | .type = CX231XX_VMUX_COMPOSITE1, | ||
113 | .vmux = CX231XX_VIN_2_1, | ||
114 | .amux = CX231XX_AMUX_LINE_IN, | ||
115 | .gpio = 0, | ||
116 | }, { | ||
117 | .type = CX231XX_VMUX_SVIDEO, | ||
118 | .vmux = CX231XX_VIN_1_1 | | ||
119 | (CX231XX_VIN_1_2 << 8) | | ||
120 | CX25840_SVIDEO_ON, | ||
121 | .amux = CX231XX_AMUX_LINE_IN, | ||
122 | .gpio = 0, | ||
123 | } | ||
124 | }, | ||
125 | }, | ||
126 | |||
127 | [CX231XX_BOARD_CNXT_RDU_250] = { | ||
128 | .name = "Conexant Hybrid TV - RDU250", | ||
129 | .tuner_type = TUNER_XC5000, | ||
130 | .tuner_addr = 0x61, | ||
131 | .tuner_gpio = RDE250_XCV_TUNER, | ||
132 | .tuner_sif_gpio = 0x05, | ||
133 | .tuner_scl_gpio = 0x1a, | ||
134 | .tuner_sda_gpio = 0x1b, | ||
135 | .decoder = CX231XX_AVDECODER, | ||
136 | .demod_xfer_mode = 0, | ||
137 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
138 | .agc_analog_digital_select_gpio = 0x0c, | ||
139 | .gpio_pin_status_mask = 0x4001000, | ||
140 | .tuner_i2c_master = 1, | ||
141 | .demod_i2c_master = 2, | ||
142 | .has_dvb = 1, | ||
143 | .demod_addr = 0x32, | ||
144 | .norm = V4L2_STD_NTSC, | ||
145 | |||
146 | .input = {{ | ||
147 | .type = CX231XX_VMUX_TELEVISION, | ||
148 | .vmux = CX231XX_VIN_3_1, | ||
149 | .amux = CX231XX_AMUX_VIDEO, | ||
150 | .gpio = 0, | ||
151 | }, { | ||
152 | .type = CX231XX_VMUX_COMPOSITE1, | ||
153 | .vmux = CX231XX_VIN_2_1, | ||
154 | .amux = CX231XX_AMUX_LINE_IN, | ||
155 | .gpio = 0, | ||
156 | }, { | ||
157 | .type = CX231XX_VMUX_SVIDEO, | ||
158 | .vmux = CX231XX_VIN_1_1 | | ||
159 | (CX231XX_VIN_1_2 << 8) | | ||
160 | CX25840_SVIDEO_ON, | ||
161 | .amux = CX231XX_AMUX_LINE_IN, | ||
162 | .gpio = 0, | ||
163 | } | ||
164 | }, | ||
165 | }, | ||
166 | }; | ||
167 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); | ||
168 | |||
169 | /* table of devices that work with this driver */ | ||
170 | struct usb_device_id cx231xx_id_table[] = { | ||
171 | {USB_DEVICE(0x0572, 0x5A3C), | ||
172 | .driver_info = CX231XX_BOARD_UNKNOWN}, | ||
173 | {USB_DEVICE(0x0572, 0x58A2), | ||
174 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, | ||
175 | {USB_DEVICE(0x0572, 0x58A1), | ||
176 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, | ||
177 | {}, | ||
178 | }; | ||
179 | |||
180 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); | ||
181 | |||
182 | /* cx231xx_tuner_callback | ||
183 | * will be used to reset XC5000 tuner using GPIO pin | ||
184 | */ | ||
185 | |||
186 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) | ||
187 | { | ||
188 | int rc = 0; | ||
189 | struct cx231xx *dev = ptr; | ||
190 | |||
191 | if (dev->tuner_type == TUNER_XC5000) { | ||
192 | if (command == XC5000_TUNER_RESET) { | ||
193 | cx231xx_info | ||
194 | ("Tuner CB: RESET: cmd %d : tuner type %d \n", | ||
195 | command, dev->tuner_type); | ||
196 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
197 | 1); | ||
198 | msleep(10); | ||
199 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
200 | 0); | ||
201 | msleep(330); | ||
202 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
203 | 1); | ||
204 | msleep(10); | ||
205 | } | ||
206 | } | ||
207 | return rc; | ||
208 | } | ||
209 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); | ||
210 | |||
211 | static inline void cx231xx_set_model(struct cx231xx *dev) | ||
212 | { | ||
213 | memcpy(&dev->board, &cx231xx_boards[dev->model], sizeof(dev->board)); | ||
214 | } | ||
215 | |||
216 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, | ||
217 | * this won't work for boards with generic PCI IDs | ||
218 | */ | ||
219 | void cx231xx_pre_card_setup(struct cx231xx *dev) | ||
220 | { | ||
221 | |||
222 | cx231xx_set_model(dev); | ||
223 | |||
224 | cx231xx_info("Identified as %s (card=%d)\n", | ||
225 | dev->board.name, dev->model); | ||
226 | |||
227 | /* set the direction for GPIO pins */ | ||
228 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); | ||
229 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); | ||
230 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); | ||
231 | |||
232 | /* request some modules if any required */ | ||
233 | |||
234 | /* reset the Tuner */ | ||
235 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
236 | |||
237 | /* set the mode to Analog mode initially */ | ||
238 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
239 | |||
240 | /* Unlock device */ | ||
241 | /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */ | ||
242 | |||
243 | } | ||
244 | |||
245 | static void cx231xx_config_tuner(struct cx231xx *dev) | ||
246 | { | ||
247 | struct tuner_setup tun_setup; | ||
248 | struct v4l2_frequency f; | ||
249 | |||
250 | if (dev->tuner_type == TUNER_ABSENT) | ||
251 | return; | ||
252 | |||
253 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | ||
254 | tun_setup.type = dev->tuner_type; | ||
255 | tun_setup.addr = dev->tuner_addr; | ||
256 | tun_setup.tuner_callback = cx231xx_tuner_callback; | ||
257 | |||
258 | tuner_call(dev, tuner, s_type_addr, &tun_setup); | ||
259 | |||
260 | #if 0 | ||
261 | if (tun_setup.type == TUNER_XC5000) { | ||
262 | static struct xc2028_ctrl ctrl = { | ||
263 | .fname = XC5000_DEFAULT_FIRMWARE, | ||
264 | .max_len = 64, | ||
265 | .demod = 0; | ||
266 | }; | ||
267 | struct v4l2_priv_tun_config cfg = { | ||
268 | .tuner = dev->tuner_type, | ||
269 | .priv = &ctrl, | ||
270 | }; | ||
271 | tuner_call(dev, tuner, s_config, &cfg); | ||
272 | } | ||
273 | #endif | ||
274 | /* configure tuner */ | ||
275 | f.tuner = 0; | ||
276 | f.type = V4L2_TUNER_ANALOG_TV; | ||
277 | f.frequency = 9076; /* just a magic number */ | ||
278 | dev->ctl_freq = f.frequency; | ||
279 | call_all(dev, tuner, s_frequency, &f); | ||
280 | |||
281 | } | ||
282 | |||
283 | /* ----------------------------------------------------------------------- */ | ||
284 | void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) | ||
285 | { | ||
286 | if (disable_ir) { | ||
287 | ir->get_key = NULL; | ||
288 | return; | ||
289 | } | ||
290 | |||
291 | /* detect & configure */ | ||
292 | switch (dev->model) { | ||
293 | |||
294 | case CX231XX_BOARD_CNXT_RDE_250: | ||
295 | break; | ||
296 | case CX231XX_BOARD_CNXT_RDU_250: | ||
297 | break; | ||
298 | default: | ||
299 | break; | ||
300 | } | ||
301 | } | ||
302 | |||
303 | void cx231xx_card_setup(struct cx231xx *dev) | ||
304 | { | ||
305 | |||
306 | cx231xx_set_model(dev); | ||
307 | |||
308 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; | ||
309 | if (cx231xx_boards[dev->model].tuner_addr) | ||
310 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; | ||
311 | |||
312 | /* request some modules */ | ||
313 | if (dev->board.decoder == CX231XX_AVDECODER) { | ||
314 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
315 | &dev->i2c_bus[0].i2c_adap, | ||
316 | "cx25840", "cx25840", 0x88 >> 1); | ||
317 | if (dev->sd_cx25840 == NULL) | ||
318 | cx231xx_info("cx25840 subdev registration failure\n"); | ||
319 | cx25840_call(dev, core, load_fw); | ||
320 | |||
321 | } | ||
322 | |||
323 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
324 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
325 | &dev->i2c_bus[1].i2c_adap, | ||
326 | "tuner", "tuner", 0xc2 >> 1); | ||
327 | if (dev->sd_tuner == NULL) | ||
328 | cx231xx_info("tuner subdev registration failure\n"); | ||
329 | |||
330 | cx231xx_config_tuner(dev); | ||
331 | } | ||
332 | |||
333 | cx231xx_config_tuner(dev); | ||
334 | |||
335 | #if 0 | ||
336 | /* TBD IR will be added later */ | ||
337 | cx231xx_ir_init(dev); | ||
338 | #endif | ||
339 | } | ||
340 | |||
341 | /* | ||
342 | * cx231xx_config() | ||
343 | * inits registers with sane defaults | ||
344 | */ | ||
345 | int cx231xx_config(struct cx231xx *dev) | ||
346 | { | ||
347 | /* TBD need to add cx231xx specific code */ | ||
348 | dev->mute = 1; /* maybe not the right place... */ | ||
349 | dev->volume = 0x1f; | ||
350 | |||
351 | return 0; | ||
352 | } | ||
353 | |||
354 | /* | ||
355 | * cx231xx_config_i2c() | ||
356 | * configure i2c attached devices | ||
357 | */ | ||
358 | void cx231xx_config_i2c(struct cx231xx *dev) | ||
359 | { | ||
360 | /* u32 input = INPUT(dev->video_input)->vmux; */ | ||
361 | |||
362 | call_all(dev, video, s_stream, 1); | ||
363 | } | ||
364 | |||
365 | /* | ||
366 | * cx231xx_realease_resources() | ||
367 | * unregisters the v4l2,i2c and usb devices | ||
368 | * called when the device gets disconected or at module unload | ||
369 | */ | ||
370 | void cx231xx_release_resources(struct cx231xx *dev) | ||
371 | { | ||
372 | |||
373 | #if 0 /* TBD IR related */ | ||
374 | if (dev->ir) | ||
375 | cx231xx_ir_fini(dev); | ||
376 | #endif | ||
377 | |||
378 | cx231xx_release_analog_resources(dev); | ||
379 | |||
380 | cx231xx_remove_from_devlist(dev); | ||
381 | |||
382 | cx231xx_dev_uninit(dev); | ||
383 | |||
384 | usb_put_dev(dev->udev); | ||
385 | |||
386 | /* Mark device as unused */ | ||
387 | cx231xx_devused &= ~(1 << dev->devno); | ||
388 | } | ||
389 | |||
390 | /* | ||
391 | * cx231xx_init_dev() | ||
392 | * allocates and inits the device structs, registers i2c bus and v4l device | ||
393 | */ | ||
394 | static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | ||
395 | int minor) | ||
396 | { | ||
397 | struct cx231xx *dev = *devhandle; | ||
398 | int retval = -ENOMEM; | ||
399 | int errCode; | ||
400 | unsigned int maxh, maxw; | ||
401 | |||
402 | dev->udev = udev; | ||
403 | mutex_init(&dev->lock); | ||
404 | mutex_init(&dev->ctrl_urb_lock); | ||
405 | mutex_init(&dev->gpio_i2c_lock); | ||
406 | |||
407 | spin_lock_init(&dev->video_mode.slock); | ||
408 | spin_lock_init(&dev->vbi_mode.slock); | ||
409 | spin_lock_init(&dev->sliced_cc_mode.slock); | ||
410 | |||
411 | init_waitqueue_head(&dev->open); | ||
412 | init_waitqueue_head(&dev->wait_frame); | ||
413 | init_waitqueue_head(&dev->wait_stream); | ||
414 | |||
415 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; | ||
416 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; | ||
417 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; | ||
418 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; | ||
419 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; | ||
420 | |||
421 | /* Query cx231xx to find what pcb config it is related to */ | ||
422 | initialize_cx231xx(dev); | ||
423 | |||
424 | /* Cx231xx pre card setup */ | ||
425 | cx231xx_pre_card_setup(dev); | ||
426 | |||
427 | errCode = cx231xx_config(dev); | ||
428 | if (errCode) { | ||
429 | cx231xx_errdev("error configuring device\n"); | ||
430 | return -ENOMEM; | ||
431 | } | ||
432 | |||
433 | /* set default norm */ | ||
434 | dev->norm = dev->board.norm; | ||
435 | |||
436 | /* register i2c bus */ | ||
437 | errCode = cx231xx_dev_init(dev); | ||
438 | if (errCode < 0) { | ||
439 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", | ||
440 | __func__, errCode); | ||
441 | return errCode; | ||
442 | } | ||
443 | |||
444 | /* Do board specific init */ | ||
445 | cx231xx_card_setup(dev); | ||
446 | |||
447 | /* configure the device */ | ||
448 | cx231xx_config_i2c(dev); | ||
449 | |||
450 | maxw = norm_maxw(dev); | ||
451 | maxh = norm_maxh(dev); | ||
452 | |||
453 | /* set default image size */ | ||
454 | dev->width = maxw; | ||
455 | dev->height = maxh; | ||
456 | dev->interlaced = 0; | ||
457 | dev->hscale = 0; | ||
458 | dev->vscale = 0; | ||
459 | dev->video_input = 0; | ||
460 | |||
461 | errCode = cx231xx_config(dev); | ||
462 | if (errCode < 0) { | ||
463 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", | ||
464 | __func__, errCode); | ||
465 | return errCode; | ||
466 | } | ||
467 | |||
468 | /* init video dma queues */ | ||
469 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); | ||
470 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); | ||
471 | |||
472 | /* init vbi dma queues */ | ||
473 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); | ||
474 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); | ||
475 | |||
476 | /* Reset other chips required if they are tied up with GPIO pins */ | ||
477 | |||
478 | cx231xx_add_into_devlist(dev); | ||
479 | |||
480 | retval = cx231xx_register_analog_devices(dev); | ||
481 | if (retval < 0) { | ||
482 | cx231xx_release_resources(dev); | ||
483 | goto fail_reg_devices; | ||
484 | } | ||
485 | |||
486 | cx231xx_init_extension(dev); | ||
487 | |||
488 | return 0; | ||
489 | |||
490 | fail_reg_devices: | ||
491 | mutex_unlock(&dev->lock); | ||
492 | return retval; | ||
493 | } | ||
494 | |||
495 | #if defined(CONFIG_MODULES) && defined(MODULE) | ||
496 | static void request_module_async(struct work_struct *work) | ||
497 | { | ||
498 | struct cx231xx *dev = container_of(work, | ||
499 | struct cx231xx, request_module_wk); | ||
500 | |||
501 | if (dev->has_alsa_audio) | ||
502 | request_module("cx231xx-alsa"); | ||
503 | |||
504 | if (dev->board.has_dvb) | ||
505 | request_module("cx231xx-dvb"); | ||
506 | |||
507 | } | ||
508 | |||
509 | static void request_modules(struct cx231xx *dev) | ||
510 | { | ||
511 | INIT_WORK(&dev->request_module_wk, request_module_async); | ||
512 | schedule_work(&dev->request_module_wk); | ||
513 | } | ||
514 | #else | ||
515 | #define request_modules(dev) | ||
516 | #endif /* CONFIG_MODULES */ | ||
517 | |||
518 | /* | ||
519 | * cx231xx_usb_probe() | ||
520 | * checks for supported devices | ||
521 | */ | ||
522 | static int cx231xx_usb_probe(struct usb_interface *interface, | ||
523 | const struct usb_device_id *id) | ||
524 | { | ||
525 | struct usb_device *udev; | ||
526 | struct usb_interface *uif; | ||
527 | struct cx231xx *dev = NULL; | ||
528 | int retval = -ENODEV; | ||
529 | int nr = 0, ifnum; | ||
530 | int i, isoc_pipe = 0; | ||
531 | char *speed; | ||
532 | char descr[255] = ""; | ||
533 | struct usb_interface *lif = NULL; | ||
534 | int skip_interface = 0; | ||
535 | struct usb_interface_assoc_descriptor *assoc_desc; | ||
536 | |||
537 | udev = usb_get_dev(interface_to_usbdev(interface)); | ||
538 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | ||
539 | |||
540 | if (!ifnum) { | ||
541 | /* | ||
542 | * Interface number 0 - IR interface | ||
543 | */ | ||
544 | /* Check to see next free device and mark as used */ | ||
545 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | ||
546 | cx231xx_devused |= 1 << nr; | ||
547 | |||
548 | if (nr >= CX231XX_MAXBOARDS) { | ||
549 | cx231xx_err(DRIVER_NAME ": Supports only %i cx231xx boards.\n", | ||
550 | CX231XX_MAXBOARDS); | ||
551 | cx231xx_devused &= ~(1 << nr); | ||
552 | return -ENOMEM; | ||
553 | } | ||
554 | |||
555 | /* allocate memory for our device state and initialize it */ | ||
556 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
557 | if (dev == NULL) { | ||
558 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); | ||
559 | cx231xx_devused &= ~(1 << nr); | ||
560 | return -ENOMEM; | ||
561 | } | ||
562 | |||
563 | snprintf(dev->name, 29, "cx231xx #%d", nr); | ||
564 | dev->devno = nr; | ||
565 | dev->model = id->driver_info; | ||
566 | dev->video_mode.alt = -1; | ||
567 | dev->interface_count++; | ||
568 | |||
569 | /* reset gpio dir and value */ | ||
570 | dev->gpio_dir = 0; | ||
571 | dev->gpio_val = 0; | ||
572 | dev->xc_fw_load_done = 0; | ||
573 | dev->has_alsa_audio = 1; | ||
574 | dev->power_mode = -1; | ||
575 | |||
576 | /* 0 - vbi ; 1 -sliced cc mode */ | ||
577 | dev->vbi_or_sliced_cc_mode = 0; | ||
578 | |||
579 | /* get maximum no.of IAD interfaces */ | ||
580 | assoc_desc = udev->actconfig->intf_assoc[0]; | ||
581 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; | ||
582 | |||
583 | /* init CIR module TBD */ | ||
584 | |||
585 | /* store the current interface */ | ||
586 | lif = interface; | ||
587 | |||
588 | switch (udev->speed) { | ||
589 | case USB_SPEED_LOW: | ||
590 | speed = "1.5"; | ||
591 | break; | ||
592 | case USB_SPEED_UNKNOWN: | ||
593 | case USB_SPEED_FULL: | ||
594 | speed = "12"; | ||
595 | break; | ||
596 | case USB_SPEED_HIGH: | ||
597 | speed = "480"; | ||
598 | break; | ||
599 | default: | ||
600 | speed = "unknown"; | ||
601 | } | ||
602 | |||
603 | if (udev->manufacturer) | ||
604 | strlcpy(descr, udev->manufacturer, sizeof(descr)); | ||
605 | |||
606 | if (udev->product) { | ||
607 | if (*descr) | ||
608 | strlcat(descr, " ", sizeof(descr)); | ||
609 | strlcat(descr, udev->product, sizeof(descr)); | ||
610 | } | ||
611 | if (*descr) | ||
612 | strlcat(descr, " ", sizeof(descr)); | ||
613 | |||
614 | cx231xx_info("New device %s@ %s Mbps " | ||
615 | "(%04x:%04x) with %d interfaces\n", | ||
616 | descr, | ||
617 | speed, | ||
618 | le16_to_cpu(udev->descriptor.idVendor), | ||
619 | le16_to_cpu(udev->descriptor.idProduct), | ||
620 | dev->max_iad_interface_count); | ||
621 | } else { | ||
622 | /* Get dev structure first */ | ||
623 | dev = usb_get_intfdata(udev->actconfig->interface[0]); | ||
624 | if (dev == NULL) { | ||
625 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); | ||
626 | return -ENODEV; | ||
627 | } | ||
628 | |||
629 | /* store the interface 0 back */ | ||
630 | lif = udev->actconfig->interface[0]; | ||
631 | |||
632 | /* increment interface count */ | ||
633 | dev->interface_count++; | ||
634 | |||
635 | /* get device number */ | ||
636 | nr = dev->devno; | ||
637 | |||
638 | /* | ||
639 | * set skip interface, for all interfaces but | ||
640 | * interface 1 and the last one | ||
641 | */ | ||
642 | if ((ifnum != 1) && ((dev->interface_count - 1) | ||
643 | != dev->max_iad_interface_count)) | ||
644 | skip_interface = 1; | ||
645 | |||
646 | if (ifnum == 1) { | ||
647 | assoc_desc = udev->actconfig->intf_assoc[0]; | ||
648 | if (assoc_desc->bFirstInterface != ifnum) { | ||
649 | cx231xx_err(DRIVER_NAME ": Not found " | ||
650 | "matching IAD interface\n"); | ||
651 | return -ENODEV; | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | |||
656 | if (skip_interface) | ||
657 | return -ENODEV; | ||
658 | |||
659 | cx231xx_info("registering interface %d\n", ifnum); | ||
660 | |||
661 | /* save our data pointer in this interface device */ | ||
662 | usb_set_intfdata(lif, dev); | ||
663 | |||
664 | if ((dev->interface_count - 1) != dev->max_iad_interface_count) | ||
665 | return 0; | ||
666 | |||
667 | /* | ||
668 | * AV device initialization - only done at the last interface | ||
669 | */ | ||
670 | |||
671 | /* Create v4l2 device */ | ||
672 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | ||
673 | if (retval) { | ||
674 | cx231xx_errdev("v4l2_device_register failed\n"); | ||
675 | cx231xx_devused &= ~(1 << nr); | ||
676 | kfree(dev); | ||
677 | return -EIO; | ||
678 | } | ||
679 | |||
680 | /* allocate device struct */ | ||
681 | retval = cx231xx_init_dev(&dev, udev, nr); | ||
682 | if (retval) { | ||
683 | cx231xx_devused &= ~(1 << dev->devno); | ||
684 | v4l2_device_unregister(&dev->v4l2_dev); | ||
685 | kfree(dev); | ||
686 | return retval; | ||
687 | } | ||
688 | |||
689 | /* compute alternate max packet sizes for video */ | ||
690 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
691 | hs_config_info[0].interface_info.video_index + 1]; | ||
692 | |||
693 | dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0]. | ||
694 | endpoint[isoc_pipe].desc.bEndpointAddress); | ||
695 | |||
696 | dev->video_mode.num_alt = uif->num_altsetting; | ||
697 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
698 | dev->video_mode.end_point_addr, | ||
699 | dev->video_mode.num_alt); | ||
700 | dev->video_mode.alt_max_pkt_size = | ||
701 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); | ||
702 | |||
703 | if (dev->video_mode.alt_max_pkt_size == NULL) { | ||
704 | cx231xx_errdev("out of memory!\n"); | ||
705 | cx231xx_devused &= ~(1 << nr); | ||
706 | v4l2_device_unregister(&dev->v4l2_dev); | ||
707 | kfree(dev); | ||
708 | return -ENOMEM; | ||
709 | } | ||
710 | |||
711 | for (i = 0; i < dev->video_mode.num_alt; i++) { | ||
712 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
713 | desc.wMaxPacketSize); | ||
714 | dev->video_mode.alt_max_pkt_size[i] = | ||
715 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
716 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
717 | dev->video_mode.alt_max_pkt_size[i]); | ||
718 | } | ||
719 | |||
720 | /* compute alternate max packet sizes for vbi */ | ||
721 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
722 | hs_config_info[0].interface_info. | ||
723 | vanc_index + 1]; | ||
724 | |||
725 | dev->vbi_mode.end_point_addr = | ||
726 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
727 | bEndpointAddress); | ||
728 | |||
729 | dev->vbi_mode.num_alt = uif->num_altsetting; | ||
730 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
731 | dev->vbi_mode.end_point_addr, | ||
732 | dev->vbi_mode.num_alt); | ||
733 | dev->vbi_mode.alt_max_pkt_size = | ||
734 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); | ||
735 | |||
736 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | ||
737 | cx231xx_errdev("out of memory!\n"); | ||
738 | cx231xx_devused &= ~(1 << nr); | ||
739 | v4l2_device_unregister(&dev->v4l2_dev); | ||
740 | kfree(dev); | ||
741 | return -ENOMEM; | ||
742 | } | ||
743 | |||
744 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { | ||
745 | u16 tmp = | ||
746 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
747 | desc.wMaxPacketSize); | ||
748 | dev->vbi_mode.alt_max_pkt_size[i] = | ||
749 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
750 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
751 | dev->vbi_mode.alt_max_pkt_size[i]); | ||
752 | } | ||
753 | |||
754 | /* compute alternate max packet sizes for sliced CC */ | ||
755 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
756 | hs_config_info[0].interface_info. | ||
757 | hanc_index + 1]; | ||
758 | |||
759 | dev->sliced_cc_mode.end_point_addr = | ||
760 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
761 | bEndpointAddress); | ||
762 | |||
763 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | ||
764 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
765 | dev->sliced_cc_mode.end_point_addr, | ||
766 | dev->sliced_cc_mode.num_alt); | ||
767 | dev->sliced_cc_mode.alt_max_pkt_size = | ||
768 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | ||
769 | |||
770 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | ||
771 | cx231xx_errdev("out of memory!\n"); | ||
772 | cx231xx_devused &= ~(1 << nr); | ||
773 | v4l2_device_unregister(&dev->v4l2_dev); | ||
774 | kfree(dev); | ||
775 | return -ENOMEM; | ||
776 | } | ||
777 | |||
778 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { | ||
779 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
780 | desc.wMaxPacketSize); | ||
781 | dev->sliced_cc_mode.alt_max_pkt_size[i] = | ||
782 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
783 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
784 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | ||
785 | } | ||
786 | |||
787 | if (dev->current_pcb_config.ts1_source != 0xff) { | ||
788 | /* compute alternate max packet sizes for TS1 */ | ||
789 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
790 | hs_config_info[0]. | ||
791 | interface_info. | ||
792 | ts1_index + 1]; | ||
793 | |||
794 | dev->ts1_mode.end_point_addr = | ||
795 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. | ||
796 | desc.bEndpointAddress); | ||
797 | |||
798 | dev->ts1_mode.num_alt = uif->num_altsetting; | ||
799 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
800 | dev->ts1_mode.end_point_addr, | ||
801 | dev->ts1_mode.num_alt); | ||
802 | dev->ts1_mode.alt_max_pkt_size = | ||
803 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); | ||
804 | |||
805 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | ||
806 | cx231xx_errdev("out of memory!\n"); | ||
807 | cx231xx_devused &= ~(1 << nr); | ||
808 | v4l2_device_unregister(&dev->v4l2_dev); | ||
809 | kfree(dev); | ||
810 | return -ENOMEM; | ||
811 | } | ||
812 | |||
813 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { | ||
814 | u16 tmp = le16_to_cpu(uif->altsetting[i]. | ||
815 | endpoint[isoc_pipe].desc. | ||
816 | wMaxPacketSize); | ||
817 | dev->ts1_mode.alt_max_pkt_size[i] = | ||
818 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
819 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
820 | dev->ts1_mode.alt_max_pkt_size[i]); | ||
821 | } | ||
822 | } | ||
823 | |||
824 | /* load other modules required */ | ||
825 | request_modules(dev); | ||
826 | |||
827 | return 0; | ||
828 | } | ||
829 | |||
830 | /* | ||
831 | * cx231xx_usb_disconnect() | ||
832 | * called when the device gets diconencted | ||
833 | * video device will be unregistered on v4l2_close in case it is still open | ||
834 | */ | ||
835 | static void cx231xx_usb_disconnect(struct usb_interface *interface) | ||
836 | { | ||
837 | struct cx231xx *dev; | ||
838 | |||
839 | dev = usb_get_intfdata(interface); | ||
840 | usb_set_intfdata(interface, NULL); | ||
841 | |||
842 | if (!dev) | ||
843 | return; | ||
844 | |||
845 | if (!dev->udev) | ||
846 | return; | ||
847 | |||
848 | /* delete v4l2 device */ | ||
849 | v4l2_device_unregister(&dev->v4l2_dev); | ||
850 | |||
851 | /* wait until all current v4l2 io is finished then deallocate | ||
852 | resources */ | ||
853 | mutex_lock(&dev->lock); | ||
854 | |||
855 | wake_up_interruptible_all(&dev->open); | ||
856 | |||
857 | if (dev->users) { | ||
858 | cx231xx_warn | ||
859 | ("device /dev/video%d is open! Deregistration and memory " | ||
860 | "deallocation are deferred on close.\n", dev->vdev->num); | ||
861 | |||
862 | dev->state |= DEV_MISCONFIGURED; | ||
863 | cx231xx_uninit_isoc(dev); | ||
864 | dev->state |= DEV_DISCONNECTED; | ||
865 | wake_up_interruptible(&dev->wait_frame); | ||
866 | wake_up_interruptible(&dev->wait_stream); | ||
867 | } else { | ||
868 | dev->state |= DEV_DISCONNECTED; | ||
869 | cx231xx_release_resources(dev); | ||
870 | } | ||
871 | |||
872 | cx231xx_close_extension(dev); | ||
873 | |||
874 | mutex_unlock(&dev->lock); | ||
875 | |||
876 | if (!dev->users) { | ||
877 | kfree(dev->video_mode.alt_max_pkt_size); | ||
878 | kfree(dev->vbi_mode.alt_max_pkt_size); | ||
879 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); | ||
880 | kfree(dev->ts1_mode.alt_max_pkt_size); | ||
881 | kfree(dev); | ||
882 | } | ||
883 | } | ||
884 | |||
885 | static struct usb_driver cx231xx_usb_driver = { | ||
886 | .name = "cx231xx", | ||
887 | .probe = cx231xx_usb_probe, | ||
888 | .disconnect = cx231xx_usb_disconnect, | ||
889 | .id_table = cx231xx_id_table, | ||
890 | }; | ||
891 | |||
892 | static int __init cx231xx_module_init(void) | ||
893 | { | ||
894 | int result; | ||
895 | |||
896 | printk(KERN_INFO DRIVER_NAME " v4l2 driver loaded.\n"); | ||
897 | |||
898 | /* register this driver with the USB subsystem */ | ||
899 | result = usb_register(&cx231xx_usb_driver); | ||
900 | if (result) | ||
901 | cx231xx_err(DRIVER_NAME | ||
902 | " usb_register failed. Error number %d.\n", result); | ||
903 | |||
904 | return result; | ||
905 | } | ||
906 | |||
907 | static void __exit cx231xx_module_exit(void) | ||
908 | { | ||
909 | /* deregister this driver with the USB subsystem */ | ||
910 | usb_deregister(&cx231xx_usb_driver); | ||
911 | } | ||
912 | |||
913 | module_init(cx231xx_module_init); | ||
914 | module_exit(cx231xx_module_exit); | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-conf-reg.h b/drivers/media/video/cx231xx/cx231xx-conf-reg.h new file mode 100644 index 000000000000..a6f398a175c5 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-conf-reg.h | |||
@@ -0,0 +1,494 @@ | |||
1 | /* | ||
2 | cx231xx_conf-reg.h - driver for Conexant Cx23100/101/102 USB | ||
3 | video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _POLARIS_REG_H_ | ||
23 | #define _POLARIS_REG_H_ | ||
24 | |||
25 | #define BOARD_CFG_STAT 0x0 | ||
26 | #define TS_MODE_REG 0x4 | ||
27 | #define TS1_CFG_REG 0x8 | ||
28 | #define TS1_LENGTH_REG 0xc | ||
29 | #define TS2_CFG_REG 0x10 | ||
30 | #define TS2_LENGTH_REG 0x14 | ||
31 | #define EP_MODE_SET 0x18 | ||
32 | #define CIR_PWR_PTN1 0x1c | ||
33 | #define CIR_PWR_PTN2 0x20 | ||
34 | #define CIR_PWR_PTN3 0x24 | ||
35 | #define CIR_PWR_MASK0 0x28 | ||
36 | #define CIR_PWR_MASK1 0x2c | ||
37 | #define CIR_PWR_MASK2 0x30 | ||
38 | #define CIR_GAIN 0x34 | ||
39 | #define CIR_CAR_REG 0x38 | ||
40 | #define CIR_OT_CFG1 0x40 | ||
41 | #define CIR_OT_CFG2 0x44 | ||
42 | #define PWR_CTL_EN 0x74 | ||
43 | |||
44 | /* Polaris Endpoints capture mask for register EP_MODE_SET */ | ||
45 | #define ENABLE_EP1 0x01 /* Bit[0]=1 */ | ||
46 | #define ENABLE_EP2 0x02 /* Bit[1]=1 */ | ||
47 | #define ENABLE_EP3 0x04 /* Bit[2]=1 */ | ||
48 | #define ENABLE_EP4 0x08 /* Bit[3]=1 */ | ||
49 | #define ENABLE_EP5 0x10 /* Bit[4]=1 */ | ||
50 | #define ENABLE_EP6 0x20 /* Bit[5]=1 */ | ||
51 | |||
52 | /* Bit definition for register PWR_CTL_EN */ | ||
53 | #define PWR_MODE_MASK 0x17f | ||
54 | #define PWR_AV_EN 0x08 /* bit3 */ | ||
55 | #define PWR_ISO_EN 0x40 /* bit6 */ | ||
56 | #define PWR_AV_MODE 0x30 /* bit4,5 */ | ||
57 | #define PWR_TUNER_EN 0x04 /* bit2 */ | ||
58 | #define PWR_DEMOD_EN 0x02 /* bit1 */ | ||
59 | #define I2C_DEMOD_EN 0x01 /* bit0 */ | ||
60 | #define PWR_RESETOUT_EN 0x100 /* bit8 */ | ||
61 | |||
62 | enum AV_MODE{ | ||
63 | POLARIS_AVMODE_DEFAULT = 0, | ||
64 | POLARIS_AVMODE_DIGITAL = 0x10, | ||
65 | POLARIS_AVMODE_ANALOGT_TV = 0x20, | ||
66 | POLARIS_AVMODE_ENXTERNAL_AV = 0x30, | ||
67 | |||
68 | }; | ||
69 | |||
70 | /* Colibri Registers */ | ||
71 | |||
72 | #define SINGLE_ENDED 0x0 | ||
73 | #define LOW_IF 0x4 | ||
74 | #define EU_IF 0x9 | ||
75 | #define US_IF 0xa | ||
76 | |||
77 | #define SUP_BLK_TUNE1 0x00 | ||
78 | #define SUP_BLK_TUNE2 0x01 | ||
79 | #define SUP_BLK_TUNE3 0x02 | ||
80 | #define SUP_BLK_XTAL 0x03 | ||
81 | #define SUP_BLK_PLL1 0x04 | ||
82 | #define SUP_BLK_PLL2 0x05 | ||
83 | #define SUP_BLK_PLL3 0x06 | ||
84 | #define SUP_BLK_REF 0x07 | ||
85 | #define SUP_BLK_PWRDN 0x08 | ||
86 | #define SUP_BLK_TESTPAD 0x09 | ||
87 | #define ADC_COM_INT5_STAB_REF 0x0a | ||
88 | #define ADC_COM_QUANT 0x0b | ||
89 | #define ADC_COM_BIAS1 0x0c | ||
90 | #define ADC_COM_BIAS2 0x0d | ||
91 | #define ADC_COM_BIAS3 0x0e | ||
92 | #define TESTBUS_CTRL 0x12 | ||
93 | |||
94 | #define FLD_PWRDN_TUNING_BIAS 0x10 | ||
95 | #define FLD_PWRDN_ENABLE_PLL 0x08 | ||
96 | #define FLD_PWRDN_PD_BANDGAP 0x04 | ||
97 | #define FLD_PWRDN_PD_BIAS 0x02 | ||
98 | #define FLD_PWRDN_PD_TUNECK 0x01 | ||
99 | |||
100 | |||
101 | #define ADC_STATUS_CH1 0x20 | ||
102 | #define ADC_STATUS_CH2 0x40 | ||
103 | #define ADC_STATUS_CH3 0x60 | ||
104 | |||
105 | #define ADC_STATUS2_CH1 0x21 | ||
106 | #define ADC_STATUS2_CH2 0x41 | ||
107 | #define ADC_STATUS2_CH3 0x61 | ||
108 | |||
109 | #define ADC_CAL_ATEST_CH1 0x22 | ||
110 | #define ADC_CAL_ATEST_CH2 0x42 | ||
111 | #define ADC_CAL_ATEST_CH3 0x62 | ||
112 | |||
113 | #define ADC_PWRDN_CLAMP_CH1 0x23 | ||
114 | #define ADC_PWRDN_CLAMP_CH2 0x43 | ||
115 | #define ADC_PWRDN_CLAMP_CH3 0x63 | ||
116 | |||
117 | #define ADC_CTRL_DAC23_CH1 0x24 | ||
118 | #define ADC_CTRL_DAC23_CH2 0x44 | ||
119 | #define ADC_CTRL_DAC23_CH3 0x64 | ||
120 | |||
121 | #define ADC_CTRL_DAC1_CH1 0x25 | ||
122 | #define ADC_CTRL_DAC1_CH2 0x45 | ||
123 | #define ADC_CTRL_DAC1_CH3 0x65 | ||
124 | |||
125 | #define ADC_DCSERVO_DEM_CH1 0x26 | ||
126 | #define ADC_DCSERVO_DEM_CH2 0x46 | ||
127 | #define ADC_DCSERVO_DEM_CH3 0x66 | ||
128 | |||
129 | #define ADC_FB_FRCRST_CH1 0x27 | ||
130 | #define ADC_FB_FRCRST_CH2 0x47 | ||
131 | #define ADC_FB_FRCRST_CH3 0x67 | ||
132 | |||
133 | #define ADC_INPUT_CH1 0x28 | ||
134 | #define ADC_INPUT_CH2 0x48 | ||
135 | #define ADC_INPUT_CH3 0x68 | ||
136 | #define INPUT_SEL_MASK 0x30 /* [5:4] in_sel */ | ||
137 | |||
138 | #define ADC_NTF_PRECLMP_EN_CH1 0x29 | ||
139 | #define ADC_NTF_PRECLMP_EN_CH2 0x49 | ||
140 | #define ADC_NTF_PRECLMP_EN_CH3 0x69 | ||
141 | |||
142 | #define ADC_QGAIN_RES_TRM_CH1 0x2a | ||
143 | #define ADC_QGAIN_RES_TRM_CH2 0x4a | ||
144 | #define ADC_QGAIN_RES_TRM_CH3 0x6a | ||
145 | |||
146 | #define ADC_SOC_PRECLMP_TERM_CH1 0x2b | ||
147 | #define ADC_SOC_PRECLMP_TERM_CH2 0x4b | ||
148 | #define ADC_SOC_PRECLMP_TERM_CH3 0x6b | ||
149 | |||
150 | #define TESTBUS_CTRL_CH1 0x32 | ||
151 | #define TESTBUS_CTRL_CH2 0x52 | ||
152 | #define TESTBUS_CTRL_CH3 0x72 | ||
153 | |||
154 | /****************************************************************************** | ||
155 | * DIF registers * | ||
156 | ******************************************************************************/ | ||
157 | #define DIRECT_IF_REVB_BASE 0x00300 | ||
158 | |||
159 | /*****************************************************************************/ | ||
160 | #define DIF_PLL_FREQ_WORD (DIRECT_IF_REVB_BASE + 0x00000000) | ||
161 | /*****************************************************************************/ | ||
162 | #define FLD_DIF_PLL_LOCK 0x80000000 | ||
163 | /* Reserved [30:29] */ | ||
164 | #define FLD_DIF_PLL_FREE_RUN 0x10000000 | ||
165 | #define FLD_DIF_PLL_FREQ 0x0fffffff | ||
166 | |||
167 | /*****************************************************************************/ | ||
168 | #define DIF_PLL_CTRL (DIRECT_IF_REVB_BASE + 0x00000004) | ||
169 | /*****************************************************************************/ | ||
170 | #define FLD_DIF_KD_PD 0xff000000 | ||
171 | /* Reserved [23:20] */ | ||
172 | #define FLD_DIF_KDS_PD 0x000f0000 | ||
173 | #define FLD_DIF_KI_PD 0x0000ff00 | ||
174 | /* Reserved [7:4] */ | ||
175 | #define FLD_DIF_KIS_PD 0x0000000f | ||
176 | |||
177 | /*****************************************************************************/ | ||
178 | #define DIF_PLL_CTRL1 (DIRECT_IF_REVB_BASE + 0x00000008) | ||
179 | /*****************************************************************************/ | ||
180 | #define FLD_DIF_KD_FD 0xff000000 | ||
181 | /* Reserved [23:20] */ | ||
182 | #define FLD_DIF_KDS_FD 0x000f0000 | ||
183 | #define FLD_DIF_KI_FD 0x0000ff00 | ||
184 | #define FLD_DIF_SIG_PROP_SZ 0x000000f0 | ||
185 | #define FLD_DIF_KIS_FD 0x0000000f | ||
186 | |||
187 | /*****************************************************************************/ | ||
188 | #define DIF_PLL_CTRL2 (DIRECT_IF_REVB_BASE + 0x0000000c) | ||
189 | /*****************************************************************************/ | ||
190 | #define FLD_DIF_PLL_AGC_REF 0xfff00000 | ||
191 | #define FLD_DIF_PLL_AGC_KI 0x000f0000 | ||
192 | /* Reserved [15] */ | ||
193 | #define FLD_DIF_FREQ_LIMIT 0x00007000 | ||
194 | #define FLD_DIF_K_FD 0x00000f00 | ||
195 | #define FLD_DIF_DOWNSMPL_FD 0x000000ff | ||
196 | |||
197 | /*****************************************************************************/ | ||
198 | #define DIF_PLL_CTRL3 (DIRECT_IF_REVB_BASE + 0x00000010) | ||
199 | /*****************************************************************************/ | ||
200 | /* Reserved [31:16] */ | ||
201 | #define FLD_DIF_PLL_AGC_EN 0x00008000 | ||
202 | /* Reserved [14:12] */ | ||
203 | #define FLD_DIF_PLL_MAN_GAIN 0x00000fff | ||
204 | |||
205 | /*****************************************************************************/ | ||
206 | #define DIF_AGC_IF_REF (DIRECT_IF_REVB_BASE + 0x00000014) | ||
207 | /*****************************************************************************/ | ||
208 | #define FLD_DIF_K_AGC_RF 0xf0000000 | ||
209 | #define FLD_DIF_K_AGC_IF 0x0f000000 | ||
210 | #define FLD_DIF_K_AGC_INT 0x00f00000 | ||
211 | /* Reserved [19:12] */ | ||
212 | #define FLD_DIF_IF_REF 0x00000fff | ||
213 | |||
214 | /*****************************************************************************/ | ||
215 | #define DIF_AGC_CTRL_IF (DIRECT_IF_REVB_BASE + 0x00000018) | ||
216 | /*****************************************************************************/ | ||
217 | #define FLD_DIF_IF_MAX 0xff000000 | ||
218 | #define FLD_DIF_IF_MIN 0x00ff0000 | ||
219 | #define FLD_DIF_IF_AGC 0x0000ffff | ||
220 | |||
221 | /*****************************************************************************/ | ||
222 | #define DIF_AGC_CTRL_INT (DIRECT_IF_REVB_BASE + 0x0000001c) | ||
223 | /*****************************************************************************/ | ||
224 | #define FLD_DIF_INT_MAX 0xff000000 | ||
225 | #define FLD_DIF_INT_MIN 0x00ff0000 | ||
226 | #define FLD_DIF_INT_AGC 0x0000ffff | ||
227 | |||
228 | /*****************************************************************************/ | ||
229 | #define DIF_AGC_CTRL_RF (DIRECT_IF_REVB_BASE + 0x00000020) | ||
230 | /*****************************************************************************/ | ||
231 | #define FLD_DIF_RF_MAX 0xff000000 | ||
232 | #define FLD_DIF_RF_MIN 0x00ff0000 | ||
233 | #define FLD_DIF_RF_AGC 0x0000ffff | ||
234 | |||
235 | /*****************************************************************************/ | ||
236 | #define DIF_AGC_IF_INT_CURRENT (DIRECT_IF_REVB_BASE + 0x00000024) | ||
237 | /*****************************************************************************/ | ||
238 | #define FLD_DIF_IF_AGC_IN 0xffff0000 | ||
239 | #define FLD_DIF_INT_AGC_IN 0x0000ffff | ||
240 | |||
241 | /*****************************************************************************/ | ||
242 | #define DIF_AGC_RF_CURRENT (DIRECT_IF_REVB_BASE + 0x00000028) | ||
243 | /*****************************************************************************/ | ||
244 | /* Reserved [31:16] */ | ||
245 | #define FLD_DIF_RF_AGC_IN 0x0000ffff | ||
246 | |||
247 | /*****************************************************************************/ | ||
248 | #define DIF_VIDEO_AGC_CTRL (DIRECT_IF_REVB_BASE + 0x0000002c) | ||
249 | /*****************************************************************************/ | ||
250 | #define FLD_DIF_AFD 0xc0000000 | ||
251 | #define FLD_DIF_K_VID_AGC 0x30000000 | ||
252 | #define FLD_DIF_LINE_LENGTH 0x0fff0000 | ||
253 | #define FLD_DIF_AGC_GAIN 0x0000ffff | ||
254 | |||
255 | /*****************************************************************************/ | ||
256 | #define DIF_VID_AUD_OVERRIDE (DIRECT_IF_REVB_BASE + 0x00000030) | ||
257 | /*****************************************************************************/ | ||
258 | #define FLD_DIF_AUDIO_AGC_OVERRIDE 0x80000000 | ||
259 | /* Reserved [30:30] */ | ||
260 | #define FLD_DIF_AUDIO_MAN_GAIN 0x3f000000 | ||
261 | /* Reserved [23:17] */ | ||
262 | #define FLD_DIF_VID_AGC_OVERRIDE 0x00010000 | ||
263 | #define FLD_DIF_VID_MAN_GAIN 0x0000ffff | ||
264 | |||
265 | /*****************************************************************************/ | ||
266 | #define DIF_AV_SEP_CTRL (DIRECT_IF_REVB_BASE + 0x00000034) | ||
267 | /*****************************************************************************/ | ||
268 | #define FLD_DIF_LPF_FREQ 0xc0000000 | ||
269 | #define FLD_DIF_AV_PHASE_INC 0x3f000000 | ||
270 | #define FLD_DIF_AUDIO_FREQ 0x00ffffff | ||
271 | |||
272 | /*****************************************************************************/ | ||
273 | #define DIF_COMP_FLT_CTRL (DIRECT_IF_REVB_BASE + 0x00000038) | ||
274 | /*****************************************************************************/ | ||
275 | /* Reserved [31:24] */ | ||
276 | #define FLD_DIF_IIR23_R2 0x00ff0000 | ||
277 | #define FLD_DIF_IIR23_R1 0x0000ff00 | ||
278 | #define FLD_DIF_IIR1_R1 0x000000ff | ||
279 | |||
280 | /*****************************************************************************/ | ||
281 | #define DIF_MISC_CTRL (DIRECT_IF_REVB_BASE + 0x0000003c) | ||
282 | /*****************************************************************************/ | ||
283 | #define FLD_DIF_DIF_BYPASS 0x80000000 | ||
284 | #define FLD_DIF_FM_NYQ_GAIN 0x40000000 | ||
285 | #define FLD_DIF_RF_AGC_ENA 0x20000000 | ||
286 | #define FLD_DIF_INT_AGC_ENA 0x10000000 | ||
287 | #define FLD_DIF_IF_AGC_ENA 0x08000000 | ||
288 | #define FLD_DIF_FORCE_RF_IF_LOCK 0x04000000 | ||
289 | #define FLD_DIF_VIDEO_AGC_ENA 0x02000000 | ||
290 | #define FLD_DIF_RF_AGC_INV 0x01000000 | ||
291 | #define FLD_DIF_INT_AGC_INV 0x00800000 | ||
292 | #define FLD_DIF_IF_AGC_INV 0x00400000 | ||
293 | #define FLD_DIF_SPEC_INV 0x00200000 | ||
294 | #define FLD_DIF_AUD_FULL_BW 0x00100000 | ||
295 | #define FLD_DIF_AUD_SRC_SEL 0x00080000 | ||
296 | /* Reserved [18] */ | ||
297 | #define FLD_DIF_IF_FREQ 0x00030000 | ||
298 | /* Reserved [15:14] */ | ||
299 | #define FLD_DIF_TIP_OFFSET 0x00003f00 | ||
300 | /* Reserved [7:5] */ | ||
301 | #define FLD_DIF_DITHER_ENA 0x00000010 | ||
302 | /* Reserved [3:1] */ | ||
303 | #define FLD_DIF_RF_IF_LOCK 0x00000001 | ||
304 | |||
305 | /*****************************************************************************/ | ||
306 | #define DIF_SRC_PHASE_INC (DIRECT_IF_REVB_BASE + 0x00000040) | ||
307 | /*****************************************************************************/ | ||
308 | /* Reserved [31:29] */ | ||
309 | #define FLD_DIF_PHASE_INC 0x1fffffff | ||
310 | |||
311 | /*****************************************************************************/ | ||
312 | #define DIF_SRC_GAIN_CONTROL (DIRECT_IF_REVB_BASE + 0x00000044) | ||
313 | /*****************************************************************************/ | ||
314 | /* Reserved [31:16] */ | ||
315 | #define FLD_DIF_SRC_KI 0x0000ff00 | ||
316 | #define FLD_DIF_SRC_KD 0x000000ff | ||
317 | |||
318 | /*****************************************************************************/ | ||
319 | #define DIF_BPF_COEFF01 (DIRECT_IF_REVB_BASE + 0x00000048) | ||
320 | /*****************************************************************************/ | ||
321 | /* Reserved [31:19] */ | ||
322 | #define FLD_DIF_BPF_COEFF_0 0x00070000 | ||
323 | /* Reserved [15:4] */ | ||
324 | #define FLD_DIF_BPF_COEFF_1 0x0000000f | ||
325 | |||
326 | /*****************************************************************************/ | ||
327 | #define DIF_BPF_COEFF23 (DIRECT_IF_REVB_BASE + 0x0000004c) | ||
328 | /*****************************************************************************/ | ||
329 | /* Reserved [31:22] */ | ||
330 | #define FLD_DIF_BPF_COEFF_2 0x003f0000 | ||
331 | /* Reserved [15:7] */ | ||
332 | #define FLD_DIF_BPF_COEFF_3 0x0000007f | ||
333 | |||
334 | /*****************************************************************************/ | ||
335 | #define DIF_BPF_COEFF45 (DIRECT_IF_REVB_BASE + 0x00000050) | ||
336 | /*****************************************************************************/ | ||
337 | /* Reserved [31:24] */ | ||
338 | #define FLD_DIF_BPF_COEFF_4 0x00ff0000 | ||
339 | /* Reserved [15:8] */ | ||
340 | #define FLD_DIF_BPF_COEFF_5 0x000000ff | ||
341 | |||
342 | /*****************************************************************************/ | ||
343 | #define DIF_BPF_COEFF67 (DIRECT_IF_REVB_BASE + 0x00000054) | ||
344 | /*****************************************************************************/ | ||
345 | /* Reserved [31:25] */ | ||
346 | #define FLD_DIF_BPF_COEFF_6 0x01ff0000 | ||
347 | /* Reserved [15:9] */ | ||
348 | #define FLD_DIF_BPF_COEFF_7 0x000001ff | ||
349 | |||
350 | /*****************************************************************************/ | ||
351 | #define DIF_BPF_COEFF89 (DIRECT_IF_REVB_BASE + 0x00000058) | ||
352 | /*****************************************************************************/ | ||
353 | /* Reserved [31:26] */ | ||
354 | #define FLD_DIF_BPF_COEFF_8 0x03ff0000 | ||
355 | /* Reserved [15:10] */ | ||
356 | #define FLD_DIF_BPF_COEFF_9 0x000003ff | ||
357 | |||
358 | /*****************************************************************************/ | ||
359 | #define DIF_BPF_COEFF1011 (DIRECT_IF_REVB_BASE + 0x0000005c) | ||
360 | /*****************************************************************************/ | ||
361 | /* Reserved [31:27] */ | ||
362 | #define FLD_DIF_BPF_COEFF_10 0x07ff0000 | ||
363 | /* Reserved [15:11] */ | ||
364 | #define FLD_DIF_BPF_COEFF_11 0x000007ff | ||
365 | |||
366 | /*****************************************************************************/ | ||
367 | #define DIF_BPF_COEFF1213 (DIRECT_IF_REVB_BASE + 0x00000060) | ||
368 | /*****************************************************************************/ | ||
369 | /* Reserved [31:27] */ | ||
370 | #define FLD_DIF_BPF_COEFF_12 0x07ff0000 | ||
371 | /* Reserved [15:12] */ | ||
372 | #define FLD_DIF_BPF_COEFF_13 0x00000fff | ||
373 | |||
374 | /*****************************************************************************/ | ||
375 | #define DIF_BPF_COEFF1415 (DIRECT_IF_REVB_BASE + 0x00000064) | ||
376 | /*****************************************************************************/ | ||
377 | /* Reserved [31:28] */ | ||
378 | #define FLD_DIF_BPF_COEFF_14 0x0fff0000 | ||
379 | /* Reserved [15:12] */ | ||
380 | #define FLD_DIF_BPF_COEFF_15 0x00000fff | ||
381 | |||
382 | /*****************************************************************************/ | ||
383 | #define DIF_BPF_COEFF1617 (DIRECT_IF_REVB_BASE + 0x00000068) | ||
384 | /*****************************************************************************/ | ||
385 | /* Reserved [31:29] */ | ||
386 | #define FLD_DIF_BPF_COEFF_16 0x1fff0000 | ||
387 | /* Reserved [15:13] */ | ||
388 | #define FLD_DIF_BPF_COEFF_17 0x00001fff | ||
389 | |||
390 | /*****************************************************************************/ | ||
391 | #define DIF_BPF_COEFF1819 (DIRECT_IF_REVB_BASE + 0x0000006c) | ||
392 | /*****************************************************************************/ | ||
393 | /* Reserved [31:29] */ | ||
394 | #define FLD_DIF_BPF_COEFF_18 0x1fff0000 | ||
395 | /* Reserved [15:13] */ | ||
396 | #define FLD_DIF_BPF_COEFF_19 0x00001fff | ||
397 | |||
398 | /*****************************************************************************/ | ||
399 | #define DIF_BPF_COEFF2021 (DIRECT_IF_REVB_BASE + 0x00000070) | ||
400 | /*****************************************************************************/ | ||
401 | /* Reserved [31:29] */ | ||
402 | #define FLD_DIF_BPF_COEFF_20 0x1fff0000 | ||
403 | /* Reserved [15:14] */ | ||
404 | #define FLD_DIF_BPF_COEFF_21 0x00003fff | ||
405 | |||
406 | /*****************************************************************************/ | ||
407 | #define DIF_BPF_COEFF2223 (DIRECT_IF_REVB_BASE + 0x00000074) | ||
408 | /*****************************************************************************/ | ||
409 | /* Reserved [31:30] */ | ||
410 | #define FLD_DIF_BPF_COEFF_22 0x3fff0000 | ||
411 | /* Reserved [15:14] */ | ||
412 | #define FLD_DIF_BPF_COEFF_23 0x00003fff | ||
413 | |||
414 | /*****************************************************************************/ | ||
415 | #define DIF_BPF_COEFF2425 (DIRECT_IF_REVB_BASE + 0x00000078) | ||
416 | /*****************************************************************************/ | ||
417 | /* Reserved [31:30] */ | ||
418 | #define FLD_DIF_BPF_COEFF_24 0x3fff0000 | ||
419 | /* Reserved [15:14] */ | ||
420 | #define FLD_DIF_BPF_COEFF_25 0x00003fff | ||
421 | |||
422 | /*****************************************************************************/ | ||
423 | #define DIF_BPF_COEFF2627 (DIRECT_IF_REVB_BASE + 0x0000007c) | ||
424 | /*****************************************************************************/ | ||
425 | /* Reserved [31:30] */ | ||
426 | #define FLD_DIF_BPF_COEFF_26 0x3fff0000 | ||
427 | /* Reserved [15:14] */ | ||
428 | #define FLD_DIF_BPF_COEFF_27 0x00003fff | ||
429 | |||
430 | /*****************************************************************************/ | ||
431 | #define DIF_BPF_COEFF2829 (DIRECT_IF_REVB_BASE + 0x00000080) | ||
432 | /*****************************************************************************/ | ||
433 | /* Reserved [31:30] */ | ||
434 | #define FLD_DIF_BPF_COEFF_28 0x3fff0000 | ||
435 | /* Reserved [15:14] */ | ||
436 | #define FLD_DIF_BPF_COEFF_29 0x00003fff | ||
437 | |||
438 | /*****************************************************************************/ | ||
439 | #define DIF_BPF_COEFF3031 (DIRECT_IF_REVB_BASE + 0x00000084) | ||
440 | /*****************************************************************************/ | ||
441 | /* Reserved [31:30] */ | ||
442 | #define FLD_DIF_BPF_COEFF_30 0x3fff0000 | ||
443 | /* Reserved [15:14] */ | ||
444 | #define FLD_DIF_BPF_COEFF_31 0x00003fff | ||
445 | |||
446 | /*****************************************************************************/ | ||
447 | #define DIF_BPF_COEFF3233 (DIRECT_IF_REVB_BASE + 0x00000088) | ||
448 | /*****************************************************************************/ | ||
449 | /* Reserved [31:30] */ | ||
450 | #define FLD_DIF_BPF_COEFF_32 0x3fff0000 | ||
451 | /* Reserved [15:14] */ | ||
452 | #define FLD_DIF_BPF_COEFF_33 0x00003fff | ||
453 | |||
454 | /*****************************************************************************/ | ||
455 | #define DIF_BPF_COEFF3435 (DIRECT_IF_REVB_BASE + 0x0000008c) | ||
456 | /*****************************************************************************/ | ||
457 | /* Reserved [31:30] */ | ||
458 | #define FLD_DIF_BPF_COEFF_34 0x3fff0000 | ||
459 | /* Reserved [15:14] */ | ||
460 | #define FLD_DIF_BPF_COEFF_35 0x00003fff | ||
461 | |||
462 | /*****************************************************************************/ | ||
463 | #define DIF_BPF_COEFF36 (DIRECT_IF_REVB_BASE + 0x00000090) | ||
464 | /*****************************************************************************/ | ||
465 | /* Reserved [31:30] */ | ||
466 | #define FLD_DIF_BPF_COEFF_36 0x3fff0000 | ||
467 | /* Reserved [15:0] */ | ||
468 | |||
469 | /*****************************************************************************/ | ||
470 | #define DIF_RPT_VARIANCE (DIRECT_IF_REVB_BASE + 0x00000094) | ||
471 | /*****************************************************************************/ | ||
472 | /* Reserved [31:20] */ | ||
473 | #define FLD_DIF_RPT_VARIANCE 0x000fffff | ||
474 | |||
475 | /*****************************************************************************/ | ||
476 | #define DIF_SOFT_RST_CTRL_REVB (DIRECT_IF_REVB_BASE + 0x00000098) | ||
477 | /*****************************************************************************/ | ||
478 | /* Reserved [31:8] */ | ||
479 | #define FLD_DIF_DIF_SOFT_RST 0x00000080 | ||
480 | #define FLD_DIF_DIF_REG_RST_MSK 0x00000040 | ||
481 | #define FLD_DIF_AGC_RST_MSK 0x00000020 | ||
482 | #define FLD_DIF_CMP_RST_MSK 0x00000010 | ||
483 | #define FLD_DIF_AVS_RST_MSK 0x00000008 | ||
484 | #define FLD_DIF_NYQ_RST_MSK 0x00000004 | ||
485 | #define FLD_DIF_DIF_SRC_RST_MSK 0x00000002 | ||
486 | #define FLD_DIF_PLL_RST_MSK 0x00000001 | ||
487 | |||
488 | /*****************************************************************************/ | ||
489 | #define DIF_PLL_FREQ_ERR (DIRECT_IF_REVB_BASE + 0x0000009c) | ||
490 | /*****************************************************************************/ | ||
491 | /* Reserved [31:25] */ | ||
492 | #define FLD_DIF_CTL_IP 0x01ffffff | ||
493 | |||
494 | #endif | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-core.c b/drivers/media/video/cx231xx/cx231xx-core.c new file mode 100644 index 000000000000..0d333e679f70 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-core.c | |||
@@ -0,0 +1,1200 @@ | |||
1 | /* | ||
2 | cx231xx-core.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/list.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/usb.h> | ||
27 | #include <linux/vmalloc.h> | ||
28 | #include <media/v4l2-common.h> | ||
29 | |||
30 | #include "cx231xx.h" | ||
31 | #include "cx231xx-reg.h" | ||
32 | |||
33 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ | ||
34 | |||
35 | static unsigned int core_debug; | ||
36 | module_param(core_debug, int, 0644); | ||
37 | MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); | ||
38 | |||
39 | #define cx231xx_coredbg(fmt, arg...) do {\ | ||
40 | if (core_debug) \ | ||
41 | printk(KERN_INFO "%s %s :"fmt, \ | ||
42 | dev->name, __func__ , ##arg); } while (0) | ||
43 | |||
44 | static unsigned int reg_debug; | ||
45 | module_param(reg_debug, int, 0644); | ||
46 | MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]"); | ||
47 | |||
48 | #define cx231xx_regdbg(fmt, arg...) do {\ | ||
49 | if (reg_debug) \ | ||
50 | printk(KERN_INFO "%s %s :"fmt, \ | ||
51 | dev->name, __func__ , ##arg); } while (0) | ||
52 | |||
53 | static int alt = CX231XX_PINOUT; | ||
54 | module_param(alt, int, 0644); | ||
55 | MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); | ||
56 | |||
57 | #define cx231xx_isocdbg(fmt, arg...) do {\ | ||
58 | if (core_debug) \ | ||
59 | printk(KERN_INFO "%s %s :"fmt, \ | ||
60 | dev->name, __func__ , ##arg); } while (0) | ||
61 | |||
62 | /***************************************************************** | ||
63 | * Device control list functions * | ||
64 | ******************************************************************/ | ||
65 | |||
66 | static LIST_HEAD(cx231xx_devlist); | ||
67 | static DEFINE_MUTEX(cx231xx_devlist_mutex); | ||
68 | |||
69 | struct cx231xx *cx231xx_get_device(int minor, | ||
70 | enum v4l2_buf_type *fh_type, int *has_radio) | ||
71 | { | ||
72 | struct cx231xx *h, *dev = NULL; | ||
73 | |||
74 | *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
75 | *has_radio = 0; | ||
76 | |||
77 | mutex_lock(&cx231xx_devlist_mutex); | ||
78 | list_for_each_entry(h, &cx231xx_devlist, devlist) { | ||
79 | if (h->vdev->minor == minor) | ||
80 | dev = h; | ||
81 | if (h->vbi_dev->minor == minor) { | ||
82 | dev = h; | ||
83 | *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
84 | } | ||
85 | if (h->radio_dev && h->radio_dev->minor == minor) { | ||
86 | dev = h; | ||
87 | *has_radio = 1; | ||
88 | } | ||
89 | } | ||
90 | mutex_unlock(&cx231xx_devlist_mutex); | ||
91 | |||
92 | return dev; | ||
93 | } | ||
94 | |||
95 | /* | ||
96 | * cx231xx_realease_resources() | ||
97 | * unregisters the v4l2,i2c and usb devices | ||
98 | * called when the device gets disconected or at module unload | ||
99 | */ | ||
100 | void cx231xx_remove_from_devlist(struct cx231xx *dev) | ||
101 | { | ||
102 | mutex_lock(&cx231xx_devlist_mutex); | ||
103 | list_del(&dev->devlist); | ||
104 | mutex_unlock(&cx231xx_devlist_mutex); | ||
105 | }; | ||
106 | |||
107 | void cx231xx_add_into_devlist(struct cx231xx *dev) | ||
108 | { | ||
109 | mutex_lock(&cx231xx_devlist_mutex); | ||
110 | list_add_tail(&dev->devlist, &cx231xx_devlist); | ||
111 | mutex_unlock(&cx231xx_devlist_mutex); | ||
112 | }; | ||
113 | |||
114 | static LIST_HEAD(cx231xx_extension_devlist); | ||
115 | static DEFINE_MUTEX(cx231xx_extension_devlist_lock); | ||
116 | |||
117 | int cx231xx_register_extension(struct cx231xx_ops *ops) | ||
118 | { | ||
119 | struct cx231xx *dev = NULL; | ||
120 | |||
121 | mutex_lock(&cx231xx_devlist_mutex); | ||
122 | mutex_lock(&cx231xx_extension_devlist_lock); | ||
123 | list_add_tail(&ops->next, &cx231xx_extension_devlist); | ||
124 | list_for_each_entry(dev, &cx231xx_devlist, devlist) { | ||
125 | if (dev) | ||
126 | ops->init(dev); | ||
127 | } | ||
128 | printk(KERN_INFO DRIVER_NAME ": %s initialized\n", ops->name); | ||
129 | mutex_unlock(&cx231xx_extension_devlist_lock); | ||
130 | mutex_unlock(&cx231xx_devlist_mutex); | ||
131 | return 0; | ||
132 | } | ||
133 | EXPORT_SYMBOL(cx231xx_register_extension); | ||
134 | |||
135 | void cx231xx_unregister_extension(struct cx231xx_ops *ops) | ||
136 | { | ||
137 | struct cx231xx *dev = NULL; | ||
138 | |||
139 | mutex_lock(&cx231xx_devlist_mutex); | ||
140 | list_for_each_entry(dev, &cx231xx_devlist, devlist) { | ||
141 | if (dev) | ||
142 | ops->fini(dev); | ||
143 | } | ||
144 | |||
145 | mutex_lock(&cx231xx_extension_devlist_lock); | ||
146 | printk(KERN_INFO DRIVER_NAME ": %s removed\n", ops->name); | ||
147 | list_del(&ops->next); | ||
148 | mutex_unlock(&cx231xx_extension_devlist_lock); | ||
149 | mutex_unlock(&cx231xx_devlist_mutex); | ||
150 | } | ||
151 | EXPORT_SYMBOL(cx231xx_unregister_extension); | ||
152 | |||
153 | void cx231xx_init_extension(struct cx231xx *dev) | ||
154 | { | ||
155 | struct cx231xx_ops *ops = NULL; | ||
156 | |||
157 | mutex_lock(&cx231xx_extension_devlist_lock); | ||
158 | if (!list_empty(&cx231xx_extension_devlist)) { | ||
159 | list_for_each_entry(ops, &cx231xx_extension_devlist, next) { | ||
160 | if (ops->init) | ||
161 | ops->init(dev); | ||
162 | } | ||
163 | } | ||
164 | mutex_unlock(&cx231xx_extension_devlist_lock); | ||
165 | } | ||
166 | |||
167 | void cx231xx_close_extension(struct cx231xx *dev) | ||
168 | { | ||
169 | struct cx231xx_ops *ops = NULL; | ||
170 | |||
171 | mutex_lock(&cx231xx_extension_devlist_lock); | ||
172 | if (!list_empty(&cx231xx_extension_devlist)) { | ||
173 | list_for_each_entry(ops, &cx231xx_extension_devlist, next) { | ||
174 | if (ops->fini) | ||
175 | ops->fini(dev); | ||
176 | } | ||
177 | } | ||
178 | mutex_unlock(&cx231xx_extension_devlist_lock); | ||
179 | } | ||
180 | |||
181 | /**************************************************************** | ||
182 | * U S B related functions * | ||
183 | *****************************************************************/ | ||
184 | int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, | ||
185 | struct cx231xx_i2c_xfer_data *req_data) | ||
186 | { | ||
187 | int status = 0; | ||
188 | struct cx231xx *dev = i2c_bus->dev; | ||
189 | struct VENDOR_REQUEST_IN ven_req; | ||
190 | |||
191 | u8 saddr_len = 0; | ||
192 | u8 _i2c_period = 0; | ||
193 | u8 _i2c_nostop = 0; | ||
194 | u8 _i2c_reserve = 0; | ||
195 | |||
196 | /* Get the I2C period, nostop and reserve parameters */ | ||
197 | _i2c_period = i2c_bus->i2c_period; | ||
198 | _i2c_nostop = i2c_bus->i2c_nostop; | ||
199 | _i2c_reserve = i2c_bus->i2c_reserve; | ||
200 | |||
201 | saddr_len = req_data->saddr_len; | ||
202 | |||
203 | /* Set wValue */ | ||
204 | if (saddr_len == 1) /* need check saddr_len == 0 */ | ||
205 | ven_req.wValue = | ||
206 | req_data-> | ||
207 | dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | | ||
208 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; | ||
209 | else | ||
210 | ven_req.wValue = | ||
211 | req_data-> | ||
212 | dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | | ||
213 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; | ||
214 | |||
215 | /* set channel number */ | ||
216 | if (req_data->direction & I2C_M_RD) { | ||
217 | /* channel number, for read,spec required channel_num +4 */ | ||
218 | ven_req.bRequest = i2c_bus->nr + 4; | ||
219 | } else | ||
220 | ven_req.bRequest = i2c_bus->nr; /* channel number, */ | ||
221 | |||
222 | /* set index value */ | ||
223 | switch (saddr_len) { | ||
224 | case 0: | ||
225 | ven_req.wIndex = 0; /* need check */ | ||
226 | break; | ||
227 | case 1: | ||
228 | ven_req.wIndex = (req_data->saddr_dat & 0xff); | ||
229 | break; | ||
230 | case 2: | ||
231 | ven_req.wIndex = req_data->saddr_dat; | ||
232 | break; | ||
233 | } | ||
234 | |||
235 | /* set wLength value */ | ||
236 | ven_req.wLength = req_data->buf_size; | ||
237 | |||
238 | /* set bData value */ | ||
239 | ven_req.bData = 0; | ||
240 | |||
241 | /* set the direction */ | ||
242 | if (req_data->direction) { | ||
243 | ven_req.direction = USB_DIR_IN; | ||
244 | memset(req_data->p_buffer, 0x00, ven_req.wLength); | ||
245 | } else | ||
246 | ven_req.direction = USB_DIR_OUT; | ||
247 | |||
248 | /* set the buffer for read / write */ | ||
249 | ven_req.pBuff = req_data->p_buffer; | ||
250 | |||
251 | |||
252 | /* call common vendor command request */ | ||
253 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | ||
254 | if (status < 0) { | ||
255 | cx231xx_info | ||
256 | ("UsbInterface::sendCommand, failed with status -%d\n", | ||
257 | status); | ||
258 | } | ||
259 | |||
260 | return status; | ||
261 | } | ||
262 | EXPORT_SYMBOL_GPL(cx231xx_send_usb_command); | ||
263 | |||
264 | /* | ||
265 | * cx231xx_read_ctrl_reg() | ||
266 | * reads data from the usb device specifying bRequest and wValue | ||
267 | */ | ||
268 | int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
269 | char *buf, int len) | ||
270 | { | ||
271 | u8 val = 0; | ||
272 | int ret; | ||
273 | int pipe = usb_rcvctrlpipe(dev->udev, 0); | ||
274 | |||
275 | if (dev->state & DEV_DISCONNECTED) | ||
276 | return -ENODEV; | ||
277 | |||
278 | if (len > URB_MAX_CTRL_SIZE) | ||
279 | return -EINVAL; | ||
280 | |||
281 | switch (len) { | ||
282 | case 1: | ||
283 | val = ENABLE_ONE_BYTE; | ||
284 | break; | ||
285 | case 2: | ||
286 | val = ENABLE_TWE_BYTE; | ||
287 | break; | ||
288 | case 3: | ||
289 | val = ENABLE_THREE_BYTE; | ||
290 | break; | ||
291 | case 4: | ||
292 | val = ENABLE_FOUR_BYTE; | ||
293 | break; | ||
294 | default: | ||
295 | val = 0xFF; /* invalid option */ | ||
296 | } | ||
297 | |||
298 | if (val == 0xFF) | ||
299 | return -EINVAL; | ||
300 | |||
301 | if (reg_debug) { | ||
302 | cx231xx_isocdbg("(pipe 0x%08x): " | ||
303 | "IN: %02x %02x %02x %02x %02x %02x %02x %02x ", | ||
304 | pipe, | ||
305 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
306 | req, 0, val, | ||
307 | reg & 0xff, reg >> 8, len & 0xff, len >> 8); | ||
308 | } | ||
309 | |||
310 | mutex_lock(&dev->ctrl_urb_lock); | ||
311 | ret = usb_control_msg(dev->udev, pipe, req, | ||
312 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
313 | val, reg, dev->urb_buf, len, HZ); | ||
314 | if (ret < 0) { | ||
315 | cx231xx_isocdbg(" failed!\n"); | ||
316 | /* mutex_unlock(&dev->ctrl_urb_lock); */ | ||
317 | return ret; | ||
318 | } | ||
319 | |||
320 | if (len) | ||
321 | memcpy(buf, dev->urb_buf, len); | ||
322 | |||
323 | mutex_unlock(&dev->ctrl_urb_lock); | ||
324 | |||
325 | if (reg_debug) { | ||
326 | int byte; | ||
327 | |||
328 | cx231xx_isocdbg("<<<"); | ||
329 | for (byte = 0; byte < len; byte++) | ||
330 | cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]); | ||
331 | cx231xx_isocdbg("\n"); | ||
332 | } | ||
333 | |||
334 | return ret; | ||
335 | } | ||
336 | |||
337 | int cx231xx_send_vendor_cmd(struct cx231xx *dev, | ||
338 | struct VENDOR_REQUEST_IN *ven_req) | ||
339 | { | ||
340 | int ret; | ||
341 | int pipe = 0; | ||
342 | |||
343 | if (dev->state & DEV_DISCONNECTED) | ||
344 | return -ENODEV; | ||
345 | |||
346 | if ((ven_req->wLength > URB_MAX_CTRL_SIZE)) | ||
347 | return -EINVAL; | ||
348 | |||
349 | if (ven_req->direction) | ||
350 | pipe = usb_rcvctrlpipe(dev->udev, 0); | ||
351 | else | ||
352 | pipe = usb_sndctrlpipe(dev->udev, 0); | ||
353 | |||
354 | if (reg_debug) { | ||
355 | int byte; | ||
356 | |||
357 | cx231xx_isocdbg("(pipe 0x%08x): " | ||
358 | "OUT: %02x %02x %02x %04x %04x %04x >>>", | ||
359 | pipe, | ||
360 | ven_req-> | ||
361 | direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
362 | ven_req->bRequest, 0, ven_req->wValue, | ||
363 | ven_req->wIndex, ven_req->wLength); | ||
364 | |||
365 | for (byte = 0; byte < ven_req->wLength; byte++) | ||
366 | cx231xx_isocdbg(" %02x", | ||
367 | (unsigned char)ven_req->pBuff[byte]); | ||
368 | cx231xx_isocdbg("\n"); | ||
369 | } | ||
370 | |||
371 | mutex_lock(&dev->ctrl_urb_lock); | ||
372 | ret = usb_control_msg(dev->udev, pipe, ven_req->bRequest, | ||
373 | ven_req-> | ||
374 | direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
375 | ven_req->wValue, ven_req->wIndex, ven_req->pBuff, | ||
376 | ven_req->wLength, HZ); | ||
377 | mutex_unlock(&dev->ctrl_urb_lock); | ||
378 | |||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | /* | ||
383 | * cx231xx_write_ctrl_reg() | ||
384 | * sends data to the usb device, specifying bRequest | ||
385 | */ | ||
386 | int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, | ||
387 | int len) | ||
388 | { | ||
389 | u8 val = 0; | ||
390 | int ret; | ||
391 | int pipe = usb_sndctrlpipe(dev->udev, 0); | ||
392 | |||
393 | if (dev->state & DEV_DISCONNECTED) | ||
394 | return -ENODEV; | ||
395 | |||
396 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) | ||
397 | return -EINVAL; | ||
398 | |||
399 | switch (len) { | ||
400 | case 1: | ||
401 | val = ENABLE_ONE_BYTE; | ||
402 | break; | ||
403 | case 2: | ||
404 | val = ENABLE_TWE_BYTE; | ||
405 | break; | ||
406 | case 3: | ||
407 | val = ENABLE_THREE_BYTE; | ||
408 | break; | ||
409 | case 4: | ||
410 | val = ENABLE_FOUR_BYTE; | ||
411 | break; | ||
412 | default: | ||
413 | val = 0xFF; /* invalid option */ | ||
414 | } | ||
415 | |||
416 | if (val == 0xFF) | ||
417 | return -EINVAL; | ||
418 | |||
419 | if (reg_debug) { | ||
420 | int byte; | ||
421 | |||
422 | cx231xx_isocdbg("(pipe 0x%08x): " | ||
423 | "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>", | ||
424 | pipe, | ||
425 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
426 | req, 0, val, reg & 0xff, | ||
427 | reg >> 8, len & 0xff, len >> 8); | ||
428 | |||
429 | for (byte = 0; byte < len; byte++) | ||
430 | cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]); | ||
431 | cx231xx_isocdbg("\n"); | ||
432 | } | ||
433 | |||
434 | mutex_lock(&dev->ctrl_urb_lock); | ||
435 | memcpy(dev->urb_buf, buf, len); | ||
436 | ret = usb_control_msg(dev->udev, pipe, req, | ||
437 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
438 | val, reg, dev->urb_buf, len, HZ); | ||
439 | mutex_unlock(&dev->ctrl_urb_lock); | ||
440 | |||
441 | return ret; | ||
442 | } | ||
443 | |||
444 | /**************************************************************** | ||
445 | * USB Alternate Setting functions * | ||
446 | *****************************************************************/ | ||
447 | |||
448 | int cx231xx_set_video_alternate(struct cx231xx *dev) | ||
449 | { | ||
450 | int errCode, prev_alt = dev->video_mode.alt; | ||
451 | unsigned int min_pkt_size = dev->width * 2 + 4; | ||
452 | u32 usb_interface_index = 0; | ||
453 | |||
454 | /* When image size is bigger than a certain value, | ||
455 | the frame size should be increased, otherwise, only | ||
456 | green screen will be received. | ||
457 | */ | ||
458 | if (dev->width * 2 * dev->height > 720 * 240 * 2) | ||
459 | min_pkt_size *= 2; | ||
460 | |||
461 | if (dev->width > 360) { | ||
462 | /* resolutions: 720,704,640 */ | ||
463 | dev->video_mode.alt = 3; | ||
464 | } else if (dev->width > 180) { | ||
465 | /* resolutions: 360,352,320,240 */ | ||
466 | dev->video_mode.alt = 2; | ||
467 | } else if (dev->width > 0) { | ||
468 | /* resolutions: 180,176,160,128,88 */ | ||
469 | dev->video_mode.alt = 1; | ||
470 | } else { | ||
471 | /* Change to alt0 BULK to release USB bandwidth */ | ||
472 | dev->video_mode.alt = 0; | ||
473 | } | ||
474 | |||
475 | /* Get the correct video interface Index */ | ||
476 | usb_interface_index = | ||
477 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
478 | video_index + 1; | ||
479 | |||
480 | if (dev->video_mode.alt != prev_alt) { | ||
481 | cx231xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | ||
482 | min_pkt_size, dev->video_mode.alt); | ||
483 | dev->video_mode.max_pkt_size = | ||
484 | dev->video_mode.alt_max_pkt_size[dev->video_mode.alt]; | ||
485 | cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", | ||
486 | dev->video_mode.alt, | ||
487 | dev->video_mode.max_pkt_size); | ||
488 | cx231xx_info | ||
489 | (" setting alt %d with wMaxPktSize=%u , Interface = %d\n", | ||
490 | dev->video_mode.alt, dev->video_mode.max_pkt_size, | ||
491 | usb_interface_index); | ||
492 | errCode = | ||
493 | usb_set_interface(dev->udev, usb_interface_index, | ||
494 | dev->video_mode.alt); | ||
495 | if (errCode < 0) { | ||
496 | cx231xx_errdev | ||
497 | ("cannot change alt number to %d (error=%i)\n", | ||
498 | dev->video_mode.alt, errCode); | ||
499 | return errCode; | ||
500 | } | ||
501 | } | ||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) | ||
506 | { | ||
507 | int status = 0; | ||
508 | u32 usb_interface_index = 0; | ||
509 | u32 max_pkt_size = 0; | ||
510 | |||
511 | switch (index) { | ||
512 | case INDEX_TS1: | ||
513 | usb_interface_index = | ||
514 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
515 | ts1_index + 1; | ||
516 | dev->video_mode.alt = alt; | ||
517 | if (dev->ts1_mode.alt_max_pkt_size != NULL) | ||
518 | max_pkt_size = dev->ts1_mode.max_pkt_size = | ||
519 | dev->ts1_mode.alt_max_pkt_size[dev->ts1_mode.alt]; | ||
520 | break; | ||
521 | case INDEX_TS2: | ||
522 | usb_interface_index = | ||
523 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
524 | ts2_index + 1; | ||
525 | break; | ||
526 | case INDEX_AUDIO: | ||
527 | usb_interface_index = | ||
528 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
529 | audio_index + 1; | ||
530 | dev->adev.alt = alt; | ||
531 | if (dev->adev.alt_max_pkt_size != NULL) | ||
532 | max_pkt_size = dev->adev.max_pkt_size = | ||
533 | dev->adev.alt_max_pkt_size[dev->adev.alt]; | ||
534 | break; | ||
535 | case INDEX_VIDEO: | ||
536 | usb_interface_index = | ||
537 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
538 | video_index + 1; | ||
539 | dev->video_mode.alt = alt; | ||
540 | if (dev->video_mode.alt_max_pkt_size != NULL) | ||
541 | max_pkt_size = dev->video_mode.max_pkt_size = | ||
542 | dev->video_mode.alt_max_pkt_size[dev->video_mode. | ||
543 | alt]; | ||
544 | break; | ||
545 | case INDEX_VANC: | ||
546 | usb_interface_index = | ||
547 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
548 | vanc_index + 1; | ||
549 | dev->vbi_mode.alt = alt; | ||
550 | if (dev->vbi_mode.alt_max_pkt_size != NULL) | ||
551 | max_pkt_size = dev->vbi_mode.max_pkt_size = | ||
552 | dev->vbi_mode.alt_max_pkt_size[dev->vbi_mode.alt]; | ||
553 | break; | ||
554 | case INDEX_HANC: | ||
555 | usb_interface_index = | ||
556 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
557 | hanc_index + 1; | ||
558 | dev->sliced_cc_mode.alt = alt; | ||
559 | if (dev->sliced_cc_mode.alt_max_pkt_size != NULL) | ||
560 | max_pkt_size = dev->sliced_cc_mode.max_pkt_size = | ||
561 | dev->sliced_cc_mode.alt_max_pkt_size[dev-> | ||
562 | sliced_cc_mode. | ||
563 | alt]; | ||
564 | break; | ||
565 | default: | ||
566 | break; | ||
567 | } | ||
568 | |||
569 | if (alt > 0 && max_pkt_size == 0) { | ||
570 | cx231xx_errdev | ||
571 | ("can't change interface %d alt no. to %d: Max. Pkt size = 0\n", | ||
572 | usb_interface_index, alt); | ||
573 | return -1; | ||
574 | } | ||
575 | |||
576 | cx231xx_info | ||
577 | (" setting alternate %d with wMaxPacketSize=%u , Interface = %d\n", | ||
578 | alt, max_pkt_size, usb_interface_index); | ||
579 | |||
580 | if (usb_interface_index > 0) { | ||
581 | status = usb_set_interface(dev->udev, usb_interface_index, alt); | ||
582 | if (status < 0) { | ||
583 | cx231xx_errdev | ||
584 | ("can't change interface %d alt no. to %d (err=%i)\n", | ||
585 | usb_interface_index, alt, status); | ||
586 | return status; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | return status; | ||
591 | } | ||
592 | EXPORT_SYMBOL_GPL(cx231xx_set_alt_setting); | ||
593 | |||
594 | int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio) | ||
595 | { | ||
596 | int rc = 0; | ||
597 | |||
598 | if (!gpio) | ||
599 | return rc; | ||
600 | |||
601 | /* Send GPIO reset sequences specified at board entry */ | ||
602 | while (gpio->sleep >= 0) { | ||
603 | rc = cx231xx_set_gpio_value(dev, gpio->bit, gpio->val); | ||
604 | if (rc < 0) | ||
605 | return rc; | ||
606 | |||
607 | if (gpio->sleep > 0) | ||
608 | msleep(gpio->sleep); | ||
609 | |||
610 | gpio++; | ||
611 | } | ||
612 | return rc; | ||
613 | } | ||
614 | |||
615 | int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) | ||
616 | { | ||
617 | if (dev->mode == set_mode) | ||
618 | return 0; | ||
619 | |||
620 | if (set_mode == CX231XX_SUSPEND) { | ||
621 | /* Set the chip in power saving mode */ | ||
622 | dev->mode = set_mode; | ||
623 | } | ||
624 | |||
625 | /* Resource is locked */ | ||
626 | if (dev->mode != CX231XX_SUSPEND) | ||
627 | return -EINVAL; | ||
628 | |||
629 | dev->mode = set_mode; | ||
630 | |||
631 | if (dev->mode == CX231XX_DIGITAL_MODE) | ||
632 | ;/* Set Digital power mode */ | ||
633 | else | ||
634 | ;/* Set Analog Power mode */ | ||
635 | |||
636 | return 0; | ||
637 | } | ||
638 | EXPORT_SYMBOL_GPL(cx231xx_set_mode); | ||
639 | |||
640 | /***************************************************************** | ||
641 | * URB Streaming functions * | ||
642 | ******************************************************************/ | ||
643 | |||
644 | /* | ||
645 | * IRQ callback, called by URB callback | ||
646 | */ | ||
647 | static void cx231xx_irq_callback(struct urb *urb) | ||
648 | { | ||
649 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
650 | struct cx231xx_video_mode *vmode = | ||
651 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
652 | struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); | ||
653 | int rc, i; | ||
654 | |||
655 | switch (urb->status) { | ||
656 | case 0: /* success */ | ||
657 | case -ETIMEDOUT: /* NAK */ | ||
658 | break; | ||
659 | case -ECONNRESET: /* kill */ | ||
660 | case -ENOENT: | ||
661 | case -ESHUTDOWN: | ||
662 | return; | ||
663 | default: /* error */ | ||
664 | cx231xx_isocdbg("urb completition error %d.\n", urb->status); | ||
665 | break; | ||
666 | } | ||
667 | |||
668 | /* Copy data from URB */ | ||
669 | spin_lock(&dev->video_mode.slock); | ||
670 | rc = dev->video_mode.isoc_ctl.isoc_copy(dev, urb); | ||
671 | spin_unlock(&dev->video_mode.slock); | ||
672 | |||
673 | /* Reset urb buffers */ | ||
674 | for (i = 0; i < urb->number_of_packets; i++) { | ||
675 | urb->iso_frame_desc[i].status = 0; | ||
676 | urb->iso_frame_desc[i].actual_length = 0; | ||
677 | } | ||
678 | urb->status = 0; | ||
679 | |||
680 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | ||
681 | if (urb->status) { | ||
682 | cx231xx_isocdbg("urb resubmit failed (error=%i)\n", | ||
683 | urb->status); | ||
684 | } | ||
685 | } | ||
686 | |||
687 | /* | ||
688 | * Stop and Deallocate URBs | ||
689 | */ | ||
690 | void cx231xx_uninit_isoc(struct cx231xx *dev) | ||
691 | { | ||
692 | struct urb *urb; | ||
693 | int i; | ||
694 | |||
695 | cx231xx_isocdbg("cx231xx: called cx231xx_uninit_isoc\n"); | ||
696 | |||
697 | dev->video_mode.isoc_ctl.nfields = -1; | ||
698 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
699 | urb = dev->video_mode.isoc_ctl.urb[i]; | ||
700 | if (urb) { | ||
701 | if (!irqs_disabled()) | ||
702 | usb_kill_urb(urb); | ||
703 | else | ||
704 | usb_unlink_urb(urb); | ||
705 | |||
706 | if (dev->video_mode.isoc_ctl.transfer_buffer[i]) { | ||
707 | usb_buffer_free(dev->udev, | ||
708 | urb->transfer_buffer_length, | ||
709 | dev->video_mode.isoc_ctl. | ||
710 | transfer_buffer[i], | ||
711 | urb->transfer_dma); | ||
712 | } | ||
713 | usb_free_urb(urb); | ||
714 | dev->video_mode.isoc_ctl.urb[i] = NULL; | ||
715 | } | ||
716 | dev->video_mode.isoc_ctl.transfer_buffer[i] = NULL; | ||
717 | } | ||
718 | |||
719 | kfree(dev->video_mode.isoc_ctl.urb); | ||
720 | kfree(dev->video_mode.isoc_ctl.transfer_buffer); | ||
721 | |||
722 | dev->video_mode.isoc_ctl.urb = NULL; | ||
723 | dev->video_mode.isoc_ctl.transfer_buffer = NULL; | ||
724 | dev->video_mode.isoc_ctl.num_bufs = 0; | ||
725 | |||
726 | cx231xx_capture_start(dev, 0, Raw_Video); | ||
727 | } | ||
728 | EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); | ||
729 | |||
730 | /* | ||
731 | * Allocate URBs and start IRQ | ||
732 | */ | ||
733 | int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | ||
734 | int num_bufs, int max_pkt_size, | ||
735 | int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) | ||
736 | { | ||
737 | struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; | ||
738 | int i; | ||
739 | int sb_size, pipe; | ||
740 | struct urb *urb; | ||
741 | int j, k; | ||
742 | int rc; | ||
743 | |||
744 | cx231xx_isocdbg("cx231xx: called cx231xx_prepare_isoc\n"); | ||
745 | |||
746 | dev->video_input = dev->video_input > 2 ? 2 : dev->video_input; | ||
747 | |||
748 | cx231xx_info("Setting Video mux to %d\n", dev->video_input); | ||
749 | video_mux(dev, dev->video_input); | ||
750 | |||
751 | /* De-allocates all pending stuff */ | ||
752 | cx231xx_uninit_isoc(dev); | ||
753 | |||
754 | dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; | ||
755 | dev->video_mode.isoc_ctl.num_bufs = num_bufs; | ||
756 | dma_q->pos = 0; | ||
757 | dma_q->is_partial_line = 0; | ||
758 | dma_q->last_sav = 0; | ||
759 | dma_q->current_field = -1; | ||
760 | dma_q->field1_done = 0; | ||
761 | dma_q->lines_per_field = dev->height / 2; | ||
762 | dma_q->bytes_left_in_line = dev->width << 1; | ||
763 | dma_q->lines_completed = 0; | ||
764 | for (i = 0; i < 8; i++) | ||
765 | dma_q->partial_buf[i] = 0; | ||
766 | |||
767 | dev->video_mode.isoc_ctl.urb = | ||
768 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
769 | if (!dev->video_mode.isoc_ctl.urb) { | ||
770 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | ||
771 | return -ENOMEM; | ||
772 | } | ||
773 | |||
774 | dev->video_mode.isoc_ctl.transfer_buffer = | ||
775 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
776 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { | ||
777 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
778 | kfree(dev->video_mode.isoc_ctl.urb); | ||
779 | return -ENOMEM; | ||
780 | } | ||
781 | |||
782 | dev->video_mode.isoc_ctl.max_pkt_size = max_pkt_size; | ||
783 | dev->video_mode.isoc_ctl.buf = NULL; | ||
784 | |||
785 | sb_size = max_packets * dev->video_mode.isoc_ctl.max_pkt_size; | ||
786 | |||
787 | /* allocate urbs and transfer buffers */ | ||
788 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
789 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); | ||
790 | if (!urb) { | ||
791 | cx231xx_err("cannot alloc isoc_ctl.urb %i\n", i); | ||
792 | cx231xx_uninit_isoc(dev); | ||
793 | return -ENOMEM; | ||
794 | } | ||
795 | dev->video_mode.isoc_ctl.urb[i] = urb; | ||
796 | |||
797 | dev->video_mode.isoc_ctl.transfer_buffer[i] = | ||
798 | usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL, | ||
799 | &urb->transfer_dma); | ||
800 | if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { | ||
801 | cx231xx_err("unable to allocate %i bytes for transfer" | ||
802 | " buffer %i%s\n", | ||
803 | sb_size, i, | ||
804 | in_interrupt() ? " while in int" : ""); | ||
805 | cx231xx_uninit_isoc(dev); | ||
806 | return -ENOMEM; | ||
807 | } | ||
808 | memset(dev->video_mode.isoc_ctl.transfer_buffer[i], 0, sb_size); | ||
809 | |||
810 | pipe = | ||
811 | usb_rcvisocpipe(dev->udev, dev->video_mode.end_point_addr); | ||
812 | |||
813 | usb_fill_int_urb(urb, dev->udev, pipe, | ||
814 | dev->video_mode.isoc_ctl.transfer_buffer[i], | ||
815 | sb_size, cx231xx_irq_callback, dma_q, 1); | ||
816 | |||
817 | urb->number_of_packets = max_packets; | ||
818 | urb->transfer_flags = URB_ISO_ASAP; | ||
819 | |||
820 | k = 0; | ||
821 | for (j = 0; j < max_packets; j++) { | ||
822 | urb->iso_frame_desc[j].offset = k; | ||
823 | urb->iso_frame_desc[j].length = | ||
824 | dev->video_mode.isoc_ctl.max_pkt_size; | ||
825 | k += dev->video_mode.isoc_ctl.max_pkt_size; | ||
826 | } | ||
827 | } | ||
828 | |||
829 | init_waitqueue_head(&dma_q->wq); | ||
830 | |||
831 | /* submit urbs and enables IRQ */ | ||
832 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
833 | rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], | ||
834 | GFP_ATOMIC); | ||
835 | if (rc) { | ||
836 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | ||
837 | rc); | ||
838 | cx231xx_uninit_isoc(dev); | ||
839 | return rc; | ||
840 | } | ||
841 | } | ||
842 | |||
843 | cx231xx_capture_start(dev, 1, Raw_Video); | ||
844 | |||
845 | return 0; | ||
846 | } | ||
847 | EXPORT_SYMBOL_GPL(cx231xx_init_isoc); | ||
848 | |||
849 | /***************************************************************** | ||
850 | * Device Init/UnInit functions * | ||
851 | ******************************************************************/ | ||
852 | int cx231xx_dev_init(struct cx231xx *dev) | ||
853 | { | ||
854 | int errCode = 0; | ||
855 | |||
856 | /* Initialize I2C bus */ | ||
857 | |||
858 | /* External Master 1 Bus */ | ||
859 | dev->i2c_bus[0].nr = 0; | ||
860 | dev->i2c_bus[0].dev = dev; | ||
861 | dev->i2c_bus[0].i2c_period = I2C_SPEED_1M; /* 1MHz */ | ||
862 | dev->i2c_bus[0].i2c_nostop = 0; | ||
863 | dev->i2c_bus[0].i2c_reserve = 0; | ||
864 | |||
865 | /* External Master 2 Bus */ | ||
866 | dev->i2c_bus[1].nr = 1; | ||
867 | dev->i2c_bus[1].dev = dev; | ||
868 | dev->i2c_bus[1].i2c_period = I2C_SPEED_1M; /* 1MHz */ | ||
869 | dev->i2c_bus[1].i2c_nostop = 0; | ||
870 | dev->i2c_bus[1].i2c_reserve = 0; | ||
871 | |||
872 | /* Internal Master 3 Bus */ | ||
873 | dev->i2c_bus[2].nr = 2; | ||
874 | dev->i2c_bus[2].dev = dev; | ||
875 | dev->i2c_bus[2].i2c_period = I2C_SPEED_400K; /* 400kHz */ | ||
876 | dev->i2c_bus[2].i2c_nostop = 0; | ||
877 | dev->i2c_bus[2].i2c_reserve = 0; | ||
878 | |||
879 | /* register I2C buses */ | ||
880 | cx231xx_i2c_register(&dev->i2c_bus[0]); | ||
881 | cx231xx_i2c_register(&dev->i2c_bus[1]); | ||
882 | cx231xx_i2c_register(&dev->i2c_bus[2]); | ||
883 | |||
884 | /* init hardware */ | ||
885 | /* Note : with out calling set power mode function, | ||
886 | afe can not be set up correctly */ | ||
887 | errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); | ||
888 | if (errCode < 0) { | ||
889 | cx231xx_errdev | ||
890 | ("%s: Failed to set Power - errCode [%d]!\n", | ||
891 | __func__, errCode); | ||
892 | return errCode; | ||
893 | } | ||
894 | |||
895 | /* initialize Colibri block */ | ||
896 | errCode = cx231xx_afe_init_super_block(dev, 0x23c); | ||
897 | if (errCode < 0) { | ||
898 | cx231xx_errdev | ||
899 | ("%s: cx231xx_afe init super block - errCode [%d]!\n", | ||
900 | __func__, errCode); | ||
901 | return errCode; | ||
902 | } | ||
903 | errCode = cx231xx_afe_init_channels(dev); | ||
904 | if (errCode < 0) { | ||
905 | cx231xx_errdev | ||
906 | ("%s: cx231xx_afe init channels - errCode [%d]!\n", | ||
907 | __func__, errCode); | ||
908 | return errCode; | ||
909 | } | ||
910 | |||
911 | /* Set DIF in By pass mode */ | ||
912 | errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
913 | if (errCode < 0) { | ||
914 | cx231xx_errdev | ||
915 | ("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", | ||
916 | __func__, errCode); | ||
917 | return errCode; | ||
918 | } | ||
919 | |||
920 | /* I2S block related functions */ | ||
921 | errCode = cx231xx_i2s_blk_initialize(dev); | ||
922 | if (errCode < 0) { | ||
923 | cx231xx_errdev | ||
924 | ("%s: cx231xx_i2s block initialize - errCode [%d]!\n", | ||
925 | __func__, errCode); | ||
926 | return errCode; | ||
927 | } | ||
928 | |||
929 | /* init control pins */ | ||
930 | errCode = cx231xx_init_ctrl_pin_status(dev); | ||
931 | if (errCode < 0) { | ||
932 | cx231xx_errdev("%s: cx231xx_init ctrl pins - errCode [%d]!\n", | ||
933 | __func__, errCode); | ||
934 | return errCode; | ||
935 | } | ||
936 | |||
937 | /* set AGC mode to Analog */ | ||
938 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); | ||
939 | if (errCode < 0) { | ||
940 | cx231xx_errdev | ||
941 | ("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", | ||
942 | __func__, errCode); | ||
943 | return errCode; | ||
944 | } | ||
945 | |||
946 | /* set all alternate settings to zero initially */ | ||
947 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); | ||
948 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
949 | cx231xx_set_alt_setting(dev, INDEX_HANC, 0); | ||
950 | if (dev->board.has_dvb) | ||
951 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | ||
952 | |||
953 | /* set the I2C master port to 3 on channel 1 */ | ||
954 | errCode = cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
955 | |||
956 | return errCode; | ||
957 | } | ||
958 | EXPORT_SYMBOL_GPL(cx231xx_dev_init); | ||
959 | |||
960 | void cx231xx_dev_uninit(struct cx231xx *dev) | ||
961 | { | ||
962 | /* Un Initialize I2C bus */ | ||
963 | cx231xx_i2c_unregister(&dev->i2c_bus[2]); | ||
964 | cx231xx_i2c_unregister(&dev->i2c_bus[1]); | ||
965 | cx231xx_i2c_unregister(&dev->i2c_bus[0]); | ||
966 | } | ||
967 | EXPORT_SYMBOL_GPL(cx231xx_dev_uninit); | ||
968 | |||
969 | /***************************************************************** | ||
970 | * G P I O related functions * | ||
971 | ******************************************************************/ | ||
972 | int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val, | ||
973 | u8 len, u8 request, u8 direction) | ||
974 | { | ||
975 | int status = 0; | ||
976 | struct VENDOR_REQUEST_IN ven_req; | ||
977 | |||
978 | /* Set wValue */ | ||
979 | ven_req.wValue = (u16) (gpio_bit >> 16 & 0xffff); | ||
980 | |||
981 | /* set request */ | ||
982 | if (!request) { | ||
983 | if (direction) | ||
984 | ven_req.bRequest = VRT_GET_GPIO; /* 0x8 gpio */ | ||
985 | else | ||
986 | ven_req.bRequest = VRT_SET_GPIO; /* 0x9 gpio */ | ||
987 | } else { | ||
988 | if (direction) | ||
989 | ven_req.bRequest = VRT_GET_GPIE; /* 0xa gpie */ | ||
990 | else | ||
991 | ven_req.bRequest = VRT_SET_GPIE; /* 0xb gpie */ | ||
992 | } | ||
993 | |||
994 | /* set index value */ | ||
995 | ven_req.wIndex = (u16) (gpio_bit & 0xffff); | ||
996 | |||
997 | /* set wLength value */ | ||
998 | ven_req.wLength = len; | ||
999 | |||
1000 | /* set bData value */ | ||
1001 | ven_req.bData = 0; | ||
1002 | |||
1003 | /* set the buffer for read / write */ | ||
1004 | ven_req.pBuff = gpio_val; | ||
1005 | |||
1006 | /* set the direction */ | ||
1007 | if (direction) { | ||
1008 | ven_req.direction = USB_DIR_IN; | ||
1009 | memset(ven_req.pBuff, 0x00, ven_req.wLength); | ||
1010 | } else | ||
1011 | ven_req.direction = USB_DIR_OUT; | ||
1012 | |||
1013 | |||
1014 | /* call common vendor command request */ | ||
1015 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | ||
1016 | if (status < 0) { | ||
1017 | cx231xx_info | ||
1018 | ("UsbInterface::sendCommand, failed with status -%d\n", | ||
1019 | status); | ||
1020 | } | ||
1021 | |||
1022 | return status; | ||
1023 | } | ||
1024 | EXPORT_SYMBOL_GPL(cx231xx_send_gpio_cmd); | ||
1025 | |||
1026 | /***************************************************************** | ||
1027 | * C O N T R O L - Register R E A D / W R I T E functions * | ||
1028 | *****************************************************************/ | ||
1029 | int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode) | ||
1030 | { | ||
1031 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
1032 | u32 tmp = 0; | ||
1033 | int status = 0; | ||
1034 | |||
1035 | status = | ||
1036 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, address, value, 4); | ||
1037 | if (status < 0) | ||
1038 | return status; | ||
1039 | |||
1040 | tmp = *((u32 *) value); | ||
1041 | tmp |= mode; | ||
1042 | |||
1043 | value[0] = (u8) tmp; | ||
1044 | value[1] = (u8) (tmp >> 8); | ||
1045 | value[2] = (u8) (tmp >> 16); | ||
1046 | value[3] = (u8) (tmp >> 24); | ||
1047 | |||
1048 | status = | ||
1049 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, address, value, 4); | ||
1050 | |||
1051 | return status; | ||
1052 | } | ||
1053 | |||
1054 | /***************************************************************** | ||
1055 | * I 2 C Internal C O N T R O L functions * | ||
1056 | *****************************************************************/ | ||
1057 | int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1058 | u8 saddr_len, u32 *data, u8 data_len) | ||
1059 | { | ||
1060 | int status = 0; | ||
1061 | struct cx231xx_i2c_xfer_data req_data; | ||
1062 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1063 | |||
1064 | if (saddr_len == 0) | ||
1065 | saddr = 0; | ||
1066 | else if (saddr_len == 0) | ||
1067 | saddr &= 0xff; | ||
1068 | |||
1069 | /* prepare xfer_data struct */ | ||
1070 | req_data.dev_addr = dev_addr >> 1; | ||
1071 | req_data.direction = I2C_M_RD; | ||
1072 | req_data.saddr_len = saddr_len; | ||
1073 | req_data.saddr_dat = saddr; | ||
1074 | req_data.buf_size = data_len; | ||
1075 | req_data.p_buffer = (u8 *) value; | ||
1076 | |||
1077 | /* usb send command */ | ||
1078 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); | ||
1079 | |||
1080 | if (status >= 0) { | ||
1081 | /* Copy the data read back to main buffer */ | ||
1082 | if (data_len == 1) | ||
1083 | *data = value[0]; | ||
1084 | else | ||
1085 | *data = | ||
1086 | value[0] | value[1] << 8 | value[2] << 16 | value[3] | ||
1087 | << 24; | ||
1088 | } | ||
1089 | |||
1090 | return status; | ||
1091 | } | ||
1092 | |||
1093 | int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1094 | u8 saddr_len, u32 data, u8 data_len) | ||
1095 | { | ||
1096 | int status = 0; | ||
1097 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1098 | struct cx231xx_i2c_xfer_data req_data; | ||
1099 | |||
1100 | value[0] = (u8) data; | ||
1101 | value[1] = (u8) (data >> 8); | ||
1102 | value[2] = (u8) (data >> 16); | ||
1103 | value[3] = (u8) (data >> 24); | ||
1104 | |||
1105 | if (saddr_len == 0) | ||
1106 | saddr = 0; | ||
1107 | else if (saddr_len == 0) | ||
1108 | saddr &= 0xff; | ||
1109 | |||
1110 | /* prepare xfer_data struct */ | ||
1111 | req_data.dev_addr = dev_addr >> 1; | ||
1112 | req_data.direction = 0; | ||
1113 | req_data.saddr_len = saddr_len; | ||
1114 | req_data.saddr_dat = saddr; | ||
1115 | req_data.buf_size = data_len; | ||
1116 | req_data.p_buffer = value; | ||
1117 | |||
1118 | /* usb send command */ | ||
1119 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); | ||
1120 | |||
1121 | return status; | ||
1122 | } | ||
1123 | |||
1124 | int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, | ||
1125 | u16 register_address, u8 bit_start, u8 bit_end, | ||
1126 | u32 value) | ||
1127 | { | ||
1128 | int status = 0; | ||
1129 | u32 tmp; | ||
1130 | u32 mask = 0; | ||
1131 | int i; | ||
1132 | |||
1133 | if (bit_start > (size - 1) || bit_end > (size - 1)) | ||
1134 | return -1; | ||
1135 | |||
1136 | if (size == 8) { | ||
1137 | status = | ||
1138 | cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, | ||
1139 | &tmp, 1); | ||
1140 | } else { | ||
1141 | status = | ||
1142 | cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, | ||
1143 | &tmp, 4); | ||
1144 | } | ||
1145 | |||
1146 | if (status < 0) | ||
1147 | return status; | ||
1148 | |||
1149 | mask = 1 << bit_end; | ||
1150 | for (i = bit_end; i > bit_start && i > 0; i--) | ||
1151 | mask = mask + (1 << (i - 1)); | ||
1152 | |||
1153 | value <<= bit_start; | ||
1154 | |||
1155 | if (size == 8) { | ||
1156 | tmp &= ~mask; | ||
1157 | tmp |= value; | ||
1158 | tmp &= 0xff; | ||
1159 | status = | ||
1160 | cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, | ||
1161 | tmp, 1); | ||
1162 | } else { | ||
1163 | tmp &= ~mask; | ||
1164 | tmp |= value; | ||
1165 | status = | ||
1166 | cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, | ||
1167 | tmp, 4); | ||
1168 | } | ||
1169 | |||
1170 | return status; | ||
1171 | } | ||
1172 | |||
1173 | int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, | ||
1174 | u16 saddr, u32 mask, u32 value) | ||
1175 | { | ||
1176 | u32 temp; | ||
1177 | int status = 0; | ||
1178 | |||
1179 | status = cx231xx_read_i2c_data(dev, dev_addr, saddr, 2, &temp, 4); | ||
1180 | |||
1181 | if (status < 0) | ||
1182 | return status; | ||
1183 | |||
1184 | temp &= ~mask; | ||
1185 | temp |= value; | ||
1186 | |||
1187 | status = cx231xx_write_i2c_data(dev, dev_addr, saddr, 2, temp, 4); | ||
1188 | |||
1189 | return status; | ||
1190 | } | ||
1191 | |||
1192 | u32 cx231xx_set_field(u32 field_mask, u32 data) | ||
1193 | { | ||
1194 | u32 temp; | ||
1195 | |||
1196 | for (temp = field_mask; (temp & 1) == 0; temp >>= 1) | ||
1197 | data <<= 1; | ||
1198 | |||
1199 | return data; | ||
1200 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c new file mode 100644 index 000000000000..c5082a4e8ced --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-dvb.c | |||
@@ -0,0 +1,559 @@ | |||
1 | /* | ||
2 | DVB device driver for cx231xx | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/usb.h> | ||
24 | |||
25 | #include "cx231xx.h" | ||
26 | #include <media/v4l2-common.h> | ||
27 | #include <media/videobuf-vmalloc.h> | ||
28 | |||
29 | #include "xc5000.h" | ||
30 | #include "dvb_dummy_fe.h" | ||
31 | |||
32 | MODULE_DESCRIPTION("driver for cx231xx based DVB cards"); | ||
33 | MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); | ||
34 | MODULE_LICENSE("GPL"); | ||
35 | |||
36 | static unsigned int debug; | ||
37 | module_param(debug, int, 0644); | ||
38 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
39 | |||
40 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
41 | |||
42 | #define dprintk(level, fmt, arg...) do { \ | ||
43 | if (debug >= level) \ | ||
44 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | ||
45 | } while (0) | ||
46 | |||
47 | #define CX231XX_DVB_NUM_BUFS 5 | ||
48 | #define CX231XX_DVB_MAX_PACKETSIZE 564 | ||
49 | #define CX231XX_DVB_MAX_PACKETS 64 | ||
50 | |||
51 | struct cx231xx_dvb { | ||
52 | struct dvb_frontend *frontend; | ||
53 | |||
54 | /* feed count management */ | ||
55 | struct mutex lock; | ||
56 | int nfeeds; | ||
57 | |||
58 | /* general boilerplate stuff */ | ||
59 | struct dvb_adapter adapter; | ||
60 | struct dvb_demux demux; | ||
61 | struct dmxdev dmxdev; | ||
62 | struct dmx_frontend fe_hw; | ||
63 | struct dmx_frontend fe_mem; | ||
64 | struct dvb_net net; | ||
65 | }; | ||
66 | |||
67 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
68 | { | ||
69 | char *errmsg = "Unknown"; | ||
70 | |||
71 | switch (status) { | ||
72 | case -ENOENT: | ||
73 | errmsg = "unlinked synchronuously"; | ||
74 | break; | ||
75 | case -ECONNRESET: | ||
76 | errmsg = "unlinked asynchronuously"; | ||
77 | break; | ||
78 | case -ENOSR: | ||
79 | errmsg = "Buffer error (overrun)"; | ||
80 | break; | ||
81 | case -EPIPE: | ||
82 | errmsg = "Stalled (device not responding)"; | ||
83 | break; | ||
84 | case -EOVERFLOW: | ||
85 | errmsg = "Babble (bad cable?)"; | ||
86 | break; | ||
87 | case -EPROTO: | ||
88 | errmsg = "Bit-stuff error (bad cable?)"; | ||
89 | break; | ||
90 | case -EILSEQ: | ||
91 | errmsg = "CRC/Timeout (could be anything)"; | ||
92 | break; | ||
93 | case -ETIME: | ||
94 | errmsg = "Device does not respond"; | ||
95 | break; | ||
96 | } | ||
97 | if (packet < 0) { | ||
98 | dprintk(1, "URB status %d [%s].\n", status, errmsg); | ||
99 | } else { | ||
100 | dprintk(1, "URB packet %d, status %d [%s].\n", | ||
101 | packet, status, errmsg); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | static inline int dvb_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
106 | { | ||
107 | int i; | ||
108 | |||
109 | if (!dev) | ||
110 | return 0; | ||
111 | |||
112 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
113 | return 0; | ||
114 | |||
115 | if (urb->status < 0) { | ||
116 | print_err_status(dev, -1, urb->status); | ||
117 | if (urb->status == -ENOENT) | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | for (i = 0; i < urb->number_of_packets; i++) { | ||
122 | int status = urb->iso_frame_desc[i].status; | ||
123 | |||
124 | if (status < 0) { | ||
125 | print_err_status(dev, i, status); | ||
126 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
127 | continue; | ||
128 | } | ||
129 | |||
130 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + | ||
131 | urb->iso_frame_desc[i].offset, | ||
132 | urb->iso_frame_desc[i].actual_length); | ||
133 | } | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static int start_streaming(struct cx231xx_dvb *dvb) | ||
139 | { | ||
140 | int rc; | ||
141 | struct cx231xx *dev = dvb->adapter.priv; | ||
142 | |||
143 | usb_set_interface(dev->udev, 0, 1); | ||
144 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
145 | if (rc < 0) | ||
146 | return rc; | ||
147 | |||
148 | return cx231xx_init_isoc(dev, CX231XX_DVB_MAX_PACKETS, | ||
149 | CX231XX_DVB_NUM_BUFS, | ||
150 | CX231XX_DVB_MAX_PACKETSIZE, dvb_isoc_copy); | ||
151 | } | ||
152 | |||
153 | static int stop_streaming(struct cx231xx_dvb *dvb) | ||
154 | { | ||
155 | struct cx231xx *dev = dvb->adapter.priv; | ||
156 | |||
157 | cx231xx_uninit_isoc(dev); | ||
158 | |||
159 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static int start_feed(struct dvb_demux_feed *feed) | ||
165 | { | ||
166 | struct dvb_demux *demux = feed->demux; | ||
167 | struct cx231xx_dvb *dvb = demux->priv; | ||
168 | int rc, ret; | ||
169 | |||
170 | if (!demux->dmx.frontend) | ||
171 | return -EINVAL; | ||
172 | |||
173 | mutex_lock(&dvb->lock); | ||
174 | dvb->nfeeds++; | ||
175 | rc = dvb->nfeeds; | ||
176 | |||
177 | if (dvb->nfeeds == 1) { | ||
178 | ret = start_streaming(dvb); | ||
179 | if (ret < 0) | ||
180 | rc = ret; | ||
181 | } | ||
182 | |||
183 | mutex_unlock(&dvb->lock); | ||
184 | return rc; | ||
185 | } | ||
186 | |||
187 | static int stop_feed(struct dvb_demux_feed *feed) | ||
188 | { | ||
189 | struct dvb_demux *demux = feed->demux; | ||
190 | struct cx231xx_dvb *dvb = demux->priv; | ||
191 | int err = 0; | ||
192 | |||
193 | mutex_lock(&dvb->lock); | ||
194 | dvb->nfeeds--; | ||
195 | |||
196 | if (0 == dvb->nfeeds) | ||
197 | err = stop_streaming(dvb); | ||
198 | |||
199 | mutex_unlock(&dvb->lock); | ||
200 | return err; | ||
201 | } | ||
202 | |||
203 | /* ------------------------------------------------------------------ */ | ||
204 | static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | ||
205 | { | ||
206 | struct cx231xx *dev = fe->dvb->priv; | ||
207 | |||
208 | if (acquire) | ||
209 | return cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
210 | else | ||
211 | return cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
212 | } | ||
213 | |||
214 | /* ------------------------------------------------------------------ */ | ||
215 | |||
216 | static struct xc5000_config cnxt_rde250_tunerconfig = { | ||
217 | .i2c_address = 0x61, | ||
218 | .if_khz = 5380, | ||
219 | }; | ||
220 | |||
221 | /* ------------------------------------------------------------------ */ | ||
222 | #if 0 | ||
223 | static int attach_xc5000(u8 addr, struct cx231xx *dev) | ||
224 | { | ||
225 | |||
226 | struct dvb_frontend *fe; | ||
227 | struct xc5000_config cfg; | ||
228 | |||
229 | memset(&cfg, 0, sizeof(cfg)); | ||
230 | cfg.i2c_adap = &dev->i2c_bus[1].i2c_adap; | ||
231 | cfg.i2c_addr = addr; | ||
232 | |||
233 | if (!dev->dvb->frontend) { | ||
234 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
235 | "Can't attach xc5000\n", dev->name); | ||
236 | return -EINVAL; | ||
237 | } | ||
238 | |||
239 | fe = dvb_attach(xc5000_attach, dev->dvb->frontend, &cfg); | ||
240 | if (!fe) { | ||
241 | printk(KERN_ERR "%s/2: xc5000 attach failed\n", dev->name); | ||
242 | dvb_frontend_detach(dev->dvb->frontend); | ||
243 | dev->dvb->frontend = NULL; | ||
244 | return -EINVAL; | ||
245 | } | ||
246 | |||
247 | printk(KERN_INFO "%s/2: xc5000 attached\n", dev->name); | ||
248 | |||
249 | return 0; | ||
250 | } | ||
251 | #endif | ||
252 | |||
253 | int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq) | ||
254 | { | ||
255 | int status = 0; | ||
256 | |||
257 | if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) { | ||
258 | |||
259 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
260 | |||
261 | if (dops->set_analog_params != NULL) { | ||
262 | struct analog_parameters params; | ||
263 | |||
264 | params.frequency = freq; | ||
265 | params.std = dev->norm; | ||
266 | params.mode = 0; /* 0- Air; 1 - cable */ | ||
267 | /*params.audmode = ; */ | ||
268 | |||
269 | /* Set the analog parameters to set the frequency */ | ||
270 | cx231xx_info("Setting Frequency for XC5000\n"); | ||
271 | dops->set_analog_params(dev->dvb->frontend, ¶ms); | ||
272 | } | ||
273 | |||
274 | } | ||
275 | |||
276 | return status; | ||
277 | } | ||
278 | |||
279 | int cx231xx_reset_analog_tuner(struct cx231xx *dev) | ||
280 | { | ||
281 | int status = 0; | ||
282 | |||
283 | if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) { | ||
284 | |||
285 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
286 | |||
287 | if (dops->init != NULL && !dev->xc_fw_load_done) { | ||
288 | |||
289 | cx231xx_info("Reloading firmware for XC5000\n"); | ||
290 | status = dops->init(dev->dvb->frontend); | ||
291 | if (status == 0) { | ||
292 | dev->xc_fw_load_done = 1; | ||
293 | cx231xx_info | ||
294 | ("XC5000 firmware download completed\n"); | ||
295 | } else { | ||
296 | dev->xc_fw_load_done = 0; | ||
297 | cx231xx_info | ||
298 | ("XC5000 firmware download failed !!!\n"); | ||
299 | } | ||
300 | } | ||
301 | |||
302 | } | ||
303 | |||
304 | return status; | ||
305 | } | ||
306 | |||
307 | /* ------------------------------------------------------------------ */ | ||
308 | |||
309 | static int register_dvb(struct cx231xx_dvb *dvb, | ||
310 | struct module *module, | ||
311 | struct cx231xx *dev, struct device *device) | ||
312 | { | ||
313 | int result; | ||
314 | |||
315 | mutex_init(&dvb->lock); | ||
316 | |||
317 | /* register adapter */ | ||
318 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, | ||
319 | adapter_nr); | ||
320 | if (result < 0) { | ||
321 | printk(KERN_WARNING | ||
322 | "%s: dvb_register_adapter failed (errno = %d)\n", | ||
323 | dev->name, result); | ||
324 | goto fail_adapter; | ||
325 | } | ||
326 | |||
327 | /* Ensure all frontends negotiate bus access */ | ||
328 | dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl; | ||
329 | |||
330 | dvb->adapter.priv = dev; | ||
331 | |||
332 | /* register frontend */ | ||
333 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | ||
334 | if (result < 0) { | ||
335 | printk(KERN_WARNING | ||
336 | "%s: dvb_register_frontend failed (errno = %d)\n", | ||
337 | dev->name, result); | ||
338 | goto fail_frontend; | ||
339 | } | ||
340 | |||
341 | /* register demux stuff */ | ||
342 | dvb->demux.dmx.capabilities = | ||
343 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | | ||
344 | DMX_MEMORY_BASED_FILTERING; | ||
345 | dvb->demux.priv = dvb; | ||
346 | dvb->demux.filternum = 256; | ||
347 | dvb->demux.feednum = 256; | ||
348 | dvb->demux.start_feed = start_feed; | ||
349 | dvb->demux.stop_feed = stop_feed; | ||
350 | |||
351 | result = dvb_dmx_init(&dvb->demux); | ||
352 | if (result < 0) { | ||
353 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", | ||
354 | dev->name, result); | ||
355 | goto fail_dmx; | ||
356 | } | ||
357 | |||
358 | dvb->dmxdev.filternum = 256; | ||
359 | dvb->dmxdev.demux = &dvb->demux.dmx; | ||
360 | dvb->dmxdev.capabilities = 0; | ||
361 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | ||
362 | if (result < 0) { | ||
363 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | ||
364 | dev->name, result); | ||
365 | goto fail_dmxdev; | ||
366 | } | ||
367 | |||
368 | dvb->fe_hw.source = DMX_FRONTEND_0; | ||
369 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
370 | if (result < 0) { | ||
371 | printk(KERN_WARNING | ||
372 | "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", | ||
373 | dev->name, result); | ||
374 | goto fail_fe_hw; | ||
375 | } | ||
376 | |||
377 | dvb->fe_mem.source = DMX_MEMORY_FE; | ||
378 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
379 | if (result < 0) { | ||
380 | printk(KERN_WARNING | ||
381 | "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", | ||
382 | dev->name, result); | ||
383 | goto fail_fe_mem; | ||
384 | } | ||
385 | |||
386 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
387 | if (result < 0) { | ||
388 | printk(KERN_WARNING | ||
389 | "%s: connect_frontend failed (errno = %d)\n", dev->name, | ||
390 | result); | ||
391 | goto fail_fe_conn; | ||
392 | } | ||
393 | |||
394 | /* register network adapter */ | ||
395 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | ||
396 | return 0; | ||
397 | |||
398 | fail_fe_conn: | ||
399 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
400 | fail_fe_mem: | ||
401 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
402 | fail_fe_hw: | ||
403 | dvb_dmxdev_release(&dvb->dmxdev); | ||
404 | fail_dmxdev: | ||
405 | dvb_dmx_release(&dvb->demux); | ||
406 | fail_dmx: | ||
407 | dvb_unregister_frontend(dvb->frontend); | ||
408 | fail_frontend: | ||
409 | dvb_frontend_detach(dvb->frontend); | ||
410 | dvb_unregister_adapter(&dvb->adapter); | ||
411 | fail_adapter: | ||
412 | return result; | ||
413 | } | ||
414 | |||
415 | static void unregister_dvb(struct cx231xx_dvb *dvb) | ||
416 | { | ||
417 | dvb_net_release(&dvb->net); | ||
418 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
419 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
420 | dvb_dmxdev_release(&dvb->dmxdev); | ||
421 | dvb_dmx_release(&dvb->demux); | ||
422 | dvb_unregister_frontend(dvb->frontend); | ||
423 | dvb_frontend_detach(dvb->frontend); | ||
424 | dvb_unregister_adapter(&dvb->adapter); | ||
425 | } | ||
426 | |||
427 | static int dvb_init(struct cx231xx *dev) | ||
428 | { | ||
429 | int result = 0; | ||
430 | struct cx231xx_dvb *dvb; | ||
431 | |||
432 | if (!dev->board.has_dvb) { | ||
433 | /* This device does not support the extension */ | ||
434 | return 0; | ||
435 | } | ||
436 | |||
437 | dvb = kzalloc(sizeof(struct cx231xx_dvb), GFP_KERNEL); | ||
438 | |||
439 | if (dvb == NULL) { | ||
440 | printk(KERN_INFO "cx231xx_dvb: memory allocation failed\n"); | ||
441 | return -ENOMEM; | ||
442 | } | ||
443 | dev->dvb = dvb; | ||
444 | dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; | ||
445 | dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; | ||
446 | |||
447 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
448 | /* init frontend */ | ||
449 | switch (dev->model) { | ||
450 | case CX231XX_BOARD_CNXT_RDE_250: | ||
451 | |||
452 | /* dev->dvb->frontend = dvb_attach(s5h1411_attach, | ||
453 | &dvico_s5h1411_config, | ||
454 | &dev->i2c_bus[1].i2c_adap); */ | ||
455 | dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); | ||
456 | |||
457 | if (dev->dvb->frontend == NULL) { | ||
458 | printk(DRIVER_NAME | ||
459 | ": Failed to attach dummy front end\n"); | ||
460 | result = -EINVAL; | ||
461 | goto out_free; | ||
462 | } | ||
463 | |||
464 | /* define general-purpose callback pointer */ | ||
465 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
466 | |||
467 | if (dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
468 | &dev->i2c_bus[1].i2c_adap, | ||
469 | &cnxt_rde250_tunerconfig) < 0) { | ||
470 | result = -EINVAL; | ||
471 | goto out_free; | ||
472 | } | ||
473 | |||
474 | break; | ||
475 | case CX231XX_BOARD_CNXT_RDU_250: | ||
476 | |||
477 | dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); | ||
478 | |||
479 | if (dev->dvb->frontend == NULL) { | ||
480 | printk(DRIVER_NAME | ||
481 | ": Failed to attach dummy front end\n"); | ||
482 | result = -EINVAL; | ||
483 | goto out_free; | ||
484 | } | ||
485 | |||
486 | /* define general-purpose callback pointer */ | ||
487 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
488 | |||
489 | if (dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
490 | &dev->i2c_bus[1].i2c_adap, | ||
491 | &cnxt_rde250_tunerconfig) < 0) { | ||
492 | result = -EINVAL; | ||
493 | goto out_free; | ||
494 | } | ||
495 | break; | ||
496 | |||
497 | default: | ||
498 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
499 | " isn't supported yet\n", dev->name); | ||
500 | break; | ||
501 | } | ||
502 | if (NULL == dvb->frontend) { | ||
503 | printk(KERN_ERR | ||
504 | "%s/2: frontend initialization failed\n", dev->name); | ||
505 | result = -EINVAL; | ||
506 | goto out_free; | ||
507 | } | ||
508 | |||
509 | /* register everything */ | ||
510 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); | ||
511 | |||
512 | if (result < 0) | ||
513 | goto out_free; | ||
514 | |||
515 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
516 | printk(KERN_INFO "Successfully loaded cx231xx-dvb\n"); | ||
517 | return 0; | ||
518 | |||
519 | out_free: | ||
520 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
521 | kfree(dvb); | ||
522 | dev->dvb = NULL; | ||
523 | return result; | ||
524 | } | ||
525 | |||
526 | static int dvb_fini(struct cx231xx *dev) | ||
527 | { | ||
528 | if (!dev->board.has_dvb) { | ||
529 | /* This device does not support the extension */ | ||
530 | return 0; | ||
531 | } | ||
532 | |||
533 | if (dev->dvb) { | ||
534 | unregister_dvb(dev->dvb); | ||
535 | dev->dvb = NULL; | ||
536 | } | ||
537 | |||
538 | return 0; | ||
539 | } | ||
540 | |||
541 | static struct cx231xx_ops dvb_ops = { | ||
542 | .id = CX231XX_DVB, | ||
543 | .name = "Cx231xx dvb Extension", | ||
544 | .init = dvb_init, | ||
545 | .fini = dvb_fini, | ||
546 | }; | ||
547 | |||
548 | static int __init cx231xx_dvb_register(void) | ||
549 | { | ||
550 | return cx231xx_register_extension(&dvb_ops); | ||
551 | } | ||
552 | |||
553 | static void __exit cx231xx_dvb_unregister(void) | ||
554 | { | ||
555 | cx231xx_unregister_extension(&dvb_ops); | ||
556 | } | ||
557 | |||
558 | module_init(cx231xx_dvb_register); | ||
559 | module_exit(cx231xx_dvb_unregister); | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c new file mode 100644 index 000000000000..b4a03d813e00 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-i2c.c | |||
@@ -0,0 +1,555 @@ | |||
1 | /* | ||
2 | cx231xx-i2c.c - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | Based on Cx23885 driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <media/v4l2-common.h> | ||
28 | #include <media/tuner.h> | ||
29 | |||
30 | #include "cx231xx.h" | ||
31 | |||
32 | /* ----------------------------------------------------------- */ | ||
33 | |||
34 | static unsigned int i2c_scan; | ||
35 | module_param(i2c_scan, int, 0444); | ||
36 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | ||
37 | |||
38 | static unsigned int i2c_debug; | ||
39 | module_param(i2c_debug, int, 0644); | ||
40 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | ||
41 | |||
42 | #define dprintk1(lvl, fmt, args...) \ | ||
43 | do { \ | ||
44 | if (i2c_debug >= lvl) { \ | ||
45 | printk(fmt, ##args); \ | ||
46 | } \ | ||
47 | } while (0) | ||
48 | |||
49 | #define dprintk2(lvl, fmt, args...) \ | ||
50 | do { \ | ||
51 | if (i2c_debug >= lvl) { \ | ||
52 | printk(KERN_DEBUG "%s at %s: " fmt, \ | ||
53 | dev->name, __func__ , ##args); \ | ||
54 | } \ | ||
55 | } while (0) | ||
56 | |||
57 | /* | ||
58 | * cx231xx_i2c_send_bytes() | ||
59 | */ | ||
60 | int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, | ||
61 | const struct i2c_msg *msg) | ||
62 | { | ||
63 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
64 | struct cx231xx *dev = bus->dev; | ||
65 | struct cx231xx_i2c_xfer_data req_data; | ||
66 | int status = 0; | ||
67 | u16 size = 0; | ||
68 | u8 loop = 0; | ||
69 | u8 saddr_len = 1; | ||
70 | u8 *buf_ptr = NULL; | ||
71 | u16 saddr = 0; | ||
72 | u8 need_gpio = 0; | ||
73 | |||
74 | if ((bus->nr == 1) && (msg->addr == 0x61) | ||
75 | && (dev->tuner_type == TUNER_XC5000)) { | ||
76 | |||
77 | size = msg->len; | ||
78 | |||
79 | if (size == 2) { /* register write sub addr */ | ||
80 | /* Just writing sub address will cause problem | ||
81 | * to XC5000. So ignore the request */ | ||
82 | return 0; | ||
83 | } else if (size == 4) { /* register write with sub addr */ | ||
84 | if (msg->len >= 2) | ||
85 | saddr = msg->buf[0] << 8 | msg->buf[1]; | ||
86 | else if (msg->len == 1) | ||
87 | saddr = msg->buf[0]; | ||
88 | |||
89 | switch (saddr) { | ||
90 | case 0x0000: /* start tuner calibration mode */ | ||
91 | need_gpio = 1; | ||
92 | /* FW Loading is done */ | ||
93 | dev->xc_fw_load_done = 1; | ||
94 | break; | ||
95 | case 0x000D: /* Set signal source */ | ||
96 | case 0x0001: /* Set TV standard - Video */ | ||
97 | case 0x0002: /* Set TV standard - Audio */ | ||
98 | case 0x0003: /* Set RF Frequency */ | ||
99 | need_gpio = 1; | ||
100 | break; | ||
101 | default: | ||
102 | if (dev->xc_fw_load_done) | ||
103 | need_gpio = 1; | ||
104 | break; | ||
105 | } | ||
106 | |||
107 | if (need_gpio) { | ||
108 | dprintk1(1, | ||
109 | "GPIO WRITE: addr 0x%x, len %d, saddr 0x%x\n", | ||
110 | msg->addr, msg->len, saddr); | ||
111 | |||
112 | return dev->cx231xx_gpio_i2c_write(dev, | ||
113 | msg->addr, | ||
114 | msg->buf, | ||
115 | msg->len); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* special case for Xc5000 tuner case */ | ||
120 | saddr_len = 1; | ||
121 | |||
122 | /* adjust the length to correct length */ | ||
123 | size -= saddr_len; | ||
124 | buf_ptr = (u8 *) (msg->buf + 1); | ||
125 | |||
126 | do { | ||
127 | /* prepare xfer_data struct */ | ||
128 | req_data.dev_addr = msg->addr; | ||
129 | req_data.direction = msg->flags; | ||
130 | req_data.saddr_len = saddr_len; | ||
131 | req_data.saddr_dat = msg->buf[0]; | ||
132 | req_data.buf_size = size > 16 ? 16 : size; | ||
133 | req_data.p_buffer = (u8 *) (buf_ptr + loop * 16); | ||
134 | |||
135 | bus->i2c_nostop = (size > 16) ? 1 : 0; | ||
136 | bus->i2c_reserve = (loop == 0) ? 0 : 1; | ||
137 | |||
138 | /* usb send command */ | ||
139 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
140 | loop++; | ||
141 | |||
142 | if (size >= 16) | ||
143 | size -= 16; | ||
144 | else | ||
145 | size = 0; | ||
146 | |||
147 | } while (size > 0); | ||
148 | |||
149 | bus->i2c_nostop = 0; | ||
150 | bus->i2c_reserve = 0; | ||
151 | |||
152 | } else { /* regular case */ | ||
153 | |||
154 | /* prepare xfer_data struct */ | ||
155 | req_data.dev_addr = msg->addr; | ||
156 | req_data.direction = msg->flags; | ||
157 | req_data.saddr_len = 0; | ||
158 | req_data.saddr_dat = 0; | ||
159 | req_data.buf_size = msg->len; | ||
160 | req_data.p_buffer = msg->buf; | ||
161 | |||
162 | /* usb send command */ | ||
163 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
164 | } | ||
165 | |||
166 | return status < 0 ? status : 0; | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | * cx231xx_i2c_recv_bytes() | ||
171 | * read a byte from the i2c device | ||
172 | */ | ||
173 | static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, | ||
174 | const struct i2c_msg *msg) | ||
175 | { | ||
176 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
177 | struct cx231xx *dev = bus->dev; | ||
178 | struct cx231xx_i2c_xfer_data req_data; | ||
179 | int status = 0; | ||
180 | u16 saddr = 0; | ||
181 | u8 need_gpio = 0; | ||
182 | |||
183 | if ((bus->nr == 1) && (msg->addr == 0x61) | ||
184 | && dev->tuner_type == TUNER_XC5000) { | ||
185 | |||
186 | if (msg->len == 2) | ||
187 | saddr = msg->buf[0] << 8 | msg->buf[1]; | ||
188 | else if (msg->len == 1) | ||
189 | saddr = msg->buf[0]; | ||
190 | |||
191 | if (dev->xc_fw_load_done) { | ||
192 | |||
193 | switch (saddr) { | ||
194 | case 0x0009: /* BUSY check */ | ||
195 | dprintk1(1, | ||
196 | "GPIO R E A D: Special case BUSY check \n"); | ||
197 | /*Try read BUSY register, just set it to zero*/ | ||
198 | msg->buf[0] = 0; | ||
199 | if (msg->len == 2) | ||
200 | msg->buf[1] = 0; | ||
201 | return 0; | ||
202 | case 0x0004: /* read Lock status */ | ||
203 | need_gpio = 1; | ||
204 | break; | ||
205 | |||
206 | } | ||
207 | |||
208 | if (need_gpio) { | ||
209 | /* this is a special case to handle Xceive tuner | ||
210 | clock stretch issue with gpio based I2C */ | ||
211 | |||
212 | dprintk1(1, | ||
213 | "GPIO R E A D: addr 0x%x, len %d, saddr 0x%x\n", | ||
214 | msg->addr, msg->len, | ||
215 | msg->buf[0] << 8 | msg->buf[1]); | ||
216 | |||
217 | status = | ||
218 | dev->cx231xx_gpio_i2c_write(dev, msg->addr, | ||
219 | msg->buf, | ||
220 | msg->len); | ||
221 | status = | ||
222 | dev->cx231xx_gpio_i2c_read(dev, msg->addr, | ||
223 | msg->buf, | ||
224 | msg->len); | ||
225 | return status; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | /* prepare xfer_data struct */ | ||
230 | req_data.dev_addr = msg->addr; | ||
231 | req_data.direction = msg->flags; | ||
232 | req_data.saddr_len = msg->len; | ||
233 | req_data.saddr_dat = msg->buf[0] << 8 | msg->buf[1]; | ||
234 | req_data.buf_size = msg->len; | ||
235 | req_data.p_buffer = msg->buf; | ||
236 | |||
237 | /* usb send command */ | ||
238 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
239 | |||
240 | } else { | ||
241 | |||
242 | /* prepare xfer_data struct */ | ||
243 | req_data.dev_addr = msg->addr; | ||
244 | req_data.direction = msg->flags; | ||
245 | req_data.saddr_len = 0; | ||
246 | req_data.saddr_dat = 0; | ||
247 | req_data.buf_size = msg->len; | ||
248 | req_data.p_buffer = msg->buf; | ||
249 | |||
250 | /* usb send command */ | ||
251 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
252 | } | ||
253 | |||
254 | return status < 0 ? status : 0; | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * cx231xx_i2c_recv_bytes_with_saddr() | ||
259 | * read a byte from the i2c device | ||
260 | */ | ||
261 | static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, | ||
262 | const struct i2c_msg *msg1, | ||
263 | const struct i2c_msg *msg2) | ||
264 | { | ||
265 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
266 | struct cx231xx *dev = bus->dev; | ||
267 | struct cx231xx_i2c_xfer_data req_data; | ||
268 | int status = 0; | ||
269 | u16 saddr = 0; | ||
270 | u8 need_gpio = 0; | ||
271 | |||
272 | if (msg1->len == 2) | ||
273 | saddr = msg1->buf[0] << 8 | msg1->buf[1]; | ||
274 | else if (msg1->len == 1) | ||
275 | saddr = msg1->buf[0]; | ||
276 | |||
277 | if ((bus->nr == 1) && (msg2->addr == 0x61) | ||
278 | && dev->tuner_type == TUNER_XC5000) { | ||
279 | |||
280 | if ((msg2->len < 16)) { | ||
281 | |||
282 | dprintk1(1, | ||
283 | "i2c_read: addr 0x%x, len %d, saddr 0x%x, len %d\n", | ||
284 | msg2->addr, msg2->len, saddr, msg1->len); | ||
285 | |||
286 | switch (saddr) { | ||
287 | case 0x0008: /* read FW load status */ | ||
288 | need_gpio = 1; | ||
289 | break; | ||
290 | case 0x0004: /* read Lock status */ | ||
291 | need_gpio = 1; | ||
292 | break; | ||
293 | } | ||
294 | |||
295 | if (need_gpio) { | ||
296 | status = | ||
297 | dev->cx231xx_gpio_i2c_write(dev, msg1->addr, | ||
298 | msg1->buf, | ||
299 | msg1->len); | ||
300 | status = | ||
301 | dev->cx231xx_gpio_i2c_read(dev, msg2->addr, | ||
302 | msg2->buf, | ||
303 | msg2->len); | ||
304 | return status; | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | |||
309 | /* prepare xfer_data struct */ | ||
310 | req_data.dev_addr = msg2->addr; | ||
311 | req_data.direction = msg2->flags; | ||
312 | req_data.saddr_len = msg1->len; | ||
313 | req_data.saddr_dat = saddr; | ||
314 | req_data.buf_size = msg2->len; | ||
315 | req_data.p_buffer = msg2->buf; | ||
316 | |||
317 | /* usb send command */ | ||
318 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
319 | |||
320 | return status < 0 ? status : 0; | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * cx231xx_i2c_check_for_device() | ||
325 | * check if there is a i2c_device at the supplied address | ||
326 | */ | ||
327 | static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, | ||
328 | const struct i2c_msg *msg) | ||
329 | { | ||
330 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
331 | struct cx231xx *dev = bus->dev; | ||
332 | struct cx231xx_i2c_xfer_data req_data; | ||
333 | int status = 0; | ||
334 | |||
335 | /* prepare xfer_data struct */ | ||
336 | req_data.dev_addr = msg->addr; | ||
337 | req_data.direction = msg->flags; | ||
338 | req_data.saddr_len = 0; | ||
339 | req_data.saddr_dat = 0; | ||
340 | req_data.buf_size = 0; | ||
341 | req_data.p_buffer = NULL; | ||
342 | |||
343 | /* usb send command */ | ||
344 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
345 | |||
346 | return status < 0 ? status : 0; | ||
347 | } | ||
348 | |||
349 | /* | ||
350 | * cx231xx_i2c_xfer() | ||
351 | * the main i2c transfer function | ||
352 | */ | ||
353 | static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap, | ||
354 | struct i2c_msg msgs[], int num) | ||
355 | { | ||
356 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
357 | struct cx231xx *dev = bus->dev; | ||
358 | int addr, rc, i, byte; | ||
359 | |||
360 | if (num <= 0) | ||
361 | return 0; | ||
362 | |||
363 | for (i = 0; i < num; i++) { | ||
364 | |||
365 | addr = msgs[i].addr >> 1; | ||
366 | |||
367 | dprintk2(2, "%s %s addr=%x len=%d:", | ||
368 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", | ||
369 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); | ||
370 | if (!msgs[i].len) { | ||
371 | /* no len: check only for device presence */ | ||
372 | rc = cx231xx_i2c_check_for_device(i2c_adap, &msgs[i]); | ||
373 | if (rc < 0) { | ||
374 | dprintk2(2, " no device\n"); | ||
375 | return rc; | ||
376 | } | ||
377 | |||
378 | } else if (msgs[i].flags & I2C_M_RD) { | ||
379 | /* read bytes */ | ||
380 | rc = cx231xx_i2c_recv_bytes(i2c_adap, &msgs[i]); | ||
381 | if (i2c_debug >= 2) { | ||
382 | for (byte = 0; byte < msgs[i].len; byte++) | ||
383 | printk(" %02x", msgs[i].buf[byte]); | ||
384 | } | ||
385 | } else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && | ||
386 | msgs[i].addr == msgs[i + 1].addr | ||
387 | && (msgs[i].len <= 2) && (bus->nr < 2)) { | ||
388 | /* read bytes */ | ||
389 | rc = cx231xx_i2c_recv_bytes_with_saddr(i2c_adap, | ||
390 | &msgs[i], | ||
391 | &msgs[i + 1]); | ||
392 | if (i2c_debug >= 2) { | ||
393 | for (byte = 0; byte < msgs[i].len; byte++) | ||
394 | printk(" %02x", msgs[i].buf[byte]); | ||
395 | } | ||
396 | i++; | ||
397 | } else { | ||
398 | /* write bytes */ | ||
399 | if (i2c_debug >= 2) { | ||
400 | for (byte = 0; byte < msgs[i].len; byte++) | ||
401 | printk(" %02x", msgs[i].buf[byte]); | ||
402 | } | ||
403 | rc = cx231xx_i2c_send_bytes(i2c_adap, &msgs[i]); | ||
404 | } | ||
405 | if (rc < 0) | ||
406 | goto err; | ||
407 | if (i2c_debug >= 2) | ||
408 | printk("\n"); | ||
409 | } | ||
410 | |||
411 | return num; | ||
412 | err: | ||
413 | dprintk2(2, " ERROR: %i\n", rc); | ||
414 | return rc; | ||
415 | } | ||
416 | |||
417 | /* ----------------------------------------------------------- */ | ||
418 | |||
419 | /* | ||
420 | * functionality() | ||
421 | */ | ||
422 | static u32 functionality(struct i2c_adapter *adap) | ||
423 | { | ||
424 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; | ||
425 | } | ||
426 | |||
427 | /* | ||
428 | * attach_inform() | ||
429 | * gets called when a device attaches to the i2c bus | ||
430 | * does some basic configuration | ||
431 | */ | ||
432 | static int attach_inform(struct i2c_client *client) | ||
433 | { | ||
434 | struct cx231xx_i2c *bus = i2c_get_adapdata(client->adapter); | ||
435 | struct cx231xx *dev = bus->dev; | ||
436 | |||
437 | switch (client->addr << 1) { | ||
438 | case 0x8e: | ||
439 | { | ||
440 | struct IR_i2c *ir = i2c_get_clientdata(client); | ||
441 | dprintk1(1, "attach_inform: IR detected (%s).\n", | ||
442 | ir->phys); | ||
443 | cx231xx_set_ir(dev, ir); | ||
444 | break; | ||
445 | } | ||
446 | break; | ||
447 | |||
448 | default: | ||
449 | break; | ||
450 | } | ||
451 | |||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static struct i2c_algorithm cx231xx_algo = { | ||
456 | .master_xfer = cx231xx_i2c_xfer, | ||
457 | .functionality = functionality, | ||
458 | }; | ||
459 | |||
460 | static struct i2c_adapter cx231xx_adap_template = { | ||
461 | .owner = THIS_MODULE, | ||
462 | .name = "cx231xx", | ||
463 | .id = I2C_HW_B_CX231XX, | ||
464 | .algo = &cx231xx_algo, | ||
465 | .client_register = attach_inform, | ||
466 | }; | ||
467 | |||
468 | static struct i2c_client cx231xx_client_template = { | ||
469 | .name = "cx231xx internal", | ||
470 | }; | ||
471 | |||
472 | /* ----------------------------------------------------------- */ | ||
473 | |||
474 | /* | ||
475 | * i2c_devs | ||
476 | * incomplete list of known devices | ||
477 | */ | ||
478 | static char *i2c_devs[128] = { | ||
479 | [0x60 >> 1] = "colibri", | ||
480 | [0x88 >> 1] = "hammerhead", | ||
481 | [0x8e >> 1] = "CIR", | ||
482 | [0x32 >> 1] = "GeminiIII", | ||
483 | [0x02 >> 1] = "Aquarius", | ||
484 | [0xa0 >> 1] = "eeprom", | ||
485 | [0xc0 >> 1] = "tuner/XC3028", | ||
486 | [0xc2 >> 1] = "tuner/XC5000", | ||
487 | }; | ||
488 | |||
489 | /* | ||
490 | * cx231xx_do_i2c_scan() | ||
491 | * check i2c address range for devices | ||
492 | */ | ||
493 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c) | ||
494 | { | ||
495 | unsigned char buf; | ||
496 | int i, rc; | ||
497 | |||
498 | cx231xx_info(": Checking for I2C devices ..\n"); | ||
499 | for (i = 0; i < 128; i++) { | ||
500 | c->addr = i; | ||
501 | rc = i2c_master_recv(c, &buf, 0); | ||
502 | if (rc < 0) | ||
503 | continue; | ||
504 | cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n", | ||
505 | dev->name, i << 1, | ||
506 | i2c_devs[i] ? i2c_devs[i] : "???"); | ||
507 | } | ||
508 | cx231xx_info(": Completed Checking for I2C devices.\n"); | ||
509 | } | ||
510 | |||
511 | /* | ||
512 | * cx231xx_i2c_register() | ||
513 | * register i2c bus | ||
514 | */ | ||
515 | int cx231xx_i2c_register(struct cx231xx_i2c *bus) | ||
516 | { | ||
517 | struct cx231xx *dev = bus->dev; | ||
518 | |||
519 | BUG_ON(!dev->cx231xx_send_usb_command); | ||
520 | |||
521 | memcpy(&bus->i2c_adap, &cx231xx_adap_template, sizeof(bus->i2c_adap)); | ||
522 | memcpy(&bus->i2c_algo, &cx231xx_algo, sizeof(bus->i2c_algo)); | ||
523 | memcpy(&bus->i2c_client, &cx231xx_client_template, | ||
524 | sizeof(bus->i2c_client)); | ||
525 | |||
526 | bus->i2c_adap.dev.parent = &dev->udev->dev; | ||
527 | |||
528 | strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); | ||
529 | |||
530 | bus->i2c_algo.data = bus; | ||
531 | bus->i2c_adap.algo_data = bus; | ||
532 | i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); | ||
533 | i2c_add_adapter(&bus->i2c_adap); | ||
534 | |||
535 | bus->i2c_client.adapter = &bus->i2c_adap; | ||
536 | |||
537 | if (0 == bus->i2c_rc) { | ||
538 | if (i2c_scan) | ||
539 | cx231xx_do_i2c_scan(dev, &bus->i2c_client); | ||
540 | } else | ||
541 | cx231xx_warn("%s: i2c bus %d register FAILED\n", | ||
542 | dev->name, bus->nr); | ||
543 | |||
544 | return bus->i2c_rc; | ||
545 | } | ||
546 | |||
547 | /* | ||
548 | * cx231xx_i2c_unregister() | ||
549 | * unregister i2c_bus | ||
550 | */ | ||
551 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus) | ||
552 | { | ||
553 | i2c_del_adapter(&bus->i2c_adap); | ||
554 | return 0; | ||
555 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c new file mode 100644 index 000000000000..97e304c3c799 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-input.c | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | handle cx231xx IR remotes via linux kernel input layer. | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | < This is a place holder for IR now.> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/input.h> | ||
29 | #include <linux/usb.h> | ||
30 | |||
31 | #include "cx231xx.h" | ||
32 | |||
33 | static unsigned int ir_debug; | ||
34 | module_param(ir_debug, int, 0644); | ||
35 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | ||
36 | |||
37 | #define i2cdprintk(fmt, arg...) \ | ||
38 | if (ir_debug) { \ | ||
39 | printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg); \ | ||
40 | } | ||
41 | |||
42 | #define dprintk(fmt, arg...) \ | ||
43 | if (ir_debug) { \ | ||
44 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \ | ||
45 | } | ||
46 | |||
47 | /********************************************************** | ||
48 | Polling structure used by cx231xx IR's | ||
49 | **********************************************************/ | ||
50 | |||
51 | struct cx231xx_ir_poll_result { | ||
52 | unsigned int toggle_bit:1; | ||
53 | unsigned int read_count:7; | ||
54 | u8 rc_address; | ||
55 | u8 rc_data[4]; | ||
56 | }; | ||
57 | |||
58 | struct cx231xx_IR { | ||
59 | struct cx231xx *dev; | ||
60 | struct input_dev *input; | ||
61 | struct ir_input_state ir; | ||
62 | char name[32]; | ||
63 | char phys[32]; | ||
64 | |||
65 | /* poll external decoder */ | ||
66 | int polling; | ||
67 | struct work_struct work; | ||
68 | struct timer_list timer; | ||
69 | unsigned int last_toggle:1; | ||
70 | unsigned int last_readcount; | ||
71 | unsigned int repeat_interval; | ||
72 | |||
73 | int (*get_key) (struct cx231xx_IR *, struct cx231xx_ir_poll_result *); | ||
74 | }; | ||
75 | |||
76 | /********************************************************** | ||
77 | Polling code for cx231xx | ||
78 | **********************************************************/ | ||
79 | |||
80 | static void cx231xx_ir_handle_key(struct cx231xx_IR *ir) | ||
81 | { | ||
82 | int result; | ||
83 | int do_sendkey = 0; | ||
84 | struct cx231xx_ir_poll_result poll_result; | ||
85 | |||
86 | /* read the registers containing the IR status */ | ||
87 | result = ir->get_key(ir, &poll_result); | ||
88 | if (result < 0) { | ||
89 | dprintk("ir->get_key() failed %d\n", result); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | dprintk("ir->get_key result tb=%02x rc=%02x lr=%02x data=%02x\n", | ||
94 | poll_result.toggle_bit, poll_result.read_count, | ||
95 | ir->last_readcount, poll_result.rc_data[0]); | ||
96 | |||
97 | if (ir->dev->chip_id == CHIP_ID_EM2874) { | ||
98 | /* The em2874 clears the readcount field every time the | ||
99 | register is read. The em2860/2880 datasheet says that it | ||
100 | is supposed to clear the readcount, but it doesn't. So with | ||
101 | the em2874, we are looking for a non-zero read count as | ||
102 | opposed to a readcount that is incrementing */ | ||
103 | ir->last_readcount = 0; | ||
104 | } | ||
105 | |||
106 | if (poll_result.read_count == 0) { | ||
107 | /* The button has not been pressed since the last read */ | ||
108 | } else if (ir->last_toggle != poll_result.toggle_bit) { | ||
109 | /* A button has been pressed */ | ||
110 | dprintk("button has been pressed\n"); | ||
111 | ir->last_toggle = poll_result.toggle_bit; | ||
112 | ir->repeat_interval = 0; | ||
113 | do_sendkey = 1; | ||
114 | } else if (poll_result.toggle_bit == ir->last_toggle && | ||
115 | poll_result.read_count > 0 && | ||
116 | poll_result.read_count != ir->last_readcount) { | ||
117 | /* The button is still being held down */ | ||
118 | dprintk("button being held down\n"); | ||
119 | |||
120 | /* Debouncer for first keypress */ | ||
121 | if (ir->repeat_interval++ > 9) { | ||
122 | /* Start repeating after 1 second */ | ||
123 | do_sendkey = 1; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | if (do_sendkey) { | ||
128 | dprintk("sending keypress\n"); | ||
129 | ir_input_keydown(ir->input, &ir->ir, poll_result.rc_data[0], | ||
130 | poll_result.rc_data[0]); | ||
131 | ir_input_nokey(ir->input, &ir->ir); | ||
132 | } | ||
133 | |||
134 | ir->last_readcount = poll_result.read_count; | ||
135 | return; | ||
136 | } | ||
137 | |||
138 | static void ir_timer(unsigned long data) | ||
139 | { | ||
140 | struct cx231xx_IR *ir = (struct cx231xx_IR *)data; | ||
141 | |||
142 | schedule_work(&ir->work); | ||
143 | } | ||
144 | |||
145 | static void cx231xx_ir_work(struct work_struct *work) | ||
146 | { | ||
147 | struct cx231xx_IR *ir = container_of(work, struct cx231xx_IR, work); | ||
148 | |||
149 | cx231xx_ir_handle_key(ir); | ||
150 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); | ||
151 | } | ||
152 | |||
153 | void cx231xx_ir_start(struct cx231xx_IR *ir) | ||
154 | { | ||
155 | setup_timer(&ir->timer, ir_timer, (unsigned long)ir); | ||
156 | INIT_WORK(&ir->work, cx231xx_ir_work); | ||
157 | schedule_work(&ir->work); | ||
158 | } | ||
159 | |||
160 | static void cx231xx_ir_stop(struct cx231xx_IR *ir) | ||
161 | { | ||
162 | del_timer_sync(&ir->timer); | ||
163 | flush_scheduled_work(); | ||
164 | } | ||
165 | |||
166 | int cx231xx_ir_init(struct cx231xx *dev) | ||
167 | { | ||
168 | struct cx231xx_IR *ir; | ||
169 | struct input_dev *input_dev; | ||
170 | u8 ir_config; | ||
171 | int err = -ENOMEM; | ||
172 | |||
173 | if (dev->board.ir_codes == NULL) { | ||
174 | /* No remote control support */ | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); | ||
179 | input_dev = input_allocate_device(); | ||
180 | if (!ir || !input_dev) | ||
181 | goto err_out_free; | ||
182 | |||
183 | ir->input = input_dev; | ||
184 | |||
185 | /* Setup the proper handler based on the chip */ | ||
186 | switch (dev->chip_id) { | ||
187 | default: | ||
188 | printk("Unrecognized cx231xx chip id: IR not supported\n"); | ||
189 | goto err_out_free; | ||
190 | } | ||
191 | |||
192 | /* This is how often we ask the chip for IR information */ | ||
193 | ir->polling = 100; /* ms */ | ||
194 | |||
195 | /* init input device */ | ||
196 | snprintf(ir->name, sizeof(ir->name), "cx231xx IR (%s)", dev->name); | ||
197 | |||
198 | usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); | ||
199 | strlcat(ir->phys, "/input0", sizeof(ir->phys)); | ||
200 | |||
201 | ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes); | ||
202 | input_dev->name = ir->name; | ||
203 | input_dev->phys = ir->phys; | ||
204 | input_dev->id.bustype = BUS_USB; | ||
205 | input_dev->id.version = 1; | ||
206 | input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); | ||
207 | input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); | ||
208 | |||
209 | input_dev->dev.parent = &dev->udev->dev; | ||
210 | /* record handles to ourself */ | ||
211 | ir->dev = dev; | ||
212 | dev->ir = ir; | ||
213 | |||
214 | cx231xx_ir_start(ir); | ||
215 | |||
216 | /* all done */ | ||
217 | err = input_register_device(ir->input); | ||
218 | if (err) | ||
219 | goto err_out_stop; | ||
220 | |||
221 | return 0; | ||
222 | err_out_stop: | ||
223 | cx231xx_ir_stop(ir); | ||
224 | dev->ir = NULL; | ||
225 | err_out_free: | ||
226 | input_free_device(input_dev); | ||
227 | kfree(ir); | ||
228 | return err; | ||
229 | } | ||
230 | |||
231 | int cx231xx_ir_fini(struct cx231xx *dev) | ||
232 | { | ||
233 | struct cx231xx_IR *ir = dev->ir; | ||
234 | |||
235 | /* skip detach on non attached boards */ | ||
236 | if (!ir) | ||
237 | return 0; | ||
238 | |||
239 | cx231xx_ir_stop(ir); | ||
240 | input_unregister_device(ir->input); | ||
241 | kfree(ir); | ||
242 | |||
243 | /* done */ | ||
244 | dev->ir = NULL; | ||
245 | return 0; | ||
246 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-pcb-cfg.c b/drivers/media/video/cx231xx/cx231xx-pcb-cfg.c new file mode 100644 index 000000000000..7473c33e823e --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-pcb-cfg.c | |||
@@ -0,0 +1,795 @@ | |||
1 | /* | ||
2 | cx231xx-pcb-config.c - driver for Conexant | ||
3 | Cx23100/101/102 USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "cx231xx.h" | ||
23 | #include "cx231xx-conf-reg.h" | ||
24 | |||
25 | static unsigned int pcb_debug; | ||
26 | module_param(pcb_debug, int, 0644); | ||
27 | MODULE_PARM_DESC(pcb_debug, "enable pcb config debug messages [video]"); | ||
28 | |||
29 | /******************************************************************************/ | ||
30 | |||
31 | struct pcb_config cx231xx_Scenario[] = { | ||
32 | { | ||
33 | INDEX_SELFPOWER_DIGITAL_ONLY, /* index */ | ||
34 | USB_SELF_POWER, /* power_type */ | ||
35 | 0, /* speed , not decide yet */ | ||
36 | MOD_DIGITAL, /* mode */ | ||
37 | SOURCE_TS_BDA, /* ts1_source, digital tv only */ | ||
38 | NOT_SUPPORTED, /* ts2_source */ | ||
39 | NOT_SUPPORTED, /* analog source */ | ||
40 | |||
41 | 0, /* digital_index */ | ||
42 | 0, /* analog index */ | ||
43 | 0, /* dif_index */ | ||
44 | 0, /* external_index */ | ||
45 | |||
46 | 1, /* only one configuration */ | ||
47 | { | ||
48 | { | ||
49 | 0, /* config index */ | ||
50 | { | ||
51 | 0, /* interrupt ep index */ | ||
52 | 1, /* ts1 index */ | ||
53 | NOT_SUPPORTED, /* TS2 index */ | ||
54 | NOT_SUPPORTED, /* AUDIO */ | ||
55 | NOT_SUPPORTED, /* VIDEO */ | ||
56 | NOT_SUPPORTED, /* VANC */ | ||
57 | NOT_SUPPORTED, /* HANC */ | ||
58 | NOT_SUPPORTED /* ir_index */ | ||
59 | } | ||
60 | , | ||
61 | } | ||
62 | , | ||
63 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
64 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
65 | NOT_SUPPORTED} | ||
66 | } | ||
67 | , | ||
68 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
69 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
70 | NOT_SUPPORTED} | ||
71 | } | ||
72 | } | ||
73 | , | ||
74 | /* full-speed config */ | ||
75 | { | ||
76 | { | ||
77 | 0, /* config index */ | ||
78 | { | ||
79 | 0, /* interrupt ep index */ | ||
80 | 1, /* ts1 index */ | ||
81 | NOT_SUPPORTED, /* TS2 index */ | ||
82 | NOT_SUPPORTED, /* AUDIO */ | ||
83 | NOT_SUPPORTED, /* VIDEO */ | ||
84 | NOT_SUPPORTED, /* VANC */ | ||
85 | NOT_SUPPORTED, /* HANC */ | ||
86 | NOT_SUPPORTED /* ir_index */ | ||
87 | } | ||
88 | } | ||
89 | , | ||
90 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
91 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
92 | NOT_SUPPORTED} | ||
93 | } | ||
94 | , | ||
95 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
96 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
97 | NOT_SUPPORTED} | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | , | ||
102 | |||
103 | { | ||
104 | INDEX_SELFPOWER_DUAL_DIGITAL, /* index */ | ||
105 | USB_SELF_POWER, /* power_type */ | ||
106 | 0, /* speed , not decide yet */ | ||
107 | MOD_DIGITAL, /* mode */ | ||
108 | SOURCE_TS_BDA, /* ts1_source, digital tv only */ | ||
109 | 0, /* ts2_source,need update from register */ | ||
110 | NOT_SUPPORTED, /* analog source */ | ||
111 | 0, /* digital_index */ | ||
112 | 0, /* analog index */ | ||
113 | 0, /* dif_index */ | ||
114 | 0, /* external_index */ | ||
115 | |||
116 | 1, /* only one configuration */ | ||
117 | { | ||
118 | { | ||
119 | 0, /* config index */ | ||
120 | { | ||
121 | 0, /* interrupt ep index */ | ||
122 | 1, /* ts1 index */ | ||
123 | 2, /* TS2 index */ | ||
124 | NOT_SUPPORTED, /* AUDIO */ | ||
125 | NOT_SUPPORTED, /* VIDEO */ | ||
126 | NOT_SUPPORTED, /* VANC */ | ||
127 | NOT_SUPPORTED, /* HANC */ | ||
128 | NOT_SUPPORTED /* ir_index */ | ||
129 | } | ||
130 | } | ||
131 | , | ||
132 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
133 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
134 | NOT_SUPPORTED} | ||
135 | } | ||
136 | , | ||
137 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
138 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
139 | NOT_SUPPORTED} | ||
140 | } | ||
141 | } | ||
142 | , | ||
143 | /* full-speed */ | ||
144 | { | ||
145 | { | ||
146 | 0, /* config index */ | ||
147 | { | ||
148 | 0, /* interrupt ep index */ | ||
149 | 1, /* ts1 index */ | ||
150 | 2, /* TS2 index */ | ||
151 | NOT_SUPPORTED, /* AUDIO */ | ||
152 | NOT_SUPPORTED, /* VIDEO */ | ||
153 | NOT_SUPPORTED, /* VANC */ | ||
154 | NOT_SUPPORTED, /* HANC */ | ||
155 | NOT_SUPPORTED /* ir_index */ | ||
156 | } | ||
157 | } | ||
158 | , | ||
159 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
160 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
161 | NOT_SUPPORTED} | ||
162 | } | ||
163 | , | ||
164 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
165 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
166 | NOT_SUPPORTED} | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | , | ||
171 | |||
172 | { | ||
173 | INDEX_SELFPOWER_ANALOG_ONLY, /* index */ | ||
174 | USB_SELF_POWER, /* power_type */ | ||
175 | 0, /* speed , not decide yet */ | ||
176 | MOD_ANALOG | MOD_DIF | MOD_EXTERNAL, /* mode ,analog tv only */ | ||
177 | NOT_SUPPORTED, /* ts1_source, NOT SUPPORT */ | ||
178 | NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */ | ||
179 | 0, /* analog source, need update */ | ||
180 | |||
181 | 0, /* digital_index */ | ||
182 | 0, /* analog index */ | ||
183 | 0, /* dif_index */ | ||
184 | 0, /* external_index */ | ||
185 | |||
186 | 1, /* only one configuration */ | ||
187 | { | ||
188 | { | ||
189 | 0, /* config index */ | ||
190 | { | ||
191 | 0, /* interrupt ep index */ | ||
192 | NOT_SUPPORTED, /* ts1 index */ | ||
193 | NOT_SUPPORTED, /* TS2 index */ | ||
194 | 1, /* AUDIO */ | ||
195 | 2, /* VIDEO */ | ||
196 | 3, /* VANC */ | ||
197 | 4, /* HANC */ | ||
198 | NOT_SUPPORTED /* ir_index */ | ||
199 | } | ||
200 | } | ||
201 | , | ||
202 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
203 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
204 | NOT_SUPPORTED} | ||
205 | } | ||
206 | , | ||
207 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
208 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
209 | NOT_SUPPORTED} | ||
210 | } | ||
211 | } | ||
212 | , | ||
213 | /* full-speed */ | ||
214 | { | ||
215 | { | ||
216 | 0, /* config index */ | ||
217 | { | ||
218 | 0, /* interrupt ep index */ | ||
219 | NOT_SUPPORTED, /* ts1 index */ | ||
220 | NOT_SUPPORTED, /* TS2 index */ | ||
221 | 1, /* AUDIO */ | ||
222 | 2, /* VIDEO */ | ||
223 | NOT_SUPPORTED, /* VANC */ | ||
224 | NOT_SUPPORTED, /* HANC */ | ||
225 | NOT_SUPPORTED /* ir_index */ | ||
226 | } | ||
227 | } | ||
228 | , | ||
229 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
230 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
231 | NOT_SUPPORTED} | ||
232 | } | ||
233 | , | ||
234 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
235 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
236 | NOT_SUPPORTED} | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | , | ||
241 | |||
242 | { | ||
243 | INDEX_SELFPOWER_DUAL, /* index */ | ||
244 | USB_SELF_POWER, /* power_type */ | ||
245 | 0, /* speed , not decide yet */ | ||
246 | /* mode ,analog tv and digital path */ | ||
247 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
248 | 0, /* ts1_source,will update in register */ | ||
249 | NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */ | ||
250 | 0, /* analog source need update */ | ||
251 | 0, /* digital_index */ | ||
252 | 0, /* analog index */ | ||
253 | 0, /* dif_index */ | ||
254 | 0, /* external_index */ | ||
255 | 1, /* only one configuration */ | ||
256 | { | ||
257 | { | ||
258 | 0, /* config index */ | ||
259 | { | ||
260 | 0, /* interrupt ep index */ | ||
261 | 1, /* ts1 index */ | ||
262 | NOT_SUPPORTED, /* TS2 index */ | ||
263 | 2, /* AUDIO */ | ||
264 | 3, /* VIDEO */ | ||
265 | 4, /* VANC */ | ||
266 | 5, /* HANC */ | ||
267 | NOT_SUPPORTED /* ir_index */ | ||
268 | } | ||
269 | } | ||
270 | , | ||
271 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
272 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
273 | NOT_SUPPORTED} | ||
274 | } | ||
275 | , | ||
276 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
277 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
278 | NOT_SUPPORTED} | ||
279 | } | ||
280 | } | ||
281 | , | ||
282 | /* full-speed */ | ||
283 | { | ||
284 | { | ||
285 | 0, /* config index */ | ||
286 | { | ||
287 | 0, /* interrupt ep index */ | ||
288 | 1, /* ts1 index */ | ||
289 | NOT_SUPPORTED, /* TS2 index */ | ||
290 | 2, /* AUDIO */ | ||
291 | 3, /* VIDEO */ | ||
292 | NOT_SUPPORTED, /* VANC */ | ||
293 | NOT_SUPPORTED, /* HANC */ | ||
294 | NOT_SUPPORTED /* ir_index */ | ||
295 | } | ||
296 | } | ||
297 | , | ||
298 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
299 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
300 | NOT_SUPPORTED} | ||
301 | } | ||
302 | , | ||
303 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
304 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
305 | NOT_SUPPORTED} | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | , | ||
310 | |||
311 | { | ||
312 | INDEX_SELFPOWER_TRIPLE, /* index */ | ||
313 | USB_SELF_POWER, /* power_type */ | ||
314 | 0, /* speed , not decide yet */ | ||
315 | /* mode ,analog tv and digital path */ | ||
316 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
317 | 0, /* ts1_source, update in register */ | ||
318 | 0, /* ts2_source,update in register */ | ||
319 | 0, /* analog source, need update */ | ||
320 | |||
321 | 0, /* digital_index */ | ||
322 | 0, /* analog index */ | ||
323 | 0, /* dif_index */ | ||
324 | 0, /* external_index */ | ||
325 | 1, /* only one configuration */ | ||
326 | { | ||
327 | { | ||
328 | 0, /* config index */ | ||
329 | { | ||
330 | 0, /* interrupt ep index */ | ||
331 | 1, /* ts1 index */ | ||
332 | 2, /* TS2 index */ | ||
333 | 3, /* AUDIO */ | ||
334 | 4, /* VIDEO */ | ||
335 | 5, /* VANC */ | ||
336 | 6, /* HANC */ | ||
337 | NOT_SUPPORTED /* ir_index */ | ||
338 | } | ||
339 | } | ||
340 | , | ||
341 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
342 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
343 | NOT_SUPPORTED} | ||
344 | } | ||
345 | , | ||
346 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
347 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
348 | NOT_SUPPORTED} | ||
349 | } | ||
350 | } | ||
351 | , | ||
352 | /* full-speed */ | ||
353 | { | ||
354 | { | ||
355 | 0, /* config index */ | ||
356 | { | ||
357 | 0, /* interrupt ep index */ | ||
358 | 1, /* ts1 index */ | ||
359 | 2, /* TS2 index */ | ||
360 | 3, /* AUDIO */ | ||
361 | 4, /* VIDEO */ | ||
362 | NOT_SUPPORTED, /* VANC */ | ||
363 | NOT_SUPPORTED, /* HANC */ | ||
364 | NOT_SUPPORTED /* ir_index */ | ||
365 | } | ||
366 | } | ||
367 | , | ||
368 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
369 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
370 | NOT_SUPPORTED} | ||
371 | } | ||
372 | , | ||
373 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
374 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
375 | NOT_SUPPORTED} | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | , | ||
380 | |||
381 | { | ||
382 | INDEX_SELFPOWER_COMPRESSOR, /* index */ | ||
383 | USB_SELF_POWER, /* power_type */ | ||
384 | 0, /* speed , not decide yet */ | ||
385 | /* mode ,analog tv AND DIGITAL path */ | ||
386 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
387 | NOT_SUPPORTED, /* ts1_source, disable */ | ||
388 | SOURCE_TS_BDA, /* ts2_source */ | ||
389 | 0, /* analog source,need update */ | ||
390 | 0, /* digital_index */ | ||
391 | 0, /* analog index */ | ||
392 | 0, /* dif_index */ | ||
393 | 0, /* external_index */ | ||
394 | 1, /* only one configuration */ | ||
395 | { | ||
396 | { | ||
397 | 0, /* config index */ | ||
398 | { | ||
399 | 0, /* interrupt ep index */ | ||
400 | NOT_SUPPORTED, /* ts1 index */ | ||
401 | 1, /* TS2 index */ | ||
402 | 2, /* AUDIO */ | ||
403 | 3, /* VIDEO */ | ||
404 | 4, /* VANC */ | ||
405 | 5, /* HANC */ | ||
406 | NOT_SUPPORTED /* ir_index */ | ||
407 | } | ||
408 | } | ||
409 | , | ||
410 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
411 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
412 | NOT_SUPPORTED} | ||
413 | } | ||
414 | , | ||
415 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
416 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
417 | NOT_SUPPORTED} | ||
418 | } | ||
419 | } | ||
420 | , | ||
421 | /* full-speed */ | ||
422 | { | ||
423 | { | ||
424 | 0, /* config index */ | ||
425 | { | ||
426 | 0, /* interrupt ep index */ | ||
427 | NOT_SUPPORTED, /* ts1 index */ | ||
428 | 1, /* TS2 index */ | ||
429 | 2, /* AUDIO */ | ||
430 | 3, /* VIDEO */ | ||
431 | NOT_SUPPORTED, /* VANC */ | ||
432 | NOT_SUPPORTED, /* HANC */ | ||
433 | NOT_SUPPORTED /* ir_index */ | ||
434 | } | ||
435 | } | ||
436 | , | ||
437 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
438 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
439 | NOT_SUPPORTED} | ||
440 | } | ||
441 | , | ||
442 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
443 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
444 | NOT_SUPPORTED} | ||
445 | } | ||
446 | } | ||
447 | } | ||
448 | , | ||
449 | |||
450 | { | ||
451 | INDEX_BUSPOWER_DIGITAL_ONLY, /* index */ | ||
452 | USB_BUS_POWER, /* power_type */ | ||
453 | 0, /* speed , not decide yet */ | ||
454 | MOD_DIGITAL, /* mode ,analog tv AND DIGITAL path */ | ||
455 | SOURCE_TS_BDA, /* ts1_source, disable */ | ||
456 | NOT_SUPPORTED, /* ts2_source */ | ||
457 | NOT_SUPPORTED, /* analog source */ | ||
458 | |||
459 | 0, /* digital_index */ | ||
460 | 0, /* analog index */ | ||
461 | 0, /* dif_index */ | ||
462 | 0, /* external_index */ | ||
463 | |||
464 | 1, /* only one configuration */ | ||
465 | { | ||
466 | { | ||
467 | 0, /* config index */ | ||
468 | { | ||
469 | 0, /* interrupt ep index = 2 */ | ||
470 | 1, /* ts1 index */ | ||
471 | NOT_SUPPORTED, /* TS2 index */ | ||
472 | NOT_SUPPORTED, /* AUDIO */ | ||
473 | NOT_SUPPORTED, /* VIDEO */ | ||
474 | NOT_SUPPORTED, /* VANC */ | ||
475 | NOT_SUPPORTED, /* HANC */ | ||
476 | NOT_SUPPORTED /* ir_index */ | ||
477 | } | ||
478 | } | ||
479 | , | ||
480 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
481 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
482 | NOT_SUPPORTED} | ||
483 | } | ||
484 | , | ||
485 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
486 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
487 | NOT_SUPPORTED} | ||
488 | } | ||
489 | } | ||
490 | , | ||
491 | /* full-speed */ | ||
492 | { | ||
493 | { | ||
494 | 0, /* config index */ | ||
495 | { | ||
496 | 0, /* interrupt ep index = 2 */ | ||
497 | 1, /* ts1 index */ | ||
498 | NOT_SUPPORTED, /* TS2 index */ | ||
499 | NOT_SUPPORTED, /* AUDIO */ | ||
500 | NOT_SUPPORTED, /* VIDEO */ | ||
501 | NOT_SUPPORTED, /* VANC */ | ||
502 | NOT_SUPPORTED, /* HANC */ | ||
503 | NOT_SUPPORTED /* ir_index */ | ||
504 | } | ||
505 | } | ||
506 | , | ||
507 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
508 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
509 | NOT_SUPPORTED} | ||
510 | } | ||
511 | , | ||
512 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
513 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
514 | NOT_SUPPORTED} | ||
515 | } | ||
516 | } | ||
517 | } | ||
518 | , | ||
519 | { | ||
520 | INDEX_BUSPOWER_ANALOG_ONLY, /* index */ | ||
521 | USB_BUS_POWER, /* power_type */ | ||
522 | 0, /* speed , not decide yet */ | ||
523 | MOD_ANALOG, /* mode ,analog tv AND DIGITAL path */ | ||
524 | NOT_SUPPORTED, /* ts1_source, disable */ | ||
525 | NOT_SUPPORTED, /* ts2_source */ | ||
526 | SOURCE_ANALOG, /* analog source--analog */ | ||
527 | 0, /* digital_index */ | ||
528 | 0, /* analog index */ | ||
529 | 0, /* dif_index */ | ||
530 | 0, /* external_index */ | ||
531 | 1, /* only one configuration */ | ||
532 | { | ||
533 | { | ||
534 | 0, /* config index */ | ||
535 | { | ||
536 | 0, /* interrupt ep index */ | ||
537 | NOT_SUPPORTED, /* ts1 index */ | ||
538 | NOT_SUPPORTED, /* TS2 index */ | ||
539 | 1, /* AUDIO */ | ||
540 | 2, /* VIDEO */ | ||
541 | 3, /* VANC */ | ||
542 | 4, /* HANC */ | ||
543 | NOT_SUPPORTED /* ir_index */ | ||
544 | } | ||
545 | } | ||
546 | , | ||
547 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
548 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
549 | NOT_SUPPORTED} | ||
550 | } | ||
551 | , | ||
552 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
553 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
554 | NOT_SUPPORTED} | ||
555 | } | ||
556 | } | ||
557 | , | ||
558 | { /* full-speed */ | ||
559 | { | ||
560 | 0, /* config index */ | ||
561 | { | ||
562 | 0, /* interrupt ep index */ | ||
563 | NOT_SUPPORTED, /* ts1 index */ | ||
564 | NOT_SUPPORTED, /* TS2 index */ | ||
565 | 1, /* AUDIO */ | ||
566 | 2, /* VIDEO */ | ||
567 | NOT_SUPPORTED, /* VANC */ | ||
568 | NOT_SUPPORTED, /* HANC */ | ||
569 | NOT_SUPPORTED /* ir_index */ | ||
570 | } | ||
571 | } | ||
572 | , | ||
573 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
574 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
575 | NOT_SUPPORTED} | ||
576 | } | ||
577 | , | ||
578 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
579 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
580 | NOT_SUPPORTED} | ||
581 | } | ||
582 | } | ||
583 | } | ||
584 | , | ||
585 | { | ||
586 | INDEX_BUSPOWER_DIF_ONLY, /* index */ | ||
587 | USB_BUS_POWER, /* power_type */ | ||
588 | 0, /* speed , not decide yet */ | ||
589 | /* mode ,analog tv AND DIGITAL path */ | ||
590 | MOD_DIF | MOD_ANALOG | MOD_DIGITAL | MOD_EXTERNAL, | ||
591 | SOURCE_TS_BDA, /* ts1_source, disable */ | ||
592 | NOT_SUPPORTED, /* ts2_source */ | ||
593 | SOURCE_DIF | SOURCE_ANALOG | SOURCE_EXTERNAL, /* analog source, dif */ | ||
594 | 0, /* digital_index */ | ||
595 | 0, /* analog index */ | ||
596 | 0, /* dif_index */ | ||
597 | 0, /* external_index */ | ||
598 | 1, /* only one configuration */ | ||
599 | { | ||
600 | { | ||
601 | 0, /* config index */ | ||
602 | { | ||
603 | 0, /* interrupt ep index */ | ||
604 | 1, /* ts1 index */ | ||
605 | NOT_SUPPORTED, /* TS2 index */ | ||
606 | 2, /* AUDIO */ | ||
607 | 3, /* VIDEO */ | ||
608 | 4, /* VANC */ | ||
609 | 5, /* HANC */ | ||
610 | NOT_SUPPORTED /* ir_index */ | ||
611 | } | ||
612 | } | ||
613 | , | ||
614 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
615 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
616 | NOT_SUPPORTED} | ||
617 | } | ||
618 | , | ||
619 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
620 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
621 | NOT_SUPPORTED} | ||
622 | } | ||
623 | } | ||
624 | , | ||
625 | { /* full speed */ | ||
626 | { | ||
627 | 0, /* config index */ | ||
628 | { | ||
629 | 0, /* interrupt ep index */ | ||
630 | 1, /* ts1 index */ | ||
631 | NOT_SUPPORTED, /* TS2 index */ | ||
632 | 2, /* AUDIO */ | ||
633 | 3, /* VIDEO */ | ||
634 | NOT_SUPPORTED, /* VANC */ | ||
635 | NOT_SUPPORTED, /* HANC */ | ||
636 | NOT_SUPPORTED /* ir_index */ | ||
637 | } | ||
638 | } | ||
639 | , | ||
640 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
641 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
642 | NOT_SUPPORTED} | ||
643 | } | ||
644 | , | ||
645 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
646 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
647 | NOT_SUPPORTED} | ||
648 | } | ||
649 | } | ||
650 | } | ||
651 | , | ||
652 | |||
653 | }; | ||
654 | |||
655 | /*****************************************************************/ | ||
656 | |||
657 | u32 initialize_cx231xx(struct cx231xx *dev) | ||
658 | { | ||
659 | u32 config_info = 0; | ||
660 | struct pcb_config *p_pcb_info; | ||
661 | u8 usb_speed = 1; /* from register,1--HS, 0--FS */ | ||
662 | u8 data[4] = { 0, 0, 0, 0 }; | ||
663 | u32 ts1_source = 0; | ||
664 | u32 ts2_source = 0; | ||
665 | u32 analog_source = 0; | ||
666 | u8 _current_scenario_idx = 0xff; | ||
667 | |||
668 | ts1_source = SOURCE_TS_BDA; | ||
669 | ts2_source = SOURCE_TS_BDA; | ||
670 | |||
671 | /* read board config register to find out which | ||
672 | pcb config it is related to */ | ||
673 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, data, 4); | ||
674 | |||
675 | config_info = *((u32 *) data); | ||
676 | usb_speed = (u8) (config_info & 0x1); | ||
677 | |||
678 | /* Verify this device belongs to Bus power or Self power device */ | ||
679 | if (config_info & BUS_POWER) { /* bus-power */ | ||
680 | switch (config_info & BUSPOWER_MASK) { | ||
681 | case TS1_PORT | BUS_POWER: | ||
682 | cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY].speed = | ||
683 | usb_speed; | ||
684 | p_pcb_info = | ||
685 | &cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY]; | ||
686 | _current_scenario_idx = INDEX_BUSPOWER_DIGITAL_ONLY; | ||
687 | break; | ||
688 | case AVDEC_ENABLE | BUS_POWER: | ||
689 | cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY].speed = | ||
690 | usb_speed; | ||
691 | p_pcb_info = | ||
692 | &cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY]; | ||
693 | _current_scenario_idx = INDEX_BUSPOWER_ANALOG_ONLY; | ||
694 | break; | ||
695 | case AVDEC_ENABLE | BUS_POWER | TS1_PORT: | ||
696 | cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY].speed = | ||
697 | usb_speed; | ||
698 | p_pcb_info = &cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY]; | ||
699 | _current_scenario_idx = INDEX_BUSPOWER_DIF_ONLY; | ||
700 | break; | ||
701 | default: | ||
702 | cx231xx_info("bad config in buspower!!!!\n"); | ||
703 | cx231xx_info("config_info=%x\n", | ||
704 | (config_info & BUSPOWER_MASK)); | ||
705 | return 1; | ||
706 | } | ||
707 | } else { /* self-power */ | ||
708 | |||
709 | switch (config_info & SELFPOWER_MASK) { | ||
710 | case TS1_PORT | SELF_POWER: | ||
711 | cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY].speed = | ||
712 | usb_speed; | ||
713 | p_pcb_info = | ||
714 | &cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY]; | ||
715 | _current_scenario_idx = INDEX_SELFPOWER_DIGITAL_ONLY; | ||
716 | break; | ||
717 | case TS1_TS2_PORT | SELF_POWER: | ||
718 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL].speed = | ||
719 | usb_speed; | ||
720 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL]. | ||
721 | ts2_source = ts2_source; | ||
722 | p_pcb_info = | ||
723 | &cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL]; | ||
724 | _current_scenario_idx = INDEX_SELFPOWER_DUAL_DIGITAL; | ||
725 | break; | ||
726 | case AVDEC_ENABLE | SELF_POWER: | ||
727 | cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY].speed = | ||
728 | usb_speed; | ||
729 | cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY]. | ||
730 | analog_source = analog_source; | ||
731 | p_pcb_info = | ||
732 | &cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY]; | ||
733 | _current_scenario_idx = INDEX_SELFPOWER_ANALOG_ONLY; | ||
734 | break; | ||
735 | case AVDEC_ENABLE | TS1_PORT | SELF_POWER: | ||
736 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].speed = | ||
737 | usb_speed; | ||
738 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].ts1_source = | ||
739 | ts1_source; | ||
740 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].analog_source = | ||
741 | analog_source; | ||
742 | p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_DUAL]; | ||
743 | _current_scenario_idx = INDEX_SELFPOWER_DUAL; | ||
744 | break; | ||
745 | case AVDEC_ENABLE | TS1_TS2_PORT | SELF_POWER: | ||
746 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].speed = | ||
747 | usb_speed; | ||
748 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts1_source = | ||
749 | ts1_source; | ||
750 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts2_source = | ||
751 | ts2_source; | ||
752 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].analog_source = | ||
753 | analog_source; | ||
754 | p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE]; | ||
755 | _current_scenario_idx = INDEX_SELFPOWER_TRIPLE; | ||
756 | break; | ||
757 | case AVDEC_ENABLE | TS1VIP_TS2_PORT | SELF_POWER: | ||
758 | cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR].speed = | ||
759 | usb_speed; | ||
760 | cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR]. | ||
761 | analog_source = analog_source; | ||
762 | p_pcb_info = | ||
763 | &cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR]; | ||
764 | _current_scenario_idx = INDEX_SELFPOWER_COMPRESSOR; | ||
765 | break; | ||
766 | default: | ||
767 | cx231xx_info("bad senario!!!!!\n"); | ||
768 | cx231xx_info("config_info=%x\n", | ||
769 | (config_info & SELFPOWER_MASK)); | ||
770 | return 1; | ||
771 | } | ||
772 | } | ||
773 | |||
774 | dev->current_scenario_idx = _current_scenario_idx; | ||
775 | |||
776 | memcpy(&dev->current_pcb_config, p_pcb_info, | ||
777 | sizeof(struct pcb_config)); | ||
778 | |||
779 | if (pcb_debug) { | ||
780 | cx231xx_info("SC(0x00) register = 0x%x\n", config_info); | ||
781 | cx231xx_info("scenario %d\n", | ||
782 | (dev->current_pcb_config.index) + 1); | ||
783 | cx231xx_info("type=%x\n", dev->current_pcb_config.type); | ||
784 | cx231xx_info("mode=%x\n", dev->current_pcb_config.mode); | ||
785 | cx231xx_info("speed=%x\n", dev->current_pcb_config.speed); | ||
786 | cx231xx_info("ts1_source=%x\n", | ||
787 | dev->current_pcb_config.ts1_source); | ||
788 | cx231xx_info("ts2_source=%x\n", | ||
789 | dev->current_pcb_config.ts2_source); | ||
790 | cx231xx_info("analog_source=%x\n", | ||
791 | dev->current_pcb_config.analog_source); | ||
792 | } | ||
793 | |||
794 | return 0; | ||
795 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-pcb-cfg.h b/drivers/media/video/cx231xx/cx231xx-pcb-cfg.h new file mode 100644 index 000000000000..f5e46e89f3ab --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-pcb-cfg.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | cx231xx-pcb-cfg.h - driver for Conexant | ||
3 | Cx23100/101/102 USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _PCB_CONFIG_H_ | ||
23 | #define _PCB_CONFIG_H_ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/module.h> | ||
27 | |||
28 | /*************************************************************************** | ||
29 | * Class Information * | ||
30 | ***************************************************************************/ | ||
31 | #define CLASS_DEFAULT 0xFF | ||
32 | |||
33 | enum VENDOR_REQUEST_TYPE { | ||
34 | /* Set/Get I2C */ | ||
35 | VRT_SET_I2C0 = 0x0, | ||
36 | VRT_SET_I2C1 = 0x1, | ||
37 | VRT_SET_I2C2 = 0x2, | ||
38 | VRT_GET_I2C0 = 0x4, | ||
39 | VRT_GET_I2C1 = 0x5, | ||
40 | VRT_GET_I2C2 = 0x6, | ||
41 | |||
42 | /* Set/Get GPIO */ | ||
43 | VRT_SET_GPIO = 0x8, | ||
44 | VRT_GET_GPIO = 0x9, | ||
45 | |||
46 | /* Set/Get GPIE */ | ||
47 | VRT_SET_GPIE = 0xA, | ||
48 | VRT_GET_GPIE = 0xB, | ||
49 | |||
50 | /* Set/Get Register Control/Status */ | ||
51 | VRT_SET_REGISTER = 0xC, | ||
52 | VRT_GET_REGISTER = 0xD, | ||
53 | |||
54 | /* Get Extended Compat ID Descriptor */ | ||
55 | VRT_GET_EXTCID_DESC = 0xFF, | ||
56 | }; | ||
57 | |||
58 | enum BYTE_ENABLE_MASK { | ||
59 | ENABLE_ONE_BYTE = 0x1, | ||
60 | ENABLE_TWE_BYTE = 0x3, | ||
61 | ENABLE_THREE_BYTE = 0x7, | ||
62 | ENABLE_FOUR_BYTE = 0xF, | ||
63 | }; | ||
64 | |||
65 | #define SPEED_MASK 0x1 | ||
66 | enum USB_SPEED{ | ||
67 | FULL_SPEED = 0x0, /* 0: full speed */ | ||
68 | HIGH_SPEED = 0x1 /* 1: high speed */ | ||
69 | }; | ||
70 | |||
71 | enum _true_false{ | ||
72 | FALSE = 0, | ||
73 | TRUE = 1 | ||
74 | }; | ||
75 | |||
76 | #define TS_MASK 0x6 | ||
77 | enum TS_PORT{ | ||
78 | NO_TS_PORT = 0x0, /* 2'b00: Neither port used. PCB not a Hybrid, | ||
79 | only offers Analog TV or Video */ | ||
80 | TS1_PORT = 0x4, /* 2'b10: TS1 Input (Hybrid mode : | ||
81 | Digital or External Analog/Compressed source) */ | ||
82 | TS1_TS2_PORT = 0x6, /* 2'b11: TS1 & TS2 Inputs | ||
83 | (Dual inputs from Digital and/or | ||
84 | External Analog/Compressed sources) */ | ||
85 | TS1_EXT_CLOCK = 0x6, /* 2'b11: TS1 & TS2 as selector | ||
86 | to external clock */ | ||
87 | TS1VIP_TS2_PORT = 0x2 /* 2'b01: TS1 used as 656/VIP Output, | ||
88 | TS2 Input (from Compressor) */ | ||
89 | }; | ||
90 | |||
91 | #define EAVP_MASK 0x8 | ||
92 | enum EAV_PRESENT{ | ||
93 | NO_EXTERNAL_AV = 0x0, /* 0: No External A/V inputs | ||
94 | (no need for i2s blcok), | ||
95 | Analog Tuner must be present */ | ||
96 | EXTERNAL_AV = 0x8 /* 1: External A/V inputs | ||
97 | present (requires i2s blk) */ | ||
98 | }; | ||
99 | |||
100 | #define ATM_MASK 0x30 | ||
101 | enum AT_MODE{ | ||
102 | DIF_TUNER = 0x30, /* 2'b11: IF Tuner (requires use of DIF) */ | ||
103 | BASEBAND_SOUND = 0x20, /* 2'b10: Baseband Composite & | ||
104 | Sound-IF Signals present */ | ||
105 | NO_TUNER = 0x10 /* 2'b0x: No Analog Tuner present */ | ||
106 | }; | ||
107 | |||
108 | #define PWR_SEL_MASK 0x40 | ||
109 | enum POWE_TYPE{ | ||
110 | SELF_POWER = 0x0, /* 0: self power */ | ||
111 | BUS_POWER = 0x40 /* 1: bus power */ | ||
112 | }; | ||
113 | |||
114 | enum USB_POWE_TYPE{ | ||
115 | USB_SELF_POWER = 0, | ||
116 | USB_BUS_POWER | ||
117 | }; | ||
118 | |||
119 | #define BO_0_MASK 0x80 | ||
120 | enum AVDEC_STATUS{ | ||
121 | AVDEC_DISABLE = 0x0, /* 0: A/V Decoder Disabled */ | ||
122 | AVDEC_ENABLE = 0x80 /* 1: A/V Decoder Enabled */ | ||
123 | }; | ||
124 | |||
125 | #define BO_1_MASK 0x100 | ||
126 | |||
127 | #define BUSPOWER_MASK 0xC4 /* for Polaris spec 0.8 */ | ||
128 | #define SELFPOWER_MASK 0x86 | ||
129 | |||
130 | /***************************************************************************/ | ||
131 | #define NOT_DECIDE_YET 0xFE | ||
132 | #define NOT_SUPPORTED 0xFF | ||
133 | |||
134 | /*************************************************************************** | ||
135 | * for mod field use * | ||
136 | ***************************************************************************/ | ||
137 | #define MOD_DIGITAL 0x1 | ||
138 | #define MOD_ANALOG 0x2 | ||
139 | #define MOD_DIF 0x4 | ||
140 | #define MOD_EXTERNAL 0x8 | ||
141 | #define CAP_ALL_MOD 0x0f | ||
142 | |||
143 | /*************************************************************************** | ||
144 | * source define * | ||
145 | ***************************************************************************/ | ||
146 | #define SOURCE_DIGITAL 0x1 | ||
147 | #define SOURCE_ANALOG 0x2 | ||
148 | #define SOURCE_DIF 0x4 | ||
149 | #define SOURCE_EXTERNAL 0x8 | ||
150 | #define SOURCE_TS_BDA 0x10 | ||
151 | #define SOURCE_TS_ENCODE 0x20 | ||
152 | #define SOURCE_TS_EXTERNAL 0x40 | ||
153 | |||
154 | /*************************************************************************** | ||
155 | * interface information define * | ||
156 | ***************************************************************************/ | ||
157 | struct INTERFACE_INFO { | ||
158 | u8 interrupt_index; | ||
159 | u8 ts1_index; | ||
160 | u8 ts2_index; | ||
161 | u8 audio_index; | ||
162 | u8 video_index; | ||
163 | u8 vanc_index; /* VBI */ | ||
164 | u8 hanc_index; /* Sliced CC */ | ||
165 | u8 ir_index; | ||
166 | }; | ||
167 | |||
168 | enum INDEX_INTERFACE_INFO{ | ||
169 | INDEX_INTERRUPT = 0x0, | ||
170 | INDEX_TS1, | ||
171 | INDEX_TS2, | ||
172 | INDEX_AUDIO, | ||
173 | INDEX_VIDEO, | ||
174 | INDEX_VANC, | ||
175 | INDEX_HANC, | ||
176 | INDEX_IR, | ||
177 | }; | ||
178 | |||
179 | /*************************************************************************** | ||
180 | * configuration information define * | ||
181 | ***************************************************************************/ | ||
182 | struct CONFIG_INFO { | ||
183 | u8 config_index; | ||
184 | struct INTERFACE_INFO interface_info; | ||
185 | }; | ||
186 | |||
187 | struct pcb_config { | ||
188 | u8 index; | ||
189 | u8 type; /* bus power or self power, | ||
190 | self power--0, bus_power--1 */ | ||
191 | u8 speed; /* usb speed, 2.0--1, 1.1--0 */ | ||
192 | u8 mode; /* digital , anlog, dif or external A/V */ | ||
193 | u32 ts1_source; /* three source -- BDA,External,encode */ | ||
194 | u32 ts2_source; | ||
195 | u32 analog_source; | ||
196 | u8 digital_index; /* bus-power used */ | ||
197 | u8 analog_index; /* bus-power used */ | ||
198 | u8 dif_index; /* bus-power used */ | ||
199 | u8 external_index; /* bus-power used */ | ||
200 | u8 config_num; /* current config num, 0,1,2, | ||
201 | for self-power, always 0 */ | ||
202 | struct CONFIG_INFO hs_config_info[3]; | ||
203 | struct CONFIG_INFO fs_config_info[3]; | ||
204 | }; | ||
205 | |||
206 | enum INDEX_PCB_CONFIG{ | ||
207 | INDEX_SELFPOWER_DIGITAL_ONLY = 0x0, | ||
208 | INDEX_SELFPOWER_DUAL_DIGITAL, | ||
209 | INDEX_SELFPOWER_ANALOG_ONLY, | ||
210 | INDEX_SELFPOWER_DUAL, | ||
211 | INDEX_SELFPOWER_TRIPLE, | ||
212 | INDEX_SELFPOWER_COMPRESSOR, | ||
213 | INDEX_BUSPOWER_DIGITAL_ONLY, | ||
214 | INDEX_BUSPOWER_ANALOG_ONLY, | ||
215 | INDEX_BUSPOWER_DIF_ONLY, | ||
216 | INDEX_BUSPOWER_EXTERNAL_ONLY, | ||
217 | INDEX_BUSPOWER_EXTERNAL_ANALOG, | ||
218 | INDEX_BUSPOWER_EXTERNAL_DIF, | ||
219 | INDEX_BUSPOWER_EXTERNAL_DIGITAL, | ||
220 | INDEX_BUSPOWER_DIGITAL_ANALOG, | ||
221 | INDEX_BUSPOWER_DIGITAL_DIF, | ||
222 | INDEX_BUSPOWER_DIGITAL_ANALOG_EXTERNAL, | ||
223 | INDEX_BUSPOWER_DIGITAL_DIF_EXTERNAL, | ||
224 | }; | ||
225 | |||
226 | /***************************************************************************/ | ||
227 | struct cx231xx; | ||
228 | |||
229 | u32 initialize_cx231xx(struct cx231xx *p_dev); | ||
230 | |||
231 | #endif | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-reg.h b/drivers/media/video/cx231xx/cx231xx-reg.h new file mode 100644 index 000000000000..750c5d37d569 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-reg.h | |||
@@ -0,0 +1,1564 @@ | |||
1 | /* | ||
2 | cx231xx-reg.h - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_REG_H | ||
23 | #define _CX231XX_REG_H | ||
24 | |||
25 | /***************************************************************************** | ||
26 | * VBI codes * | ||
27 | *****************************************************************************/ | ||
28 | |||
29 | #define SAV_ACTIVE_VIDEO_FIELD1 0x80 | ||
30 | #define EAV_ACTIVE_VIDEO_FIELD1 0x90 | ||
31 | |||
32 | #define SAV_ACTIVE_VIDEO_FIELD2 0xc0 | ||
33 | #define EAV_ACTIVE_VIDEO_FIELD2 0xd0 | ||
34 | |||
35 | #define SAV_VBLANK_FIELD1 0xa0 | ||
36 | #define EAV_VBLANK_FIELD1 0xb0 | ||
37 | |||
38 | #define SAV_VBLANK_FIELD2 0xe0 | ||
39 | #define EAV_VBLANK_FIELD2 0xf0 | ||
40 | |||
41 | #define SAV_VBI_FIELD1 0x20 | ||
42 | #define EAV_VBI_FIELD1 0x30 | ||
43 | |||
44 | #define SAV_VBI_FIELD2 0x60 | ||
45 | #define EAV_VBI_FIELD2 0x70 | ||
46 | |||
47 | /*****************************************************************************/ | ||
48 | /* Audio ADC Registers */ | ||
49 | #define CH_PWR_CTRL1 0x0000000e | ||
50 | #define CH_PWR_CTRL2 0x0000000f | ||
51 | /*****************************************************************************/ | ||
52 | |||
53 | #define HOST_REG1 0x000 | ||
54 | #define FLD_FORCE_CHIP_SEL 0x80 | ||
55 | #define FLD_AUTO_INC_DIS 0x20 | ||
56 | #define FLD_PREFETCH_EN 0x10 | ||
57 | /* Reserved [2:3] */ | ||
58 | #define FLD_DIGITAL_PWR_DN 0x02 | ||
59 | #define FLD_SLEEP 0x01 | ||
60 | |||
61 | /*****************************************************************************/ | ||
62 | #define HOST_REG2 0x001 | ||
63 | |||
64 | /*****************************************************************************/ | ||
65 | #define HOST_REG3 0x002 | ||
66 | |||
67 | /*****************************************************************************/ | ||
68 | /* added for polaris */ | ||
69 | #define GPIO_PIN_CTL0 0x3 | ||
70 | #define GPIO_PIN_CTL1 0x4 | ||
71 | #define GPIO_PIN_CTL2 0x5 | ||
72 | #define GPIO_PIN_CTL3 0x6 | ||
73 | #define TS1_PIN_CTL0 0x7 | ||
74 | #define TS1_PIN_CTL1 0x8 | ||
75 | /*****************************************************************************/ | ||
76 | |||
77 | #define FLD_CLK_IN_EN 0x80 | ||
78 | #define FLD_XTAL_CTRL 0x70 | ||
79 | #define FLD_BB_CLK_MODE 0x0C | ||
80 | #define FLD_REF_DIV_PLL 0x02 | ||
81 | #define FLD_REF_SEL_PLL1 0x01 | ||
82 | |||
83 | /*****************************************************************************/ | ||
84 | #define CHIP_CTRL 0x100 | ||
85 | /* Reserved [27] */ | ||
86 | /* Reserved [31:21] */ | ||
87 | #define FLD_CHIP_ACFG_DIS 0x00100000 | ||
88 | /* Reserved [19] */ | ||
89 | #define FLD_DUAL_MODE_ADC2 0x00040000 | ||
90 | #define FLD_SIF_EN 0x00020000 | ||
91 | #define FLD_SOFT_RST 0x00010000 | ||
92 | #define FLD_DEVICE_ID 0x0000ffff | ||
93 | |||
94 | /*****************************************************************************/ | ||
95 | #define AFE_CTRL 0x104 | ||
96 | #define AFE_CTRL_C2HH_SRC_CTRL 0x104 | ||
97 | #define FLD_DIF_OUT_SEL 0xc0000000 | ||
98 | #define FLD_AUX_PLL_CLK_ALT_SEL 0x3c000000 | ||
99 | #define FLD_UV_ORDER_MODE 0x02000000 | ||
100 | #define FLD_FUNC_MODE 0x01800000 | ||
101 | #define FLD_ROT1_PHASE_CTL 0x007f8000 | ||
102 | #define FLD_AUD_IN_SEL 0x00004000 | ||
103 | #define FLD_LUMA_IN_SEL 0x00002000 | ||
104 | #define FLD_CHROMA_IN_SEL 0x00001000 | ||
105 | /* reserve [11:10] */ | ||
106 | #define FLD_INV_SPEC_DIS 0x00000200 | ||
107 | #define FLD_VGA_SEL_CH3 0x00000100 | ||
108 | #define FLD_VGA_SEL_CH2 0x00000080 | ||
109 | #define FLD_VGA_SEL_CH1 0x00000040 | ||
110 | #define FLD_DCR_BYP_CH1 0x00000020 | ||
111 | #define FLD_DCR_BYP_CH2 0x00000010 | ||
112 | #define FLD_DCR_BYP_CH3 0x00000008 | ||
113 | #define FLD_EN_12DB_CH3 0x00000004 | ||
114 | #define FLD_EN_12DB_CH2 0x00000002 | ||
115 | #define FLD_EN_12DB_CH1 0x00000001 | ||
116 | |||
117 | /* redefine in Cx231xx */ | ||
118 | /*****************************************************************************/ | ||
119 | #define DC_CTRL1 0x108 | ||
120 | /* reserve [31:30] */ | ||
121 | #define FLD_CLAMP_LVL_CH1 0x3fff8000 | ||
122 | #define FLD_CLAMP_LVL_CH2 0x00007fff | ||
123 | /*****************************************************************************/ | ||
124 | |||
125 | /*****************************************************************************/ | ||
126 | #define DC_CTRL2 0x10c | ||
127 | /* reserve [31:28] */ | ||
128 | #define FLD_CLAMP_LVL_CH3 0x00fffe00 | ||
129 | #define FLD_CLAMP_WIND_LENTH 0x000001e0 | ||
130 | #define FLD_C2HH_SAT_MIN 0x0000001e | ||
131 | #define FLD_FLT_BYP_SEL 0x00000001 | ||
132 | /*****************************************************************************/ | ||
133 | |||
134 | /*****************************************************************************/ | ||
135 | #define DC_CTRL3 0x110 | ||
136 | /* reserve [31:16] */ | ||
137 | #define FLD_ERR_GAIN_CTL 0x00070000 | ||
138 | #define FLD_LPF_MIN 0x0000ffff | ||
139 | /*****************************************************************************/ | ||
140 | |||
141 | /*****************************************************************************/ | ||
142 | #define DC_CTRL4 0x114 | ||
143 | /* reserve [31:31] */ | ||
144 | #define FLD_INTG_CH1 0x7fffffff | ||
145 | /*****************************************************************************/ | ||
146 | |||
147 | /*****************************************************************************/ | ||
148 | #define DC_CTRL5 0x118 | ||
149 | /* reserve [31:31] */ | ||
150 | #define FLD_INTG_CH2 0x7fffffff | ||
151 | /*****************************************************************************/ | ||
152 | |||
153 | /*****************************************************************************/ | ||
154 | #define DC_CTRL6 0x11c | ||
155 | /* reserve [31:31] */ | ||
156 | #define FLD_INTG_CH3 0x7fffffff | ||
157 | /*****************************************************************************/ | ||
158 | |||
159 | /*****************************************************************************/ | ||
160 | #define PIN_CTRL 0x120 | ||
161 | #define FLD_OEF_AGC_RF 0x00000001 | ||
162 | #define FLD_OEF_AGC_IFVGA 0x00000002 | ||
163 | #define FLD_OEF_AGC_IF 0x00000004 | ||
164 | #define FLD_REG_BO_PUD 0x80000000 | ||
165 | #define FLD_IR_IRQ_STAT 0x40000000 | ||
166 | #define FLD_AUD_IRQ_STAT 0x20000000 | ||
167 | #define FLD_VID_IRQ_STAT 0x10000000 | ||
168 | /* Reserved [27:26] */ | ||
169 | #define FLD_IRQ_N_OUT_EN 0x02000000 | ||
170 | #define FLD_IRQ_N_POLAR 0x01000000 | ||
171 | /* Reserved [23:6] */ | ||
172 | #define FLD_OE_AUX_PLL_CLK 0x00000020 | ||
173 | #define FLD_OE_I2S_BCLK 0x00000010 | ||
174 | #define FLD_OE_I2S_WCLK 0x00000008 | ||
175 | #define FLD_OE_AGC_IF 0x00000004 | ||
176 | #define FLD_OE_AGC_IFVGA 0x00000002 | ||
177 | #define FLD_OE_AGC_RF 0x00000001 | ||
178 | |||
179 | /*****************************************************************************/ | ||
180 | #define AUD_IO_CTRL 0x124 | ||
181 | /* Reserved [31:8] */ | ||
182 | #define FLD_I2S_PORT_DIR 0x00000080 | ||
183 | #define FLD_I2S_OUT_SRC 0x00000040 | ||
184 | #define FLD_AUD_CHAN3_SRC 0x00000030 | ||
185 | #define FLD_AUD_CHAN2_SRC 0x0000000c | ||
186 | #define FLD_AUD_CHAN1_SRC 0x00000003 | ||
187 | |||
188 | /*****************************************************************************/ | ||
189 | #define AUD_LOCK1 0x128 | ||
190 | #define FLD_AUD_LOCK_KI_SHIFT 0xc0000000 | ||
191 | #define FLD_AUD_LOCK_KD_SHIFT 0x30000000 | ||
192 | /* Reserved [27:25] */ | ||
193 | #define FLD_EN_AV_LOCK 0x01000000 | ||
194 | #define FLD_VID_COUNT 0x00ffffff | ||
195 | |||
196 | /*****************************************************************************/ | ||
197 | #define AUD_LOCK2 0x12c | ||
198 | #define FLD_AUD_LOCK_KI_MULT 0xf0000000 | ||
199 | #define FLD_AUD_LOCK_KD_MULT 0x0F000000 | ||
200 | /* Reserved [23:22] */ | ||
201 | #define FLD_AUD_LOCK_FREQ_SHIFT 0x00300000 | ||
202 | #define FLD_AUD_COUNT 0x000fffff | ||
203 | |||
204 | /*****************************************************************************/ | ||
205 | #define AFE_DIAG_CTRL1 0x134 | ||
206 | /* Reserved [31:16] */ | ||
207 | #define FLD_CUV_DLY_LENGTH 0x0000ff00 | ||
208 | #define FLD_YC_DLY_LENGTH 0x000000ff | ||
209 | |||
210 | /*****************************************************************************/ | ||
211 | /* Poalris redefine */ | ||
212 | #define AFE_DIAG_CTRL3 0x138 | ||
213 | /* Reserved [31:26] */ | ||
214 | #define FLD_AUD_DUAL_FLAG_POL 0x02000000 | ||
215 | #define FLD_VID_DUAL_FLAG_POL 0x01000000 | ||
216 | /* Reserved [23:23] */ | ||
217 | #define FLD_COL_CLAMP_DIS_CH1 0x00400000 | ||
218 | #define FLD_COL_CLAMP_DIS_CH2 0x00200000 | ||
219 | #define FLD_COL_CLAMP_DIS_CH3 0x00100000 | ||
220 | |||
221 | #define TEST_CTRL1 0x144 | ||
222 | /* Reserved [31:29] */ | ||
223 | #define FLD_LBIST_EN 0x10000000 | ||
224 | /* Reserved [27:10] */ | ||
225 | #define FLD_FI_BIST_INTR_R 0x0000200 | ||
226 | #define FLD_FI_BIST_INTR_L 0x0000100 | ||
227 | #define FLD_BIST_FAIL_AUD_PLL 0x0000080 | ||
228 | #define FLD_BIST_INTR_AUD_PLL 0x0000040 | ||
229 | #define FLD_BIST_FAIL_VID_PLL 0x0000020 | ||
230 | #define FLD_BIST_INTR_VID_PLL 0x0000010 | ||
231 | /* Reserved [3:1] */ | ||
232 | #define FLD_CIR_TEST_DIS 0x00000001 | ||
233 | |||
234 | /*****************************************************************************/ | ||
235 | #define TEST_CTRL2 0x148 | ||
236 | #define FLD_TSXCLK_POL_CTL 0x80000000 | ||
237 | #define FLD_ISO_CTL_SEL 0x40000000 | ||
238 | #define FLD_ISO_CTL_EN 0x20000000 | ||
239 | #define FLD_BIST_DEBUGZ 0x10000000 | ||
240 | #define FLD_AUD_BIST_TEST_H 0x0f000000 | ||
241 | /* Reserved [23:22] */ | ||
242 | #define FLD_FLTRN_BIST_TEST_H 0x00020000 | ||
243 | #define FLD_VID_BIST_TEST_H 0x00010000 | ||
244 | /* Reserved [19:17] */ | ||
245 | #define FLD_BIST_TEST_H 0x00010000 | ||
246 | /* Reserved [15:13] */ | ||
247 | #define FLD_TAB_EN 0x00001000 | ||
248 | /* Reserved [11:0] */ | ||
249 | |||
250 | /*****************************************************************************/ | ||
251 | #define BIST_STAT 0x14c | ||
252 | #define FLD_AUD_BIST_FAIL_H 0xfff00000 | ||
253 | #define FLD_FLTRN_BIST_FAIL_H 0x00180000 | ||
254 | #define FLD_VID_BIST_FAIL_H 0x00070000 | ||
255 | #define FLD_AUD_BIST_TST_DONE 0x0000fff0 | ||
256 | #define FLD_FLTRN_BIST_TST_DONE 0x00000008 | ||
257 | #define FLD_VID_BIST_TST_DONE 0x00000007 | ||
258 | |||
259 | /*****************************************************************************/ | ||
260 | /* DirectIF registers definition have been moved to DIF_reg.h */ | ||
261 | /*****************************************************************************/ | ||
262 | #define MODE_CTRL 0x400 | ||
263 | #define FLD_AFD_PAL60_DIS 0x20000000 | ||
264 | #define FLD_AFD_FORCE_SECAM 0x10000000 | ||
265 | #define FLD_AFD_FORCE_PALNC 0x08000000 | ||
266 | #define FLD_AFD_FORCE_PAL 0x04000000 | ||
267 | #define FLD_AFD_PALM_SEL 0x03000000 | ||
268 | #define FLD_CKILL_MODE 0x00300000 | ||
269 | #define FLD_COMB_NOTCH_MODE 0x00c00000 /* bit[19:18] */ | ||
270 | #define FLD_CLR_LOCK_STAT 0x00020000 | ||
271 | #define FLD_FAST_LOCK_MD 0x00010000 | ||
272 | #define FLD_WCEN 0x00008000 | ||
273 | #define FLD_CAGCEN 0x00004000 | ||
274 | #define FLD_CKILLEN 0x00002000 | ||
275 | #define FLD_AUTO_SC_LOCK 0x00001000 | ||
276 | #define FLD_MAN_SC_FAST_LOCK 0x00000800 | ||
277 | #define FLD_INPUT_MODE 0x00000600 | ||
278 | #define FLD_AFD_ACQUIRE 0x00000100 | ||
279 | #define FLD_AFD_NTSC_SEL 0x00000080 | ||
280 | #define FLD_AFD_PAL_SEL 0x00000040 | ||
281 | #define FLD_ACFG_DIS 0x00000020 | ||
282 | #define FLD_SQ_PIXEL 0x00000010 | ||
283 | #define FLD_VID_FMT_SEL 0x0000000f | ||
284 | |||
285 | /*****************************************************************************/ | ||
286 | #define OUT_CTRL1 0x404 | ||
287 | #define FLD_POLAR 0x7f000000 | ||
288 | /* Reserved [23] */ | ||
289 | #define FLD_RND_MODE 0x00600000 | ||
290 | #define FLD_VIPCLAMP_EN 0x00100000 | ||
291 | #define FLD_VIPBLANK_EN 0x00080000 | ||
292 | #define FLD_VIP_OPT_AL 0x00040000 | ||
293 | #define FLD_IDID0_SOURCE 0x00020000 | ||
294 | #define FLD_DCMODE 0x00010000 | ||
295 | #define FLD_CLK_GATING 0x0000c000 | ||
296 | #define FLD_CLK_INVERT 0x00002000 | ||
297 | #define FLD_HSFMT 0x00001000 | ||
298 | #define FLD_VALIDFMT 0x00000800 | ||
299 | #define FLD_ACTFMT 0x00000400 | ||
300 | #define FLD_SWAPRAW 0x00000200 | ||
301 | #define FLD_CLAMPRAW_EN 0x00000100 | ||
302 | #define FLD_BLUE_FIELD_EN 0x00000080 | ||
303 | #define FLD_BLUE_FIELD_ACT 0x00000040 | ||
304 | #define FLD_TASKBIT_VAL 0x00000020 | ||
305 | #define FLD_ANC_DATA_EN 0x00000010 | ||
306 | #define FLD_VBIHACTRAW_EN 0x00000008 | ||
307 | #define FLD_MODE10B 0x00000004 | ||
308 | #define FLD_OUT_MODE 0x00000003 | ||
309 | |||
310 | /*****************************************************************************/ | ||
311 | #define OUT_CTRL2 0x408 | ||
312 | #define FLD_AUD_GRP 0xc0000000 | ||
313 | #define FLD_SAMPLE_RATE 0x30000000 | ||
314 | #define FLD_AUD_ANC_EN 0x08000000 | ||
315 | #define FLD_EN_C 0x04000000 | ||
316 | #define FLD_EN_B 0x02000000 | ||
317 | #define FLD_EN_A 0x01000000 | ||
318 | /* Reserved [23:20] */ | ||
319 | #define FLD_IDID1_LSB 0x000c0000 | ||
320 | #define FLD_IDID0_LSB 0x00030000 | ||
321 | #define FLD_IDID1_MSB 0x0000ff00 | ||
322 | #define FLD_IDID0_MSB 0x000000ff | ||
323 | |||
324 | /*****************************************************************************/ | ||
325 | #define GEN_STAT 0x40c | ||
326 | #define FLD_VCR_DETECT 0x00800000 | ||
327 | #define FLD_SPECIAL_PLAY_N 0x00400000 | ||
328 | #define FLD_VPRES 0x00200000 | ||
329 | #define FLD_AGC_LOCK 0x00100000 | ||
330 | #define FLD_CSC_LOCK 0x00080000 | ||
331 | #define FLD_VLOCK 0x00040000 | ||
332 | #define FLD_SRC_LOCK 0x00020000 | ||
333 | #define FLD_HLOCK 0x00010000 | ||
334 | #define FLD_VSYNC_N 0x00008000 | ||
335 | #define FLD_SRC_FIFO_UFLOW 0x00004000 | ||
336 | #define FLD_SRC_FIFO_OFLOW 0x00002000 | ||
337 | #define FLD_FIELD 0x00001000 | ||
338 | #define FLD_AFD_FMT_STAT 0x00000f00 | ||
339 | #define FLD_MV_TYPE2_PAIR 0x00000080 | ||
340 | #define FLD_MV_T3CS 0x00000040 | ||
341 | #define FLD_MV_CS 0x00000020 | ||
342 | #define FLD_MV_PSP 0x00000010 | ||
343 | /* Reserved [3] */ | ||
344 | #define FLD_MV_CDAT 0x00000003 | ||
345 | |||
346 | /*****************************************************************************/ | ||
347 | #define INT_STAT_MASK 0x410 | ||
348 | #define FLD_COMB_3D_FIFO_MSK 0x80000000 | ||
349 | #define FLD_WSS_DAT_AVAIL_MSK 0x40000000 | ||
350 | #define FLD_GS2_DAT_AVAIL_MSK 0x20000000 | ||
351 | #define FLD_GS1_DAT_AVAIL_MSK 0x10000000 | ||
352 | #define FLD_CC_DAT_AVAIL_MSK 0x08000000 | ||
353 | #define FLD_VPRES_CHANGE_MSK 0x04000000 | ||
354 | #define FLD_MV_CHANGE_MSK 0x02000000 | ||
355 | #define FLD_END_VBI_EVEN_MSK 0x01000000 | ||
356 | #define FLD_END_VBI_ODD_MSK 0x00800000 | ||
357 | #define FLD_FMT_CHANGE_MSK 0x00400000 | ||
358 | #define FLD_VSYNC_TRAIL_MSK 0x00200000 | ||
359 | #define FLD_HLOCK_CHANGE_MSK 0x00100000 | ||
360 | #define FLD_VLOCK_CHANGE_MSK 0x00080000 | ||
361 | #define FLD_CSC_LOCK_CHANGE_MSK 0x00040000 | ||
362 | #define FLD_SRC_FIFO_UFLOW_MSK 0x00020000 | ||
363 | #define FLD_SRC_FIFO_OFLOW_MSK 0x00010000 | ||
364 | #define FLD_COMB_3D_FIFO_STAT 0x00008000 | ||
365 | #define FLD_WSS_DAT_AVAIL_STAT 0x00004000 | ||
366 | #define FLD_GS2_DAT_AVAIL_STAT 0x00002000 | ||
367 | #define FLD_GS1_DAT_AVAIL_STAT 0x00001000 | ||
368 | #define FLD_CC_DAT_AVAIL_STAT 0x00000800 | ||
369 | #define FLD_VPRES_CHANGE_STAT 0x00000400 | ||
370 | #define FLD_MV_CHANGE_STAT 0x00000200 | ||
371 | #define FLD_END_VBI_EVEN_STAT 0x00000100 | ||
372 | #define FLD_END_VBI_ODD_STAT 0x00000080 | ||
373 | #define FLD_FMT_CHANGE_STAT 0x00000040 | ||
374 | #define FLD_VSYNC_TRAIL_STAT 0x00000020 | ||
375 | #define FLD_HLOCK_CHANGE_STAT 0x00000010 | ||
376 | #define FLD_VLOCK_CHANGE_STAT 0x00000008 | ||
377 | #define FLD_CSC_LOCK_CHANGE_STAT 0x00000004 | ||
378 | #define FLD_SRC_FIFO_UFLOW_STAT 0x00000002 | ||
379 | #define FLD_SRC_FIFO_OFLOW_STAT 0x00000001 | ||
380 | |||
381 | /*****************************************************************************/ | ||
382 | #define LUMA_CTRL 0x414 | ||
383 | #define BRIGHTNESS_CTRL_BYTE 0x414 | ||
384 | #define CONTRAST_CTRL_BYTE 0x415 | ||
385 | #define LUMA_CTRL_BYTE_3 0x416 | ||
386 | #define FLD_LUMA_CORE_SEL 0x00c00000 | ||
387 | #define FLD_RANGE 0x00300000 | ||
388 | /* Reserved [19] */ | ||
389 | #define FLD_PEAK_EN 0x00040000 | ||
390 | #define FLD_PEAK_SEL 0x00030000 | ||
391 | #define FLD_CNTRST 0x0000ff00 | ||
392 | #define FLD_BRITE 0x000000ff | ||
393 | |||
394 | /*****************************************************************************/ | ||
395 | #define HSCALE_CTRL 0x418 | ||
396 | #define FLD_HFILT 0x03000000 | ||
397 | #define FLD_HSCALE 0x00ffffff | ||
398 | |||
399 | /*****************************************************************************/ | ||
400 | #define VSCALE_CTRL 0x41c | ||
401 | #define FLD_LINE_AVG_DIS 0x01000000 | ||
402 | /* Reserved [23:20] */ | ||
403 | #define FLD_VS_INTRLACE 0x00080000 | ||
404 | #define FLD_VFILT 0x00070000 | ||
405 | /* Reserved [15:13] */ | ||
406 | #define FLD_VSCALE 0x00001fff | ||
407 | |||
408 | /*****************************************************************************/ | ||
409 | #define CHROMA_CTRL 0x420 | ||
410 | #define USAT_CTRL_BYTE 0x420 | ||
411 | #define VSAT_CTRL_BYTE 0x421 | ||
412 | #define HUE_CTRL_BYTE 0x422 | ||
413 | #define FLD_C_LPF_EN 0x20000000 | ||
414 | #define FLD_CHR_DELAY 0x1c000000 | ||
415 | #define FLD_C_CORE_SEL 0x03000000 | ||
416 | #define FLD_HUE 0x00ff0000 | ||
417 | #define FLD_VSAT 0x0000ff00 | ||
418 | #define FLD_USAT 0x000000ff | ||
419 | |||
420 | /*****************************************************************************/ | ||
421 | #define VBI_LINE_CTRL1 0x424 | ||
422 | #define FLD_VBI_MD_LINE4 0xff000000 | ||
423 | #define FLD_VBI_MD_LINE3 0x00ff0000 | ||
424 | #define FLD_VBI_MD_LINE2 0x0000ff00 | ||
425 | #define FLD_VBI_MD_LINE1 0x000000ff | ||
426 | |||
427 | /*****************************************************************************/ | ||
428 | #define VBI_LINE_CTRL2 0x428 | ||
429 | #define FLD_VBI_MD_LINE8 0xff000000 | ||
430 | #define FLD_VBI_MD_LINE7 0x00ff0000 | ||
431 | #define FLD_VBI_MD_LINE6 0x0000ff00 | ||
432 | #define FLD_VBI_MD_LINE5 0x000000ff | ||
433 | |||
434 | /*****************************************************************************/ | ||
435 | #define VBI_LINE_CTRL3 0x42c | ||
436 | #define FLD_VBI_MD_LINE12 0xff000000 | ||
437 | #define FLD_VBI_MD_LINE11 0x00ff0000 | ||
438 | #define FLD_VBI_MD_LINE10 0x0000ff00 | ||
439 | #define FLD_VBI_MD_LINE9 0x000000ff | ||
440 | |||
441 | /*****************************************************************************/ | ||
442 | #define VBI_LINE_CTRL4 0x430 | ||
443 | #define FLD_VBI_MD_LINE16 0xff000000 | ||
444 | #define FLD_VBI_MD_LINE15 0x00ff0000 | ||
445 | #define FLD_VBI_MD_LINE14 0x0000ff00 | ||
446 | #define FLD_VBI_MD_LINE13 0x000000ff | ||
447 | |||
448 | /*****************************************************************************/ | ||
449 | #define VBI_LINE_CTRL5 0x434 | ||
450 | #define FLD_VBI_MD_LINE17 0x000000ff | ||
451 | |||
452 | /*****************************************************************************/ | ||
453 | #define VBI_FC_CFG 0x438 | ||
454 | #define FLD_FC_ALT2 0xff000000 | ||
455 | #define FLD_FC_ALT1 0x00ff0000 | ||
456 | #define FLD_FC_ALT2_TYPE 0x0000f000 | ||
457 | #define FLD_FC_ALT1_TYPE 0x00000f00 | ||
458 | /* Reserved [7:1] */ | ||
459 | #define FLD_FC_SEARCH_MODE 0x00000001 | ||
460 | |||
461 | /*****************************************************************************/ | ||
462 | #define VBI_MISC_CFG1 0x43c | ||
463 | #define FLD_TTX_PKTADRU 0xfff00000 | ||
464 | #define FLD_TTX_PKTADRL 0x000fff00 | ||
465 | /* Reserved [7:6] */ | ||
466 | #define FLD_MOJI_PACK_DIS 0x00000020 | ||
467 | #define FLD_VPS_DEC_DIS 0x00000010 | ||
468 | #define FLD_CRI_MARG_SCALE 0x0000000c | ||
469 | #define FLD_EDGE_RESYNC_EN 0x00000002 | ||
470 | #define FLD_ADAPT_SLICE_DIS 0x00000001 | ||
471 | |||
472 | /*****************************************************************************/ | ||
473 | #define VBI_MISC_CFG2 0x440 | ||
474 | #define FLD_HAMMING_TYPE 0x0f000000 | ||
475 | /* Reserved [23:20] */ | ||
476 | #define FLD_WSS_FIFO_RST 0x00080000 | ||
477 | #define FLD_GS2_FIFO_RST 0x00040000 | ||
478 | #define FLD_GS1_FIFO_RST 0x00020000 | ||
479 | #define FLD_CC_FIFO_RST 0x00010000 | ||
480 | /* Reserved [15:12] */ | ||
481 | #define FLD_VBI3_SDID 0x00000f00 | ||
482 | #define FLD_VBI2_SDID 0x000000f0 | ||
483 | #define FLD_VBI1_SDID 0x0000000f | ||
484 | |||
485 | /*****************************************************************************/ | ||
486 | #define VBI_PAY1 0x444 | ||
487 | #define FLD_GS1_FIFO_DAT 0xFF000000 | ||
488 | #define FLD_GS1_STAT 0x00FF0000 | ||
489 | #define FLD_CC_FIFO_DAT 0x0000FF00 | ||
490 | #define FLD_CC_STAT 0x000000FF | ||
491 | |||
492 | /*****************************************************************************/ | ||
493 | #define VBI_PAY2 0x448 | ||
494 | #define FLD_WSS_FIFO_DAT 0xff000000 | ||
495 | #define FLD_WSS_STAT 0x00ff0000 | ||
496 | #define FLD_GS2_FIFO_DAT 0x0000ff00 | ||
497 | #define FLD_GS2_STAT 0x000000ff | ||
498 | |||
499 | /*****************************************************************************/ | ||
500 | #define VBI_CUST1_CFG1 0x44c | ||
501 | /* Reserved [31] */ | ||
502 | #define FLD_VBI1_CRIWIN 0x7f000000 | ||
503 | #define FLD_VBI1_SLICE_DIST 0x00f00000 | ||
504 | #define FLD_VBI1_BITINC 0x000fff00 | ||
505 | #define FLD_VBI1_HDELAY 0x000000ff | ||
506 | |||
507 | /*****************************************************************************/ | ||
508 | #define VBI_CUST1_CFG2 0x450 | ||
509 | #define FLD_VBI1_FC_LENGTH 0x1f000000 | ||
510 | #define FLD_VBI1_FRAME_CODE 0x00ffffff | ||
511 | |||
512 | /*****************************************************************************/ | ||
513 | #define VBI_CUST1_CFG3 0x454 | ||
514 | #define FLD_VBI1_HAM_EN 0x80000000 | ||
515 | #define FLD_VBI1_FIFO_MODE 0x70000000 | ||
516 | #define FLD_VBI1_FORMAT_TYPE 0x0f000000 | ||
517 | #define FLD_VBI1_PAYLD_LENGTH 0x00ff0000 | ||
518 | #define FLD_VBI1_CRI_LENGTH 0x0000f000 | ||
519 | #define FLD_VBI1_CRI_MARGIN 0x00000f00 | ||
520 | #define FLD_VBI1_CRI_TIME 0x000000ff | ||
521 | |||
522 | /*****************************************************************************/ | ||
523 | #define VBI_CUST2_CFG1 0x458 | ||
524 | /* Reserved [31] */ | ||
525 | #define FLD_VBI2_CRIWIN 0x7f000000 | ||
526 | #define FLD_VBI2_SLICE_DIST 0x00f00000 | ||
527 | #define FLD_VBI2_BITINC 0x000fff00 | ||
528 | #define FLD_VBI2_HDELAY 0x000000ff | ||
529 | |||
530 | /*****************************************************************************/ | ||
531 | #define VBI_CUST2_CFG2 0x45c | ||
532 | #define FLD_VBI2_FC_LENGTH 0x1f000000 | ||
533 | #define FLD_VBI2_FRAME_CODE 0x00ffffff | ||
534 | |||
535 | /*****************************************************************************/ | ||
536 | #define VBI_CUST2_CFG3 0x460 | ||
537 | #define FLD_VBI2_HAM_EN 0x80000000 | ||
538 | #define FLD_VBI2_FIFO_MODE 0x70000000 | ||
539 | #define FLD_VBI2_FORMAT_TYPE 0x0f000000 | ||
540 | #define FLD_VBI2_PAYLD_LENGTH 0x00ff0000 | ||
541 | #define FLD_VBI2_CRI_LENGTH 0x0000f000 | ||
542 | #define FLD_VBI2_CRI_MARGIN 0x00000f00 | ||
543 | #define FLD_VBI2_CRI_TIME 0x000000ff | ||
544 | |||
545 | /*****************************************************************************/ | ||
546 | #define VBI_CUST3_CFG1 0x464 | ||
547 | /* Reserved [31] */ | ||
548 | #define FLD_VBI3_CRIWIN 0x7f000000 | ||
549 | #define FLD_VBI3_SLICE_DIST 0x00f00000 | ||
550 | #define FLD_VBI3_BITINC 0x000fff00 | ||
551 | #define FLD_VBI3_HDELAY 0x000000ff | ||
552 | |||
553 | /*****************************************************************************/ | ||
554 | #define VBI_CUST3_CFG2 0x468 | ||
555 | #define FLD_VBI3_FC_LENGTH 0x1f000000 | ||
556 | #define FLD_VBI3_FRAME_CODE 0x00ffffff | ||
557 | |||
558 | /*****************************************************************************/ | ||
559 | #define VBI_CUST3_CFG3 0x46c | ||
560 | #define FLD_VBI3_HAM_EN 0x80000000 | ||
561 | #define FLD_VBI3_FIFO_MODE 0x70000000 | ||
562 | #define FLD_VBI3_FORMAT_TYPE 0x0f000000 | ||
563 | #define FLD_VBI3_PAYLD_LENGTH 0x00ff0000 | ||
564 | #define FLD_VBI3_CRI_LENGTH 0x0000f000 | ||
565 | #define FLD_VBI3_CRI_MARGIN 0x00000f00 | ||
566 | #define FLD_VBI3_CRI_TIME 0x000000ff | ||
567 | |||
568 | /*****************************************************************************/ | ||
569 | #define HORIZ_TIM_CTRL 0x470 | ||
570 | #define FLD_BGDEL_CNT 0xff000000 | ||
571 | /* Reserved [23:22] */ | ||
572 | #define FLD_HACTIVE_CNT 0x003ff000 | ||
573 | /* Reserved [11:10] */ | ||
574 | #define FLD_HBLANK_CNT 0x000003ff | ||
575 | |||
576 | /*****************************************************************************/ | ||
577 | #define VERT_TIM_CTRL 0x474 | ||
578 | #define FLD_V656BLANK_CNT 0xff000000 | ||
579 | /* Reserved [23:22] */ | ||
580 | #define FLD_VACTIVE_CNT 0x003ff000 | ||
581 | /* Reserved [11:10] */ | ||
582 | #define FLD_VBLANK_CNT 0x000003ff | ||
583 | |||
584 | /*****************************************************************************/ | ||
585 | #define SRC_COMB_CFG 0x478 | ||
586 | #define FLD_CCOMB_2LN_CHECK 0x80000000 | ||
587 | #define FLD_CCOMB_3LN_EN 0x40000000 | ||
588 | #define FLD_CCOMB_2LN_EN 0x20000000 | ||
589 | #define FLD_CCOMB_3D_EN 0x10000000 | ||
590 | /* Reserved [27] */ | ||
591 | #define FLD_LCOMB_3LN_EN 0x04000000 | ||
592 | #define FLD_LCOMB_2LN_EN 0x02000000 | ||
593 | #define FLD_LCOMB_3D_EN 0x01000000 | ||
594 | #define FLD_LUMA_LPF_SEL 0x00c00000 | ||
595 | #define FLD_UV_LPF_SEL 0x00300000 | ||
596 | #define FLD_BLEND_SLOPE 0x000f0000 | ||
597 | #define FLD_CCOMB_REDUCE_EN 0x00008000 | ||
598 | /* Reserved [14:10] */ | ||
599 | #define FLD_SRC_DECIM_RATIO 0x000003ff | ||
600 | |||
601 | /*****************************************************************************/ | ||
602 | #define CHROMA_VBIOFF_CFG 0x47c | ||
603 | #define FLD_VBI_VOFFSET 0x1f000000 | ||
604 | /* Reserved [23:20] */ | ||
605 | #define FLD_SC_STEP 0x000fffff | ||
606 | |||
607 | /*****************************************************************************/ | ||
608 | #define FIELD_COUNT 0x480 | ||
609 | #define FLD_FIELD_COUNT_FLD 0x000003ff | ||
610 | |||
611 | /*****************************************************************************/ | ||
612 | #define MISC_TIM_CTRL 0x484 | ||
613 | #define FLD_DEBOUNCE_COUNT 0xc0000000 | ||
614 | #define FLD_VT_LINE_CNT_HYST 0x30000000 | ||
615 | /* Reserved [27] */ | ||
616 | #define FLD_AFD_STAT 0x07ff0000 | ||
617 | #define FLD_VPRES_VERT_EN 0x00008000 | ||
618 | /* Reserved [14:12] */ | ||
619 | #define FLD_HR32 0x00000800 | ||
620 | #define FLD_TDALGN 0x00000400 | ||
621 | #define FLD_TDFIELD 0x00000200 | ||
622 | /* Reserved [8:6] */ | ||
623 | #define FLD_TEMPDEC 0x0000003f | ||
624 | |||
625 | /*****************************************************************************/ | ||
626 | #define DFE_CTRL1 0x488 | ||
627 | #define FLD_CLAMP_AUTO_EN 0x80000000 | ||
628 | #define FLD_AGC_AUTO_EN 0x40000000 | ||
629 | #define FLD_VGA_CRUSH_EN 0x20000000 | ||
630 | #define FLD_VGA_AUTO_EN 0x10000000 | ||
631 | #define FLD_VBI_GATE_EN 0x08000000 | ||
632 | #define FLD_CLAMP_LEVEL 0x07000000 | ||
633 | /* Reserved [23:22] */ | ||
634 | #define FLD_CLAMP_SKIP_CNT 0x00300000 | ||
635 | #define FLD_AGC_GAIN 0x000fff00 | ||
636 | /* Reserved [7:6] */ | ||
637 | #define FLD_VGA_GAIN 0x0000003f | ||
638 | |||
639 | /*****************************************************************************/ | ||
640 | #define DFE_CTRL2 0x48c | ||
641 | #define FLD_VGA_ACQUIRE_RANGE 0x00ff0000 | ||
642 | #define FLD_VGA_TRACK_RANGE 0x0000ff00 | ||
643 | #define FLD_VGA_SYNC 0x000000ff | ||
644 | |||
645 | /*****************************************************************************/ | ||
646 | #define DFE_CTRL3 0x490 | ||
647 | #define FLD_BP_PERCENT 0xff000000 | ||
648 | #define FLD_DFT_THRESHOLD 0x00ff0000 | ||
649 | /* Reserved [15:12] */ | ||
650 | #define FLD_SYNC_WIDTH_SEL 0x00000600 | ||
651 | #define FLD_BP_LOOP_GAIN 0x00000300 | ||
652 | #define FLD_SYNC_LOOP_GAIN 0x000000c0 | ||
653 | /* Reserved [5:4] */ | ||
654 | #define FLD_AGC_LOOP_GAIN 0x0000000c | ||
655 | #define FLD_DCC_LOOP_GAIN 0x00000003 | ||
656 | |||
657 | /*****************************************************************************/ | ||
658 | #define PLL_CTRL 0x494 | ||
659 | #define FLD_PLL_KD 0xff000000 | ||
660 | #define FLD_PLL_KI 0x00ff0000 | ||
661 | #define FLD_PLL_MAX_OFFSET 0x0000ffff | ||
662 | |||
663 | /*****************************************************************************/ | ||
664 | #define HTL_CTRL 0x498 | ||
665 | /* Reserved [31:24] */ | ||
666 | #define FLD_AUTO_LOCK_SPD 0x00080000 | ||
667 | #define FLD_MAN_FAST_LOCK 0x00040000 | ||
668 | #define FLD_HTL_15K_EN 0x00020000 | ||
669 | #define FLD_HTL_500K_EN 0x00010000 | ||
670 | #define FLD_HTL_KD 0x0000ff00 | ||
671 | #define FLD_HTL_KI 0x000000ff | ||
672 | |||
673 | /*****************************************************************************/ | ||
674 | #define COMB_CTRL 0x49c | ||
675 | #define FLD_COMB_PHASE_LIMIT 0xff000000 | ||
676 | #define FLD_CCOMB_ERR_LIMIT 0x00ff0000 | ||
677 | #define FLD_LUMA_THRESHOLD 0x0000ff00 | ||
678 | #define FLD_LCOMB_ERR_LIMIT 0x000000ff | ||
679 | |||
680 | /*****************************************************************************/ | ||
681 | #define CRUSH_CTRL 0x4a0 | ||
682 | #define FLD_WTW_EN 0x00400000 | ||
683 | #define FLD_CRUSH_FREQ 0x00200000 | ||
684 | #define FLD_MAJ_SEL_EN 0x00100000 | ||
685 | #define FLD_MAJ_SEL 0x000c0000 | ||
686 | /* Reserved [17:15] */ | ||
687 | #define FLD_SYNC_TIP_REDUCE 0x00007e00 | ||
688 | /* Reserved [8:6] */ | ||
689 | #define FLD_SYNC_TIP_INC 0x0000003f | ||
690 | |||
691 | /*****************************************************************************/ | ||
692 | #define SOFT_RST_CTRL 0x4a4 | ||
693 | #define FLD_VD_SOFT_RST 0x00008000 | ||
694 | /* Reserved [14:12] */ | ||
695 | #define FLD_REG_RST_MSK 0x00000800 | ||
696 | #define FLD_VOF_RST_MSK 0x00000400 | ||
697 | #define FLD_MVDET_RST_MSK 0x00000200 | ||
698 | #define FLD_VBI_RST_MSK 0x00000100 | ||
699 | #define FLD_SCALE_RST_MSK 0x00000080 | ||
700 | #define FLD_CHROMA_RST_MSK 0x00000040 | ||
701 | #define FLD_LUMA_RST_MSK 0x00000020 | ||
702 | #define FLD_VTG_RST_MSK 0x00000010 | ||
703 | #define FLD_YCSEP_RST_MSK 0x00000008 | ||
704 | #define FLD_SRC_RST_MSK 0x00000004 | ||
705 | #define FLD_DFE_RST_MSK 0x00000002 | ||
706 | /* Reserved [0] */ | ||
707 | |||
708 | /*****************************************************************************/ | ||
709 | #define MV_DT_CTRL1 0x4a8 | ||
710 | /* Reserved [31:29] */ | ||
711 | #define FLD_PSP_STOP_LINE 0x1f000000 | ||
712 | /* Reserved [23:21] */ | ||
713 | #define FLD_PSP_STRT_LINE 0x001f0000 | ||
714 | /* Reserved [15] */ | ||
715 | #define FLD_PSP_LLIMW 0x00007f00 | ||
716 | /* Reserved [7] */ | ||
717 | #define FLD_PSP_ULIMW 0x0000007f | ||
718 | |||
719 | /*****************************************************************************/ | ||
720 | #define MV_DT_CTRL2 0x4aC | ||
721 | #define FLD_CS_STOPWIN 0xff000000 | ||
722 | #define FLD_CS_STRTWIN 0x00ff0000 | ||
723 | #define FLD_CS_WIDTH 0x0000ff00 | ||
724 | #define FLD_PSP_SPEC_VAL 0x000000ff | ||
725 | |||
726 | /*****************************************************************************/ | ||
727 | #define MV_DT_CTRL3 0x4B0 | ||
728 | #define FLD_AUTO_RATE_DIS 0x80000000 | ||
729 | #define FLD_HLOCK_DIS 0x40000000 | ||
730 | #define FLD_SEL_FIELD_CNT 0x20000000 | ||
731 | #define FLD_CS_TYPE2_SEL 0x10000000 | ||
732 | #define FLD_CS_LINE_THRSH_SEL 0x08000000 | ||
733 | #define FLD_CS_ATHRESH_SEL 0x04000000 | ||
734 | #define FLD_PSP_SPEC_SEL 0x02000000 | ||
735 | #define FLD_PSP_LINES_SEL 0x01000000 | ||
736 | #define FLD_FIELD_CNT 0x00f00000 | ||
737 | #define FLD_CS_TYPE2_CNT 0x000fc000 | ||
738 | #define FLD_CS_LINE_CNT 0x00003f00 | ||
739 | #define FLD_CS_ATHRESH_LEV 0x000000ff | ||
740 | |||
741 | /*****************************************************************************/ | ||
742 | #define CHIP_VERSION 0x4b4 | ||
743 | /* Cx231xx redefine */ | ||
744 | #define VERSION 0x4b4 | ||
745 | #define FLD_REV_ID 0x000000ff | ||
746 | |||
747 | /*****************************************************************************/ | ||
748 | #define MISC_DIAG_CTRL 0x4b8 | ||
749 | /* Reserved [31:24] */ | ||
750 | #define FLD_SC_CONVERGE_THRESH 0x00ff0000 | ||
751 | #define FLD_CCOMB_ERR_LIMIT_3D 0x0000ff00 | ||
752 | #define FLD_LCOMB_ERR_LIMIT_3D 0x000000ff | ||
753 | |||
754 | /*****************************************************************************/ | ||
755 | #define VBI_PASS_CTRL 0x4bc | ||
756 | #define FLD_VBI_PASS_MD 0x00200000 | ||
757 | #define FLD_VBI_SETUP_DIS 0x00100000 | ||
758 | #define FLD_PASS_LINE_CTRL 0x000fffff | ||
759 | |||
760 | /*****************************************************************************/ | ||
761 | /* Cx231xx redefine */ | ||
762 | #define VCR_DET_CTRL 0x4c0 | ||
763 | #define FLD_EN_FIELD_PHASE_DET 0x80000000 | ||
764 | #define FLD_EN_HEAD_SW_DET 0x40000000 | ||
765 | #define FLD_FIELD_PHASE_LENGTH 0x01ff0000 | ||
766 | /* Reserved [29:25] */ | ||
767 | #define FLD_FIELD_PHASE_DELAY 0x0000ff00 | ||
768 | #define FLD_FIELD_PHASE_LIMIT 0x000000f0 | ||
769 | #define FLD_HEAD_SW_DET_LIMIT 0x0000000f | ||
770 | |||
771 | /*****************************************************************************/ | ||
772 | #define DL_CTL 0x800 | ||
773 | #define DL_CTL_ADDRESS_LOW 0x800 /* Byte 1 in DL_CTL */ | ||
774 | #define DL_CTL_ADDRESS_HIGH 0x801 /* Byte 2 in DL_CTL */ | ||
775 | #define DL_CTL_DATA 0x802 /* Byte 3 in DL_CTL */ | ||
776 | #define DL_CTL_CONTROL 0x803 /* Byte 4 in DL_CTL */ | ||
777 | /* Reserved [31:5] */ | ||
778 | #define FLD_START_8051 0x10000000 | ||
779 | #define FLD_DL_ENABLE 0x08000000 | ||
780 | #define FLD_DL_AUTO_INC 0x04000000 | ||
781 | #define FLD_DL_MAP 0x03000000 | ||
782 | |||
783 | /*****************************************************************************/ | ||
784 | #define STD_DET_STATUS 0x804 | ||
785 | #define FLD_SPARE_STATUS1 0xff000000 | ||
786 | #define FLD_SPARE_STATUS0 0x00ff0000 | ||
787 | #define FLD_MOD_DET_STATUS1 0x0000ff00 | ||
788 | #define FLD_MOD_DET_STATUS0 0x000000ff | ||
789 | |||
790 | /*****************************************************************************/ | ||
791 | #define AUD_BUILD_NUM 0x806 | ||
792 | #define AUD_VER_NUM 0x807 | ||
793 | #define STD_DET_CTL 0x808 | ||
794 | #define STD_DET_CTL_AUD_CTL 0x808 /* Byte 1 in STD_DET_CTL */ | ||
795 | #define STD_DET_CTL_PREF_MODE 0x809 /* Byte 2 in STD_DET_CTL */ | ||
796 | #define FLD_SPARE_CTL0 0xff000000 | ||
797 | #define FLD_DIS_DBX 0x00800000 | ||
798 | #define FLD_DIS_BTSC 0x00400000 | ||
799 | #define FLD_DIS_NICAM_A2 0x00200000 | ||
800 | #define FLD_VIDEO_PRESENT 0x00100000 | ||
801 | #define FLD_DW8051_VIDEO_FORMAT 0x000f0000 | ||
802 | #define FLD_PREF_DEC_MODE 0x0000ff00 | ||
803 | #define FLD_AUD_CONFIG 0x000000ff | ||
804 | |||
805 | /*****************************************************************************/ | ||
806 | #define DW8051_INT 0x80c | ||
807 | #define FLD_VIDEO_PRESENT_CHANGE 0x80000000 | ||
808 | #define FLD_VIDEO_CHANGE 0x40000000 | ||
809 | #define FLD_RDS_READY 0x20000000 | ||
810 | #define FLD_AC97_INT 0x10000000 | ||
811 | #define FLD_NICAM_BIT_ERROR_TOO_HIGH 0x08000000 | ||
812 | #define FLD_NICAM_LOCK 0x04000000 | ||
813 | #define FLD_NICAM_UNLOCK 0x02000000 | ||
814 | #define FLD_DFT4_TH_CMP 0x01000000 | ||
815 | /* Reserved [23:22] */ | ||
816 | #define FLD_LOCK_IND_INT 0x00200000 | ||
817 | #define FLD_DFT3_TH_CMP 0x00100000 | ||
818 | #define FLD_DFT2_TH_CMP 0x00080000 | ||
819 | #define FLD_DFT1_TH_CMP 0x00040000 | ||
820 | #define FLD_FM2_DFT_TH_CMP 0x00020000 | ||
821 | #define FLD_FM1_DFT_TH_CMP 0x00010000 | ||
822 | #define FLD_VIDEO_PRESENT_EN 0x00008000 | ||
823 | #define FLD_VIDEO_CHANGE_EN 0x00004000 | ||
824 | #define FLD_RDS_READY_EN 0x00002000 | ||
825 | #define FLD_AC97_INT_EN 0x00001000 | ||
826 | #define FLD_NICAM_BIT_ERROR_TOO_HIGH_EN 0x00000800 | ||
827 | #define FLD_NICAM_LOCK_EN 0x00000400 | ||
828 | #define FLD_NICAM_UNLOCK_EN 0x00000200 | ||
829 | #define FLD_DFT4_TH_CMP_EN 0x00000100 | ||
830 | /* Reserved [7] */ | ||
831 | #define FLD_DW8051_INT6_CTL1 0x00000040 | ||
832 | #define FLD_DW8051_INT5_CTL1 0x00000020 | ||
833 | #define FLD_DW8051_INT4_CTL1 0x00000010 | ||
834 | #define FLD_DW8051_INT3_CTL1 0x00000008 | ||
835 | #define FLD_DW8051_INT2_CTL1 0x00000004 | ||
836 | #define FLD_DW8051_INT1_CTL1 0x00000002 | ||
837 | #define FLD_DW8051_INT0_CTL1 0x00000001 | ||
838 | |||
839 | /*****************************************************************************/ | ||
840 | #define GENERAL_CTL 0x810 | ||
841 | #define FLD_RDS_INT 0x80000000 | ||
842 | #define FLD_NBER_INT 0x40000000 | ||
843 | #define FLD_NLL_INT 0x20000000 | ||
844 | #define FLD_IFL_INT 0x10000000 | ||
845 | #define FLD_FDL_INT 0x08000000 | ||
846 | #define FLD_AFC_INT 0x04000000 | ||
847 | #define FLD_AMC_INT 0x02000000 | ||
848 | #define FLD_AC97_INT_CTL 0x01000000 | ||
849 | #define FLD_RDS_INT_DIS 0x00800000 | ||
850 | #define FLD_NBER_INT_DIS 0x00400000 | ||
851 | #define FLD_NLL_INT_DIS 0x00200000 | ||
852 | #define FLD_IFL_INT_DIS 0x00100000 | ||
853 | #define FLD_FDL_INT_DIS 0x00080000 | ||
854 | #define FLD_FC_INT_DIS 0x00040000 | ||
855 | #define FLD_AMC_INT_DIS 0x00020000 | ||
856 | #define FLD_AC97_INT_DIS 0x00010000 | ||
857 | #define FLD_REV_NUM 0x0000ff00 | ||
858 | /* Reserved [7:5] */ | ||
859 | #define FLD_DBX_SOFT_RESET_REG 0x00000010 | ||
860 | #define FLD_AD_SOFT_RESET_REG 0x00000008 | ||
861 | #define FLD_SRC_SOFT_RESET_REG 0x00000004 | ||
862 | #define FLD_CDMOD_SOFT_RESET 0x00000002 | ||
863 | #define FLD_8051_SOFT_RESET 0x00000001 | ||
864 | |||
865 | /*****************************************************************************/ | ||
866 | #define AAGC_CTL 0x814 | ||
867 | #define FLD_AFE_12DB_EN 0x80000000 | ||
868 | #define FLD_AAGC_DEFAULT_EN 0x40000000 | ||
869 | #define FLD_AAGC_DEFAULT 0x3f000000 | ||
870 | /* Reserved [23] */ | ||
871 | #define FLD_AAGC_GAIN 0x00600000 | ||
872 | #define FLD_AAGC_TH 0x001f0000 | ||
873 | /* Reserved [15:14] */ | ||
874 | #define FLD_AAGC_HYST2 0x00003f00 | ||
875 | /* Reserved [7:6] */ | ||
876 | #define FLD_AAGC_HYST1 0x0000003f | ||
877 | |||
878 | /*****************************************************************************/ | ||
879 | #define IF_SRC_CTL 0x818 | ||
880 | #define FLD_DBX_BYPASS 0x80000000 | ||
881 | /* Reserved [30:25] */ | ||
882 | #define FLD_IF_SRC_MODE 0x01000000 | ||
883 | /* Reserved [23:18] */ | ||
884 | #define FLD_IF_SRC_PHASE_INC 0x0001ffff | ||
885 | |||
886 | /*****************************************************************************/ | ||
887 | #define ANALOG_DEMOD_CTL 0x81c | ||
888 | #define FLD_ROT1_PHACC_PROG 0xffff0000 | ||
889 | /* Reserved [15] */ | ||
890 | #define FLD_FM1_DELAY_FIX 0x00007000 | ||
891 | #define FLD_PDF4_SHIFT 0x00000c00 | ||
892 | #define FLD_PDF3_SHIFT 0x00000300 | ||
893 | #define FLD_PDF2_SHIFT 0x000000c0 | ||
894 | #define FLD_PDF1_SHIFT 0x00000030 | ||
895 | #define FLD_FMBYPASS_MODE2 0x00000008 | ||
896 | #define FLD_FMBYPASS_MODE1 0x00000004 | ||
897 | #define FLD_NICAM_MODE 0x00000002 | ||
898 | #define FLD_BTSC_FMRADIO_MODE 0x00000001 | ||
899 | |||
900 | /*****************************************************************************/ | ||
901 | #define ROT_FREQ_CTL 0x820 | ||
902 | #define FLD_ROT3_PHACC_PROG 0xffff0000 | ||
903 | #define FLD_ROT2_PHACC_PROG 0x0000ffff | ||
904 | |||
905 | /*****************************************************************************/ | ||
906 | #define FM_CTL 0x824 | ||
907 | #define FLD_FM2_DC_FB_SHIFT 0xf0000000 | ||
908 | #define FLD_FM2_DC_INT_SHIFT 0x0f000000 | ||
909 | #define FLD_FM2_AFC_RESET 0x00800000 | ||
910 | #define FLD_FM2_DC_PASS_IN 0x00400000 | ||
911 | #define FLD_FM2_DAGC_SHIFT 0x00380000 | ||
912 | #define FLD_FM2_CORDIC_SHIFT 0x00070000 | ||
913 | #define FLD_FM1_DC_FB_SHIFT 0x0000f000 | ||
914 | #define FLD_FM1_DC_INT_SHIFT 0x00000f00 | ||
915 | #define FLD_FM1_AFC_RESET 0x00000080 | ||
916 | #define FLD_FM1_DC_PASS_IN 0x00000040 | ||
917 | #define FLD_FM1_DAGC_SHIFT 0x00000038 | ||
918 | #define FLD_FM1_CORDIC_SHIFT 0x00000007 | ||
919 | |||
920 | /*****************************************************************************/ | ||
921 | #define LPF_PDF_CTL 0x828 | ||
922 | /* Reserved [31:30] */ | ||
923 | #define FLD_LPF32_SHIFT1 0x30000000 | ||
924 | #define FLD_LPF32_SHIFT2 0x0c000000 | ||
925 | #define FLD_LPF160_SHIFTA 0x03000000 | ||
926 | #define FLD_LPF160_SHIFTB 0x00c00000 | ||
927 | #define FLD_LPF160_SHIFTC 0x00300000 | ||
928 | #define FLD_LPF32_COEF_SEL2 0x000c0000 | ||
929 | #define FLD_LPF32_COEF_SEL1 0x00030000 | ||
930 | #define FLD_LPF160_COEF_SELC 0x0000c000 | ||
931 | #define FLD_LPF160_COEF_SELB 0x00003000 | ||
932 | #define FLD_LPF160_COEF_SELA 0x00000c00 | ||
933 | #define FLD_LPF160_IN_EN_REG 0x00000300 | ||
934 | #define FLD_PDF4_PDF_SEL 0x000000c0 | ||
935 | #define FLD_PDF3_PDF_SEL 0x00000030 | ||
936 | #define FLD_PDF2_PDF_SEL 0x0000000c | ||
937 | #define FLD_PDF1_PDF_SEL 0x00000003 | ||
938 | |||
939 | /*****************************************************************************/ | ||
940 | #define DFT1_CTL1 0x82c | ||
941 | #define FLD_DFT1_DWELL 0xffff0000 | ||
942 | #define FLD_DFT1_FREQ 0x0000ffff | ||
943 | |||
944 | /*****************************************************************************/ | ||
945 | #define DFT1_CTL2 0x830 | ||
946 | #define FLD_DFT1_THRESHOLD 0xffffff00 | ||
947 | #define FLD_DFT1_CMP_CTL 0x00000080 | ||
948 | #define FLD_DFT1_AVG 0x00000070 | ||
949 | /* Reserved [3:1] */ | ||
950 | #define FLD_DFT1_START 0x00000001 | ||
951 | |||
952 | /*****************************************************************************/ | ||
953 | #define DFT1_STATUS 0x834 | ||
954 | #define FLD_DFT1_DONE 0x80000000 | ||
955 | #define FLD_DFT1_TH_CMP_STAT 0x40000000 | ||
956 | #define FLD_DFT1_RESULT 0x3fffffff | ||
957 | |||
958 | /*****************************************************************************/ | ||
959 | #define DFT2_CTL1 0x838 | ||
960 | #define FLD_DFT2_DWELL 0xffff0000 | ||
961 | #define FLD_DFT2_FREQ 0x0000ffff | ||
962 | |||
963 | /*****************************************************************************/ | ||
964 | #define DFT2_CTL2 0x83C | ||
965 | #define FLD_DFT2_THRESHOLD 0xffffff00 | ||
966 | #define FLD_DFT2_CMP_CTL 0x00000080 | ||
967 | #define FLD_DFT2_AVG 0x00000070 | ||
968 | /* Reserved [3:1] */ | ||
969 | #define FLD_DFT2_START 0x00000001 | ||
970 | |||
971 | /*****************************************************************************/ | ||
972 | #define DFT2_STATUS 0x840 | ||
973 | #define FLD_DFT2_DONE 0x80000000 | ||
974 | #define FLD_DFT2_TH_CMP_STAT 0x40000000 | ||
975 | #define FLD_DFT2_RESULT 0x3fffffff | ||
976 | |||
977 | /*****************************************************************************/ | ||
978 | #define DFT3_CTL1 0x844 | ||
979 | #define FLD_DFT3_DWELL 0xffff0000 | ||
980 | #define FLD_DFT3_FREQ 0x0000ffff | ||
981 | |||
982 | /*****************************************************************************/ | ||
983 | #define DFT3_CTL2 0x848 | ||
984 | #define FLD_DFT3_THRESHOLD 0xffffff00 | ||
985 | #define FLD_DFT3_CMP_CTL 0x00000080 | ||
986 | #define FLD_DFT3_AVG 0x00000070 | ||
987 | /* Reserved [3:1] */ | ||
988 | #define FLD_DFT3_START 0x00000001 | ||
989 | |||
990 | /*****************************************************************************/ | ||
991 | #define DFT3_STATUS 0x84c | ||
992 | #define FLD_DFT3_DONE 0x80000000 | ||
993 | #define FLD_DFT3_TH_CMP_STAT 0x40000000 | ||
994 | #define FLD_DFT3_RESULT 0x3fffffff | ||
995 | |||
996 | /*****************************************************************************/ | ||
997 | #define DFT4_CTL1 0x850 | ||
998 | #define FLD_DFT4_DWELL 0xffff0000 | ||
999 | #define FLD_DFT4_FREQ 0x0000ffff | ||
1000 | |||
1001 | /*****************************************************************************/ | ||
1002 | #define DFT4_CTL2 0x854 | ||
1003 | #define FLD_DFT4_THRESHOLD 0xffffff00 | ||
1004 | #define FLD_DFT4_CMP_CTL 0x00000080 | ||
1005 | #define FLD_DFT4_AVG 0x00000070 | ||
1006 | /* Reserved [3:1] */ | ||
1007 | #define FLD_DFT4_START 0x00000001 | ||
1008 | |||
1009 | /*****************************************************************************/ | ||
1010 | #define DFT4_STATUS 0x858 | ||
1011 | #define FLD_DFT4_DONE 0x80000000 | ||
1012 | #define FLD_DFT4_TH_CMP_STAT 0x40000000 | ||
1013 | #define FLD_DFT4_RESULT 0x3fffffff | ||
1014 | |||
1015 | /*****************************************************************************/ | ||
1016 | #define AM_MTS_DET 0x85c | ||
1017 | #define FLD_AM_MTS_MODE 0x80000000 | ||
1018 | /* Reserved [30:26] */ | ||
1019 | #define FLD_AM_SUB 0x02000000 | ||
1020 | #define FLD_AM_GAIN_EN 0x01000000 | ||
1021 | /* Reserved [23:16] */ | ||
1022 | #define FLD_AMMTS_GAIN_SCALE 0x0000e000 | ||
1023 | #define FLD_MTS_PDF_SHIFT 0x00001800 | ||
1024 | #define FLD_AM_REG_GAIN 0x00000700 | ||
1025 | #define FLD_AGC_REF 0x000000ff | ||
1026 | |||
1027 | /*****************************************************************************/ | ||
1028 | #define ANALOG_MUX_CTL 0x860 | ||
1029 | /* Reserved [31:29] */ | ||
1030 | #define FLD_MUX21_SEL 0x10000000 | ||
1031 | #define FLD_MUX20_SEL 0x08000000 | ||
1032 | #define FLD_MUX19_SEL 0x04000000 | ||
1033 | #define FLD_MUX18_SEL 0x02000000 | ||
1034 | #define FLD_MUX17_SEL 0x01000000 | ||
1035 | #define FLD_MUX16_SEL 0x00800000 | ||
1036 | #define FLD_MUX15_SEL 0x00400000 | ||
1037 | #define FLD_MUX14_SEL 0x00300000 | ||
1038 | #define FLD_MUX13_SEL 0x000C0000 | ||
1039 | #define FLD_MUX12_SEL 0x00020000 | ||
1040 | #define FLD_MUX11_SEL 0x00018000 | ||
1041 | #define FLD_MUX10_SEL 0x00004000 | ||
1042 | #define FLD_MUX9_SEL 0x00002000 | ||
1043 | #define FLD_MUX8_SEL 0x00001000 | ||
1044 | #define FLD_MUX7_SEL 0x00000800 | ||
1045 | #define FLD_MUX6_SEL 0x00000600 | ||
1046 | #define FLD_MUX5_SEL 0x00000100 | ||
1047 | #define FLD_MUX4_SEL 0x000000c0 | ||
1048 | #define FLD_MUX3_SEL 0x00000030 | ||
1049 | #define FLD_MUX2_SEL 0x0000000c | ||
1050 | #define FLD_MUX1_SEL 0x00000003 | ||
1051 | |||
1052 | /*****************************************************************************/ | ||
1053 | /* Cx231xx redefine */ | ||
1054 | #define DPLL_CTRL1 0x864 | ||
1055 | #define DIG_PLL_CTL1 0x864 | ||
1056 | |||
1057 | #define FLD_PLL_STATUS 0x07000000 | ||
1058 | #define FLD_BANDWIDTH_SELECT 0x00030000 | ||
1059 | #define FLD_PLL_SHIFT_REG 0x00007000 | ||
1060 | #define FLD_PHASE_SHIFT 0x000007ff | ||
1061 | |||
1062 | /*****************************************************************************/ | ||
1063 | /* Cx231xx redefine */ | ||
1064 | #define DPLL_CTRL2 0x868 | ||
1065 | #define DIG_PLL_CTL2 0x868 | ||
1066 | #define FLD_PLL_UNLOCK_THR 0xff000000 | ||
1067 | #define FLD_PLL_LOCK_THR 0x00ff0000 | ||
1068 | /* Reserved [15:8] */ | ||
1069 | #define FLD_AM_PDF_SEL2 0x000000c0 | ||
1070 | #define FLD_AM_PDF_SEL1 0x00000030 | ||
1071 | #define FLD_DPLL_FSM_CTRL 0x0000000c | ||
1072 | /* Reserved [1] */ | ||
1073 | #define FLD_PLL_PILOT_DET 0x00000001 | ||
1074 | |||
1075 | /*****************************************************************************/ | ||
1076 | /* Cx231xx redefine */ | ||
1077 | #define DPLL_CTRL3 0x86c | ||
1078 | #define DIG_PLL_CTL3 0x86c | ||
1079 | #define FLD_DISABLE_LOOP 0x01000000 | ||
1080 | #define FLD_A1_DS1_SEL 0x000c0000 | ||
1081 | #define FLD_A1_DS2_SEL 0x00030000 | ||
1082 | #define FLD_A1_KI 0x0000ff00 | ||
1083 | #define FLD_A1_KD 0x000000ff | ||
1084 | |||
1085 | /*****************************************************************************/ | ||
1086 | /* Cx231xx redefine */ | ||
1087 | #define DPLL_CTRL4 0x870 | ||
1088 | #define DIG_PLL_CTL4 0x870 | ||
1089 | #define FLD_A2_DS1_SEL 0x000c0000 | ||
1090 | #define FLD_A2_DS2_SEL 0x00030000 | ||
1091 | #define FLD_A2_KI 0x0000ff00 | ||
1092 | #define FLD_A2_KD 0x000000ff | ||
1093 | |||
1094 | /*****************************************************************************/ | ||
1095 | /* Cx231xx redefine */ | ||
1096 | #define DPLL_CTRL5 0x874 | ||
1097 | #define DIG_PLL_CTL5 0x874 | ||
1098 | #define FLD_TRK_DS1_SEL 0x000c0000 | ||
1099 | #define FLD_TRK_DS2_SEL 0x00030000 | ||
1100 | #define FLD_TRK_KI 0x0000ff00 | ||
1101 | #define FLD_TRK_KD 0x000000ff | ||
1102 | |||
1103 | /*****************************************************************************/ | ||
1104 | #define DEEMPH_GAIN_CTL 0x878 | ||
1105 | #define FLD_DEEMPH2_GAIN 0xFFFF0000 | ||
1106 | #define FLD_DEEMPH1_GAIN 0x0000FFFF | ||
1107 | |||
1108 | /*****************************************************************************/ | ||
1109 | /* Cx231xx redefine */ | ||
1110 | #define DEEMPH_COEFF1 0x87c | ||
1111 | #define DEEMPH_COEF1 0x87c | ||
1112 | #define FLD_DEEMPH_B0 0xffff0000 | ||
1113 | #define FLD_DEEMPH_A0 0x0000ffff | ||
1114 | |||
1115 | /*****************************************************************************/ | ||
1116 | /* Cx231xx redefine */ | ||
1117 | #define DEEMPH_COEFF2 0x880 | ||
1118 | #define DEEMPH_COEF2 0x880 | ||
1119 | #define FLD_DEEMPH_B1 0xFFFF0000 | ||
1120 | #define FLD_DEEMPH_A1 0x0000FFFF | ||
1121 | |||
1122 | /*****************************************************************************/ | ||
1123 | #define DBX1_CTL1 0x884 | ||
1124 | #define FLD_DBX1_WBE_GAIN 0xffff0000 | ||
1125 | #define FLD_DBX1_IN_GAIN 0x0000ffff | ||
1126 | |||
1127 | /*****************************************************************************/ | ||
1128 | #define DBX1_CTL2 0x888 | ||
1129 | #define FLD_DBX1_SE_BYPASS 0xffff0000 | ||
1130 | #define FLD_DBX1_SE_GAIN 0x0000ffff | ||
1131 | |||
1132 | /*****************************************************************************/ | ||
1133 | #define DBX1_RMS_SE 0x88C | ||
1134 | #define FLD_DBX1_RMS_WBE 0xffff0000 | ||
1135 | #define FLD_DBX1_RMS_SE_FLD 0x0000ffff | ||
1136 | |||
1137 | /*****************************************************************************/ | ||
1138 | #define DBX2_CTL1 0x890 | ||
1139 | #define FLD_DBX2_WBE_GAIN 0xffff0000 | ||
1140 | #define FLD_DBX2_IN_GAIN 0x0000ffff | ||
1141 | |||
1142 | /*****************************************************************************/ | ||
1143 | #define DBX2_CTL2 0x894 | ||
1144 | #define FLD_DBX2_SE_BYPASS 0xffff0000 | ||
1145 | #define FLD_DBX2_SE_GAIN 0x0000ffff | ||
1146 | |||
1147 | /*****************************************************************************/ | ||
1148 | #define DBX2_RMS_SE 0x898 | ||
1149 | #define FLD_DBX2_RMS_WBE 0xffff0000 | ||
1150 | #define FLD_DBX2_RMS_SE_FLD 0x0000ffff | ||
1151 | |||
1152 | /*****************************************************************************/ | ||
1153 | #define AM_FM_DIFF 0x89c | ||
1154 | /* Reserved [31] */ | ||
1155 | #define FLD_FM_DIFF_OUT 0x7fff0000 | ||
1156 | /* Reserved [15] */ | ||
1157 | #define FLD_AM_DIFF_OUT 0x00007fff | ||
1158 | |||
1159 | /*****************************************************************************/ | ||
1160 | #define NICAM_FAW 0x8a0 | ||
1161 | #define FLD_FAWDETWINEND 0xFc000000 | ||
1162 | #define FLD_FAWDETWINSTR 0x03ff0000 | ||
1163 | /* Reserved [15:12] */ | ||
1164 | #define FLD_FAWDETTHRSHLD3 0x00000f00 | ||
1165 | #define FLD_FAWDETTHRSHLD2 0x000000f0 | ||
1166 | #define FLD_FAWDETTHRSHLD1 0x0000000f | ||
1167 | |||
1168 | /*****************************************************************************/ | ||
1169 | /* Cx231xx redefine */ | ||
1170 | #define DEEMPH_GAIN 0x8a4 | ||
1171 | #define NICAM_DEEMPHGAIN 0x8a4 | ||
1172 | /* Reserved [31:18] */ | ||
1173 | #define FLD_DEEMPHGAIN 0x0003ffff | ||
1174 | |||
1175 | /*****************************************************************************/ | ||
1176 | /* Cx231xx redefine */ | ||
1177 | #define DEEMPH_NUMER1 0x8a8 | ||
1178 | #define NICAM_DEEMPHNUMER1 0x8a8 | ||
1179 | /* Reserved [31:18] */ | ||
1180 | #define FLD_DEEMPHNUMER1 0x0003ffff | ||
1181 | |||
1182 | /*****************************************************************************/ | ||
1183 | /* Cx231xx redefine */ | ||
1184 | #define DEEMPH_NUMER2 0x8ac | ||
1185 | #define NICAM_DEEMPHNUMER2 0x8ac | ||
1186 | /* Reserved [31:18] */ | ||
1187 | #define FLD_DEEMPHNUMER2 0x0003ffff | ||
1188 | |||
1189 | /*****************************************************************************/ | ||
1190 | /* Cx231xx redefine */ | ||
1191 | #define DEEMPH_DENOM1 0x8b0 | ||
1192 | #define NICAM_DEEMPHDENOM1 0x8b0 | ||
1193 | /* Reserved [31:18] */ | ||
1194 | #define FLD_DEEMPHDENOM1 0x0003ffff | ||
1195 | |||
1196 | /*****************************************************************************/ | ||
1197 | /* Cx231xx redefine */ | ||
1198 | #define DEEMPH_DENOM2 0x8b4 | ||
1199 | #define NICAM_DEEMPHDENOM2 0x8b4 | ||
1200 | /* Reserved [31:18] */ | ||
1201 | #define FLD_DEEMPHDENOM2 0x0003ffff | ||
1202 | |||
1203 | /*****************************************************************************/ | ||
1204 | #define NICAM_ERRLOG_CTL1 0x8B8 | ||
1205 | /* Reserved [31:28] */ | ||
1206 | #define FLD_ERRINTRPTTHSHLD1 0x0fff0000 | ||
1207 | /* Reserved [15:12] */ | ||
1208 | #define FLD_ERRLOGPERIOD 0x00000fff | ||
1209 | |||
1210 | /*****************************************************************************/ | ||
1211 | #define NICAM_ERRLOG_CTL2 0x8bc | ||
1212 | /* Reserved [31:28] */ | ||
1213 | #define FLD_ERRINTRPTTHSHLD3 0x0fff0000 | ||
1214 | /* Reserved [15:12] */ | ||
1215 | #define FLD_ERRINTRPTTHSHLD2 0x00000fff | ||
1216 | |||
1217 | /*****************************************************************************/ | ||
1218 | #define NICAM_ERRLOG_STS1 0x8c0 | ||
1219 | /* Reserved [31:28] */ | ||
1220 | #define FLD_ERRLOG2 0x0fff0000 | ||
1221 | /* Reserved [15:12] */ | ||
1222 | #define FLD_ERRLOG1 0x00000fff | ||
1223 | |||
1224 | /*****************************************************************************/ | ||
1225 | #define NICAM_ERRLOG_STS2 0x8c4 | ||
1226 | /* Reserved [31:12] */ | ||
1227 | #define FLD_ERRLOG3 0x00000fff | ||
1228 | |||
1229 | /*****************************************************************************/ | ||
1230 | #define NICAM_STATUS 0x8c8 | ||
1231 | /* Reserved [31:20] */ | ||
1232 | #define FLD_NICAM_CIB 0x000c0000 | ||
1233 | #define FLD_NICAM_LOCK_STAT 0x00020000 | ||
1234 | #define FLD_NICAM_MUTE 0x00010000 | ||
1235 | #define FLD_NICAMADDIT_DATA 0x0000ffe0 | ||
1236 | #define FLD_NICAMCNTRL 0x0000001f | ||
1237 | |||
1238 | /*****************************************************************************/ | ||
1239 | #define DEMATRIX_CTL 0x8cc | ||
1240 | #define FLD_AC97_IN_SHIFT 0xf0000000 | ||
1241 | #define FLD_I2S_IN_SHIFT 0x0f000000 | ||
1242 | #define FLD_DEMATRIX_SEL_CTL 0x00ff0000 | ||
1243 | /* Reserved [15:11] */ | ||
1244 | #define FLD_DMTRX_BYPASS 0x00000400 | ||
1245 | #define FLD_DEMATRIX_MODE 0x00000300 | ||
1246 | /* Reserved [7:6] */ | ||
1247 | #define FLD_PH_DBX_SEL 0x00000020 | ||
1248 | #define FLD_PH_CH_SEL 0x00000010 | ||
1249 | #define FLD_PHASE_FIX 0x0000000f | ||
1250 | |||
1251 | /*****************************************************************************/ | ||
1252 | #define PATH1_CTL1 0x8d0 | ||
1253 | /* Reserved [31:29] */ | ||
1254 | #define FLD_PATH1_MUTE_CTL 0x1f000000 | ||
1255 | /* Reserved [23:22] */ | ||
1256 | #define FLD_PATH1_AVC_CG 0x00300000 | ||
1257 | #define FLD_PATH1_AVC_RT 0x000f0000 | ||
1258 | #define FLD_PATH1_AVC_AT 0x0000f000 | ||
1259 | #define FLD_PATH1_AVC_STEREO 0x00000800 | ||
1260 | #define FLD_PATH1_AVC_CR 0x00000700 | ||
1261 | #define FLD_PATH1_AVC_RMS_CON 0x000000f0 | ||
1262 | #define FLD_PATH1_SEL_CTL 0x0000000f | ||
1263 | |||
1264 | /*****************************************************************************/ | ||
1265 | #define PATH1_VOL_CTL 0x8d4 | ||
1266 | #define FLD_PATH1_AVC_THRESHOLD 0x7fff0000 | ||
1267 | #define FLD_PATH1_BAL_LEFT 0x00008000 | ||
1268 | #define FLD_PATH1_BAL_LEVEL 0x00007f00 | ||
1269 | #define FLD_PATH1_VOLUME 0x000000ff | ||
1270 | |||
1271 | /*****************************************************************************/ | ||
1272 | #define PATH1_EQ_CTL 0x8d8 | ||
1273 | /* Reserved [31:30] */ | ||
1274 | #define FLD_PATH1_EQ_TREBLE_VOL 0x3f000000 | ||
1275 | /* Reserved [23:22] */ | ||
1276 | #define FLD_PATH1_EQ_MID_VOL 0x003f0000 | ||
1277 | /* Reserved [15:14] */ | ||
1278 | #define FLD_PATH1_EQ_BASS_VOL 0x00003f00 | ||
1279 | /* Reserved [7:1] */ | ||
1280 | #define FLD_PATH1_EQ_BAND_SEL 0x00000001 | ||
1281 | |||
1282 | /*****************************************************************************/ | ||
1283 | #define PATH1_SC_CTL 0x8dc | ||
1284 | #define FLD_PATH1_SC_THRESHOLD 0x7fff0000 | ||
1285 | #define FLD_PATH1_SC_RT 0x0000f000 | ||
1286 | #define FLD_PATH1_SC_AT 0x00000f00 | ||
1287 | #define FLD_PATH1_SC_STEREO 0x00000080 | ||
1288 | #define FLD_PATH1_SC_CR 0x00000070 | ||
1289 | #define FLD_PATH1_SC_RMS_CON 0x0000000f | ||
1290 | |||
1291 | /*****************************************************************************/ | ||
1292 | #define PATH2_CTL1 0x8e0 | ||
1293 | /* Reserved [31:26] */ | ||
1294 | #define FLD_PATH2_MUTE_CTL 0x03000000 | ||
1295 | /* Reserved [23:22] */ | ||
1296 | #define FLD_PATH2_AVC_CG 0x00300000 | ||
1297 | #define FLD_PATH2_AVC_RT 0x000f0000 | ||
1298 | #define FLD_PATH2_AVC_AT 0x0000f000 | ||
1299 | #define FLD_PATH2_AVC_STEREO 0x00000800 | ||
1300 | #define FLD_PATH2_AVC_CR 0x00000700 | ||
1301 | #define FLD_PATH2_AVC_RMS_CON 0x000000f0 | ||
1302 | #define FLD_PATH2_SEL_CTL 0x0000000f | ||
1303 | |||
1304 | /*****************************************************************************/ | ||
1305 | #define PATH2_VOL_CTL 0x8e4 | ||
1306 | #define FLD_PATH2_AVC_THRESHOLD 0xffff0000 | ||
1307 | #define FLD_PATH2_BAL_LEFT 0x00008000 | ||
1308 | #define FLD_PATH2_BAL_LEVEL 0x00007f00 | ||
1309 | #define FLD_PATH2_VOLUME 0x000000ff | ||
1310 | |||
1311 | /*****************************************************************************/ | ||
1312 | #define PATH2_EQ_CTL 0x8e8 | ||
1313 | /* Reserved [31:30] */ | ||
1314 | #define FLD_PATH2_EQ_TREBLE_VOL 0x3f000000 | ||
1315 | /* Reserved [23:22] */ | ||
1316 | #define FLD_PATH2_EQ_MID_VOL 0x003f0000 | ||
1317 | /* Reserved [15:14] */ | ||
1318 | #define FLD_PATH2_EQ_BASS_VOL 0x00003f00 | ||
1319 | /* Reserved [7:1] */ | ||
1320 | #define FLD_PATH2_EQ_BAND_SEL 0x00000001 | ||
1321 | |||
1322 | /*****************************************************************************/ | ||
1323 | #define PATH2_SC_CTL 0x8eC | ||
1324 | #define FLD_PATH2_SC_THRESHOLD 0xffff0000 | ||
1325 | #define FLD_PATH2_SC_RT 0x0000f000 | ||
1326 | #define FLD_PATH2_SC_AT 0x00000f00 | ||
1327 | #define FLD_PATH2_SC_STEREO 0x00000080 | ||
1328 | #define FLD_PATH2_SC_CR 0x00000070 | ||
1329 | #define FLD_PATH2_SC_RMS_CON 0x0000000f | ||
1330 | |||
1331 | /*****************************************************************************/ | ||
1332 | #define SRC_CTL 0x8f0 | ||
1333 | #define FLD_SRC_STATUS 0xffffff00 | ||
1334 | #define FLD_FIFO_LF_EN 0x000000fc | ||
1335 | #define FLD_BYPASS_LI 0x00000002 | ||
1336 | #define FLD_BYPASS_PF 0x00000001 | ||
1337 | |||
1338 | /*****************************************************************************/ | ||
1339 | #define SRC_LF_COEF 0x8f4 | ||
1340 | #define FLD_LOOP_FILTER_COEF2 0xffff0000 | ||
1341 | #define FLD_LOOP_FILTER_COEF1 0x0000ffff | ||
1342 | |||
1343 | /*****************************************************************************/ | ||
1344 | #define SRC1_CTL 0x8f8 | ||
1345 | /* Reserved [31:28] */ | ||
1346 | #define FLD_SRC1_FIFO_RD_TH 0x0f000000 | ||
1347 | /* Reserved [23:18] */ | ||
1348 | #define FLD_SRC1_PHASE_INC 0x0003ffff | ||
1349 | |||
1350 | /*****************************************************************************/ | ||
1351 | #define SRC2_CTL 0x8fc | ||
1352 | /* Reserved [31:28] */ | ||
1353 | #define FLD_SRC2_FIFO_RD_TH 0x0f000000 | ||
1354 | /* Reserved [23:18] */ | ||
1355 | #define FLD_SRC2_PHASE_INC 0x0003ffff | ||
1356 | |||
1357 | /*****************************************************************************/ | ||
1358 | #define SRC3_CTL 0x900 | ||
1359 | /* Reserved [31:28] */ | ||
1360 | #define FLD_SRC3_FIFO_RD_TH 0x0f000000 | ||
1361 | /* Reserved [23:18] */ | ||
1362 | #define FLD_SRC3_PHASE_INC 0x0003ffff | ||
1363 | |||
1364 | /*****************************************************************************/ | ||
1365 | #define SRC4_CTL 0x904 | ||
1366 | /* Reserved [31:28] */ | ||
1367 | #define FLD_SRC4_FIFO_RD_TH 0x0f000000 | ||
1368 | /* Reserved [23:18] */ | ||
1369 | #define FLD_SRC4_PHASE_INC 0x0003ffff | ||
1370 | |||
1371 | /*****************************************************************************/ | ||
1372 | #define SRC5_CTL 0x908 | ||
1373 | /* Reserved [31:28] */ | ||
1374 | #define FLD_SRC5_FIFO_RD_TH 0x0f000000 | ||
1375 | /* Reserved [23:18] */ | ||
1376 | #define FLD_SRC5_PHASE_INC 0x0003ffff | ||
1377 | |||
1378 | /*****************************************************************************/ | ||
1379 | #define SRC6_CTL 0x90c | ||
1380 | /* Reserved [31:28] */ | ||
1381 | #define FLD_SRC6_FIFO_RD_TH 0x0f000000 | ||
1382 | /* Reserved [23:18] */ | ||
1383 | #define FLD_SRC6_PHASE_INC 0x0003ffff | ||
1384 | |||
1385 | /*****************************************************************************/ | ||
1386 | #define BAND_OUT_SEL 0x910 | ||
1387 | #define FLD_SRC6_IN_SEL 0xc0000000 | ||
1388 | #define FLD_SRC6_CLK_SEL 0x30000000 | ||
1389 | #define FLD_SRC5_IN_SEL 0x0c000000 | ||
1390 | #define FLD_SRC5_CLK_SEL 0x03000000 | ||
1391 | #define FLD_SRC4_IN_SEL 0x00c00000 | ||
1392 | #define FLD_SRC4_CLK_SEL 0x00300000 | ||
1393 | #define FLD_SRC3_IN_SEL 0x000c0000 | ||
1394 | #define FLD_SRC3_CLK_SEL 0x00030000 | ||
1395 | #define FLD_BASEBAND_BYPASS_CTL 0x0000ff00 | ||
1396 | #define FLD_AC97_SRC_SEL 0x000000c0 | ||
1397 | #define FLD_I2S_SRC_SEL 0x00000030 | ||
1398 | #define FLD_PARALLEL2_SRC_SEL 0x0000000c | ||
1399 | #define FLD_PARALLEL1_SRC_SEL 0x00000003 | ||
1400 | |||
1401 | /*****************************************************************************/ | ||
1402 | #define I2S_IN_CTL 0x914 | ||
1403 | /* Reserved [31:11] */ | ||
1404 | #define FLD_I2S_UP2X_BW20K 0x00000400 | ||
1405 | #define FLD_I2S_UP2X_BYPASS 0x00000200 | ||
1406 | #define FLD_I2S_IN_MASTER_MODE 0x00000100 | ||
1407 | #define FLD_I2S_IN_SONY_MODE 0x00000080 | ||
1408 | #define FLD_I2S_IN_RIGHT_JUST 0x00000040 | ||
1409 | #define FLD_I2S_IN_WS_SEL 0x00000020 | ||
1410 | #define FLD_I2S_IN_BCN_DEL 0x0000001f | ||
1411 | |||
1412 | /*****************************************************************************/ | ||
1413 | #define I2S_OUT_CTL 0x918 | ||
1414 | /* Reserved [31:17] */ | ||
1415 | #define FLD_I2S_OUT_SOFT_RESET_EN 0x00010000 | ||
1416 | /* Reserved [15:9] */ | ||
1417 | #define FLD_I2S_OUT_MASTER_MODE 0x00000100 | ||
1418 | #define FLD_I2S_OUT_SONY_MODE 0x00000080 | ||
1419 | #define FLD_I2S_OUT_RIGHT_JUST 0x00000040 | ||
1420 | #define FLD_I2S_OUT_WS_SEL 0x00000020 | ||
1421 | #define FLD_I2S_OUT_BCN_DEL 0x0000001f | ||
1422 | |||
1423 | /*****************************************************************************/ | ||
1424 | #define AC97_CTL 0x91c | ||
1425 | /* Reserved [31:26] */ | ||
1426 | #define FLD_AC97_UP2X_BW20K 0x02000000 | ||
1427 | #define FLD_AC97_UP2X_BYPASS 0x01000000 | ||
1428 | /* Reserved [23:17] */ | ||
1429 | #define FLD_AC97_RST_ACL 0x00010000 | ||
1430 | /* Reserved [15:9] */ | ||
1431 | #define FLD_AC97_WAKE_UP_SYNC 0x00000100 | ||
1432 | /* Reserved [7:1] */ | ||
1433 | #define FLD_AC97_SHUTDOWN 0x00000001 | ||
1434 | |||
1435 | /* Cx231xx redefine */ | ||
1436 | #define QPSK_IAGC_CTL1 0x94c | ||
1437 | #define QPSK_IAGC_CTL2 0x950 | ||
1438 | #define QPSK_FEPR_FREQ 0x954 | ||
1439 | #define QPSK_BTL_CTL1 0x958 | ||
1440 | #define QPSK_BTL_CTL2 0x95c | ||
1441 | #define QPSK_CTL_CTL1 0x960 | ||
1442 | #define QPSK_CTL_CTL2 0x964 | ||
1443 | #define QPSK_MF_FAGC_CTL 0x968 | ||
1444 | #define QPSK_EQ_CTL 0x96c | ||
1445 | #define QPSK_LOCK_CTL 0x970 | ||
1446 | |||
1447 | /*****************************************************************************/ | ||
1448 | #define FM1_DFT_CTL 0x9a8 | ||
1449 | #define FLD_FM1_DFT_THRESHOLD 0xffff0000 | ||
1450 | /* Reserved [15:8] */ | ||
1451 | #define FLD_FM1_DFT_CMP_CTL 0x00000080 | ||
1452 | #define FLD_FM1_DFT_AVG 0x00000070 | ||
1453 | /* Reserved [3:1] */ | ||
1454 | #define FLD_FM1_DFT_START 0x00000001 | ||
1455 | |||
1456 | /*****************************************************************************/ | ||
1457 | #define FM1_DFT_STATUS 0x9ac | ||
1458 | #define FLD_FM1_DFT_DONE 0x80000000 | ||
1459 | /* Reserved [30:19] */ | ||
1460 | #define FLD_FM_DFT_TH_CMP 0x00040000 | ||
1461 | #define FLD_FM1_DFT 0x0003ffff | ||
1462 | |||
1463 | /*****************************************************************************/ | ||
1464 | #define FM2_DFT_CTL 0x9b0 | ||
1465 | #define FLD_FM2_DFT_THRESHOLD 0xffff0000 | ||
1466 | /* Reserved [15:8] */ | ||
1467 | #define FLD_FM2_DFT_CMP_CTL 0x00000080 | ||
1468 | #define FLD_FM2_DFT_AVG 0x00000070 | ||
1469 | /* Reserved [3:1] */ | ||
1470 | #define FLD_FM2_DFT_START 0x00000001 | ||
1471 | |||
1472 | /*****************************************************************************/ | ||
1473 | #define FM2_DFT_STATUS 0x9b4 | ||
1474 | #define FLD_FM2_DFT_DONE 0x80000000 | ||
1475 | /* Reserved [30:19] */ | ||
1476 | #define FLD_FM2_DFT_TH_CMP_STAT 0x00040000 | ||
1477 | #define FLD_FM2_DFT 0x0003ffff | ||
1478 | |||
1479 | /*****************************************************************************/ | ||
1480 | /* Cx231xx redefine */ | ||
1481 | #define AAGC_STATUS_REG 0x9b8 | ||
1482 | #define AAGC_STATUS 0x9b8 | ||
1483 | /* Reserved [31:27] */ | ||
1484 | #define FLD_FM2_DAGC_OUT 0x07000000 | ||
1485 | /* Reserved [23:19] */ | ||
1486 | #define FLD_FM1_DAGC_OUT 0x00070000 | ||
1487 | /* Reserved [15:6] */ | ||
1488 | #define FLD_AFE_VGA_OUT 0x0000003f | ||
1489 | |||
1490 | /*****************************************************************************/ | ||
1491 | #define MTS_GAIN_STATUS 0x9bc | ||
1492 | /* Reserved [31:14] */ | ||
1493 | #define FLD_MTS_GAIN 0x00003fff | ||
1494 | |||
1495 | #define RDS_OUT 0x9c0 | ||
1496 | #define FLD_RDS_Q 0xffff0000 | ||
1497 | #define FLD_RDS_I 0x0000ffff | ||
1498 | |||
1499 | /*****************************************************************************/ | ||
1500 | #define AUTOCONFIG_REG 0x9c4 | ||
1501 | /* Reserved [31:4] */ | ||
1502 | #define FLD_AUTOCONFIG_MODE 0x0000000f | ||
1503 | |||
1504 | #define FM_AFC 0x9c8 | ||
1505 | #define FLD_FM2_AFC 0xffff0000 | ||
1506 | #define FLD_FM1_AFC 0x0000ffff | ||
1507 | |||
1508 | /*****************************************************************************/ | ||
1509 | /* Cx231xx redefine */ | ||
1510 | #define NEW_SPARE 0x9cc | ||
1511 | #define NEW_SPARE_REG 0x9cc | ||
1512 | |||
1513 | /*****************************************************************************/ | ||
1514 | #define DBX_ADJ 0x9d0 | ||
1515 | /* Reserved [31:28] */ | ||
1516 | #define FLD_DBX2_ADJ 0x0fff0000 | ||
1517 | /* Reserved [15:12] */ | ||
1518 | #define FLD_DBX1_ADJ 0x00000fff | ||
1519 | |||
1520 | #define VID_FMT_AUTO 0 | ||
1521 | #define VID_FMT_NTSC_M 1 | ||
1522 | #define VID_FMT_NTSC_J 2 | ||
1523 | #define VID_FMT_NTSC_443 3 | ||
1524 | #define VID_FMT_PAL_BDGHI 4 | ||
1525 | #define VID_FMT_PAL_M 5 | ||
1526 | #define VID_FMT_PAL_N 6 | ||
1527 | #define VID_FMT_PAL_NC 7 | ||
1528 | #define VID_FMT_PAL_60 8 | ||
1529 | #define VID_FMT_SECAM 12 | ||
1530 | #define VID_FMT_SECAM_60 13 | ||
1531 | |||
1532 | #define INPUT_MODE_CVBS_0 0 /* INPUT_MODE_VALUE(0) */ | ||
1533 | #define INPUT_MODE_YC_1 1 /* INPUT_MODE_VALUE(1) */ | ||
1534 | #define INPUT_MODE_YC2_2 2 /* INPUT_MODE_VALUE(2) */ | ||
1535 | #define INPUT_MODE_YUV_3 3 /* INPUT_MODE_VALUE(3) */ | ||
1536 | |||
1537 | #define LUMA_LPF_LOW_BANDPASS 0 /* 0.6Mhz LPF BW */ | ||
1538 | #define LUMA_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz LPF BW */ | ||
1539 | #define LUMA_LPF_HIGH_BANDPASS 2 /* 1.5Mhz LPF BW */ | ||
1540 | |||
1541 | #define UV_LPF_LOW_BANDPASS 0 /* 0.6Mhz LPF BW */ | ||
1542 | #define UV_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz LPF BW */ | ||
1543 | #define UV_LPF_HIGH_BANDPASS 2 /* 1.5Mhz LPF BW */ | ||
1544 | |||
1545 | #define TWO_TAP_FILT 0 | ||
1546 | #define THREE_TAP_FILT 1 | ||
1547 | #define FOUR_TAP_FILT 2 | ||
1548 | #define FIVE_TAP_FILT 3 | ||
1549 | |||
1550 | #define AUD_CHAN_SRC_PARALLEL 0 | ||
1551 | #define AUD_CHAN_SRC_I2S_INPUT 1 | ||
1552 | #define AUD_CHAN_SRC_FLATIRON 2 | ||
1553 | #define AUD_CHAN_SRC_PARALLEL3 3 | ||
1554 | |||
1555 | #define OUT_MODE_601 0 | ||
1556 | #define OUT_MODE_656 1 | ||
1557 | #define OUT_MODE_VIP11 2 | ||
1558 | #define OUT_MODE_VIP20 3 | ||
1559 | |||
1560 | #define PHASE_INC_49MHZ 0x0df22 | ||
1561 | #define PHASE_INC_56MHZ 0x0fa5b | ||
1562 | #define PHASE_INC_28MHZ 0x010000 | ||
1563 | |||
1564 | #endif | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c new file mode 100644 index 000000000000..94180526909c --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-vbi.c | |||
@@ -0,0 +1,701 @@ | |||
1 | /* | ||
2 | cx231xx_vbi.c - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on cx88 driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/bitmap.h> | ||
27 | #include <linux/usb.h> | ||
28 | #include <linux/i2c.h> | ||
29 | #include <linux/version.h> | ||
30 | #include <linux/mm.h> | ||
31 | #include <linux/mutex.h> | ||
32 | |||
33 | #include <media/v4l2-common.h> | ||
34 | #include <media/v4l2-ioctl.h> | ||
35 | #include <media/v4l2-chip-ident.h> | ||
36 | #include <media/msp3400.h> | ||
37 | #include <media/tuner.h> | ||
38 | |||
39 | #include "cx231xx.h" | ||
40 | #include "cx231xx-vbi.h" | ||
41 | |||
42 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
43 | { | ||
44 | char *errmsg = "Unknown"; | ||
45 | |||
46 | switch (status) { | ||
47 | case -ENOENT: | ||
48 | errmsg = "unlinked synchronuously"; | ||
49 | break; | ||
50 | case -ECONNRESET: | ||
51 | errmsg = "unlinked asynchronuously"; | ||
52 | break; | ||
53 | case -ENOSR: | ||
54 | errmsg = "Buffer error (overrun)"; | ||
55 | break; | ||
56 | case -EPIPE: | ||
57 | errmsg = "Stalled (device not responding)"; | ||
58 | break; | ||
59 | case -EOVERFLOW: | ||
60 | errmsg = "Babble (bad cable?)"; | ||
61 | break; | ||
62 | case -EPROTO: | ||
63 | errmsg = "Bit-stuff error (bad cable?)"; | ||
64 | break; | ||
65 | case -EILSEQ: | ||
66 | errmsg = "CRC/Timeout (could be anything)"; | ||
67 | break; | ||
68 | case -ETIME: | ||
69 | errmsg = "Device does not respond"; | ||
70 | break; | ||
71 | } | ||
72 | if (packet < 0) { | ||
73 | cx231xx_err(DRIVER_NAME "URB status %d [%s].\n", status, | ||
74 | errmsg); | ||
75 | } else { | ||
76 | cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n", | ||
77 | packet, status, errmsg); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /* | ||
82 | * Controls the isoc copy of each urb packet | ||
83 | */ | ||
84 | static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) | ||
85 | { | ||
86 | struct cx231xx_buffer *buf; | ||
87 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
88 | int rc = 1; | ||
89 | unsigned char *p_buffer; | ||
90 | u32 bytes_parsed = 0, buffer_size = 0; | ||
91 | u8 sav_eav = 0; | ||
92 | |||
93 | if (!dev) | ||
94 | return 0; | ||
95 | |||
96 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
97 | return 0; | ||
98 | |||
99 | if (urb->status < 0) { | ||
100 | print_err_status(dev, -1, urb->status); | ||
101 | if (urb->status == -ENOENT) | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | buf = dev->vbi_mode.isoc_ctl.buf; | ||
106 | |||
107 | /* get buffer pointer and length */ | ||
108 | p_buffer = urb->transfer_buffer; | ||
109 | buffer_size = urb->actual_length; | ||
110 | |||
111 | if (buffer_size > 0) { | ||
112 | bytes_parsed = 0; | ||
113 | |||
114 | if (dma_q->is_partial_line) { | ||
115 | /* Handle the case where we were working on a partial | ||
116 | line */ | ||
117 | sav_eav = dma_q->last_sav; | ||
118 | } else { | ||
119 | /* Check for a SAV/EAV overlapping the | ||
120 | buffer boundary */ | ||
121 | |||
122 | sav_eav = cx231xx_find_boundary_SAV_EAV(p_buffer, | ||
123 | dma_q->partial_buf, | ||
124 | &bytes_parsed); | ||
125 | } | ||
126 | |||
127 | sav_eav &= 0xF0; | ||
128 | /* Get the first line if we have some portion of an SAV/EAV from | ||
129 | the last buffer or a partial line */ | ||
130 | if (sav_eav) { | ||
131 | bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, | ||
132 | sav_eav, /* SAV/EAV */ | ||
133 | p_buffer + bytes_parsed, /* p_buffer */ | ||
134 | buffer_size - bytes_parsed); /* buffer size */ | ||
135 | } | ||
136 | |||
137 | /* Now parse data that is completely in this buffer */ | ||
138 | dma_q->is_partial_line = 0; | ||
139 | |||
140 | while (bytes_parsed < buffer_size) { | ||
141 | u32 bytes_used = 0; | ||
142 | |||
143 | sav_eav = cx231xx_find_next_SAV_EAV( | ||
144 | p_buffer + bytes_parsed, /* p_buffer */ | ||
145 | buffer_size - bytes_parsed, /* buffer size */ | ||
146 | &bytes_used); /* bytes used to get SAV/EAV */ | ||
147 | |||
148 | bytes_parsed += bytes_used; | ||
149 | |||
150 | sav_eav &= 0xF0; | ||
151 | if (sav_eav && (bytes_parsed < buffer_size)) { | ||
152 | bytes_parsed += cx231xx_get_vbi_line(dev, | ||
153 | dma_q, sav_eav, /* SAV/EAV */ | ||
154 | p_buffer+bytes_parsed, /* p_buffer */ | ||
155 | buffer_size-bytes_parsed);/*buf size*/ | ||
156 | } | ||
157 | } | ||
158 | |||
159 | /* Save the last four bytes of the buffer so we can | ||
160 | check the buffer boundary condition next time */ | ||
161 | memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); | ||
162 | bytes_parsed = 0; | ||
163 | } | ||
164 | |||
165 | return rc; | ||
166 | } | ||
167 | |||
168 | /* ------------------------------------------------------------------ | ||
169 | Vbi buf operations | ||
170 | ------------------------------------------------------------------*/ | ||
171 | |||
172 | static int | ||
173 | vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count, | ||
174 | unsigned int *size) | ||
175 | { | ||
176 | struct cx231xx_fh *fh = vq->priv_data; | ||
177 | struct cx231xx *dev = fh->dev; | ||
178 | u32 height = 0; | ||
179 | |||
180 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
181 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
182 | |||
183 | *size = (dev->width * height * 2); | ||
184 | if (0 == *count) | ||
185 | *count = CX231XX_DEF_VBI_BUF; | ||
186 | |||
187 | if (*count < CX231XX_MIN_BUF) | ||
188 | *count = CX231XX_MIN_BUF; | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | /* This is called *without* dev->slock held; please keep it that way */ | ||
194 | static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) | ||
195 | { | ||
196 | struct cx231xx_fh *fh = vq->priv_data; | ||
197 | struct cx231xx *dev = fh->dev; | ||
198 | unsigned long flags = 0; | ||
199 | if (in_interrupt()) | ||
200 | BUG(); | ||
201 | |||
202 | /* We used to wait for the buffer to finish here, but this didn't work | ||
203 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
204 | videobuf_queue_cancel marked it as finished for us. | ||
205 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
206 | |||
207 | This should be safe; by the time we get here, the buffer isn't | ||
208 | queued anymore. If we ever start marking the buffers as | ||
209 | VIDEOBUF_ACTIVE, it won't be, though. | ||
210 | */ | ||
211 | spin_lock_irqsave(&dev->vbi_mode.slock, flags); | ||
212 | if (dev->vbi_mode.isoc_ctl.buf == buf) | ||
213 | dev->vbi_mode.isoc_ctl.buf = NULL; | ||
214 | spin_unlock_irqrestore(&dev->vbi_mode.slock, flags); | ||
215 | |||
216 | videobuf_vmalloc_free(&buf->vb); | ||
217 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
218 | } | ||
219 | |||
220 | static int | ||
221 | vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
222 | enum v4l2_field field) | ||
223 | { | ||
224 | struct cx231xx_fh *fh = vq->priv_data; | ||
225 | struct cx231xx_buffer *buf = | ||
226 | container_of(vb, struct cx231xx_buffer, vb); | ||
227 | struct cx231xx *dev = fh->dev; | ||
228 | int rc = 0, urb_init = 0; | ||
229 | u32 height = 0; | ||
230 | |||
231 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
232 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
233 | buf->vb.size = ((dev->width << 1) * height); | ||
234 | |||
235 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
236 | return -EINVAL; | ||
237 | |||
238 | buf->vb.width = dev->width; | ||
239 | buf->vb.height = height; | ||
240 | buf->vb.field = field; | ||
241 | buf->vb.field = V4L2_FIELD_SEQ_TB; | ||
242 | |||
243 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
244 | rc = videobuf_iolock(vq, &buf->vb, NULL); | ||
245 | if (rc < 0) | ||
246 | goto fail; | ||
247 | } | ||
248 | |||
249 | if (!dev->vbi_mode.isoc_ctl.num_bufs) | ||
250 | urb_init = 1; | ||
251 | |||
252 | if (urb_init) { | ||
253 | rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS, | ||
254 | CX231XX_NUM_VBI_BUFS, | ||
255 | dev->vbi_mode.alt_max_pkt_size[0], | ||
256 | cx231xx_isoc_vbi_copy); | ||
257 | if (rc < 0) | ||
258 | goto fail; | ||
259 | } | ||
260 | |||
261 | buf->vb.state = VIDEOBUF_PREPARED; | ||
262 | return 0; | ||
263 | |||
264 | fail: | ||
265 | free_buffer(vq, buf); | ||
266 | return rc; | ||
267 | } | ||
268 | |||
269 | static void | ||
270 | vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
271 | { | ||
272 | struct cx231xx_buffer *buf = | ||
273 | container_of(vb, struct cx231xx_buffer, vb); | ||
274 | struct cx231xx_fh *fh = vq->priv_data; | ||
275 | struct cx231xx *dev = fh->dev; | ||
276 | struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq; | ||
277 | |||
278 | buf->vb.state = VIDEOBUF_QUEUED; | ||
279 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
280 | |||
281 | } | ||
282 | |||
283 | static void vbi_buffer_release(struct videobuf_queue *vq, | ||
284 | struct videobuf_buffer *vb) | ||
285 | { | ||
286 | struct cx231xx_buffer *buf = | ||
287 | container_of(vb, struct cx231xx_buffer, vb); | ||
288 | |||
289 | |||
290 | free_buffer(vq, buf); | ||
291 | } | ||
292 | |||
293 | struct videobuf_queue_ops cx231xx_vbi_qops = { | ||
294 | .buf_setup = vbi_buffer_setup, | ||
295 | .buf_prepare = vbi_buffer_prepare, | ||
296 | .buf_queue = vbi_buffer_queue, | ||
297 | .buf_release = vbi_buffer_release, | ||
298 | }; | ||
299 | |||
300 | /* ------------------------------------------------------------------ | ||
301 | URB control | ||
302 | ------------------------------------------------------------------*/ | ||
303 | |||
304 | /* | ||
305 | * IRQ callback, called by URB callback | ||
306 | */ | ||
307 | static void cx231xx_irq_vbi_callback(struct urb *urb) | ||
308 | { | ||
309 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
310 | struct cx231xx_video_mode *vmode = | ||
311 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
312 | struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); | ||
313 | int rc; | ||
314 | |||
315 | switch (urb->status) { | ||
316 | case 0: /* success */ | ||
317 | case -ETIMEDOUT: /* NAK */ | ||
318 | break; | ||
319 | case -ECONNRESET: /* kill */ | ||
320 | case -ENOENT: | ||
321 | case -ESHUTDOWN: | ||
322 | return; | ||
323 | default: /* error */ | ||
324 | cx231xx_err(DRIVER_NAME "urb completition error %d.\n", | ||
325 | urb->status); | ||
326 | break; | ||
327 | } | ||
328 | |||
329 | /* Copy data from URB */ | ||
330 | spin_lock(&dev->vbi_mode.slock); | ||
331 | rc = dev->vbi_mode.isoc_ctl.isoc_copy(dev, urb); | ||
332 | spin_unlock(&dev->vbi_mode.slock); | ||
333 | |||
334 | /* Reset status */ | ||
335 | urb->status = 0; | ||
336 | |||
337 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | ||
338 | if (urb->status) { | ||
339 | cx231xx_err(DRIVER_NAME "urb resubmit failed (error=%i)\n", | ||
340 | urb->status); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * Stop and Deallocate URBs | ||
346 | */ | ||
347 | void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) | ||
348 | { | ||
349 | struct urb *urb; | ||
350 | int i; | ||
351 | |||
352 | cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n"); | ||
353 | |||
354 | dev->vbi_mode.isoc_ctl.nfields = -1; | ||
355 | for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { | ||
356 | urb = dev->vbi_mode.isoc_ctl.urb[i]; | ||
357 | if (urb) { | ||
358 | if (!irqs_disabled()) | ||
359 | usb_kill_urb(urb); | ||
360 | else | ||
361 | usb_unlink_urb(urb); | ||
362 | |||
363 | if (dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { | ||
364 | |||
365 | kfree(dev->vbi_mode.isoc_ctl. | ||
366 | transfer_buffer[i]); | ||
367 | dev->vbi_mode.isoc_ctl.transfer_buffer[i] = | ||
368 | NULL; | ||
369 | } | ||
370 | usb_free_urb(urb); | ||
371 | dev->vbi_mode.isoc_ctl.urb[i] = NULL; | ||
372 | } | ||
373 | dev->vbi_mode.isoc_ctl.transfer_buffer[i] = NULL; | ||
374 | } | ||
375 | |||
376 | kfree(dev->vbi_mode.isoc_ctl.urb); | ||
377 | kfree(dev->vbi_mode.isoc_ctl.transfer_buffer); | ||
378 | |||
379 | dev->vbi_mode.isoc_ctl.urb = NULL; | ||
380 | dev->vbi_mode.isoc_ctl.transfer_buffer = NULL; | ||
381 | dev->vbi_mode.isoc_ctl.num_bufs = 0; | ||
382 | |||
383 | cx231xx_capture_start(dev, 0, Vbi); | ||
384 | } | ||
385 | EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc); | ||
386 | |||
387 | /* | ||
388 | * Allocate URBs and start IRQ | ||
389 | */ | ||
390 | int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | ||
391 | int num_bufs, int max_pkt_size, | ||
392 | int (*isoc_copy) (struct cx231xx *dev, | ||
393 | struct urb *urb)) | ||
394 | { | ||
395 | struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq; | ||
396 | int i; | ||
397 | int sb_size, pipe; | ||
398 | struct urb *urb; | ||
399 | int rc; | ||
400 | |||
401 | cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_prepare_isoc\n"); | ||
402 | |||
403 | /* De-allocates all pending stuff */ | ||
404 | cx231xx_uninit_vbi_isoc(dev); | ||
405 | |||
406 | /* clear if any halt */ | ||
407 | usb_clear_halt(dev->udev, | ||
408 | usb_rcvbulkpipe(dev->udev, | ||
409 | dev->vbi_mode.end_point_addr)); | ||
410 | |||
411 | dev->vbi_mode.isoc_ctl.isoc_copy = isoc_copy; | ||
412 | dev->vbi_mode.isoc_ctl.num_bufs = num_bufs; | ||
413 | dma_q->pos = 0; | ||
414 | dma_q->is_partial_line = 0; | ||
415 | dma_q->last_sav = 0; | ||
416 | dma_q->current_field = -1; | ||
417 | dma_q->bytes_left_in_line = dev->width << 1; | ||
418 | dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ? | ||
419 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
420 | dma_q->lines_completed = 0; | ||
421 | for (i = 0; i < 8; i++) | ||
422 | dma_q->partial_buf[i] = 0; | ||
423 | |||
424 | dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs, | ||
425 | GFP_KERNEL); | ||
426 | if (!dev->vbi_mode.isoc_ctl.urb) { | ||
427 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | ||
428 | return -ENOMEM; | ||
429 | } | ||
430 | |||
431 | dev->vbi_mode.isoc_ctl.transfer_buffer = | ||
432 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
433 | if (!dev->vbi_mode.isoc_ctl.transfer_buffer) { | ||
434 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
435 | kfree(dev->vbi_mode.isoc_ctl.urb); | ||
436 | return -ENOMEM; | ||
437 | } | ||
438 | |||
439 | dev->vbi_mode.isoc_ctl.max_pkt_size = max_pkt_size; | ||
440 | dev->vbi_mode.isoc_ctl.buf = NULL; | ||
441 | |||
442 | sb_size = max_packets * dev->vbi_mode.isoc_ctl.max_pkt_size; | ||
443 | |||
444 | /* allocate urbs and transfer buffers */ | ||
445 | for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { | ||
446 | |||
447 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
448 | if (!urb) { | ||
449 | cx231xx_err(DRIVER_NAME | ||
450 | ": cannot alloc isoc_ctl.urb %i\n", i); | ||
451 | cx231xx_uninit_vbi_isoc(dev); | ||
452 | return -ENOMEM; | ||
453 | } | ||
454 | dev->vbi_mode.isoc_ctl.urb[i] = urb; | ||
455 | urb->transfer_flags = 0; | ||
456 | |||
457 | dev->vbi_mode.isoc_ctl.transfer_buffer[i] = | ||
458 | kzalloc(sb_size, GFP_KERNEL); | ||
459 | if (!dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { | ||
460 | cx231xx_err(DRIVER_NAME | ||
461 | ": unable to allocate %i bytes for transfer" | ||
462 | " buffer %i%s\n", sb_size, i, | ||
463 | in_interrupt() ? " while in int" : ""); | ||
464 | cx231xx_uninit_vbi_isoc(dev); | ||
465 | return -ENOMEM; | ||
466 | } | ||
467 | |||
468 | pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr); | ||
469 | usb_fill_bulk_urb(urb, dev->udev, pipe, | ||
470 | dev->vbi_mode.isoc_ctl.transfer_buffer[i], | ||
471 | sb_size, cx231xx_irq_vbi_callback, dma_q); | ||
472 | } | ||
473 | |||
474 | init_waitqueue_head(&dma_q->wq); | ||
475 | |||
476 | /* submit urbs and enables IRQ */ | ||
477 | for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { | ||
478 | rc = usb_submit_urb(dev->vbi_mode.isoc_ctl.urb[i], GFP_ATOMIC); | ||
479 | if (rc) { | ||
480 | cx231xx_err(DRIVER_NAME | ||
481 | ": submit of urb %i failed (error=%i)\n", i, | ||
482 | rc); | ||
483 | cx231xx_uninit_vbi_isoc(dev); | ||
484 | return rc; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | cx231xx_capture_start(dev, 1, Vbi); | ||
489 | |||
490 | return 0; | ||
491 | } | ||
492 | EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc); | ||
493 | |||
494 | u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
495 | u8 sav_eav, u8 *p_buffer, u32 buffer_size) | ||
496 | { | ||
497 | u32 bytes_copied = 0; | ||
498 | int current_field = -1; | ||
499 | |||
500 | switch (sav_eav) { | ||
501 | |||
502 | case SAV_VBI_FIELD1: | ||
503 | current_field = 1; | ||
504 | break; | ||
505 | |||
506 | case SAV_VBI_FIELD2: | ||
507 | current_field = 2; | ||
508 | break; | ||
509 | default: | ||
510 | break; | ||
511 | } | ||
512 | |||
513 | if (current_field < 0) | ||
514 | return bytes_copied; | ||
515 | |||
516 | dma_q->last_sav = sav_eav; | ||
517 | |||
518 | bytes_copied = | ||
519 | cx231xx_copy_vbi_line(dev, dma_q, p_buffer, buffer_size, | ||
520 | current_field); | ||
521 | |||
522 | return bytes_copied; | ||
523 | } | ||
524 | |||
525 | /* | ||
526 | * Announces that a buffer were filled and request the next | ||
527 | */ | ||
528 | static inline void vbi_buffer_filled(struct cx231xx *dev, | ||
529 | struct cx231xx_dmaqueue *dma_q, | ||
530 | struct cx231xx_buffer *buf) | ||
531 | { | ||
532 | /* Advice that buffer was filled */ | ||
533 | /* cx231xx_info(DRIVER_NAME "[%p/%d] wakeup\n", buf, buf->vb.i); */ | ||
534 | |||
535 | buf->vb.state = VIDEOBUF_DONE; | ||
536 | buf->vb.field_count++; | ||
537 | do_gettimeofday(&buf->vb.ts); | ||
538 | |||
539 | dev->vbi_mode.isoc_ctl.buf = NULL; | ||
540 | |||
541 | list_del(&buf->vb.queue); | ||
542 | wake_up(&buf->vb.done); | ||
543 | } | ||
544 | |||
545 | u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
546 | u8 *p_line, u32 length, int field_number) | ||
547 | { | ||
548 | u32 bytes_to_copy; | ||
549 | struct cx231xx_buffer *buf; | ||
550 | u32 _line_size = dev->width * 2; | ||
551 | |||
552 | if (dma_q->current_field != field_number) | ||
553 | cx231xx_reset_vbi_buffer(dev, dma_q); | ||
554 | |||
555 | /* get the buffer pointer */ | ||
556 | buf = dev->vbi_mode.isoc_ctl.buf; | ||
557 | |||
558 | /* Remember the field number for next time */ | ||
559 | dma_q->current_field = field_number; | ||
560 | |||
561 | bytes_to_copy = dma_q->bytes_left_in_line; | ||
562 | if (bytes_to_copy > length) | ||
563 | bytes_to_copy = length; | ||
564 | |||
565 | if (dma_q->lines_completed >= dma_q->lines_per_field) { | ||
566 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
567 | dma_q->is_partial_line = | ||
568 | (dma_q->bytes_left_in_line == 0) ? 0 : 1; | ||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | dma_q->is_partial_line = 1; | ||
573 | |||
574 | /* If we don't have a buffer, just return the number of bytes we would | ||
575 | have copied if we had a buffer. */ | ||
576 | if (!buf) { | ||
577 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
578 | dma_q->is_partial_line = | ||
579 | (dma_q->bytes_left_in_line == 0) ? 0 : 1; | ||
580 | return bytes_to_copy; | ||
581 | } | ||
582 | |||
583 | /* copy the data to video buffer */ | ||
584 | cx231xx_do_vbi_copy(dev, dma_q, p_line, bytes_to_copy); | ||
585 | |||
586 | dma_q->pos += bytes_to_copy; | ||
587 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
588 | |||
589 | if (dma_q->bytes_left_in_line == 0) { | ||
590 | |||
591 | dma_q->bytes_left_in_line = _line_size; | ||
592 | dma_q->lines_completed++; | ||
593 | dma_q->is_partial_line = 0; | ||
594 | |||
595 | if (cx231xx_is_vbi_buffer_done(dev, dma_q) && buf) { | ||
596 | |||
597 | vbi_buffer_filled(dev, dma_q, buf); | ||
598 | |||
599 | dma_q->pos = 0; | ||
600 | buf = NULL; | ||
601 | dma_q->lines_completed = 0; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | return bytes_to_copy; | ||
606 | } | ||
607 | |||
608 | /* | ||
609 | * video-buf generic routine to get the next available buffer | ||
610 | */ | ||
611 | static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, | ||
612 | struct cx231xx_buffer **buf) | ||
613 | { | ||
614 | struct cx231xx_video_mode *vmode = | ||
615 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
616 | struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); | ||
617 | char *outp; | ||
618 | |||
619 | if (list_empty(&dma_q->active)) { | ||
620 | cx231xx_err(DRIVER_NAME ": No active queue to serve\n"); | ||
621 | dev->vbi_mode.isoc_ctl.buf = NULL; | ||
622 | *buf = NULL; | ||
623 | return; | ||
624 | } | ||
625 | |||
626 | /* Get the next buffer */ | ||
627 | *buf = list_entry(dma_q->active.next, struct cx231xx_buffer, vb.queue); | ||
628 | |||
629 | /* Cleans up buffer - Usefull for testing for frame/URB loss */ | ||
630 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
631 | memset(outp, 0, (*buf)->vb.size); | ||
632 | |||
633 | dev->vbi_mode.isoc_ctl.buf = *buf; | ||
634 | |||
635 | return; | ||
636 | } | ||
637 | |||
638 | void cx231xx_reset_vbi_buffer(struct cx231xx *dev, | ||
639 | struct cx231xx_dmaqueue *dma_q) | ||
640 | { | ||
641 | struct cx231xx_buffer *buf; | ||
642 | |||
643 | buf = dev->vbi_mode.isoc_ctl.buf; | ||
644 | |||
645 | if (buf == NULL) { | ||
646 | /* first try to get the buffer */ | ||
647 | get_next_vbi_buf(dma_q, &buf); | ||
648 | |||
649 | dma_q->pos = 0; | ||
650 | dma_q->current_field = -1; | ||
651 | } | ||
652 | |||
653 | dma_q->bytes_left_in_line = dev->width << 1; | ||
654 | dma_q->lines_completed = 0; | ||
655 | } | ||
656 | |||
657 | int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
658 | u8 *p_buffer, u32 bytes_to_copy) | ||
659 | { | ||
660 | u8 *p_out_buffer = NULL; | ||
661 | u32 current_line_bytes_copied = 0; | ||
662 | struct cx231xx_buffer *buf; | ||
663 | u32 _line_size = dev->width << 1; | ||
664 | void *startwrite; | ||
665 | int offset, lencopy; | ||
666 | |||
667 | buf = dev->vbi_mode.isoc_ctl.buf; | ||
668 | |||
669 | if (buf == NULL) | ||
670 | return -EINVAL; | ||
671 | |||
672 | p_out_buffer = videobuf_to_vmalloc(&buf->vb); | ||
673 | |||
674 | if (dma_q->bytes_left_in_line != _line_size) { | ||
675 | current_line_bytes_copied = | ||
676 | _line_size - dma_q->bytes_left_in_line; | ||
677 | } | ||
678 | |||
679 | offset = (dma_q->lines_completed * _line_size) + | ||
680 | current_line_bytes_copied; | ||
681 | |||
682 | /* prepare destination address */ | ||
683 | startwrite = p_out_buffer + offset; | ||
684 | |||
685 | lencopy = dma_q->bytes_left_in_line > bytes_to_copy ? | ||
686 | bytes_to_copy : dma_q->bytes_left_in_line; | ||
687 | |||
688 | memcpy(startwrite, p_buffer, lencopy); | ||
689 | |||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev, | ||
694 | struct cx231xx_dmaqueue *dma_q) | ||
695 | { | ||
696 | u32 height = 0; | ||
697 | |||
698 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
699 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
700 | return (dma_q->lines_completed == height) ? 1 : 0; | ||
701 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.h b/drivers/media/video/cx231xx/cx231xx-vbi.h new file mode 100644 index 000000000000..89c7fe80b261 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-vbi.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | cx231xx_vbi.h - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on cx88 driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_VBI_H | ||
23 | #define _CX231XX_VBI_H | ||
24 | |||
25 | extern struct videobuf_queue_ops cx231xx_vbi_qops; | ||
26 | |||
27 | #define NTSC_VBI_START_LINE 10 /* line 10 - 21 */ | ||
28 | #define NTSC_VBI_END_LINE 21 | ||
29 | #define NTSC_VBI_LINES (NTSC_VBI_END_LINE-NTSC_VBI_START_LINE+1) | ||
30 | |||
31 | #define PAL_VBI_START_LINE 6 | ||
32 | #define PAL_VBI_END_LINE 23 | ||
33 | #define PAL_VBI_LINES (PAL_VBI_END_LINE-PAL_VBI_START_LINE+1) | ||
34 | |||
35 | #define VBI_STRIDE 1440 | ||
36 | #define VBI_SAMPLES_PER_LINE 1440 | ||
37 | |||
38 | #define CX231XX_NUM_VBI_PACKETS 4 | ||
39 | #define CX231XX_NUM_VBI_BUFS 5 | ||
40 | |||
41 | /* stream functions */ | ||
42 | int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | ||
43 | int num_bufs, int max_pkt_size, | ||
44 | int (*isoc_copy) (struct cx231xx *dev, | ||
45 | struct urb *urb)); | ||
46 | |||
47 | void cx231xx_uninit_vbi_isoc(struct cx231xx *dev); | ||
48 | |||
49 | /* vbi data copy functions */ | ||
50 | u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
51 | u8 sav_eav, u8 *p_buffer, u32 buffer_size); | ||
52 | |||
53 | u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
54 | u8 *p_line, u32 length, int field_number); | ||
55 | |||
56 | void cx231xx_reset_vbi_buffer(struct cx231xx *dev, | ||
57 | struct cx231xx_dmaqueue *dma_q); | ||
58 | |||
59 | int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
60 | u8 *p_buffer, u32 bytes_to_copy); | ||
61 | |||
62 | u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev, | ||
63 | struct cx231xx_dmaqueue *dma_q); | ||
64 | |||
65 | #endif | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c new file mode 100644 index 000000000000..a23ae73fe634 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-video.c | |||
@@ -0,0 +1,2434 @@ | |||
1 | /* | ||
2 | cx231xx-video.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | Based on cx23885 driver | ||
8 | Based on cx88 driver | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/bitmap.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | ||
32 | #include <linux/version.h> | ||
33 | #include <linux/mm.h> | ||
34 | #include <linux/mutex.h> | ||
35 | |||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-ioctl.h> | ||
38 | #include <media/v4l2-chip-ident.h> | ||
39 | #include <media/msp3400.h> | ||
40 | #include <media/tuner.h> | ||
41 | |||
42 | #include "dvb_frontend.h" | ||
43 | |||
44 | #include "cx231xx.h" | ||
45 | #include "cx231xx-vbi.h" | ||
46 | |||
47 | #define CX231XX_VERSION_CODE KERNEL_VERSION(0, 0, 1) | ||
48 | |||
49 | #define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>" | ||
50 | #define DRIVER_DESC "Conexant cx231xx based USB video device driver" | ||
51 | |||
52 | #define cx231xx_videodbg(fmt, arg...) do {\ | ||
53 | if (video_debug) \ | ||
54 | printk(KERN_INFO "%s %s :"fmt, \ | ||
55 | dev->name, __func__ , ##arg); } while (0) | ||
56 | |||
57 | static unsigned int isoc_debug; | ||
58 | module_param(isoc_debug, int, 0644); | ||
59 | MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); | ||
60 | |||
61 | #define cx231xx_isocdbg(fmt, arg...) \ | ||
62 | do {\ | ||
63 | if (isoc_debug) { \ | ||
64 | printk(KERN_INFO "%s %s :"fmt, \ | ||
65 | dev->name, __func__ , ##arg); \ | ||
66 | } \ | ||
67 | } while (0) | ||
68 | |||
69 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
70 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
71 | MODULE_LICENSE("GPL"); | ||
72 | |||
73 | static unsigned int card[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
74 | static unsigned int video_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
75 | static unsigned int vbi_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
76 | static unsigned int radio_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
77 | |||
78 | module_param_array(card, int, NULL, 0444); | ||
79 | module_param_array(video_nr, int, NULL, 0444); | ||
80 | module_param_array(vbi_nr, int, NULL, 0444); | ||
81 | module_param_array(radio_nr, int, NULL, 0444); | ||
82 | |||
83 | MODULE_PARM_DESC(card, "card type"); | ||
84 | MODULE_PARM_DESC(video_nr, "video device numbers"); | ||
85 | MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); | ||
86 | MODULE_PARM_DESC(radio_nr, "radio device numbers"); | ||
87 | |||
88 | static unsigned int video_debug; | ||
89 | module_param(video_debug, int, 0644); | ||
90 | MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); | ||
91 | |||
92 | /* supported video standards */ | ||
93 | static struct cx231xx_fmt format[] = { | ||
94 | { | ||
95 | .name = "16bpp YUY2, 4:2:2, packed", | ||
96 | .fourcc = V4L2_PIX_FMT_YUYV, | ||
97 | .depth = 16, | ||
98 | .reg = 0, | ||
99 | }, | ||
100 | }; | ||
101 | |||
102 | /* supported controls */ | ||
103 | /* Common to all boards */ | ||
104 | |||
105 | /* ------------------------------------------------------------------- */ | ||
106 | |||
107 | static const struct v4l2_queryctrl no_ctl = { | ||
108 | .name = "42", | ||
109 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
110 | }; | ||
111 | |||
112 | static struct cx231xx_ctrl cx231xx_ctls[] = { | ||
113 | /* --- video --- */ | ||
114 | { | ||
115 | .v = { | ||
116 | .id = V4L2_CID_BRIGHTNESS, | ||
117 | .name = "Brightness", | ||
118 | .minimum = 0x00, | ||
119 | .maximum = 0xff, | ||
120 | .step = 1, | ||
121 | .default_value = 0x7f, | ||
122 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
123 | }, | ||
124 | .off = 128, | ||
125 | .reg = LUMA_CTRL, | ||
126 | .mask = 0x00ff, | ||
127 | .shift = 0, | ||
128 | }, { | ||
129 | .v = { | ||
130 | .id = V4L2_CID_CONTRAST, | ||
131 | .name = "Contrast", | ||
132 | .minimum = 0, | ||
133 | .maximum = 0xff, | ||
134 | .step = 1, | ||
135 | .default_value = 0x3f, | ||
136 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
137 | }, | ||
138 | .off = 0, | ||
139 | .reg = LUMA_CTRL, | ||
140 | .mask = 0xff00, | ||
141 | .shift = 8, | ||
142 | }, { | ||
143 | .v = { | ||
144 | .id = V4L2_CID_HUE, | ||
145 | .name = "Hue", | ||
146 | .minimum = 0, | ||
147 | .maximum = 0xff, | ||
148 | .step = 1, | ||
149 | .default_value = 0x7f, | ||
150 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
151 | }, | ||
152 | .off = 128, | ||
153 | .reg = CHROMA_CTRL, | ||
154 | .mask = 0xff0000, | ||
155 | .shift = 16, | ||
156 | }, { | ||
157 | /* strictly, this only describes only U saturation. | ||
158 | * V saturation is handled specially through code. | ||
159 | */ | ||
160 | .v = { | ||
161 | .id = V4L2_CID_SATURATION, | ||
162 | .name = "Saturation", | ||
163 | .minimum = 0, | ||
164 | .maximum = 0xff, | ||
165 | .step = 1, | ||
166 | .default_value = 0x7f, | ||
167 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
168 | }, | ||
169 | .off = 0, | ||
170 | .reg = CHROMA_CTRL, | ||
171 | .mask = 0x00ff, | ||
172 | .shift = 0, | ||
173 | }, { | ||
174 | /* --- audio --- */ | ||
175 | .v = { | ||
176 | .id = V4L2_CID_AUDIO_MUTE, | ||
177 | .name = "Mute", | ||
178 | .minimum = 0, | ||
179 | .maximum = 1, | ||
180 | .default_value = 1, | ||
181 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
182 | }, | ||
183 | .reg = PATH1_CTL1, | ||
184 | .mask = (0x1f << 24), | ||
185 | .shift = 24, | ||
186 | }, { | ||
187 | .v = { | ||
188 | .id = V4L2_CID_AUDIO_VOLUME, | ||
189 | .name = "Volume", | ||
190 | .minimum = 0, | ||
191 | .maximum = 0x3f, | ||
192 | .step = 1, | ||
193 | .default_value = 0x3f, | ||
194 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
195 | }, | ||
196 | .reg = PATH1_VOL_CTL, | ||
197 | .mask = 0xff, | ||
198 | .shift = 0, | ||
199 | } | ||
200 | }; | ||
201 | static const int CX231XX_CTLS = ARRAY_SIZE(cx231xx_ctls); | ||
202 | |||
203 | static const u32 cx231xx_user_ctrls[] = { | ||
204 | V4L2_CID_USER_CLASS, | ||
205 | V4L2_CID_BRIGHTNESS, | ||
206 | V4L2_CID_CONTRAST, | ||
207 | V4L2_CID_SATURATION, | ||
208 | V4L2_CID_HUE, | ||
209 | V4L2_CID_AUDIO_VOLUME, | ||
210 | #if 0 | ||
211 | V4L2_CID_AUDIO_BALANCE, | ||
212 | #endif | ||
213 | V4L2_CID_AUDIO_MUTE, | ||
214 | 0 | ||
215 | }; | ||
216 | |||
217 | static const u32 *ctrl_classes[] = { | ||
218 | cx231xx_user_ctrls, | ||
219 | NULL | ||
220 | }; | ||
221 | |||
222 | /* ------------------------------------------------------------------ | ||
223 | Video buffer and parser functions | ||
224 | ------------------------------------------------------------------*/ | ||
225 | |||
226 | /* | ||
227 | * Announces that a buffer were filled and request the next | ||
228 | */ | ||
229 | static inline void buffer_filled(struct cx231xx *dev, | ||
230 | struct cx231xx_dmaqueue *dma_q, | ||
231 | struct cx231xx_buffer *buf) | ||
232 | { | ||
233 | /* Advice that buffer was filled */ | ||
234 | cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | ||
235 | buf->vb.state = VIDEOBUF_DONE; | ||
236 | buf->vb.field_count++; | ||
237 | do_gettimeofday(&buf->vb.ts); | ||
238 | |||
239 | dev->video_mode.isoc_ctl.buf = NULL; | ||
240 | |||
241 | list_del(&buf->vb.queue); | ||
242 | wake_up(&buf->vb.done); | ||
243 | } | ||
244 | |||
245 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
246 | { | ||
247 | char *errmsg = "Unknown"; | ||
248 | |||
249 | switch (status) { | ||
250 | case -ENOENT: | ||
251 | errmsg = "unlinked synchronuously"; | ||
252 | break; | ||
253 | case -ECONNRESET: | ||
254 | errmsg = "unlinked asynchronuously"; | ||
255 | break; | ||
256 | case -ENOSR: | ||
257 | errmsg = "Buffer error (overrun)"; | ||
258 | break; | ||
259 | case -EPIPE: | ||
260 | errmsg = "Stalled (device not responding)"; | ||
261 | break; | ||
262 | case -EOVERFLOW: | ||
263 | errmsg = "Babble (bad cable?)"; | ||
264 | break; | ||
265 | case -EPROTO: | ||
266 | errmsg = "Bit-stuff error (bad cable?)"; | ||
267 | break; | ||
268 | case -EILSEQ: | ||
269 | errmsg = "CRC/Timeout (could be anything)"; | ||
270 | break; | ||
271 | case -ETIME: | ||
272 | errmsg = "Device does not respond"; | ||
273 | break; | ||
274 | } | ||
275 | if (packet < 0) { | ||
276 | cx231xx_isocdbg("URB status %d [%s].\n", status, errmsg); | ||
277 | } else { | ||
278 | cx231xx_isocdbg("URB packet %d, status %d [%s].\n", | ||
279 | packet, status, errmsg); | ||
280 | } | ||
281 | } | ||
282 | |||
283 | /* | ||
284 | * video-buf generic routine to get the next available buffer | ||
285 | */ | ||
286 | static inline void get_next_buf(struct cx231xx_dmaqueue *dma_q, | ||
287 | struct cx231xx_buffer **buf) | ||
288 | { | ||
289 | struct cx231xx_video_mode *vmode = | ||
290 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
291 | struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); | ||
292 | |||
293 | char *outp; | ||
294 | |||
295 | if (list_empty(&dma_q->active)) { | ||
296 | cx231xx_isocdbg("No active queue to serve\n"); | ||
297 | dev->video_mode.isoc_ctl.buf = NULL; | ||
298 | *buf = NULL; | ||
299 | return; | ||
300 | } | ||
301 | |||
302 | /* Get the next buffer */ | ||
303 | *buf = list_entry(dma_q->active.next, struct cx231xx_buffer, vb.queue); | ||
304 | |||
305 | /* Cleans up buffer - Usefull for testing for frame/URB loss */ | ||
306 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
307 | memset(outp, 0, (*buf)->vb.size); | ||
308 | |||
309 | dev->video_mode.isoc_ctl.buf = *buf; | ||
310 | |||
311 | return; | ||
312 | } | ||
313 | |||
314 | /* | ||
315 | * Controls the isoc copy of each urb packet | ||
316 | */ | ||
317 | static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
318 | { | ||
319 | struct cx231xx_buffer *buf; | ||
320 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
321 | unsigned char *outp = NULL; | ||
322 | int i, rc = 1; | ||
323 | unsigned char *p_buffer; | ||
324 | u32 bytes_parsed = 0, buffer_size = 0; | ||
325 | u8 sav_eav = 0; | ||
326 | |||
327 | if (!dev) | ||
328 | return 0; | ||
329 | |||
330 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
331 | return 0; | ||
332 | |||
333 | if (urb->status < 0) { | ||
334 | print_err_status(dev, -1, urb->status); | ||
335 | if (urb->status == -ENOENT) | ||
336 | return 0; | ||
337 | } | ||
338 | |||
339 | buf = dev->video_mode.isoc_ctl.buf; | ||
340 | if (buf != NULL) | ||
341 | outp = videobuf_to_vmalloc(&buf->vb); | ||
342 | |||
343 | for (i = 0; i < urb->number_of_packets; i++) { | ||
344 | int status = urb->iso_frame_desc[i].status; | ||
345 | |||
346 | if (status < 0) { | ||
347 | print_err_status(dev, i, status); | ||
348 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
349 | continue; | ||
350 | } | ||
351 | |||
352 | if (urb->iso_frame_desc[i].actual_length <= 0) { | ||
353 | /* cx231xx_isocdbg("packet %d is empty",i); - spammy */ | ||
354 | continue; | ||
355 | } | ||
356 | if (urb->iso_frame_desc[i].actual_length > | ||
357 | dev->video_mode.max_pkt_size) { | ||
358 | cx231xx_isocdbg("packet bigger than packet size"); | ||
359 | continue; | ||
360 | } | ||
361 | |||
362 | /* get buffer pointer and length */ | ||
363 | p_buffer = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | ||
364 | buffer_size = urb->iso_frame_desc[i].actual_length; | ||
365 | bytes_parsed = 0; | ||
366 | |||
367 | if (dma_q->is_partial_line) { | ||
368 | /* Handle the case of a partial line */ | ||
369 | sav_eav = dma_q->last_sav; | ||
370 | } else { | ||
371 | /* Check for a SAV/EAV overlapping | ||
372 | the buffer boundary */ | ||
373 | sav_eav = | ||
374 | cx231xx_find_boundary_SAV_EAV(p_buffer, | ||
375 | dma_q->partial_buf, | ||
376 | &bytes_parsed); | ||
377 | } | ||
378 | |||
379 | sav_eav &= 0xF0; | ||
380 | /* Get the first line if we have some portion of an SAV/EAV from | ||
381 | the last buffer or a partial line */ | ||
382 | if (sav_eav) { | ||
383 | bytes_parsed += cx231xx_get_video_line(dev, dma_q, | ||
384 | sav_eav, /* SAV/EAV */ | ||
385 | p_buffer + bytes_parsed, /* p_buffer */ | ||
386 | buffer_size - bytes_parsed);/* buf size */ | ||
387 | } | ||
388 | |||
389 | /* Now parse data that is completely in this buffer */ | ||
390 | /* dma_q->is_partial_line = 0; */ | ||
391 | |||
392 | while (bytes_parsed < buffer_size) { | ||
393 | u32 bytes_used = 0; | ||
394 | |||
395 | sav_eav = cx231xx_find_next_SAV_EAV( | ||
396 | p_buffer + bytes_parsed, /* p_buffer */ | ||
397 | buffer_size - bytes_parsed, /* buf size */ | ||
398 | &bytes_used);/* bytes used to get SAV/EAV */ | ||
399 | |||
400 | bytes_parsed += bytes_used; | ||
401 | |||
402 | sav_eav &= 0xF0; | ||
403 | if (sav_eav && (bytes_parsed < buffer_size)) { | ||
404 | bytes_parsed += cx231xx_get_video_line(dev, | ||
405 | dma_q, sav_eav, /* SAV/EAV */ | ||
406 | p_buffer + bytes_parsed,/* p_buffer */ | ||
407 | buffer_size - bytes_parsed);/*buf size*/ | ||
408 | } | ||
409 | } | ||
410 | |||
411 | /* Save the last four bytes of the buffer so we can check the | ||
412 | buffer boundary condition next time */ | ||
413 | memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); | ||
414 | bytes_parsed = 0; | ||
415 | |||
416 | } | ||
417 | return rc; | ||
418 | } | ||
419 | |||
420 | u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, | ||
421 | u32 *p_bytes_used) | ||
422 | { | ||
423 | u32 bytes_used; | ||
424 | u8 boundary_bytes[8]; | ||
425 | u8 sav_eav = 0; | ||
426 | |||
427 | *p_bytes_used = 0; | ||
428 | |||
429 | /* Create an array of the last 4 bytes of the last buffer and the first | ||
430 | 4 bytes of the current buffer. */ | ||
431 | |||
432 | memcpy(boundary_bytes, partial_buf, 4); | ||
433 | memcpy(boundary_bytes + 4, p_buffer, 4); | ||
434 | |||
435 | /* Check for the SAV/EAV in the boundary buffer */ | ||
436 | sav_eav = cx231xx_find_next_SAV_EAV((u8 *)&boundary_bytes, 8, | ||
437 | &bytes_used); | ||
438 | |||
439 | if (sav_eav) { | ||
440 | /* found a boundary SAV/EAV. Updates the bytes used to reflect | ||
441 | only those used in the new buffer */ | ||
442 | *p_bytes_used = bytes_used - 4; | ||
443 | } | ||
444 | |||
445 | return sav_eav; | ||
446 | } | ||
447 | |||
448 | u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used) | ||
449 | { | ||
450 | u32 i; | ||
451 | u8 sav_eav = 0; | ||
452 | |||
453 | /* | ||
454 | * Don't search if the buffer size is less than 4. It causes a page | ||
455 | * fault since buffer_size - 4 evaluates to a large number in that | ||
456 | * case. | ||
457 | */ | ||
458 | if (buffer_size < 4) { | ||
459 | *p_bytes_used = buffer_size; | ||
460 | return 0; | ||
461 | } | ||
462 | |||
463 | for (i = 0; i < (buffer_size - 3); i++) { | ||
464 | |||
465 | if ((p_buffer[i] == 0xFF) && | ||
466 | (p_buffer[i + 1] == 0x00) && (p_buffer[i + 2] == 0x00)) { | ||
467 | |||
468 | *p_bytes_used = i + 4; | ||
469 | sav_eav = p_buffer[i + 3]; | ||
470 | return sav_eav; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | *p_bytes_used = buffer_size; | ||
475 | return 0; | ||
476 | } | ||
477 | |||
478 | u32 cx231xx_get_video_line(struct cx231xx *dev, | ||
479 | struct cx231xx_dmaqueue *dma_q, u8 sav_eav, | ||
480 | u8 *p_buffer, u32 buffer_size) | ||
481 | { | ||
482 | u32 bytes_copied = 0; | ||
483 | int current_field = -1; | ||
484 | |||
485 | switch (sav_eav) { | ||
486 | case SAV_ACTIVE_VIDEO_FIELD1: | ||
487 | /* looking for skipped line which occurred in PAL 720x480 mode. | ||
488 | In this case, there will be no active data contained | ||
489 | between the SAV and EAV */ | ||
490 | if ((buffer_size > 3) && (p_buffer[0] == 0xFF) && | ||
491 | (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && | ||
492 | ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || | ||
493 | (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || | ||
494 | (p_buffer[3] == EAV_VBLANK_FIELD1) || | ||
495 | (p_buffer[3] == EAV_VBLANK_FIELD2))) | ||
496 | return bytes_copied; | ||
497 | current_field = 1; | ||
498 | break; | ||
499 | |||
500 | case SAV_ACTIVE_VIDEO_FIELD2: | ||
501 | /* looking for skipped line which occurred in PAL 720x480 mode. | ||
502 | In this case, there will be no active data contained between | ||
503 | the SAV and EAV */ | ||
504 | if ((buffer_size > 3) && (p_buffer[0] == 0xFF) && | ||
505 | (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && | ||
506 | ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || | ||
507 | (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || | ||
508 | (p_buffer[3] == EAV_VBLANK_FIELD1) || | ||
509 | (p_buffer[3] == EAV_VBLANK_FIELD2))) | ||
510 | return bytes_copied; | ||
511 | current_field = 2; | ||
512 | break; | ||
513 | } | ||
514 | |||
515 | dma_q->last_sav = sav_eav; | ||
516 | |||
517 | bytes_copied = cx231xx_copy_video_line(dev, dma_q, p_buffer, | ||
518 | buffer_size, current_field); | ||
519 | |||
520 | return bytes_copied; | ||
521 | } | ||
522 | |||
523 | u32 cx231xx_copy_video_line(struct cx231xx *dev, | ||
524 | struct cx231xx_dmaqueue *dma_q, u8 *p_line, | ||
525 | u32 length, int field_number) | ||
526 | { | ||
527 | u32 bytes_to_copy; | ||
528 | struct cx231xx_buffer *buf; | ||
529 | u32 _line_size = dev->width * 2; | ||
530 | |||
531 | if (dma_q->current_field != field_number) | ||
532 | cx231xx_reset_video_buffer(dev, dma_q); | ||
533 | |||
534 | /* get the buffer pointer */ | ||
535 | buf = dev->video_mode.isoc_ctl.buf; | ||
536 | |||
537 | /* Remember the field number for next time */ | ||
538 | dma_q->current_field = field_number; | ||
539 | |||
540 | bytes_to_copy = dma_q->bytes_left_in_line; | ||
541 | if (bytes_to_copy > length) | ||
542 | bytes_to_copy = length; | ||
543 | |||
544 | if (dma_q->lines_completed >= dma_q->lines_per_field) { | ||
545 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
546 | dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? | ||
547 | 0 : 1; | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | dma_q->is_partial_line = 1; | ||
552 | |||
553 | /* If we don't have a buffer, just return the number of bytes we would | ||
554 | have copied if we had a buffer. */ | ||
555 | if (!buf) { | ||
556 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
557 | dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) | ||
558 | ? 0 : 1; | ||
559 | return bytes_to_copy; | ||
560 | } | ||
561 | |||
562 | /* copy the data to video buffer */ | ||
563 | cx231xx_do_copy(dev, dma_q, p_line, bytes_to_copy); | ||
564 | |||
565 | dma_q->pos += bytes_to_copy; | ||
566 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
567 | |||
568 | if (dma_q->bytes_left_in_line == 0) { | ||
569 | dma_q->bytes_left_in_line = _line_size; | ||
570 | dma_q->lines_completed++; | ||
571 | dma_q->is_partial_line = 0; | ||
572 | |||
573 | if (cx231xx_is_buffer_done(dev, dma_q) && buf) { | ||
574 | buffer_filled(dev, dma_q, buf); | ||
575 | |||
576 | dma_q->pos = 0; | ||
577 | buf = NULL; | ||
578 | dma_q->lines_completed = 0; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | return bytes_to_copy; | ||
583 | } | ||
584 | |||
585 | void cx231xx_reset_video_buffer(struct cx231xx *dev, | ||
586 | struct cx231xx_dmaqueue *dma_q) | ||
587 | { | ||
588 | struct cx231xx_buffer *buf; | ||
589 | |||
590 | /* handle the switch from field 1 to field 2 */ | ||
591 | if (dma_q->current_field == 1) { | ||
592 | if (dma_q->lines_completed >= dma_q->lines_per_field) | ||
593 | dma_q->field1_done = 1; | ||
594 | else | ||
595 | dma_q->field1_done = 0; | ||
596 | } | ||
597 | |||
598 | buf = dev->video_mode.isoc_ctl.buf; | ||
599 | |||
600 | if (buf == NULL) { | ||
601 | u8 *outp = NULL; | ||
602 | /* first try to get the buffer */ | ||
603 | get_next_buf(dma_q, &buf); | ||
604 | |||
605 | if (buf) | ||
606 | outp = videobuf_to_vmalloc(&buf->vb); | ||
607 | |||
608 | dma_q->pos = 0; | ||
609 | dma_q->field1_done = 0; | ||
610 | dma_q->current_field = -1; | ||
611 | } | ||
612 | |||
613 | /* reset the counters */ | ||
614 | dma_q->bytes_left_in_line = dev->width << 1; | ||
615 | dma_q->lines_completed = 0; | ||
616 | } | ||
617 | |||
618 | int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
619 | u8 *p_buffer, u32 bytes_to_copy) | ||
620 | { | ||
621 | u8 *p_out_buffer = NULL; | ||
622 | u32 current_line_bytes_copied = 0; | ||
623 | struct cx231xx_buffer *buf; | ||
624 | u32 _line_size = dev->width << 1; | ||
625 | void *startwrite; | ||
626 | int offset, lencopy; | ||
627 | |||
628 | buf = dev->video_mode.isoc_ctl.buf; | ||
629 | |||
630 | if (buf == NULL) | ||
631 | return -1; | ||
632 | |||
633 | p_out_buffer = videobuf_to_vmalloc(&buf->vb); | ||
634 | |||
635 | current_line_bytes_copied = _line_size - dma_q->bytes_left_in_line; | ||
636 | |||
637 | /* Offset field 2 one line from the top of the buffer */ | ||
638 | offset = (dma_q->current_field == 1) ? 0 : _line_size; | ||
639 | |||
640 | /* Offset for field 2 */ | ||
641 | startwrite = p_out_buffer + offset; | ||
642 | |||
643 | /* lines already completed in the current field */ | ||
644 | startwrite += (dma_q->lines_completed * _line_size * 2); | ||
645 | |||
646 | /* bytes already completed in the current line */ | ||
647 | startwrite += current_line_bytes_copied; | ||
648 | |||
649 | lencopy = dma_q->bytes_left_in_line > bytes_to_copy ? | ||
650 | bytes_to_copy : dma_q->bytes_left_in_line; | ||
651 | |||
652 | if ((u8 *)(startwrite + lencopy) > (u8 *)(p_out_buffer + buf->vb.size)) | ||
653 | return 0; | ||
654 | |||
655 | /* The below copies the UYVY data straight into video buffer */ | ||
656 | cx231xx_swab((u16 *) p_buffer, (u16 *) startwrite, (u16) lencopy); | ||
657 | |||
658 | return 0; | ||
659 | } | ||
660 | |||
661 | void cx231xx_swab(u16 *from, u16 *to, u16 len) | ||
662 | { | ||
663 | u16 i; | ||
664 | |||
665 | if (len <= 0) | ||
666 | return; | ||
667 | |||
668 | for (i = 0; i < len / 2; i++) | ||
669 | to[i] = (from[i] << 8) | (from[i] >> 8); | ||
670 | } | ||
671 | |||
672 | u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q) | ||
673 | { | ||
674 | u8 buffer_complete = 0; | ||
675 | |||
676 | /* Dual field stream */ | ||
677 | buffer_complete = ((dma_q->current_field == 2) && | ||
678 | (dma_q->lines_completed >= dma_q->lines_per_field) && | ||
679 | dma_q->field1_done); | ||
680 | |||
681 | return buffer_complete; | ||
682 | } | ||
683 | |||
684 | /* ------------------------------------------------------------------ | ||
685 | Videobuf operations | ||
686 | ------------------------------------------------------------------*/ | ||
687 | |||
688 | static int | ||
689 | buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | ||
690 | { | ||
691 | struct cx231xx_fh *fh = vq->priv_data; | ||
692 | struct cx231xx *dev = fh->dev; | ||
693 | struct v4l2_frequency f; | ||
694 | |||
695 | *size = (fh->dev->width * fh->dev->height * dev->format->depth + 7)>>3; | ||
696 | if (0 == *count) | ||
697 | *count = CX231XX_DEF_BUF; | ||
698 | |||
699 | if (*count < CX231XX_MIN_BUF) | ||
700 | *count = CX231XX_MIN_BUF; | ||
701 | |||
702 | /* Ask tuner to go to analog mode */ | ||
703 | memset(&f, 0, sizeof(f)); | ||
704 | f.frequency = dev->ctl_freq; | ||
705 | f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
706 | |||
707 | call_all(dev, tuner, s_frequency, &f); | ||
708 | |||
709 | return 0; | ||
710 | } | ||
711 | |||
712 | /* This is called *without* dev->slock held; please keep it that way */ | ||
713 | static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) | ||
714 | { | ||
715 | struct cx231xx_fh *fh = vq->priv_data; | ||
716 | struct cx231xx *dev = fh->dev; | ||
717 | unsigned long flags = 0; | ||
718 | |||
719 | if (in_interrupt()) | ||
720 | BUG(); | ||
721 | |||
722 | /* We used to wait for the buffer to finish here, but this didn't work | ||
723 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
724 | videobuf_queue_cancel marked it as finished for us. | ||
725 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
726 | |||
727 | This should be safe; by the time we get here, the buffer isn't | ||
728 | queued anymore. If we ever start marking the buffers as | ||
729 | VIDEOBUF_ACTIVE, it won't be, though. | ||
730 | */ | ||
731 | spin_lock_irqsave(&dev->video_mode.slock, flags); | ||
732 | if (dev->video_mode.isoc_ctl.buf == buf) | ||
733 | dev->video_mode.isoc_ctl.buf = NULL; | ||
734 | spin_unlock_irqrestore(&dev->video_mode.slock, flags); | ||
735 | |||
736 | videobuf_vmalloc_free(&buf->vb); | ||
737 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
738 | } | ||
739 | |||
740 | static int | ||
741 | buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
742 | enum v4l2_field field) | ||
743 | { | ||
744 | struct cx231xx_fh *fh = vq->priv_data; | ||
745 | struct cx231xx_buffer *buf = | ||
746 | container_of(vb, struct cx231xx_buffer, vb); | ||
747 | struct cx231xx *dev = fh->dev; | ||
748 | int rc = 0, urb_init = 0; | ||
749 | |||
750 | /* The only currently supported format is 16 bits/pixel */ | ||
751 | buf->vb.size = (fh->dev->width * fh->dev->height * dev->format->depth | ||
752 | + 7) >> 3; | ||
753 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
754 | return -EINVAL; | ||
755 | |||
756 | buf->vb.width = dev->width; | ||
757 | buf->vb.height = dev->height; | ||
758 | buf->vb.field = field; | ||
759 | |||
760 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
761 | rc = videobuf_iolock(vq, &buf->vb, NULL); | ||
762 | if (rc < 0) | ||
763 | goto fail; | ||
764 | } | ||
765 | |||
766 | if (!dev->video_mode.isoc_ctl.num_bufs) | ||
767 | urb_init = 1; | ||
768 | |||
769 | if (urb_init) { | ||
770 | rc = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, | ||
771 | CX231XX_NUM_BUFS, | ||
772 | dev->video_mode.max_pkt_size, | ||
773 | cx231xx_isoc_copy); | ||
774 | if (rc < 0) | ||
775 | goto fail; | ||
776 | } | ||
777 | |||
778 | buf->vb.state = VIDEOBUF_PREPARED; | ||
779 | return 0; | ||
780 | |||
781 | fail: | ||
782 | free_buffer(vq, buf); | ||
783 | return rc; | ||
784 | } | ||
785 | |||
786 | static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
787 | { | ||
788 | struct cx231xx_buffer *buf = | ||
789 | container_of(vb, struct cx231xx_buffer, vb); | ||
790 | struct cx231xx_fh *fh = vq->priv_data; | ||
791 | struct cx231xx *dev = fh->dev; | ||
792 | struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; | ||
793 | |||
794 | buf->vb.state = VIDEOBUF_QUEUED; | ||
795 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
796 | |||
797 | } | ||
798 | |||
799 | static void buffer_release(struct videobuf_queue *vq, | ||
800 | struct videobuf_buffer *vb) | ||
801 | { | ||
802 | struct cx231xx_buffer *buf = | ||
803 | container_of(vb, struct cx231xx_buffer, vb); | ||
804 | struct cx231xx_fh *fh = vq->priv_data; | ||
805 | struct cx231xx *dev = (struct cx231xx *)fh->dev; | ||
806 | |||
807 | cx231xx_isocdbg("cx231xx: called buffer_release\n"); | ||
808 | |||
809 | free_buffer(vq, buf); | ||
810 | } | ||
811 | |||
812 | static struct videobuf_queue_ops cx231xx_video_qops = { | ||
813 | .buf_setup = buffer_setup, | ||
814 | .buf_prepare = buffer_prepare, | ||
815 | .buf_queue = buffer_queue, | ||
816 | .buf_release = buffer_release, | ||
817 | }; | ||
818 | |||
819 | /********************* v4l2 interface **************************************/ | ||
820 | |||
821 | void video_mux(struct cx231xx *dev, int index) | ||
822 | { | ||
823 | dev->video_input = index; | ||
824 | dev->ctl_ainput = INPUT(index)->amux; | ||
825 | |||
826 | cx231xx_set_video_input_mux(dev, index); | ||
827 | |||
828 | cx25840_call(dev, video, s_routing, INPUT(index)->vmux, 0, 0); | ||
829 | |||
830 | cx231xx_set_audio_input(dev, dev->ctl_ainput); | ||
831 | |||
832 | cx231xx_info("video_mux : %d\n", index); | ||
833 | |||
834 | /* do mode control overrides if required */ | ||
835 | cx231xx_do_mode_ctrl_overrides(dev); | ||
836 | } | ||
837 | |||
838 | /* Usage lock check functions */ | ||
839 | static int res_get(struct cx231xx_fh *fh) | ||
840 | { | ||
841 | struct cx231xx *dev = fh->dev; | ||
842 | int rc = 0; | ||
843 | |||
844 | /* This instance already has stream_on */ | ||
845 | if (fh->stream_on) | ||
846 | return rc; | ||
847 | |||
848 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
849 | if (dev->stream_on) | ||
850 | return -EBUSY; | ||
851 | dev->stream_on = 1; | ||
852 | } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
853 | if (dev->vbi_stream_on) | ||
854 | return -EBUSY; | ||
855 | dev->vbi_stream_on = 1; | ||
856 | } else | ||
857 | return -EINVAL; | ||
858 | |||
859 | fh->stream_on = 1; | ||
860 | |||
861 | return rc; | ||
862 | } | ||
863 | |||
864 | static int res_check(struct cx231xx_fh *fh) | ||
865 | { | ||
866 | return fh->stream_on; | ||
867 | } | ||
868 | |||
869 | static void res_free(struct cx231xx_fh *fh) | ||
870 | { | ||
871 | struct cx231xx *dev = fh->dev; | ||
872 | |||
873 | fh->stream_on = 0; | ||
874 | |||
875 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
876 | dev->stream_on = 0; | ||
877 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) | ||
878 | dev->vbi_stream_on = 0; | ||
879 | } | ||
880 | |||
881 | static int check_dev(struct cx231xx *dev) | ||
882 | { | ||
883 | if (dev->state & DEV_DISCONNECTED) { | ||
884 | cx231xx_errdev("v4l2 ioctl: device not present\n"); | ||
885 | return -ENODEV; | ||
886 | } | ||
887 | |||
888 | if (dev->state & DEV_MISCONFIGURED) { | ||
889 | cx231xx_errdev("v4l2 ioctl: device is misconfigured; " | ||
890 | "close and open it again\n"); | ||
891 | return -EIO; | ||
892 | } | ||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | void get_scale(struct cx231xx *dev, | ||
897 | unsigned int width, unsigned int height, | ||
898 | unsigned int *hscale, unsigned int *vscale) | ||
899 | { | ||
900 | unsigned int maxw = norm_maxw(dev); | ||
901 | unsigned int maxh = norm_maxh(dev); | ||
902 | |||
903 | *hscale = (((unsigned long)maxw) << 12) / width - 4096L; | ||
904 | if (*hscale >= 0x4000) | ||
905 | *hscale = 0x3fff; | ||
906 | |||
907 | *vscale = (((unsigned long)maxh) << 12) / height - 4096L; | ||
908 | if (*vscale >= 0x4000) | ||
909 | *vscale = 0x3fff; | ||
910 | |||
911 | dev->hscale = *hscale; | ||
912 | dev->vscale = *vscale; | ||
913 | |||
914 | } | ||
915 | |||
916 | /* ------------------------------------------------------------------ | ||
917 | IOCTL vidioc handling | ||
918 | ------------------------------------------------------------------*/ | ||
919 | |||
920 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | ||
921 | struct v4l2_format *f) | ||
922 | { | ||
923 | struct cx231xx_fh *fh = priv; | ||
924 | struct cx231xx *dev = fh->dev; | ||
925 | |||
926 | mutex_lock(&dev->lock); | ||
927 | |||
928 | f->fmt.pix.width = dev->width; | ||
929 | f->fmt.pix.height = dev->height; | ||
930 | f->fmt.pix.pixelformat = dev->format->fourcc;; | ||
931 | f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3;; | ||
932 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; | ||
933 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
934 | |||
935 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | ||
936 | |||
937 | mutex_unlock(&dev->lock); | ||
938 | |||
939 | return 0; | ||
940 | } | ||
941 | |||
942 | static struct cx231xx_fmt *format_by_fourcc(unsigned int fourcc) | ||
943 | { | ||
944 | unsigned int i; | ||
945 | |||
946 | for (i = 0; i < ARRAY_SIZE(format); i++) | ||
947 | if (format[i].fourcc == fourcc) | ||
948 | return &format[i]; | ||
949 | |||
950 | return NULL; | ||
951 | } | ||
952 | |||
953 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | ||
954 | struct v4l2_format *f) | ||
955 | { | ||
956 | struct cx231xx_fh *fh = priv; | ||
957 | struct cx231xx *dev = fh->dev; | ||
958 | int width = f->fmt.pix.width; | ||
959 | int height = f->fmt.pix.height; | ||
960 | unsigned int maxw = norm_maxw(dev); | ||
961 | unsigned int maxh = norm_maxh(dev); | ||
962 | unsigned int hscale, vscale; | ||
963 | struct cx231xx_fmt *fmt; | ||
964 | |||
965 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
966 | if (!fmt) { | ||
967 | cx231xx_videodbg("Fourcc format (%08x) invalid.\n", | ||
968 | f->fmt.pix.pixelformat); | ||
969 | return -EINVAL; | ||
970 | } | ||
971 | |||
972 | /* width must even because of the YUYV format | ||
973 | height must be even because of interlacing */ | ||
974 | height &= 0xfffe; | ||
975 | width &= 0xfffe; | ||
976 | |||
977 | if (unlikely(height < 32)) | ||
978 | height = 32; | ||
979 | if (unlikely(height > maxh)) | ||
980 | height = maxh; | ||
981 | if (unlikely(width < 48)) | ||
982 | width = 48; | ||
983 | if (unlikely(width > maxw)) | ||
984 | width = maxw; | ||
985 | |||
986 | get_scale(dev, width, height, &hscale, &vscale); | ||
987 | |||
988 | width = (((unsigned long)maxw) << 12) / (hscale + 4096L); | ||
989 | height = (((unsigned long)maxh) << 12) / (vscale + 4096L); | ||
990 | |||
991 | f->fmt.pix.width = width; | ||
992 | f->fmt.pix.height = height; | ||
993 | f->fmt.pix.pixelformat = fmt->fourcc; | ||
994 | f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; | ||
995 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; | ||
996 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
997 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | ||
998 | |||
999 | return 0; | ||
1000 | } | ||
1001 | |||
1002 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | ||
1003 | struct v4l2_format *f) | ||
1004 | { | ||
1005 | struct cx231xx_fh *fh = priv; | ||
1006 | struct cx231xx *dev = fh->dev; | ||
1007 | int rc; | ||
1008 | struct cx231xx_fmt *fmt; | ||
1009 | |||
1010 | rc = check_dev(dev); | ||
1011 | if (rc < 0) | ||
1012 | return rc; | ||
1013 | |||
1014 | mutex_lock(&dev->lock); | ||
1015 | |||
1016 | vidioc_try_fmt_vid_cap(file, priv, f); | ||
1017 | |||
1018 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
1019 | if (!fmt) { | ||
1020 | rc = -EINVAL; | ||
1021 | goto out; | ||
1022 | } | ||
1023 | |||
1024 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | ||
1025 | cx231xx_errdev("%s queue busy\n", __func__); | ||
1026 | rc = -EBUSY; | ||
1027 | goto out; | ||
1028 | } | ||
1029 | |||
1030 | if (dev->stream_on && !fh->stream_on) { | ||
1031 | cx231xx_errdev("%s device in use by another fh\n", __func__); | ||
1032 | rc = -EBUSY; | ||
1033 | goto out; | ||
1034 | } | ||
1035 | |||
1036 | /* set new image size */ | ||
1037 | dev->width = f->fmt.pix.width; | ||
1038 | dev->height = f->fmt.pix.height; | ||
1039 | dev->format = fmt; | ||
1040 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | ||
1041 | |||
1042 | call_all(dev, video, s_fmt, f); | ||
1043 | |||
1044 | /* Set the correct alternate setting for this resolution */ | ||
1045 | cx231xx_resolution_set(dev); | ||
1046 | |||
1047 | out: | ||
1048 | mutex_unlock(&dev->lock); | ||
1049 | return rc; | ||
1050 | } | ||
1051 | |||
1052 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id * id) | ||
1053 | { | ||
1054 | struct cx231xx_fh *fh = priv; | ||
1055 | struct cx231xx *dev = fh->dev; | ||
1056 | |||
1057 | *id = dev->norm; | ||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | ||
1062 | { | ||
1063 | struct cx231xx_fh *fh = priv; | ||
1064 | struct cx231xx *dev = fh->dev; | ||
1065 | struct v4l2_format f; | ||
1066 | int rc; | ||
1067 | |||
1068 | rc = check_dev(dev); | ||
1069 | if (rc < 0) | ||
1070 | return rc; | ||
1071 | |||
1072 | cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm); | ||
1073 | |||
1074 | mutex_lock(&dev->lock); | ||
1075 | dev->norm = *norm; | ||
1076 | |||
1077 | /* Adjusts width/height, if needed */ | ||
1078 | f.fmt.pix.width = dev->width; | ||
1079 | f.fmt.pix.height = dev->height; | ||
1080 | vidioc_try_fmt_vid_cap(file, priv, &f); | ||
1081 | |||
1082 | /* set new image size */ | ||
1083 | dev->width = f.fmt.pix.width; | ||
1084 | dev->height = f.fmt.pix.height; | ||
1085 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | ||
1086 | |||
1087 | call_all(dev, core, s_std, dev->norm); | ||
1088 | |||
1089 | mutex_unlock(&dev->lock); | ||
1090 | |||
1091 | cx231xx_resolution_set(dev); | ||
1092 | |||
1093 | /* do mode control overrides */ | ||
1094 | cx231xx_do_mode_ctrl_overrides(dev); | ||
1095 | |||
1096 | return 0; | ||
1097 | } | ||
1098 | |||
1099 | static const char *iname[] = { | ||
1100 | [CX231XX_VMUX_COMPOSITE1] = "Composite1", | ||
1101 | [CX231XX_VMUX_SVIDEO] = "S-Video", | ||
1102 | [CX231XX_VMUX_TELEVISION] = "Television", | ||
1103 | [CX231XX_VMUX_CABLE] = "Cable TV", | ||
1104 | [CX231XX_VMUX_DVB] = "DVB", | ||
1105 | [CX231XX_VMUX_DEBUG] = "for debug only", | ||
1106 | }; | ||
1107 | |||
1108 | static int vidioc_enum_input(struct file *file, void *priv, | ||
1109 | struct v4l2_input *i) | ||
1110 | { | ||
1111 | struct cx231xx_fh *fh = priv; | ||
1112 | struct cx231xx *dev = fh->dev; | ||
1113 | unsigned int n; | ||
1114 | |||
1115 | n = i->index; | ||
1116 | if (n >= MAX_CX231XX_INPUT) | ||
1117 | return -EINVAL; | ||
1118 | if (0 == INPUT(n)->type) | ||
1119 | return -EINVAL; | ||
1120 | |||
1121 | i->index = n; | ||
1122 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
1123 | |||
1124 | strcpy(i->name, iname[INPUT(n)->type]); | ||
1125 | |||
1126 | if ((CX231XX_VMUX_TELEVISION == INPUT(n)->type) || | ||
1127 | (CX231XX_VMUX_CABLE == INPUT(n)->type)) | ||
1128 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1129 | |||
1130 | i->std = dev->vdev->tvnorms; | ||
1131 | |||
1132 | return 0; | ||
1133 | } | ||
1134 | |||
1135 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) | ||
1136 | { | ||
1137 | struct cx231xx_fh *fh = priv; | ||
1138 | struct cx231xx *dev = fh->dev; | ||
1139 | |||
1140 | *i = dev->video_input; | ||
1141 | |||
1142 | return 0; | ||
1143 | } | ||
1144 | |||
1145 | static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | ||
1146 | { | ||
1147 | struct cx231xx_fh *fh = priv; | ||
1148 | struct cx231xx *dev = fh->dev; | ||
1149 | int rc; | ||
1150 | |||
1151 | rc = check_dev(dev); | ||
1152 | if (rc < 0) | ||
1153 | return rc; | ||
1154 | |||
1155 | if (i >= MAX_CX231XX_INPUT) | ||
1156 | return -EINVAL; | ||
1157 | if (0 == INPUT(i)->type) | ||
1158 | return -EINVAL; | ||
1159 | |||
1160 | mutex_lock(&dev->lock); | ||
1161 | |||
1162 | video_mux(dev, i); | ||
1163 | |||
1164 | mutex_unlock(&dev->lock); | ||
1165 | return 0; | ||
1166 | } | ||
1167 | |||
1168 | static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
1169 | { | ||
1170 | struct cx231xx_fh *fh = priv; | ||
1171 | struct cx231xx *dev = fh->dev; | ||
1172 | |||
1173 | switch (a->index) { | ||
1174 | case CX231XX_AMUX_VIDEO: | ||
1175 | strcpy(a->name, "Television"); | ||
1176 | break; | ||
1177 | case CX231XX_AMUX_LINE_IN: | ||
1178 | strcpy(a->name, "Line In"); | ||
1179 | break; | ||
1180 | default: | ||
1181 | return -EINVAL; | ||
1182 | } | ||
1183 | |||
1184 | a->index = dev->ctl_ainput; | ||
1185 | a->capability = V4L2_AUDCAP_STEREO; | ||
1186 | |||
1187 | return 0; | ||
1188 | } | ||
1189 | |||
1190 | static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
1191 | { | ||
1192 | struct cx231xx_fh *fh = priv; | ||
1193 | struct cx231xx *dev = fh->dev; | ||
1194 | int status = 0; | ||
1195 | |||
1196 | /* Doesn't allow manual routing */ | ||
1197 | if (a->index != dev->ctl_ainput) | ||
1198 | return -EINVAL; | ||
1199 | |||
1200 | dev->ctl_ainput = INPUT(a->index)->amux; | ||
1201 | status = cx231xx_set_audio_input(dev, dev->ctl_ainput); | ||
1202 | |||
1203 | return status; | ||
1204 | } | ||
1205 | |||
1206 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
1207 | struct v4l2_queryctrl *qc) | ||
1208 | { | ||
1209 | struct cx231xx_fh *fh = priv; | ||
1210 | struct cx231xx *dev = fh->dev; | ||
1211 | int id = qc->id; | ||
1212 | int i; | ||
1213 | int rc; | ||
1214 | |||
1215 | rc = check_dev(dev); | ||
1216 | if (rc < 0) | ||
1217 | return rc; | ||
1218 | |||
1219 | qc->id = v4l2_ctrl_next(ctrl_classes, qc->id); | ||
1220 | if (unlikely(qc->id == 0)) | ||
1221 | return -EINVAL; | ||
1222 | |||
1223 | memset(qc, 0, sizeof(*qc)); | ||
1224 | |||
1225 | qc->id = id; | ||
1226 | |||
1227 | if (qc->id < V4L2_CID_BASE || qc->id >= V4L2_CID_LASTP1) | ||
1228 | return -EINVAL; | ||
1229 | |||
1230 | for (i = 0; i < CX231XX_CTLS; i++) | ||
1231 | if (cx231xx_ctls[i].v.id == qc->id) | ||
1232 | break; | ||
1233 | |||
1234 | if (i == CX231XX_CTLS) { | ||
1235 | *qc = no_ctl; | ||
1236 | return 0; | ||
1237 | } | ||
1238 | *qc = cx231xx_ctls[i].v; | ||
1239 | |||
1240 | mutex_lock(&dev->lock); | ||
1241 | call_all(dev, core, queryctrl, qc); | ||
1242 | mutex_unlock(&dev->lock); | ||
1243 | |||
1244 | if (qc->type) | ||
1245 | return 0; | ||
1246 | else | ||
1247 | return -EINVAL; | ||
1248 | } | ||
1249 | |||
1250 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
1251 | struct v4l2_control *ctrl) | ||
1252 | { | ||
1253 | struct cx231xx_fh *fh = priv; | ||
1254 | struct cx231xx *dev = fh->dev; | ||
1255 | int rc; | ||
1256 | |||
1257 | rc = check_dev(dev); | ||
1258 | if (rc < 0) | ||
1259 | return rc; | ||
1260 | |||
1261 | mutex_lock(&dev->lock); | ||
1262 | call_all(dev, core, g_ctrl, ctrl); | ||
1263 | mutex_unlock(&dev->lock); | ||
1264 | return rc; | ||
1265 | } | ||
1266 | |||
1267 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
1268 | struct v4l2_control *ctrl) | ||
1269 | { | ||
1270 | struct cx231xx_fh *fh = priv; | ||
1271 | struct cx231xx *dev = fh->dev; | ||
1272 | int rc; | ||
1273 | |||
1274 | rc = check_dev(dev); | ||
1275 | if (rc < 0) | ||
1276 | return rc; | ||
1277 | |||
1278 | mutex_lock(&dev->lock); | ||
1279 | call_all(dev, core, s_ctrl, ctrl); | ||
1280 | mutex_unlock(&dev->lock); | ||
1281 | return rc; | ||
1282 | } | ||
1283 | |||
1284 | static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1285 | { | ||
1286 | struct cx231xx_fh *fh = priv; | ||
1287 | struct cx231xx *dev = fh->dev; | ||
1288 | int rc; | ||
1289 | |||
1290 | rc = check_dev(dev); | ||
1291 | if (rc < 0) | ||
1292 | return rc; | ||
1293 | |||
1294 | if (0 != t->index) | ||
1295 | return -EINVAL; | ||
1296 | |||
1297 | strcpy(t->name, "Tuner"); | ||
1298 | |||
1299 | t->type = V4L2_TUNER_ANALOG_TV; | ||
1300 | t->capability = V4L2_TUNER_CAP_NORM; | ||
1301 | t->rangehigh = 0xffffffffUL; | ||
1302 | t->signal = 0xffff; /* LOCKED */ | ||
1303 | |||
1304 | return 0; | ||
1305 | } | ||
1306 | |||
1307 | static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1308 | { | ||
1309 | struct cx231xx_fh *fh = priv; | ||
1310 | struct cx231xx *dev = fh->dev; | ||
1311 | int rc; | ||
1312 | |||
1313 | rc = check_dev(dev); | ||
1314 | if (rc < 0) | ||
1315 | return rc; | ||
1316 | |||
1317 | if (0 != t->index) | ||
1318 | return -EINVAL; | ||
1319 | #if 0 | ||
1320 | mutex_lock(&dev->lock); | ||
1321 | call_all(dev, tuner, s_tuner, t); | ||
1322 | mutex_unlock(&dev->lock); | ||
1323 | #endif | ||
1324 | return 0; | ||
1325 | } | ||
1326 | |||
1327 | static int vidioc_g_frequency(struct file *file, void *priv, | ||
1328 | struct v4l2_frequency *f) | ||
1329 | { | ||
1330 | struct cx231xx_fh *fh = priv; | ||
1331 | struct cx231xx *dev = fh->dev; | ||
1332 | |||
1333 | mutex_lock(&dev->lock); | ||
1334 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1335 | f->frequency = dev->ctl_freq; | ||
1336 | |||
1337 | call_all(dev, tuner, g_frequency, f); | ||
1338 | |||
1339 | mutex_unlock(&dev->lock); | ||
1340 | |||
1341 | return 0; | ||
1342 | } | ||
1343 | |||
1344 | static int vidioc_s_frequency(struct file *file, void *priv, | ||
1345 | struct v4l2_frequency *f) | ||
1346 | { | ||
1347 | struct cx231xx_fh *fh = priv; | ||
1348 | struct cx231xx *dev = fh->dev; | ||
1349 | int rc; | ||
1350 | |||
1351 | rc = check_dev(dev); | ||
1352 | if (rc < 0) | ||
1353 | return rc; | ||
1354 | |||
1355 | if (0 != f->tuner) | ||
1356 | return -EINVAL; | ||
1357 | |||
1358 | if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) | ||
1359 | return -EINVAL; | ||
1360 | if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) | ||
1361 | return -EINVAL; | ||
1362 | |||
1363 | /* set pre channel change settings in DIF first */ | ||
1364 | rc = cx231xx_tuner_pre_channel_change(dev); | ||
1365 | |||
1366 | mutex_lock(&dev->lock); | ||
1367 | |||
1368 | dev->ctl_freq = f->frequency; | ||
1369 | |||
1370 | if (dev->tuner_type == TUNER_XC5000) { | ||
1371 | if (dev->cx231xx_set_analog_freq != NULL) | ||
1372 | dev->cx231xx_set_analog_freq(dev, f->frequency); | ||
1373 | } else | ||
1374 | call_all(dev, tuner, s_frequency, f); | ||
1375 | |||
1376 | mutex_unlock(&dev->lock); | ||
1377 | |||
1378 | /* set post channel change settings in DIF first */ | ||
1379 | rc = cx231xx_tuner_post_channel_change(dev); | ||
1380 | |||
1381 | cx231xx_info("Set New FREQUENCY to %d\n", f->frequency); | ||
1382 | |||
1383 | return rc; | ||
1384 | } | ||
1385 | |||
1386 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1387 | |||
1388 | /* | ||
1389 | -R, --list-registers=type=<host/i2cdrv/i2caddr>, | ||
1390 | chip=<chip>[,min=<addr>,max=<addr>] | ||
1391 | dump registers from <min> to <max> [VIDIOC_DBG_G_REGISTER] | ||
1392 | -r, --set-register=type=<host/i2cdrv/i2caddr>, | ||
1393 | chip=<chip>,reg=<addr>,val=<val> | ||
1394 | set the register [VIDIOC_DBG_S_REGISTER] | ||
1395 | |||
1396 | if type == host, then <chip> is the hosts chip ID (default 0) | ||
1397 | if type == i2cdrv (default), then <chip> is the I2C driver name or ID | ||
1398 | if type == i2caddr, then <chip> is the 7-bit I2C address | ||
1399 | */ | ||
1400 | |||
1401 | static int vidioc_g_register(struct file *file, void *priv, | ||
1402 | struct v4l2_dbg_register *reg) | ||
1403 | { | ||
1404 | struct cx231xx_fh *fh = priv; | ||
1405 | struct cx231xx *dev = fh->dev; | ||
1406 | int ret = 0; | ||
1407 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1408 | u32 data = 0; | ||
1409 | |||
1410 | switch (reg->match.type) { | ||
1411 | case V4L2_CHIP_MATCH_HOST: | ||
1412 | switch (reg->match.addr) { | ||
1413 | case 0: /* Cx231xx - internal registers */ | ||
1414 | ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | ||
1415 | (u16)reg->reg, value, 4); | ||
1416 | reg->val = value[0] | value[1] << 8 | | ||
1417 | value[2] << 16 | value[3] << 24; | ||
1418 | break; | ||
1419 | case 1: /* AFE - read byte */ | ||
1420 | ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
1421 | (u16)reg->reg, 2, &data, 1); | ||
1422 | reg->val = le32_to_cpu(data & 0xff); | ||
1423 | break; | ||
1424 | case 14: /* AFE - read dword */ | ||
1425 | ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
1426 | (u16)reg->reg, 2, &data, 4); | ||
1427 | reg->val = le32_to_cpu(data); | ||
1428 | break; | ||
1429 | case 2: /* Video Block - read byte */ | ||
1430 | ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
1431 | (u16)reg->reg, 2, &data, 1); | ||
1432 | reg->val = le32_to_cpu(data & 0xff); | ||
1433 | break; | ||
1434 | case 24: /* Video Block - read dword */ | ||
1435 | ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
1436 | (u16)reg->reg, 2, &data, 4); | ||
1437 | reg->val = le32_to_cpu(data); | ||
1438 | break; | ||
1439 | case 3: /* I2S block - read byte */ | ||
1440 | ret = cx231xx_read_i2c_data(dev, | ||
1441 | I2S_BLK_DEVICE_ADDRESS, | ||
1442 | (u16)reg->reg, 1, | ||
1443 | &data, 1); | ||
1444 | reg->val = le32_to_cpu(data & 0xff); | ||
1445 | break; | ||
1446 | case 34: /* I2S Block - read dword */ | ||
1447 | ret = | ||
1448 | cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1449 | (u16)reg->reg, 1, &data, 4); | ||
1450 | reg->val = le32_to_cpu(data); | ||
1451 | break; | ||
1452 | } | ||
1453 | return ret < 0 ? ret : 0; | ||
1454 | |||
1455 | case V4L2_CHIP_MATCH_I2C_DRIVER: | ||
1456 | call_all(dev, core, g_register, reg); | ||
1457 | return 0; | ||
1458 | case V4L2_CHIP_MATCH_I2C_ADDR: | ||
1459 | /* Not supported yet */ | ||
1460 | return -EINVAL; | ||
1461 | default: | ||
1462 | if (!v4l2_chip_match_host(®->match)) | ||
1463 | return -EINVAL; | ||
1464 | } | ||
1465 | |||
1466 | mutex_lock(&dev->lock); | ||
1467 | call_all(dev, core, g_register, reg); | ||
1468 | mutex_unlock(&dev->lock); | ||
1469 | |||
1470 | return ret; | ||
1471 | } | ||
1472 | |||
1473 | static int vidioc_s_register(struct file *file, void *priv, | ||
1474 | struct v4l2_dbg_register *reg) | ||
1475 | { | ||
1476 | struct cx231xx_fh *fh = priv; | ||
1477 | struct cx231xx *dev = fh->dev; | ||
1478 | int ret = 0; | ||
1479 | __le64 buf; | ||
1480 | u32 value; | ||
1481 | u8 data[4] = { 0, 0, 0, 0 }; | ||
1482 | |||
1483 | buf = cpu_to_le64(reg->val); | ||
1484 | |||
1485 | switch (reg->match.type) { | ||
1486 | case V4L2_CHIP_MATCH_HOST: | ||
1487 | { | ||
1488 | value = (u32) buf & 0xffffffff; | ||
1489 | |||
1490 | switch (reg->match.addr) { | ||
1491 | case 0: /* cx231xx internal registers */ | ||
1492 | data[0] = (u8) value; | ||
1493 | data[1] = (u8) (value >> 8); | ||
1494 | data[2] = (u8) (value >> 16); | ||
1495 | data[3] = (u8) (value >> 24); | ||
1496 | ret = cx231xx_write_ctrl_reg(dev, | ||
1497 | VRT_SET_REGISTER, | ||
1498 | (u16)reg->reg, data, | ||
1499 | 4); | ||
1500 | break; | ||
1501 | case 1: /* AFE - read byte */ | ||
1502 | ret = cx231xx_write_i2c_data(dev, | ||
1503 | AFE_DEVICE_ADDRESS, | ||
1504 | (u16)reg->reg, 2, | ||
1505 | value, 1); | ||
1506 | break; | ||
1507 | case 14: /* AFE - read dword */ | ||
1508 | ret = cx231xx_write_i2c_data(dev, | ||
1509 | AFE_DEVICE_ADDRESS, | ||
1510 | (u16)reg->reg, 2, | ||
1511 | value, 4); | ||
1512 | break; | ||
1513 | case 2: /* Video Block - read byte */ | ||
1514 | ret = | ||
1515 | cx231xx_write_i2c_data(dev, | ||
1516 | VID_BLK_I2C_ADDRESS, | ||
1517 | (u16)reg->reg, 2, | ||
1518 | value, 1); | ||
1519 | break; | ||
1520 | case 24: /* Video Block - read dword */ | ||
1521 | ret = | ||
1522 | cx231xx_write_i2c_data(dev, | ||
1523 | VID_BLK_I2C_ADDRESS, | ||
1524 | (u16)reg->reg, 2, | ||
1525 | value, 4); | ||
1526 | break; | ||
1527 | case 3: /* I2S block - read byte */ | ||
1528 | ret = | ||
1529 | cx231xx_write_i2c_data(dev, | ||
1530 | I2S_BLK_DEVICE_ADDRESS, | ||
1531 | (u16)reg->reg, 1, | ||
1532 | value, 1); | ||
1533 | break; | ||
1534 | case 34: /* I2S block - read dword */ | ||
1535 | ret = | ||
1536 | cx231xx_write_i2c_data(dev, | ||
1537 | I2S_BLK_DEVICE_ADDRESS, | ||
1538 | (u16)reg->reg, 1, | ||
1539 | value, 4); | ||
1540 | break; | ||
1541 | } | ||
1542 | } | ||
1543 | return ret < 0 ? ret : 0; | ||
1544 | |||
1545 | default: | ||
1546 | break; | ||
1547 | } | ||
1548 | |||
1549 | mutex_lock(&dev->lock); | ||
1550 | call_all(dev, core, s_register, reg); | ||
1551 | mutex_unlock(&dev->lock); | ||
1552 | |||
1553 | return ret; | ||
1554 | } | ||
1555 | #endif | ||
1556 | |||
1557 | static int vidioc_cropcap(struct file *file, void *priv, | ||
1558 | struct v4l2_cropcap *cc) | ||
1559 | { | ||
1560 | struct cx231xx_fh *fh = priv; | ||
1561 | struct cx231xx *dev = fh->dev; | ||
1562 | |||
1563 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1564 | return -EINVAL; | ||
1565 | |||
1566 | cc->bounds.left = 0; | ||
1567 | cc->bounds.top = 0; | ||
1568 | cc->bounds.width = dev->width; | ||
1569 | cc->bounds.height = dev->height; | ||
1570 | cc->defrect = cc->bounds; | ||
1571 | cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ | ||
1572 | cc->pixelaspect.denominator = 59; | ||
1573 | |||
1574 | return 0; | ||
1575 | } | ||
1576 | |||
1577 | static int vidioc_streamon(struct file *file, void *priv, | ||
1578 | enum v4l2_buf_type type) | ||
1579 | { | ||
1580 | struct cx231xx_fh *fh = priv; | ||
1581 | struct cx231xx *dev = fh->dev; | ||
1582 | int rc; | ||
1583 | |||
1584 | rc = check_dev(dev); | ||
1585 | if (rc < 0) | ||
1586 | return rc; | ||
1587 | |||
1588 | mutex_lock(&dev->lock); | ||
1589 | rc = res_get(fh); | ||
1590 | |||
1591 | if (likely(rc >= 0)) | ||
1592 | rc = videobuf_streamon(&fh->vb_vidq); | ||
1593 | |||
1594 | call_all(dev, video, s_stream, 1); | ||
1595 | |||
1596 | mutex_unlock(&dev->lock); | ||
1597 | |||
1598 | return rc; | ||
1599 | } | ||
1600 | |||
1601 | static int vidioc_streamoff(struct file *file, void *priv, | ||
1602 | enum v4l2_buf_type type) | ||
1603 | { | ||
1604 | struct cx231xx_fh *fh = priv; | ||
1605 | struct cx231xx *dev = fh->dev; | ||
1606 | int rc; | ||
1607 | |||
1608 | rc = check_dev(dev); | ||
1609 | if (rc < 0) | ||
1610 | return rc; | ||
1611 | |||
1612 | if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && | ||
1613 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) | ||
1614 | return -EINVAL; | ||
1615 | if (type != fh->type) | ||
1616 | return -EINVAL; | ||
1617 | |||
1618 | mutex_lock(&dev->lock); | ||
1619 | |||
1620 | cx25840_call(dev, video, s_stream, 0); | ||
1621 | |||
1622 | videobuf_streamoff(&fh->vb_vidq); | ||
1623 | res_free(fh); | ||
1624 | |||
1625 | mutex_unlock(&dev->lock); | ||
1626 | |||
1627 | return 0; | ||
1628 | } | ||
1629 | |||
1630 | static int vidioc_querycap(struct file *file, void *priv, | ||
1631 | struct v4l2_capability *cap) | ||
1632 | { | ||
1633 | struct cx231xx_fh *fh = priv; | ||
1634 | struct cx231xx *dev = fh->dev; | ||
1635 | |||
1636 | strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); | ||
1637 | strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); | ||
1638 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | ||
1639 | |||
1640 | cap->version = CX231XX_VERSION_CODE; | ||
1641 | |||
1642 | cap->capabilities = V4L2_CAP_VBI_CAPTURE | | ||
1643 | #if 0 | ||
1644 | V4L2_CAP_SLICED_VBI_CAPTURE | | ||
1645 | #endif | ||
1646 | V4L2_CAP_VIDEO_CAPTURE | | ||
1647 | V4L2_CAP_AUDIO | | ||
1648 | V4L2_CAP_READWRITE | | ||
1649 | V4L2_CAP_STREAMING; | ||
1650 | |||
1651 | if (dev->tuner_type != TUNER_ABSENT) | ||
1652 | cap->capabilities |= V4L2_CAP_TUNER; | ||
1653 | |||
1654 | return 0; | ||
1655 | } | ||
1656 | |||
1657 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | ||
1658 | struct v4l2_fmtdesc *f) | ||
1659 | { | ||
1660 | if (unlikely(f->index >= ARRAY_SIZE(format))) | ||
1661 | return -EINVAL; | ||
1662 | |||
1663 | strlcpy(f->description, format[f->index].name, sizeof(f->description)); | ||
1664 | f->pixelformat = format[f->index].fourcc; | ||
1665 | |||
1666 | return 0; | ||
1667 | } | ||
1668 | |||
1669 | /* Sliced VBI ioctls */ | ||
1670 | static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | ||
1671 | struct v4l2_format *f) | ||
1672 | { | ||
1673 | struct cx231xx_fh *fh = priv; | ||
1674 | struct cx231xx *dev = fh->dev; | ||
1675 | int rc; | ||
1676 | |||
1677 | rc = check_dev(dev); | ||
1678 | if (rc < 0) | ||
1679 | return rc; | ||
1680 | |||
1681 | mutex_lock(&dev->lock); | ||
1682 | |||
1683 | f->fmt.sliced.service_set = 0; | ||
1684 | |||
1685 | call_all(dev, video, g_fmt, f); | ||
1686 | |||
1687 | if (f->fmt.sliced.service_set == 0) | ||
1688 | rc = -EINVAL; | ||
1689 | |||
1690 | mutex_unlock(&dev->lock); | ||
1691 | return rc; | ||
1692 | } | ||
1693 | |||
1694 | static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, | ||
1695 | struct v4l2_format *f) | ||
1696 | { | ||
1697 | struct cx231xx_fh *fh = priv; | ||
1698 | struct cx231xx *dev = fh->dev; | ||
1699 | int rc; | ||
1700 | |||
1701 | rc = check_dev(dev); | ||
1702 | if (rc < 0) | ||
1703 | return rc; | ||
1704 | |||
1705 | mutex_lock(&dev->lock); | ||
1706 | call_all(dev, video, g_fmt, f); | ||
1707 | mutex_unlock(&dev->lock); | ||
1708 | |||
1709 | if (f->fmt.sliced.service_set == 0) | ||
1710 | return -EINVAL; | ||
1711 | |||
1712 | return 0; | ||
1713 | } | ||
1714 | |||
1715 | /* RAW VBI ioctls */ | ||
1716 | |||
1717 | static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, | ||
1718 | struct v4l2_format *f) | ||
1719 | { | ||
1720 | struct cx231xx_fh *fh = priv; | ||
1721 | struct cx231xx *dev = fh->dev; | ||
1722 | |||
1723 | f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ? | ||
1724 | 35468950 : 28636363; | ||
1725 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; | ||
1726 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
1727 | f->fmt.vbi.offset = 64 * 4; | ||
1728 | f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1729 | PAL_VBI_START_LINE : NTSC_VBI_START_LINE; | ||
1730 | f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1731 | PAL_VBI_LINES : NTSC_VBI_LINES; | ||
1732 | f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ? | ||
1733 | PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263; | ||
1734 | f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; | ||
1735 | |||
1736 | return 0; | ||
1737 | |||
1738 | } | ||
1739 | |||
1740 | static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv, | ||
1741 | struct v4l2_format *f) | ||
1742 | { | ||
1743 | struct cx231xx_fh *fh = priv; | ||
1744 | struct cx231xx *dev = fh->dev; | ||
1745 | |||
1746 | if (dev->vbi_stream_on && !fh->stream_on) { | ||
1747 | cx231xx_errdev("%s device in use by another fh\n", __func__); | ||
1748 | return -EBUSY; | ||
1749 | } | ||
1750 | |||
1751 | f->type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
1752 | f->fmt.vbi.sampling_rate = (dev->norm & V4L2_STD_625_50) ? | ||
1753 | 35468950 : 28636363; | ||
1754 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; | ||
1755 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
1756 | f->fmt.vbi.offset = 244; | ||
1757 | f->fmt.vbi.flags = 0; | ||
1758 | f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1759 | PAL_VBI_START_LINE : NTSC_VBI_START_LINE; | ||
1760 | f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1761 | PAL_VBI_LINES : NTSC_VBI_LINES; | ||
1762 | f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ? | ||
1763 | PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263; | ||
1764 | f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; | ||
1765 | |||
1766 | return 0; | ||
1767 | |||
1768 | } | ||
1769 | |||
1770 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1771 | struct v4l2_requestbuffers *rb) | ||
1772 | { | ||
1773 | struct cx231xx_fh *fh = priv; | ||
1774 | struct cx231xx *dev = fh->dev; | ||
1775 | int rc; | ||
1776 | |||
1777 | rc = check_dev(dev); | ||
1778 | if (rc < 0) | ||
1779 | return rc; | ||
1780 | |||
1781 | return videobuf_reqbufs(&fh->vb_vidq, rb); | ||
1782 | } | ||
1783 | |||
1784 | static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1785 | { | ||
1786 | struct cx231xx_fh *fh = priv; | ||
1787 | struct cx231xx *dev = fh->dev; | ||
1788 | int rc; | ||
1789 | |||
1790 | rc = check_dev(dev); | ||
1791 | if (rc < 0) | ||
1792 | return rc; | ||
1793 | |||
1794 | return videobuf_querybuf(&fh->vb_vidq, b); | ||
1795 | } | ||
1796 | |||
1797 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1798 | { | ||
1799 | struct cx231xx_fh *fh = priv; | ||
1800 | struct cx231xx *dev = fh->dev; | ||
1801 | int rc; | ||
1802 | |||
1803 | rc = check_dev(dev); | ||
1804 | if (rc < 0) | ||
1805 | return rc; | ||
1806 | |||
1807 | return videobuf_qbuf(&fh->vb_vidq, b); | ||
1808 | } | ||
1809 | |||
1810 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1811 | { | ||
1812 | struct cx231xx_fh *fh = priv; | ||
1813 | struct cx231xx *dev = fh->dev; | ||
1814 | int rc; | ||
1815 | |||
1816 | rc = check_dev(dev); | ||
1817 | if (rc < 0) | ||
1818 | return rc; | ||
1819 | |||
1820 | return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK); | ||
1821 | } | ||
1822 | |||
1823 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
1824 | static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | ||
1825 | { | ||
1826 | struct cx231xx_fh *fh = priv; | ||
1827 | |||
1828 | return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); | ||
1829 | } | ||
1830 | #endif | ||
1831 | |||
1832 | /* ----------------------------------------------------------- */ | ||
1833 | /* RADIO ESPECIFIC IOCTLS */ | ||
1834 | /* ----------------------------------------------------------- */ | ||
1835 | |||
1836 | static int radio_querycap(struct file *file, void *priv, | ||
1837 | struct v4l2_capability *cap) | ||
1838 | { | ||
1839 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
1840 | |||
1841 | strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); | ||
1842 | strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); | ||
1843 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | ||
1844 | |||
1845 | cap->version = CX231XX_VERSION_CODE; | ||
1846 | cap->capabilities = V4L2_CAP_TUNER; | ||
1847 | return 0; | ||
1848 | } | ||
1849 | |||
1850 | static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1851 | { | ||
1852 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
1853 | |||
1854 | if (unlikely(t->index > 0)) | ||
1855 | return -EINVAL; | ||
1856 | |||
1857 | strcpy(t->name, "Radio"); | ||
1858 | t->type = V4L2_TUNER_RADIO; | ||
1859 | |||
1860 | mutex_lock(&dev->lock); | ||
1861 | call_all(dev, tuner, s_tuner, t); | ||
1862 | mutex_unlock(&dev->lock); | ||
1863 | |||
1864 | return 0; | ||
1865 | } | ||
1866 | |||
1867 | static int radio_enum_input(struct file *file, void *priv, struct v4l2_input *i) | ||
1868 | { | ||
1869 | if (i->index != 0) | ||
1870 | return -EINVAL; | ||
1871 | strcpy(i->name, "Radio"); | ||
1872 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1873 | |||
1874 | return 0; | ||
1875 | } | ||
1876 | |||
1877 | static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
1878 | { | ||
1879 | if (unlikely(a->index)) | ||
1880 | return -EINVAL; | ||
1881 | |||
1882 | strcpy(a->name, "Radio"); | ||
1883 | return 0; | ||
1884 | } | ||
1885 | |||
1886 | static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1887 | { | ||
1888 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
1889 | |||
1890 | if (0 != t->index) | ||
1891 | return -EINVAL; | ||
1892 | |||
1893 | mutex_lock(&dev->lock); | ||
1894 | call_all(dev, tuner, s_tuner, t); | ||
1895 | mutex_unlock(&dev->lock); | ||
1896 | |||
1897 | return 0; | ||
1898 | } | ||
1899 | |||
1900 | static int radio_s_audio(struct file *file, void *fh, struct v4l2_audio *a) | ||
1901 | { | ||
1902 | return 0; | ||
1903 | } | ||
1904 | |||
1905 | static int radio_s_input(struct file *file, void *fh, unsigned int i) | ||
1906 | { | ||
1907 | return 0; | ||
1908 | } | ||
1909 | |||
1910 | static int radio_queryctrl(struct file *file, void *priv, | ||
1911 | struct v4l2_queryctrl *c) | ||
1912 | { | ||
1913 | int i; | ||
1914 | |||
1915 | if (c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1) | ||
1916 | return -EINVAL; | ||
1917 | if (c->id == V4L2_CID_AUDIO_MUTE) { | ||
1918 | for (i = 0; i < CX231XX_CTLS; i++) | ||
1919 | if (cx231xx_ctls[i].v.id == c->id) | ||
1920 | break; | ||
1921 | *c = cx231xx_ctls[i].v; | ||
1922 | } else | ||
1923 | *c = no_ctl; | ||
1924 | return 0; | ||
1925 | } | ||
1926 | |||
1927 | /* | ||
1928 | * cx231xx_v4l2_open() | ||
1929 | * inits the device and starts isoc transfer | ||
1930 | */ | ||
1931 | static int cx231xx_v4l2_open(struct file *filp) | ||
1932 | { | ||
1933 | int minor = video_devdata(filp)->minor; | ||
1934 | int errCode = 0, radio = 0; | ||
1935 | struct cx231xx *dev = NULL; | ||
1936 | struct cx231xx_fh *fh; | ||
1937 | enum v4l2_buf_type fh_type = 0; | ||
1938 | |||
1939 | dev = cx231xx_get_device(minor, &fh_type, &radio); | ||
1940 | if (NULL == dev) | ||
1941 | return -ENODEV; | ||
1942 | |||
1943 | mutex_lock(&dev->lock); | ||
1944 | |||
1945 | cx231xx_videodbg("open minor=%d type=%s users=%d\n", | ||
1946 | minor, v4l2_type_names[fh_type], dev->users); | ||
1947 | |||
1948 | #if 0 | ||
1949 | errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
1950 | if (errCode < 0) { | ||
1951 | cx231xx_errdev | ||
1952 | ("Device locked on digital mode. Can't open analog\n"); | ||
1953 | mutex_unlock(&dev->lock); | ||
1954 | return -EBUSY; | ||
1955 | } | ||
1956 | #endif | ||
1957 | |||
1958 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); | ||
1959 | if (!fh) { | ||
1960 | cx231xx_errdev("cx231xx-video.c: Out of memory?!\n"); | ||
1961 | mutex_unlock(&dev->lock); | ||
1962 | return -ENOMEM; | ||
1963 | } | ||
1964 | fh->dev = dev; | ||
1965 | fh->radio = radio; | ||
1966 | fh->type = fh_type; | ||
1967 | filp->private_data = fh; | ||
1968 | |||
1969 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | ||
1970 | dev->width = norm_maxw(dev); | ||
1971 | dev->height = norm_maxh(dev); | ||
1972 | dev->hscale = 0; | ||
1973 | dev->vscale = 0; | ||
1974 | |||
1975 | /* Power up in Analog TV mode */ | ||
1976 | cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); | ||
1977 | |||
1978 | #if 0 | ||
1979 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
1980 | #endif | ||
1981 | cx231xx_resolution_set(dev); | ||
1982 | |||
1983 | /* set video alternate setting */ | ||
1984 | cx231xx_set_video_alternate(dev); | ||
1985 | |||
1986 | /* Needed, since GPIO might have disabled power of | ||
1987 | some i2c device */ | ||
1988 | cx231xx_config_i2c(dev); | ||
1989 | |||
1990 | /* device needs to be initialized before isoc transfer */ | ||
1991 | dev->video_input = dev->video_input > 2 ? 2 : dev->video_input; | ||
1992 | video_mux(dev, dev->video_input); | ||
1993 | |||
1994 | } | ||
1995 | if (fh->radio) { | ||
1996 | cx231xx_videodbg("video_open: setting radio device\n"); | ||
1997 | |||
1998 | /* cx231xx_start_radio(dev); */ | ||
1999 | |||
2000 | call_all(dev, tuner, s_radio); | ||
2001 | } | ||
2002 | |||
2003 | dev->users++; | ||
2004 | |||
2005 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2006 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, | ||
2007 | NULL, &dev->video_mode.slock, | ||
2008 | fh->type, V4L2_FIELD_INTERLACED, | ||
2009 | sizeof(struct cx231xx_buffer), fh); | ||
2010 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2011 | /* Set the required alternate setting VBI interface works in | ||
2012 | Bulk mode only */ | ||
2013 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
2014 | |||
2015 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, | ||
2016 | NULL, &dev->vbi_mode.slock, | ||
2017 | fh->type, V4L2_FIELD_SEQ_TB, | ||
2018 | sizeof(struct cx231xx_buffer), fh); | ||
2019 | } | ||
2020 | |||
2021 | mutex_unlock(&dev->lock); | ||
2022 | |||
2023 | return errCode; | ||
2024 | } | ||
2025 | |||
2026 | /* | ||
2027 | * cx231xx_realease_resources() | ||
2028 | * unregisters the v4l2,i2c and usb devices | ||
2029 | * called when the device gets disconected or at module unload | ||
2030 | */ | ||
2031 | void cx231xx_release_analog_resources(struct cx231xx *dev) | ||
2032 | { | ||
2033 | |||
2034 | /*FIXME: I2C IR should be disconnected */ | ||
2035 | |||
2036 | if (dev->radio_dev) { | ||
2037 | if (-1 != dev->radio_dev->minor) | ||
2038 | video_unregister_device(dev->radio_dev); | ||
2039 | else | ||
2040 | video_device_release(dev->radio_dev); | ||
2041 | dev->radio_dev = NULL; | ||
2042 | } | ||
2043 | if (dev->vbi_dev) { | ||
2044 | cx231xx_info("V4L2 device /dev/vbi%d deregistered\n", | ||
2045 | dev->vbi_dev->num); | ||
2046 | if (-1 != dev->vbi_dev->minor) | ||
2047 | video_unregister_device(dev->vbi_dev); | ||
2048 | else | ||
2049 | video_device_release(dev->vbi_dev); | ||
2050 | dev->vbi_dev = NULL; | ||
2051 | } | ||
2052 | if (dev->vdev) { | ||
2053 | cx231xx_info("V4L2 device /dev/video%d deregistered\n", | ||
2054 | dev->vdev->num); | ||
2055 | if (-1 != dev->vdev->minor) | ||
2056 | video_unregister_device(dev->vdev); | ||
2057 | else | ||
2058 | video_device_release(dev->vdev); | ||
2059 | dev->vdev = NULL; | ||
2060 | } | ||
2061 | } | ||
2062 | |||
2063 | /* | ||
2064 | * cx231xx_v4l2_close() | ||
2065 | * stops streaming and deallocates all resources allocated by the v4l2 | ||
2066 | * calls and ioctls | ||
2067 | */ | ||
2068 | static int cx231xx_v4l2_close(struct file *filp) | ||
2069 | { | ||
2070 | struct cx231xx_fh *fh = filp->private_data; | ||
2071 | struct cx231xx *dev = fh->dev; | ||
2072 | |||
2073 | cx231xx_videodbg("users=%d\n", dev->users); | ||
2074 | |||
2075 | mutex_lock(&dev->lock); | ||
2076 | |||
2077 | if (res_check(fh)) | ||
2078 | res_free(fh); | ||
2079 | |||
2080 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2081 | videobuf_stop(&fh->vb_vidq); | ||
2082 | videobuf_mmap_free(&fh->vb_vidq); | ||
2083 | |||
2084 | /* the device is already disconnect, | ||
2085 | free the remaining resources */ | ||
2086 | if (dev->state & DEV_DISCONNECTED) { | ||
2087 | cx231xx_release_resources(dev); | ||
2088 | mutex_unlock(&dev->lock); | ||
2089 | kfree(dev); | ||
2090 | return 0; | ||
2091 | } | ||
2092 | |||
2093 | /* do this before setting alternate! */ | ||
2094 | cx231xx_uninit_vbi_isoc(dev); | ||
2095 | |||
2096 | /* set alternate 0 */ | ||
2097 | if (!dev->vbi_or_sliced_cc_mode) | ||
2098 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
2099 | else | ||
2100 | cx231xx_set_alt_setting(dev, INDEX_HANC, 0); | ||
2101 | |||
2102 | kfree(fh); | ||
2103 | dev->users--; | ||
2104 | wake_up_interruptible_nr(&dev->open, 1); | ||
2105 | mutex_unlock(&dev->lock); | ||
2106 | return 0; | ||
2107 | } | ||
2108 | |||
2109 | if (dev->users == 1) { | ||
2110 | videobuf_stop(&fh->vb_vidq); | ||
2111 | videobuf_mmap_free(&fh->vb_vidq); | ||
2112 | |||
2113 | /* the device is already disconnect, | ||
2114 | free the remaining resources */ | ||
2115 | if (dev->state & DEV_DISCONNECTED) { | ||
2116 | cx231xx_release_resources(dev); | ||
2117 | mutex_unlock(&dev->lock); | ||
2118 | kfree(dev); | ||
2119 | return 0; | ||
2120 | } | ||
2121 | |||
2122 | /* Save some power by putting tuner to sleep */ | ||
2123 | call_all(dev, tuner, s_standby); | ||
2124 | |||
2125 | /* do this before setting alternate! */ | ||
2126 | cx231xx_uninit_isoc(dev); | ||
2127 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
2128 | |||
2129 | /* set alternate 0 */ | ||
2130 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); | ||
2131 | } | ||
2132 | kfree(fh); | ||
2133 | dev->users--; | ||
2134 | wake_up_interruptible_nr(&dev->open, 1); | ||
2135 | mutex_unlock(&dev->lock); | ||
2136 | return 0; | ||
2137 | } | ||
2138 | |||
2139 | /* | ||
2140 | * cx231xx_v4l2_read() | ||
2141 | * will allocate buffers when called for the first time | ||
2142 | */ | ||
2143 | static ssize_t | ||
2144 | cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, | ||
2145 | loff_t *pos) | ||
2146 | { | ||
2147 | struct cx231xx_fh *fh = filp->private_data; | ||
2148 | struct cx231xx *dev = fh->dev; | ||
2149 | int rc; | ||
2150 | |||
2151 | rc = check_dev(dev); | ||
2152 | if (rc < 0) | ||
2153 | return rc; | ||
2154 | |||
2155 | if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) || | ||
2156 | (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) { | ||
2157 | mutex_lock(&dev->lock); | ||
2158 | rc = res_get(fh); | ||
2159 | mutex_unlock(&dev->lock); | ||
2160 | |||
2161 | if (unlikely(rc < 0)) | ||
2162 | return rc; | ||
2163 | |||
2164 | return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0, | ||
2165 | filp->f_flags & O_NONBLOCK); | ||
2166 | } | ||
2167 | return 0; | ||
2168 | } | ||
2169 | |||
2170 | /* | ||
2171 | * cx231xx_v4l2_poll() | ||
2172 | * will allocate buffers when called for the first time | ||
2173 | */ | ||
2174 | static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table * wait) | ||
2175 | { | ||
2176 | struct cx231xx_fh *fh = filp->private_data; | ||
2177 | struct cx231xx *dev = fh->dev; | ||
2178 | int rc; | ||
2179 | |||
2180 | rc = check_dev(dev); | ||
2181 | if (rc < 0) | ||
2182 | return rc; | ||
2183 | |||
2184 | mutex_lock(&dev->lock); | ||
2185 | rc = res_get(fh); | ||
2186 | mutex_unlock(&dev->lock); | ||
2187 | |||
2188 | if (unlikely(rc < 0)) | ||
2189 | return POLLERR; | ||
2190 | |||
2191 | if ((V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) || | ||
2192 | (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)) | ||
2193 | return videobuf_poll_stream(filp, &fh->vb_vidq, wait); | ||
2194 | else | ||
2195 | return POLLERR; | ||
2196 | } | ||
2197 | |||
2198 | /* | ||
2199 | * cx231xx_v4l2_mmap() | ||
2200 | */ | ||
2201 | static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | ||
2202 | { | ||
2203 | struct cx231xx_fh *fh = filp->private_data; | ||
2204 | struct cx231xx *dev = fh->dev; | ||
2205 | int rc; | ||
2206 | |||
2207 | rc = check_dev(dev); | ||
2208 | if (rc < 0) | ||
2209 | return rc; | ||
2210 | |||
2211 | mutex_lock(&dev->lock); | ||
2212 | rc = res_get(fh); | ||
2213 | mutex_unlock(&dev->lock); | ||
2214 | |||
2215 | if (unlikely(rc < 0)) | ||
2216 | return rc; | ||
2217 | |||
2218 | rc = videobuf_mmap_mapper(&fh->vb_vidq, vma); | ||
2219 | |||
2220 | cx231xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", | ||
2221 | (unsigned long)vma->vm_start, | ||
2222 | (unsigned long)vma->vm_end - | ||
2223 | (unsigned long)vma->vm_start, rc); | ||
2224 | |||
2225 | return rc; | ||
2226 | } | ||
2227 | |||
2228 | static const struct v4l2_file_operations cx231xx_v4l_fops = { | ||
2229 | .owner = THIS_MODULE, | ||
2230 | .open = cx231xx_v4l2_open, | ||
2231 | .release = cx231xx_v4l2_close, | ||
2232 | .read = cx231xx_v4l2_read, | ||
2233 | .poll = cx231xx_v4l2_poll, | ||
2234 | .mmap = cx231xx_v4l2_mmap, | ||
2235 | .ioctl = video_ioctl2, | ||
2236 | }; | ||
2237 | |||
2238 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | ||
2239 | .vidioc_querycap = vidioc_querycap, | ||
2240 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, | ||
2241 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | ||
2242 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | ||
2243 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | ||
2244 | .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, | ||
2245 | .vidioc_try_fmt_vbi_cap = vidioc_try_fmt_vbi_cap, | ||
2246 | .vidioc_s_fmt_vbi_cap = vidioc_try_fmt_vbi_cap, | ||
2247 | .vidioc_g_audio = vidioc_g_audio, | ||
2248 | .vidioc_s_audio = vidioc_s_audio, | ||
2249 | .vidioc_cropcap = vidioc_cropcap, | ||
2250 | .vidioc_g_fmt_sliced_vbi_cap = vidioc_g_fmt_sliced_vbi_cap, | ||
2251 | .vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap, | ||
2252 | .vidioc_reqbufs = vidioc_reqbufs, | ||
2253 | .vidioc_querybuf = vidioc_querybuf, | ||
2254 | .vidioc_qbuf = vidioc_qbuf, | ||
2255 | .vidioc_dqbuf = vidioc_dqbuf, | ||
2256 | .vidioc_s_std = vidioc_s_std, | ||
2257 | .vidioc_g_std = vidioc_g_std, | ||
2258 | .vidioc_enum_input = vidioc_enum_input, | ||
2259 | .vidioc_g_input = vidioc_g_input, | ||
2260 | .vidioc_s_input = vidioc_s_input, | ||
2261 | .vidioc_queryctrl = vidioc_queryctrl, | ||
2262 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
2263 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2264 | .vidioc_streamon = vidioc_streamon, | ||
2265 | .vidioc_streamoff = vidioc_streamoff, | ||
2266 | .vidioc_g_tuner = vidioc_g_tuner, | ||
2267 | .vidioc_s_tuner = vidioc_s_tuner, | ||
2268 | .vidioc_g_frequency = vidioc_g_frequency, | ||
2269 | .vidioc_s_frequency = vidioc_s_frequency, | ||
2270 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2271 | .vidioc_g_register = vidioc_g_register, | ||
2272 | .vidioc_s_register = vidioc_s_register, | ||
2273 | #endif | ||
2274 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
2275 | .vidiocgmbuf = vidiocgmbuf, | ||
2276 | #endif | ||
2277 | }; | ||
2278 | |||
2279 | static struct video_device cx231xx_vbi_template; | ||
2280 | |||
2281 | static const struct video_device cx231xx_video_template = { | ||
2282 | .fops = &cx231xx_v4l_fops, | ||
2283 | .release = video_device_release, | ||
2284 | .ioctl_ops = &video_ioctl_ops, | ||
2285 | .minor = -1, | ||
2286 | .tvnorms = V4L2_STD_ALL, | ||
2287 | .current_norm = V4L2_STD_PAL, | ||
2288 | }; | ||
2289 | |||
2290 | static const struct v4l2_file_operations radio_fops = { | ||
2291 | .owner = THIS_MODULE, | ||
2292 | .open = cx231xx_v4l2_open, | ||
2293 | .release = cx231xx_v4l2_close, | ||
2294 | .ioctl = video_ioctl2, | ||
2295 | }; | ||
2296 | |||
2297 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | ||
2298 | .vidioc_querycap = radio_querycap, | ||
2299 | .vidioc_g_tuner = radio_g_tuner, | ||
2300 | .vidioc_enum_input = radio_enum_input, | ||
2301 | .vidioc_g_audio = radio_g_audio, | ||
2302 | .vidioc_s_tuner = radio_s_tuner, | ||
2303 | .vidioc_s_audio = radio_s_audio, | ||
2304 | .vidioc_s_input = radio_s_input, | ||
2305 | .vidioc_queryctrl = radio_queryctrl, | ||
2306 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
2307 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2308 | .vidioc_g_frequency = vidioc_g_frequency, | ||
2309 | .vidioc_s_frequency = vidioc_s_frequency, | ||
2310 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2311 | .vidioc_g_register = vidioc_g_register, | ||
2312 | .vidioc_s_register = vidioc_s_register, | ||
2313 | #endif | ||
2314 | }; | ||
2315 | |||
2316 | static struct video_device cx231xx_radio_template = { | ||
2317 | .name = "cx231xx-radio", | ||
2318 | .fops = &radio_fops, | ||
2319 | .ioctl_ops = &radio_ioctl_ops, | ||
2320 | .minor = -1, | ||
2321 | }; | ||
2322 | |||
2323 | /******************************** usb interface ******************************/ | ||
2324 | |||
2325 | static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, | ||
2326 | const struct video_device | ||
2327 | *template, const char *type_name) | ||
2328 | { | ||
2329 | struct video_device *vfd; | ||
2330 | |||
2331 | vfd = video_device_alloc(); | ||
2332 | if (NULL == vfd) | ||
2333 | return NULL; | ||
2334 | |||
2335 | *vfd = *template; | ||
2336 | vfd->minor = -1; | ||
2337 | vfd->v4l2_dev = &dev->v4l2_dev; | ||
2338 | vfd->release = video_device_release; | ||
2339 | vfd->debug = video_debug; | ||
2340 | |||
2341 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); | ||
2342 | |||
2343 | return vfd; | ||
2344 | } | ||
2345 | |||
2346 | int cx231xx_register_analog_devices(struct cx231xx *dev) | ||
2347 | { | ||
2348 | int ret; | ||
2349 | |||
2350 | cx231xx_info("%s: v4l2 driver version %d.%d.%d\n", | ||
2351 | dev->name, | ||
2352 | (CX231XX_VERSION_CODE >> 16) & 0xff, | ||
2353 | (CX231XX_VERSION_CODE >> 8) & 0xff, | ||
2354 | CX231XX_VERSION_CODE & 0xff); | ||
2355 | |||
2356 | /* set default norm */ | ||
2357 | /*dev->norm = cx231xx_video_template.current_norm; */ | ||
2358 | dev->width = norm_maxw(dev); | ||
2359 | dev->height = norm_maxh(dev); | ||
2360 | dev->interlaced = 0; | ||
2361 | dev->hscale = 0; | ||
2362 | dev->vscale = 0; | ||
2363 | |||
2364 | /* Analog specific initialization */ | ||
2365 | dev->format = &format[0]; | ||
2366 | /* video_mux(dev, dev->video_input); */ | ||
2367 | |||
2368 | /* Audio defaults */ | ||
2369 | dev->mute = 1; | ||
2370 | dev->volume = 0x1f; | ||
2371 | |||
2372 | /* enable vbi capturing */ | ||
2373 | /* write code here... */ | ||
2374 | |||
2375 | /* allocate and fill video video_device struct */ | ||
2376 | dev->vdev = cx231xx_vdev_init(dev, &cx231xx_video_template, "video"); | ||
2377 | if (!dev->vdev) { | ||
2378 | cx231xx_errdev("cannot allocate video_device.\n"); | ||
2379 | return -ENODEV; | ||
2380 | } | ||
2381 | |||
2382 | /* register v4l2 video video_device */ | ||
2383 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | ||
2384 | video_nr[dev->devno]); | ||
2385 | if (ret) { | ||
2386 | cx231xx_errdev("unable to register video device (error=%i).\n", | ||
2387 | ret); | ||
2388 | return ret; | ||
2389 | } | ||
2390 | |||
2391 | cx231xx_info("%s/0: registered device video%d [v4l2]\n", | ||
2392 | dev->name, dev->vdev->num); | ||
2393 | |||
2394 | /* Initialize VBI template */ | ||
2395 | memcpy(&cx231xx_vbi_template, &cx231xx_video_template, | ||
2396 | sizeof(cx231xx_vbi_template)); | ||
2397 | strcpy(cx231xx_vbi_template.name, "cx231xx-vbi"); | ||
2398 | |||
2399 | /* Allocate and fill vbi video_device struct */ | ||
2400 | dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi"); | ||
2401 | |||
2402 | /* register v4l2 vbi video_device */ | ||
2403 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | ||
2404 | vbi_nr[dev->devno]); | ||
2405 | if (ret < 0) { | ||
2406 | cx231xx_errdev("unable to register vbi device\n"); | ||
2407 | return ret; | ||
2408 | } | ||
2409 | |||
2410 | cx231xx_info("%s/0: registered device vbi%d\n", | ||
2411 | dev->name, dev->vbi_dev->num); | ||
2412 | |||
2413 | if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) { | ||
2414 | dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template, | ||
2415 | "radio"); | ||
2416 | if (!dev->radio_dev) { | ||
2417 | cx231xx_errdev("cannot allocate video_device.\n"); | ||
2418 | return -ENODEV; | ||
2419 | } | ||
2420 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | ||
2421 | radio_nr[dev->devno]); | ||
2422 | if (ret < 0) { | ||
2423 | cx231xx_errdev("can't register radio device\n"); | ||
2424 | return ret; | ||
2425 | } | ||
2426 | cx231xx_info("Registered radio device as /dev/radio%d\n", | ||
2427 | dev->radio_dev->num); | ||
2428 | } | ||
2429 | |||
2430 | cx231xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", | ||
2431 | dev->vdev->num, dev->vbi_dev->num); | ||
2432 | |||
2433 | return 0; | ||
2434 | } | ||
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h new file mode 100644 index 000000000000..aa4a23ef491a --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx.h | |||
@@ -0,0 +1,779 @@ | |||
1 | /* | ||
2 | cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_H | ||
23 | #define _CX231XX_H | ||
24 | |||
25 | #include <linux/videodev2.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/ioctl.h> | ||
28 | #include <linux/i2c.h> | ||
29 | #include <linux/i2c-algo-bit.h> | ||
30 | #include <linux/mutex.h> | ||
31 | |||
32 | |||
33 | #include <media/videobuf-vmalloc.h> | ||
34 | #include <media/v4l2-device.h> | ||
35 | #include <media/ir-kbd-i2c.h> | ||
36 | #if defined(CONFIG_VIDEO_CX231XX_DVB) || \ | ||
37 | defined(CONFIG_VIDEO_CX231XX_DVB_MODULE) | ||
38 | #include <media/videobuf-dvb.h> | ||
39 | #endif | ||
40 | |||
41 | #include "cx231xx-reg.h" | ||
42 | #include "cx231xx-pcb-cfg.h" | ||
43 | #include "cx231xx-conf-reg.h" | ||
44 | |||
45 | #define DRIVER_NAME "cx231xx" | ||
46 | #define PWR_SLEEP_INTERVAL 5 | ||
47 | |||
48 | /* I2C addresses for control block in Cx231xx */ | ||
49 | #define AFE_DEVICE_ADDRESS 0x60 | ||
50 | #define I2S_BLK_DEVICE_ADDRESS 0x98 | ||
51 | #define VID_BLK_I2C_ADDRESS 0x88 | ||
52 | #define DIF_USE_BASEBAND 0xFFFFFFFF | ||
53 | |||
54 | /* Boards supported by driver */ | ||
55 | #define CX231XX_BOARD_UNKNOWN 0 | ||
56 | #define CX231XX_BOARD_CNXT_RDE_250 1 | ||
57 | #define CX231XX_BOARD_CNXT_RDU_250 2 | ||
58 | |||
59 | /* Limits minimum and default number of buffers */ | ||
60 | #define CX231XX_MIN_BUF 4 | ||
61 | #define CX231XX_DEF_BUF 12 | ||
62 | #define CX231XX_DEF_VBI_BUF 6 | ||
63 | |||
64 | #define VBI_LINE_COUNT 17 | ||
65 | #define VBI_LINE_LENGTH 1440 | ||
66 | |||
67 | /*Limits the max URB message size */ | ||
68 | #define URB_MAX_CTRL_SIZE 80 | ||
69 | |||
70 | /* Params for validated field */ | ||
71 | #define CX231XX_BOARD_NOT_VALIDATED 1 | ||
72 | #define CX231XX_BOARD_VALIDATED 0 | ||
73 | |||
74 | /* maximum number of cx231xx boards */ | ||
75 | #define CX231XX_MAXBOARDS 8 | ||
76 | |||
77 | /* maximum number of frames that can be queued */ | ||
78 | #define CX231XX_NUM_FRAMES 5 | ||
79 | |||
80 | /* number of buffers for isoc transfers */ | ||
81 | #define CX231XX_NUM_BUFS 8 | ||
82 | |||
83 | /* number of packets for each buffer | ||
84 | windows requests only 40 packets .. so we better do the same | ||
85 | this is what I found out for all alternate numbers there! | ||
86 | */ | ||
87 | #define CX231XX_NUM_PACKETS 40 | ||
88 | |||
89 | /* default alternate; 0 means choose the best */ | ||
90 | #define CX231XX_PINOUT 0 | ||
91 | |||
92 | #define CX231XX_INTERLACED_DEFAULT 1 | ||
93 | |||
94 | /* time to wait when stopping the isoc transfer */ | ||
95 | #define CX231XX_URB_TIMEOUT \ | ||
96 | msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS) | ||
97 | |||
98 | enum cx231xx_mode { | ||
99 | CX231XX_SUSPEND, | ||
100 | CX231XX_ANALOG_MODE, | ||
101 | CX231XX_DIGITAL_MODE, | ||
102 | }; | ||
103 | |||
104 | enum cx231xx_std_mode { | ||
105 | CX231XX_TV_AIR = 0, | ||
106 | CX231XX_TV_CABLE | ||
107 | }; | ||
108 | |||
109 | enum cx231xx_stream_state { | ||
110 | STREAM_OFF, | ||
111 | STREAM_INTERRUPT, | ||
112 | STREAM_ON, | ||
113 | }; | ||
114 | |||
115 | struct cx231xx; | ||
116 | |||
117 | struct cx231xx_usb_isoc_ctl { | ||
118 | /* max packet size of isoc transaction */ | ||
119 | int max_pkt_size; | ||
120 | |||
121 | /* number of allocated urbs */ | ||
122 | int num_bufs; | ||
123 | |||
124 | /* urb for isoc transfers */ | ||
125 | struct urb **urb; | ||
126 | |||
127 | /* transfer buffers for isoc transfer */ | ||
128 | char **transfer_buffer; | ||
129 | |||
130 | /* Last buffer command and region */ | ||
131 | u8 cmd; | ||
132 | int pos, size, pktsize; | ||
133 | |||
134 | /* Last field: ODD or EVEN? */ | ||
135 | int field; | ||
136 | |||
137 | /* Stores incomplete commands */ | ||
138 | u32 tmp_buf; | ||
139 | int tmp_buf_len; | ||
140 | |||
141 | /* Stores already requested buffers */ | ||
142 | struct cx231xx_buffer *buf; | ||
143 | |||
144 | /* Stores the number of received fields */ | ||
145 | int nfields; | ||
146 | |||
147 | /* isoc urb callback */ | ||
148 | int (*isoc_copy) (struct cx231xx *dev, struct urb *urb); | ||
149 | }; | ||
150 | |||
151 | struct cx231xx_fmt { | ||
152 | char *name; | ||
153 | u32 fourcc; /* v4l2 format id */ | ||
154 | int depth; | ||
155 | int reg; | ||
156 | }; | ||
157 | |||
158 | /* buffer for one video frame */ | ||
159 | struct cx231xx_buffer { | ||
160 | /* common v4l buffer stuff -- must be first */ | ||
161 | struct videobuf_buffer vb; | ||
162 | |||
163 | struct list_head frame; | ||
164 | int top_field; | ||
165 | int receiving; | ||
166 | }; | ||
167 | |||
168 | struct cx231xx_dmaqueue { | ||
169 | struct list_head active; | ||
170 | struct list_head queued; | ||
171 | |||
172 | wait_queue_head_t wq; | ||
173 | |||
174 | /* Counters to control buffer fill */ | ||
175 | int pos; | ||
176 | u8 is_partial_line; | ||
177 | u8 partial_buf[8]; | ||
178 | u8 last_sav; | ||
179 | int current_field; | ||
180 | u32 bytes_left_in_line; | ||
181 | u32 lines_completed; | ||
182 | u8 field1_done; | ||
183 | u32 lines_per_field; | ||
184 | }; | ||
185 | |||
186 | /* inputs */ | ||
187 | |||
188 | #define MAX_CX231XX_INPUT 4 | ||
189 | |||
190 | enum cx231xx_itype { | ||
191 | CX231XX_VMUX_COMPOSITE1 = 1, | ||
192 | CX231XX_VMUX_SVIDEO, | ||
193 | CX231XX_VMUX_TELEVISION, | ||
194 | CX231XX_VMUX_CABLE, | ||
195 | CX231XX_RADIO, | ||
196 | CX231XX_VMUX_DVB, | ||
197 | CX231XX_VMUX_DEBUG | ||
198 | }; | ||
199 | |||
200 | enum cx231xx_v_input { | ||
201 | CX231XX_VIN_1_1 = 0x1, | ||
202 | CX231XX_VIN_2_1, | ||
203 | CX231XX_VIN_3_1, | ||
204 | CX231XX_VIN_4_1, | ||
205 | CX231XX_VIN_1_2 = 0x01, | ||
206 | CX231XX_VIN_2_2, | ||
207 | CX231XX_VIN_3_2, | ||
208 | CX231XX_VIN_1_3 = 0x1, | ||
209 | CX231XX_VIN_2_3, | ||
210 | CX231XX_VIN_3_3, | ||
211 | }; | ||
212 | |||
213 | /* cx231xx has two audio inputs: tuner and line in */ | ||
214 | enum cx231xx_amux { | ||
215 | /* This is the only entry for cx231xx tuner input */ | ||
216 | CX231XX_AMUX_VIDEO, /* cx231xx tuner */ | ||
217 | CX231XX_AMUX_LINE_IN, /* Line In */ | ||
218 | }; | ||
219 | |||
220 | struct cx231xx_reg_seq { | ||
221 | unsigned char bit; | ||
222 | unsigned char val; | ||
223 | int sleep; | ||
224 | }; | ||
225 | |||
226 | struct cx231xx_input { | ||
227 | enum cx231xx_itype type; | ||
228 | unsigned int vmux; | ||
229 | enum cx231xx_amux amux; | ||
230 | struct cx231xx_reg_seq *gpio; | ||
231 | }; | ||
232 | |||
233 | #define INPUT(nr) (&cx231xx_boards[dev->model].input[nr]) | ||
234 | |||
235 | enum cx231xx_decoder { | ||
236 | CX231XX_NODECODER, | ||
237 | CX231XX_AVDECODER | ||
238 | }; | ||
239 | |||
240 | enum CX231XX_I2C_MASTER_PORT { | ||
241 | I2C_0 = 0, | ||
242 | I2C_1 = 1, | ||
243 | I2C_2 = 2, | ||
244 | I2C_3 = 3 | ||
245 | }; | ||
246 | |||
247 | struct cx231xx_board { | ||
248 | char *name; | ||
249 | int vchannels; | ||
250 | int tuner_type; | ||
251 | int tuner_addr; | ||
252 | v4l2_std_id norm; /* tv norm */ | ||
253 | |||
254 | /* demod related */ | ||
255 | int demod_addr; | ||
256 | u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */ | ||
257 | |||
258 | /* GPIO Pins */ | ||
259 | struct cx231xx_reg_seq *dvb_gpio; | ||
260 | struct cx231xx_reg_seq *suspend_gpio; | ||
261 | struct cx231xx_reg_seq *tuner_gpio; | ||
262 | u8 tuner_sif_gpio; | ||
263 | u8 tuner_scl_gpio; | ||
264 | u8 tuner_sda_gpio; | ||
265 | |||
266 | /* PIN ctrl */ | ||
267 | u32 ctl_pin_status_mask; | ||
268 | u8 agc_analog_digital_select_gpio; | ||
269 | u32 gpio_pin_status_mask; | ||
270 | |||
271 | /* i2c masters */ | ||
272 | u8 tuner_i2c_master; | ||
273 | u8 demod_i2c_master; | ||
274 | |||
275 | unsigned int max_range_640_480:1; | ||
276 | unsigned int has_dvb:1; | ||
277 | unsigned int valid:1; | ||
278 | |||
279 | unsigned char xclk, i2c_speed; | ||
280 | |||
281 | enum cx231xx_decoder decoder; | ||
282 | |||
283 | struct cx231xx_input input[MAX_CX231XX_INPUT]; | ||
284 | struct cx231xx_input radio; | ||
285 | IR_KEYTAB_TYPE *ir_codes; | ||
286 | }; | ||
287 | |||
288 | /* device states */ | ||
289 | enum cx231xx_dev_state { | ||
290 | DEV_INITIALIZED = 0x01, | ||
291 | DEV_DISCONNECTED = 0x02, | ||
292 | DEV_MISCONFIGURED = 0x04, | ||
293 | }; | ||
294 | |||
295 | enum AFE_MODE { | ||
296 | AFE_MODE_LOW_IF, | ||
297 | AFE_MODE_BASEBAND, | ||
298 | AFE_MODE_EU_HI_IF, | ||
299 | AFE_MODE_US_HI_IF, | ||
300 | AFE_MODE_JAPAN_HI_IF | ||
301 | }; | ||
302 | |||
303 | enum AUDIO_INPUT { | ||
304 | AUDIO_INPUT_MUTE, | ||
305 | AUDIO_INPUT_LINE, | ||
306 | AUDIO_INPUT_TUNER_TV, | ||
307 | AUDIO_INPUT_SPDIF, | ||
308 | AUDIO_INPUT_TUNER_FM | ||
309 | }; | ||
310 | |||
311 | #define CX231XX_AUDIO_BUFS 5 | ||
312 | #define CX231XX_NUM_AUDIO_PACKETS 64 | ||
313 | #define CX231XX_CAPTURE_STREAM_EN 1 | ||
314 | #define CX231XX_STOP_AUDIO 0 | ||
315 | #define CX231XX_START_AUDIO 1 | ||
316 | |||
317 | /* cx231xx extensions */ | ||
318 | #define CX231XX_AUDIO 0x10 | ||
319 | #define CX231XX_DVB 0x20 | ||
320 | |||
321 | struct cx231xx_audio { | ||
322 | char name[50]; | ||
323 | char *transfer_buffer[CX231XX_AUDIO_BUFS]; | ||
324 | struct urb *urb[CX231XX_AUDIO_BUFS]; | ||
325 | struct usb_device *udev; | ||
326 | unsigned int capture_transfer_done; | ||
327 | struct snd_pcm_substream *capture_pcm_substream; | ||
328 | |||
329 | unsigned int hwptr_done_capture; | ||
330 | struct snd_card *sndcard; | ||
331 | |||
332 | int users, shutdown; | ||
333 | enum cx231xx_stream_state capture_stream; | ||
334 | spinlock_t slock; | ||
335 | |||
336 | int alt; /* alternate */ | ||
337 | int max_pkt_size; /* max packet size of isoc transaction */ | ||
338 | int num_alt; /* Number of alternative settings */ | ||
339 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | ||
340 | u16 end_point_addr; | ||
341 | }; | ||
342 | |||
343 | struct cx231xx; | ||
344 | |||
345 | struct cx231xx_fh { | ||
346 | struct cx231xx *dev; | ||
347 | unsigned int stream_on:1; /* Locks streams */ | ||
348 | int radio; | ||
349 | |||
350 | struct videobuf_queue vb_vidq; | ||
351 | |||
352 | enum v4l2_buf_type type; | ||
353 | }; | ||
354 | |||
355 | /*****************************************************************/ | ||
356 | /* set/get i2c */ | ||
357 | /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ | ||
358 | #define I2C_SPEED_1M 0x0 | ||
359 | #define I2C_SPEED_400K 0x1 | ||
360 | #define I2C_SPEED_100K 0x2 | ||
361 | #define I2C_SPEED_5M 0x3 | ||
362 | |||
363 | /* 0-- STOP transaction */ | ||
364 | #define I2C_STOP 0x0 | ||
365 | /* 1-- do not transmit STOP at end of transaction */ | ||
366 | #define I2C_NOSTOP 0x1 | ||
367 | /* 1--alllow slave to insert clock wait states */ | ||
368 | #define I2C_SYNC 0x1 | ||
369 | |||
370 | struct cx231xx_i2c { | ||
371 | struct cx231xx *dev; | ||
372 | |||
373 | int nr; | ||
374 | |||
375 | /* i2c i/o */ | ||
376 | struct i2c_adapter i2c_adap; | ||
377 | struct i2c_algo_bit_data i2c_algo; | ||
378 | struct i2c_client i2c_client; | ||
379 | u32 i2c_rc; | ||
380 | |||
381 | /* different settings for each bus */ | ||
382 | u8 i2c_period; | ||
383 | u8 i2c_nostop; | ||
384 | u8 i2c_reserve; | ||
385 | }; | ||
386 | |||
387 | struct cx231xx_i2c_xfer_data { | ||
388 | u8 dev_addr; | ||
389 | u8 direction; /* 1 - IN, 0 - OUT */ | ||
390 | u8 saddr_len; /* sub address len */ | ||
391 | u16 saddr_dat; /* sub addr data */ | ||
392 | u8 buf_size; /* buffer size */ | ||
393 | u8 *p_buffer; /* pointer to the buffer */ | ||
394 | }; | ||
395 | |||
396 | struct VENDOR_REQUEST_IN { | ||
397 | u8 bRequest; | ||
398 | u16 wValue; | ||
399 | u16 wIndex; | ||
400 | u16 wLength; | ||
401 | u8 direction; | ||
402 | u8 bData; | ||
403 | u8 *pBuff; | ||
404 | }; | ||
405 | |||
406 | struct cx231xx_ctrl { | ||
407 | struct v4l2_queryctrl v; | ||
408 | u32 off; | ||
409 | u32 reg; | ||
410 | u32 mask; | ||
411 | u32 shift; | ||
412 | }; | ||
413 | |||
414 | enum TRANSFER_TYPE { | ||
415 | Raw_Video = 0, | ||
416 | Audio, | ||
417 | Vbi, /* VANC */ | ||
418 | Sliced_cc, /* HANC */ | ||
419 | TS1_serial_mode, | ||
420 | TS2, | ||
421 | TS1_parallel_mode | ||
422 | } ; | ||
423 | |||
424 | struct cx231xx_video_mode { | ||
425 | /* Isoc control struct */ | ||
426 | struct cx231xx_dmaqueue vidq; | ||
427 | struct cx231xx_usb_isoc_ctl isoc_ctl; | ||
428 | spinlock_t slock; | ||
429 | |||
430 | /* usb transfer */ | ||
431 | int alt; /* alternate */ | ||
432 | int max_pkt_size; /* max packet size of isoc transaction */ | ||
433 | int num_alt; /* Number of alternative settings */ | ||
434 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | ||
435 | u16 end_point_addr; | ||
436 | }; | ||
437 | |||
438 | /* main device struct */ | ||
439 | struct cx231xx { | ||
440 | /* generic device properties */ | ||
441 | char name[30]; /* name (including minor) of the device */ | ||
442 | int model; /* index in the device_data struct */ | ||
443 | int devno; /* marks the number of this device */ | ||
444 | |||
445 | struct cx231xx_board board; | ||
446 | |||
447 | unsigned int stream_on:1; /* Locks streams */ | ||
448 | unsigned int vbi_stream_on:1; /* Locks streams for VBI */ | ||
449 | unsigned int has_audio_class:1; | ||
450 | unsigned int has_alsa_audio:1; | ||
451 | |||
452 | struct cx231xx_fmt *format; | ||
453 | |||
454 | struct v4l2_device v4l2_dev; | ||
455 | struct v4l2_subdev *sd_cx25840; | ||
456 | struct v4l2_subdev *sd_tuner; | ||
457 | |||
458 | struct cx231xx_IR *ir; | ||
459 | |||
460 | struct list_head devlist; | ||
461 | |||
462 | int tuner_type; /* type of the tuner */ | ||
463 | int tuner_addr; /* tuner address */ | ||
464 | |||
465 | /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ | ||
466 | struct cx231xx_i2c i2c_bus[3]; | ||
467 | unsigned int xc_fw_load_done:1; | ||
468 | struct mutex gpio_i2c_lock; | ||
469 | |||
470 | /* video for linux */ | ||
471 | int users; /* user count for exclusive use */ | ||
472 | struct video_device *vdev; /* video for linux device struct */ | ||
473 | v4l2_std_id norm; /* selected tv norm */ | ||
474 | int ctl_freq; /* selected frequency */ | ||
475 | unsigned int ctl_ainput; /* selected audio input */ | ||
476 | int mute; | ||
477 | int volume; | ||
478 | |||
479 | /* frame properties */ | ||
480 | int width; /* current frame width */ | ||
481 | int height; /* current frame height */ | ||
482 | unsigned hscale; /* horizontal scale factor (see datasheet) */ | ||
483 | unsigned vscale; /* vertical scale factor (see datasheet) */ | ||
484 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ | ||
485 | |||
486 | struct cx231xx_audio adev; | ||
487 | |||
488 | /* states */ | ||
489 | enum cx231xx_dev_state state; | ||
490 | |||
491 | struct work_struct request_module_wk; | ||
492 | |||
493 | /* locks */ | ||
494 | struct mutex lock; | ||
495 | struct mutex ctrl_urb_lock; /* protects urb_buf */ | ||
496 | struct list_head inqueue, outqueue; | ||
497 | wait_queue_head_t open, wait_frame, wait_stream; | ||
498 | struct video_device *vbi_dev; | ||
499 | struct video_device *radio_dev; | ||
500 | |||
501 | unsigned char eedata[256]; | ||
502 | |||
503 | struct cx231xx_video_mode video_mode; | ||
504 | struct cx231xx_video_mode vbi_mode; | ||
505 | struct cx231xx_video_mode sliced_cc_mode; | ||
506 | struct cx231xx_video_mode ts1_mode; | ||
507 | |||
508 | struct usb_device *udev; /* the usb device */ | ||
509 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ | ||
510 | |||
511 | /* helper funcs that call usb_control_msg */ | ||
512 | int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, | ||
513 | char *buf, int len); | ||
514 | int (*cx231xx_write_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, | ||
515 | char *buf, int len); | ||
516 | int (*cx231xx_send_usb_command) (struct cx231xx_i2c *i2c_bus, | ||
517 | struct cx231xx_i2c_xfer_data *req_data); | ||
518 | int (*cx231xx_gpio_i2c_read) (struct cx231xx *dev, u8 dev_addr, | ||
519 | u8 *buf, u8 len); | ||
520 | int (*cx231xx_gpio_i2c_write) (struct cx231xx *dev, u8 dev_addr, | ||
521 | u8 *buf, u8 len); | ||
522 | |||
523 | int (*cx231xx_set_analog_freq) (struct cx231xx *dev, u32 freq); | ||
524 | int (*cx231xx_reset_analog_tuner) (struct cx231xx *dev); | ||
525 | |||
526 | enum cx231xx_mode mode; | ||
527 | |||
528 | struct cx231xx_dvb *dvb; | ||
529 | |||
530 | /* Cx231xx supported PCB config's */ | ||
531 | struct pcb_config current_pcb_config; | ||
532 | u8 current_scenario_idx; | ||
533 | u8 interface_count; | ||
534 | u8 max_iad_interface_count; | ||
535 | |||
536 | /* GPIO related register direction and values */ | ||
537 | u32 gpio_dir; | ||
538 | u32 gpio_val; | ||
539 | |||
540 | /* Power Modes */ | ||
541 | int power_mode; | ||
542 | |||
543 | /* afe parameters */ | ||
544 | enum AFE_MODE afe_mode; | ||
545 | u32 afe_ref_count; | ||
546 | |||
547 | /* video related parameters */ | ||
548 | u32 video_input; | ||
549 | u32 active_mode; | ||
550 | u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */ | ||
551 | enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */ | ||
552 | |||
553 | }; | ||
554 | |||
555 | #define cx25840_call(cx231xx, o, f, args...) \ | ||
556 | v4l2_subdev_call(cx231xx->sd_cx25840, o, f, ##args) | ||
557 | #define tuner_call(cx231xx, o, f, args...) \ | ||
558 | v4l2_subdev_call(cx231xx->sd_tuner, o, f, ##args) | ||
559 | #define call_all(dev, o, f, args...) \ | ||
560 | v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) | ||
561 | |||
562 | struct cx231xx_ops { | ||
563 | struct list_head next; | ||
564 | char *name; | ||
565 | int id; | ||
566 | int (*init) (struct cx231xx *); | ||
567 | int (*fini) (struct cx231xx *); | ||
568 | }; | ||
569 | |||
570 | /* call back functions in dvb module */ | ||
571 | int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq); | ||
572 | int cx231xx_reset_analog_tuner(struct cx231xx *dev); | ||
573 | |||
574 | /* Provided by cx231xx-i2c.c */ | ||
575 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); | ||
576 | int cx231xx_i2c_register(struct cx231xx_i2c *bus); | ||
577 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); | ||
578 | |||
579 | /* Internal block control functions */ | ||
580 | int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, | ||
581 | u16 saddr, u8 saddr_len, u32 *data, u8 data_len); | ||
582 | int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, | ||
583 | u16 saddr, u8 saddr_len, u32 data, u8 data_len); | ||
584 | int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, | ||
585 | u16 register_address, u8 bit_start, u8 bit_end, | ||
586 | u32 value); | ||
587 | int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, | ||
588 | u16 saddr, u32 mask, u32 value); | ||
589 | u32 cx231xx_set_field(u32 field_mask, u32 data); | ||
590 | |||
591 | /* afe related functions */ | ||
592 | int cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count); | ||
593 | int cx231xx_afe_init_channels(struct cx231xx *dev); | ||
594 | int cx231xx_afe_setup_AFE_for_baseband(struct cx231xx *dev); | ||
595 | int cx231xx_afe_set_input_mux(struct cx231xx *dev, u32 input_mux); | ||
596 | int cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode); | ||
597 | int cx231xx_afe_update_power_control(struct cx231xx *dev, | ||
598 | enum AV_MODE avmode); | ||
599 | int cx231xx_afe_adjust_ref_count(struct cx231xx *dev, u32 video_input); | ||
600 | |||
601 | /* i2s block related functions */ | ||
602 | int cx231xx_i2s_blk_initialize(struct cx231xx *dev); | ||
603 | int cx231xx_i2s_blk_update_power_control(struct cx231xx *dev, | ||
604 | enum AV_MODE avmode); | ||
605 | int cx231xx_i2s_blk_set_audio_input(struct cx231xx *dev, u8 audio_input); | ||
606 | |||
607 | /* DIF related functions */ | ||
608 | int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | ||
609 | u32 function_mode, u32 standard); | ||
610 | int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard); | ||
611 | int cx231xx_tuner_pre_channel_change(struct cx231xx *dev); | ||
612 | int cx231xx_tuner_post_channel_change(struct cx231xx *dev); | ||
613 | |||
614 | /* video parser functions */ | ||
615 | u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, | ||
616 | u32 *p_bytes_used); | ||
617 | u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, | ||
618 | u32 *p_bytes_used); | ||
619 | int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
620 | u8 *p_buffer, u32 bytes_to_copy); | ||
621 | void cx231xx_reset_video_buffer(struct cx231xx *dev, | ||
622 | struct cx231xx_dmaqueue *dma_q); | ||
623 | u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q); | ||
624 | u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
625 | u8 *p_line, u32 length, int field_number); | ||
626 | u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
627 | u8 sav_eav, u8 *p_buffer, u32 buffer_size); | ||
628 | void cx231xx_swab(u16 *from, u16 *to, u16 len); | ||
629 | |||
630 | /* Provided by cx231xx-core.c */ | ||
631 | |||
632 | u32 cx231xx_request_buffers(struct cx231xx *dev, u32 count); | ||
633 | void cx231xx_queue_unusedframes(struct cx231xx *dev); | ||
634 | void cx231xx_release_buffers(struct cx231xx *dev); | ||
635 | |||
636 | /* read from control pipe */ | ||
637 | int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
638 | char *buf, int len); | ||
639 | |||
640 | /* write to control pipe */ | ||
641 | int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
642 | char *buf, int len); | ||
643 | int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode); | ||
644 | |||
645 | int cx231xx_send_vendor_cmd(struct cx231xx *dev, | ||
646 | struct VENDOR_REQUEST_IN *ven_req); | ||
647 | int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, | ||
648 | struct cx231xx_i2c_xfer_data *req_data); | ||
649 | |||
650 | /* Gpio related functions */ | ||
651 | int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, | ||
652 | u8 len, u8 request, u8 direction); | ||
653 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val); | ||
654 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val); | ||
655 | int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value); | ||
656 | int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number, | ||
657 | int pin_value); | ||
658 | |||
659 | int cx231xx_gpio_i2c_start(struct cx231xx *dev); | ||
660 | int cx231xx_gpio_i2c_end(struct cx231xx *dev); | ||
661 | int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data); | ||
662 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf); | ||
663 | int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev); | ||
664 | int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev); | ||
665 | int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev); | ||
666 | |||
667 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); | ||
668 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); | ||
669 | |||
670 | /* audio related functions */ | ||
671 | int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | ||
672 | enum AUDIO_INPUT audio_input); | ||
673 | |||
674 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type); | ||
675 | int cx231xx_resolution_set(struct cx231xx *dev); | ||
676 | int cx231xx_set_video_alternate(struct cx231xx *dev); | ||
677 | int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt); | ||
678 | int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | ||
679 | int num_bufs, int max_pkt_size, | ||
680 | int (*isoc_copy) (struct cx231xx *dev, | ||
681 | struct urb *urb)); | ||
682 | void cx231xx_uninit_isoc(struct cx231xx *dev); | ||
683 | int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode); | ||
684 | int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio); | ||
685 | |||
686 | /* Device list functions */ | ||
687 | void cx231xx_release_resources(struct cx231xx *dev); | ||
688 | void cx231xx_release_analog_resources(struct cx231xx *dev); | ||
689 | int cx231xx_register_analog_devices(struct cx231xx *dev); | ||
690 | void cx231xx_remove_from_devlist(struct cx231xx *dev); | ||
691 | void cx231xx_add_into_devlist(struct cx231xx *dev); | ||
692 | struct cx231xx *cx231xx_get_device(int minor, | ||
693 | enum v4l2_buf_type *fh_type, int *has_radio); | ||
694 | void cx231xx_init_extension(struct cx231xx *dev); | ||
695 | void cx231xx_close_extension(struct cx231xx *dev); | ||
696 | |||
697 | /* hardware init functions */ | ||
698 | int cx231xx_dev_init(struct cx231xx *dev); | ||
699 | void cx231xx_dev_uninit(struct cx231xx *dev); | ||
700 | void cx231xx_config_i2c(struct cx231xx *dev); | ||
701 | int cx231xx_config(struct cx231xx *dev); | ||
702 | |||
703 | /* Stream control functions */ | ||
704 | int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask); | ||
705 | int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask); | ||
706 | |||
707 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type); | ||
708 | |||
709 | /* Power control functions */ | ||
710 | int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode); | ||
711 | int cx231xx_power_suspend(struct cx231xx *dev); | ||
712 | |||
713 | /* chip specific control functions */ | ||
714 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); | ||
715 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | ||
716 | u8 analog_or_digital); | ||
717 | int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex); | ||
718 | |||
719 | /* video audio decoder related functions */ | ||
720 | void video_mux(struct cx231xx *dev, int index); | ||
721 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input); | ||
722 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input); | ||
723 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); | ||
724 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input); | ||
725 | void get_scale(struct cx231xx *dev, | ||
726 | unsigned int width, unsigned int height, | ||
727 | unsigned int *hscale, unsigned int *vscale); | ||
728 | |||
729 | /* Provided by cx231xx-video.c */ | ||
730 | int cx231xx_register_extension(struct cx231xx_ops *dev); | ||
731 | void cx231xx_unregister_extension(struct cx231xx_ops *dev); | ||
732 | void cx231xx_init_extension(struct cx231xx *dev); | ||
733 | void cx231xx_close_extension(struct cx231xx *dev); | ||
734 | |||
735 | /* Provided by cx231xx-cards.c */ | ||
736 | extern void cx231xx_pre_card_setup(struct cx231xx *dev); | ||
737 | extern void cx231xx_card_setup(struct cx231xx *dev); | ||
738 | extern struct cx231xx_board cx231xx_boards[]; | ||
739 | extern struct usb_device_id cx231xx_id_table[]; | ||
740 | extern const unsigned int cx231xx_bcount; | ||
741 | void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir); | ||
742 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg); | ||
743 | |||
744 | /* Provided by cx231xx-input.c */ | ||
745 | int cx231xx_ir_init(struct cx231xx *dev); | ||
746 | int cx231xx_ir_fini(struct cx231xx *dev); | ||
747 | |||
748 | /* printk macros */ | ||
749 | |||
750 | #define cx231xx_err(fmt, arg...) do {\ | ||
751 | printk(KERN_ERR fmt , ##arg); } while (0) | ||
752 | |||
753 | #define cx231xx_errdev(fmt, arg...) do {\ | ||
754 | printk(KERN_ERR "%s: "fmt,\ | ||
755 | dev->name , ##arg); } while (0) | ||
756 | |||
757 | #define cx231xx_info(fmt, arg...) do {\ | ||
758 | printk(KERN_INFO "%s: "fmt,\ | ||
759 | dev->name , ##arg); } while (0) | ||
760 | #define cx231xx_warn(fmt, arg...) do {\ | ||
761 | printk(KERN_WARNING "%s: "fmt,\ | ||
762 | dev->name , ##arg); } while (0) | ||
763 | |||
764 | static inline unsigned int norm_maxw(struct cx231xx *dev) | ||
765 | { | ||
766 | if (dev->board.max_range_640_480) | ||
767 | return 640; | ||
768 | else | ||
769 | return 720; | ||
770 | } | ||
771 | |||
772 | static inline unsigned int norm_maxh(struct cx231xx *dev) | ||
773 | { | ||
774 | if (dev->board.max_range_640_480) | ||
775 | return 480; | ||
776 | else | ||
777 | return (dev->norm & V4L2_STD_625_50) ? 576 : 480; | ||
778 | } | ||
779 | #endif | ||
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c index 5e4b7e790d94..a3c0565be1a9 100644 --- a/drivers/media/video/cx23885/cx23885-cards.c +++ b/drivers/media/video/cx23885/cx23885-cards.c | |||
@@ -739,9 +739,10 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
739 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: | 739 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: |
740 | case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: | 740 | case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: |
741 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: | 741 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: |
742 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->i2c_bus[2].i2c_adap, | 742 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
743 | &dev->i2c_bus[2].i2c_adap, | ||
743 | "cx25840", "cx25840", 0x88 >> 1); | 744 | "cx25840", "cx25840", 0x88 >> 1); |
744 | v4l2_subdev_call(dev->sd_cx25840, core, init, 0); | 745 | v4l2_subdev_call(dev->sd_cx25840, core, load_fw); |
745 | break; | 746 | break; |
746 | } | 747 | } |
747 | 748 | ||
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index dc7fff22cfdd..beda42925ce7 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
@@ -875,7 +875,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
875 | cx23885_i2c_register(&dev->i2c_bus[1]); | 875 | cx23885_i2c_register(&dev->i2c_bus[1]); |
876 | cx23885_i2c_register(&dev->i2c_bus[2]); | 876 | cx23885_i2c_register(&dev->i2c_bus[2]); |
877 | cx23885_card_setup(dev); | 877 | cx23885_card_setup(dev); |
878 | call_all(dev, core, s_standby, 0); | 878 | call_all(dev, tuner, s_standby); |
879 | cx23885_ir_init(dev); | 879 | cx23885_ir_init(dev); |
880 | 880 | ||
881 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { | 881 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { |
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index d43c74396767..f48454ab3900 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -673,7 +673,7 @@ static int dvb_register(struct cx23885_tsport *port) | |||
673 | fe0->dvb.frontend->callback = cx23885_tuner_callback; | 673 | fe0->dvb.frontend->callback = cx23885_tuner_callback; |
674 | 674 | ||
675 | /* Put the analog decoder in standby to keep it quiet */ | 675 | /* Put the analog decoder in standby to keep it quiet */ |
676 | call_all(dev, core, s_standby, 0); | 676 | call_all(dev, tuner, s_standby); |
677 | 677 | ||
678 | if (fe0->dvb.frontend->ops.analog_ops.standby) | 678 | if (fe0->dvb.frontend->ops.analog_ops.standby) |
679 | fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); | 679 | fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index f0ac62c5dc83..68068c6d0987 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -299,7 +299,7 @@ static int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) | |||
299 | 299 | ||
300 | dev->tvnorm = norm; | 300 | dev->tvnorm = norm; |
301 | 301 | ||
302 | call_all(dev, tuner, s_std, norm); | 302 | call_all(dev, core, s_std, norm); |
303 | 303 | ||
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
@@ -393,9 +393,6 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, | |||
393 | 393 | ||
394 | static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) | 394 | static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) |
395 | { | 395 | { |
396 | struct v4l2_routing route; | ||
397 | memset(&route, 0, sizeof(route)); | ||
398 | |||
399 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", | 396 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", |
400 | __func__, | 397 | __func__, |
401 | input, INPUT(input)->vmux, | 398 | input, INPUT(input)->vmux, |
@@ -403,10 +400,9 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) | |||
403 | INPUT(input)->gpio2, INPUT(input)->gpio3); | 400 | INPUT(input)->gpio2, INPUT(input)->gpio3); |
404 | dev->input = input; | 401 | dev->input = input; |
405 | 402 | ||
406 | route.input = INPUT(input)->vmux; | ||
407 | |||
408 | /* Tell the internal A/V decoder */ | 403 | /* Tell the internal A/V decoder */ |
409 | v4l2_subdev_call(dev->sd_cx25840, video, s_routing, &route); | 404 | v4l2_subdev_call(dev->sd_cx25840, video, s_routing, |
405 | INPUT(input)->vmux, 0, 0); | ||
410 | 406 | ||
411 | return 0; | 407 | return 0; |
412 | } | 408 | } |
@@ -1523,10 +1519,12 @@ int cx23885_video_register(struct cx23885_dev *dev) | |||
1523 | struct v4l2_subdev *sd = NULL; | 1519 | struct v4l2_subdev *sd = NULL; |
1524 | 1520 | ||
1525 | if (dev->tuner_addr) | 1521 | if (dev->tuner_addr) |
1526 | sd = v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap, | 1522 | sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
1523 | &dev->i2c_bus[1].i2c_adap, | ||
1527 | "tuner", "tuner", dev->tuner_addr); | 1524 | "tuner", "tuner", dev->tuner_addr); |
1528 | else | 1525 | else |
1529 | sd = v4l2_i2c_new_probed_subdev(&dev->i2c_bus[1].i2c_adap, | 1526 | sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, |
1527 | &dev->i2c_bus[1].i2c_adap, | ||
1530 | "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV)); | 1528 | "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV)); |
1531 | if (sd) { | 1529 | if (sd) { |
1532 | struct tuner_setup tun_setup; | 1530 | struct tuner_setup tun_setup; |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index 02d980a29962..85642831ea8e 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/version.h> | 37 | #include <linux/version.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | 39 | ||
40 | #define CX23885_VERSION_CODE KERNEL_VERSION(0, 0, 1) | 40 | #define CX23885_VERSION_CODE KERNEL_VERSION(0, 0, 2) |
41 | 41 | ||
42 | #define UNSET (-1U) | 42 | #define UNSET (-1U) |
43 | 43 | ||
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c index 93d74bee292a..2f846f5e0f9f 100644 --- a/drivers/media/video/cx25840/cx25840-audio.c +++ b/drivers/media/video/cx25840/cx25840-audio.c | |||
@@ -32,7 +32,7 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
32 | 32 | ||
33 | /* common for all inputs and rates */ | 33 | /* common for all inputs and rates */ |
34 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ | 34 | /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ |
35 | if (!state->is_cx23885) | 35 | if (!state->is_cx23885 && !state->is_cx231xx) |
36 | cx25840_write(client, 0x127, 0x50); | 36 | cx25840_write(client, 0x127, 0x50); |
37 | 37 | ||
38 | if (state->aud_input != CX25840_AUDIO_SERIAL) { | 38 | if (state->aud_input != CX25840_AUDIO_SERIAL) { |
@@ -43,11 +43,14 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
43 | * so avoid destroying registers. */ | 43 | * so avoid destroying registers. */ |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | /* VID_PLL and AUX_PLL */ | ||
47 | cx25840_write4(client, 0x108, 0x1006040f); | ||
48 | 46 | ||
49 | /* AUX_PLL_FRAC */ | 47 | if (!state->is_cx231xx) { |
50 | cx25840_write4(client, 0x110, 0x01bb39ee); | 48 | /* VID_PLL and AUX_PLL */ |
49 | cx25840_write4(client, 0x108, 0x1006040f); | ||
50 | |||
51 | /* AUX_PLL_FRAC */ | ||
52 | cx25840_write4(client, 0x110, 0x01bb39ee); | ||
53 | } | ||
51 | 54 | ||
52 | if (state->is_cx25836) | 55 | if (state->is_cx25836) |
53 | break; | 56 | break; |
@@ -64,11 +67,14 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
64 | * so avoid destroying registers. */ | 67 | * so avoid destroying registers. */ |
65 | break; | 68 | break; |
66 | } | 69 | } |
67 | /* VID_PLL and AUX_PLL */ | ||
68 | cx25840_write4(client, 0x108, 0x1009040f); | ||
69 | 70 | ||
70 | /* AUX_PLL_FRAC */ | 71 | if (!state->is_cx231xx) { |
71 | cx25840_write4(client, 0x110, 0x00ec6bd6); | 72 | /* VID_PLL and AUX_PLL */ |
73 | cx25840_write4(client, 0x108, 0x1009040f); | ||
74 | |||
75 | /* AUX_PLL_FRAC */ | ||
76 | cx25840_write4(client, 0x110, 0x00ec6bd6); | ||
77 | } | ||
72 | 78 | ||
73 | if (state->is_cx25836) | 79 | if (state->is_cx25836) |
74 | break; | 80 | break; |
@@ -85,11 +91,14 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
85 | * so avoid destroying registers. */ | 91 | * so avoid destroying registers. */ |
86 | break; | 92 | break; |
87 | } | 93 | } |
88 | /* VID_PLL and AUX_PLL */ | ||
89 | cx25840_write4(client, 0x108, 0x100a040f); | ||
90 | 94 | ||
91 | /* AUX_PLL_FRAC */ | 95 | if (!state->is_cx231xx) { |
92 | cx25840_write4(client, 0x110, 0x0098d6e5); | 96 | /* VID_PLL and AUX_PLL */ |
97 | cx25840_write4(client, 0x108, 0x100a040f); | ||
98 | |||
99 | /* AUX_PLL_FRAC */ | ||
100 | cx25840_write4(client, 0x110, 0x0098d6e5); | ||
101 | } | ||
93 | 102 | ||
94 | if (state->is_cx25836) | 103 | if (state->is_cx25836) |
95 | break; | 104 | break; |
@@ -108,11 +117,14 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
108 | * so avoid destroying registers. */ | 117 | * so avoid destroying registers. */ |
109 | break; | 118 | break; |
110 | } | 119 | } |
111 | /* VID_PLL and AUX_PLL */ | ||
112 | cx25840_write4(client, 0x108, 0x1e08040f); | ||
113 | 120 | ||
114 | /* AUX_PLL_FRAC */ | 121 | if (!state->is_cx231xx) { |
115 | cx25840_write4(client, 0x110, 0x012a0869); | 122 | /* VID_PLL and AUX_PLL */ |
123 | cx25840_write4(client, 0x108, 0x1e08040f); | ||
124 | |||
125 | /* AUX_PLL_FRAC */ | ||
126 | cx25840_write4(client, 0x110, 0x012a0869); | ||
127 | } | ||
116 | 128 | ||
117 | if (state->is_cx25836) | 129 | if (state->is_cx25836) |
118 | break; | 130 | break; |
@@ -136,11 +148,14 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
136 | break; | 148 | break; |
137 | } | 149 | } |
138 | 150 | ||
139 | /* VID_PLL and AUX_PLL */ | ||
140 | cx25840_write4(client, 0x108, 0x1809040f); | ||
141 | 151 | ||
142 | /* AUX_PLL_FRAC */ | 152 | if (!state->is_cx231xx) { |
143 | cx25840_write4(client, 0x110, 0x00ec6bd6); | 153 | /* VID_PLL and AUX_PLL */ |
154 | cx25840_write4(client, 0x108, 0x1809040f); | ||
155 | |||
156 | /* AUX_PLL_FRAC */ | ||
157 | cx25840_write4(client, 0x110, 0x00ec6bd6); | ||
158 | } | ||
144 | 159 | ||
145 | if (state->is_cx25836) | 160 | if (state->is_cx25836) |
146 | break; | 161 | break; |
@@ -155,7 +170,7 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
155 | break; | 170 | break; |
156 | 171 | ||
157 | case 48000: | 172 | case 48000: |
158 | if (!state->is_cx23885) { | 173 | if (!state->is_cx23885 && !state->is_cx231xx) { |
159 | /* VID_PLL and AUX_PLL */ | 174 | /* VID_PLL and AUX_PLL */ |
160 | cx25840_write4(client, 0x108, 0x180a040f); | 175 | cx25840_write4(client, 0x108, 0x180a040f); |
161 | 176 | ||
@@ -166,7 +181,7 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq) | |||
166 | if (state->is_cx25836) | 181 | if (state->is_cx25836) |
167 | break; | 182 | break; |
168 | 183 | ||
169 | if (!state->is_cx23885) { | 184 | if (!state->is_cx23885 && !state->is_cx231xx) { |
170 | /* src1_ctl */ | 185 | /* src1_ctl */ |
171 | cx25840_write4(client, 0x8f8, 0x08018000); | 186 | cx25840_write4(client, 0x8f8, 0x08018000); |
172 | 187 | ||
@@ -227,10 +242,9 @@ void cx25840_audio_set_path(struct i2c_client *client) | |||
227 | /* deassert soft reset */ | 242 | /* deassert soft reset */ |
228 | cx25840_and_or(client, 0x810, ~0x1, 0x00); | 243 | cx25840_and_or(client, 0x810, ~0x1, 0x00); |
229 | 244 | ||
230 | if (state->is_cx23885) { | 245 | /* Ensure the controller is running when we exit */ |
231 | /* Ensure the controller is running when we exit */ | 246 | if (state->is_cx23885 || state->is_cx231xx) |
232 | cx25840_and_or(client, 0x803, ~0x10, 0x10); | 247 | cx25840_and_or(client, 0x803, ~0x10, 0x10); |
233 | } | ||
234 | } | 248 | } |
235 | 249 | ||
236 | static int get_volume(struct i2c_client *client) | 250 | static int get_volume(struct i2c_client *client) |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 737ee4ea8830..0be51b65f098 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -345,6 +345,77 @@ static void cx23885_initialize(struct i2c_client *client) | |||
345 | 345 | ||
346 | /* ----------------------------------------------------------------------- */ | 346 | /* ----------------------------------------------------------------------- */ |
347 | 347 | ||
348 | static void cx231xx_initialize(struct i2c_client *client) | ||
349 | { | ||
350 | DEFINE_WAIT(wait); | ||
351 | struct cx25840_state *state = to_state(i2c_get_clientdata(client)); | ||
352 | struct workqueue_struct *q; | ||
353 | |||
354 | /* Internal Reset */ | ||
355 | cx25840_and_or(client, 0x102, ~0x01, 0x01); | ||
356 | cx25840_and_or(client, 0x102, ~0x01, 0x00); | ||
357 | |||
358 | /* Stop microcontroller */ | ||
359 | cx25840_and_or(client, 0x803, ~0x10, 0x00); | ||
360 | |||
361 | /* DIF in reset? */ | ||
362 | cx25840_write(client, 0x398, 0); | ||
363 | |||
364 | /* Trust the default xtal, no division */ | ||
365 | /* This changes for the cx23888 products */ | ||
366 | cx25840_write(client, 0x2, 0x76); | ||
367 | |||
368 | /* Bring down the regulator for AUX clk */ | ||
369 | cx25840_write(client, 0x1, 0x40); | ||
370 | |||
371 | /* Disable DIF bypass */ | ||
372 | cx25840_write4(client, 0x33c, 0x00000001); | ||
373 | |||
374 | /* DIF Src phase inc */ | ||
375 | cx25840_write4(client, 0x340, 0x0df7df83); | ||
376 | |||
377 | /* Luma */ | ||
378 | cx25840_write4(client, 0x414, 0x00107d12); | ||
379 | |||
380 | /* Chroma */ | ||
381 | cx25840_write4(client, 0x420, 0x3d008282); | ||
382 | |||
383 | /* ADC2 input select */ | ||
384 | cx25840_write(client, 0x102, 0x10); | ||
385 | |||
386 | /* VIN1 & VIN5 */ | ||
387 | cx25840_write(client, 0x103, 0x11); | ||
388 | |||
389 | /* Enable format auto detect */ | ||
390 | cx25840_write(client, 0x400, 0); | ||
391 | /* Fast subchroma lock */ | ||
392 | /* White crush, Chroma AGC & Chroma Killer enabled */ | ||
393 | cx25840_write(client, 0x401, 0xe8); | ||
394 | |||
395 | /* Do the firmware load in a work handler to prevent. | ||
396 | Otherwise the kernel is blocked waiting for the | ||
397 | bit-banging i2c interface to finish uploading the | ||
398 | firmware. */ | ||
399 | INIT_WORK(&state->fw_work, cx25840_work_handler); | ||
400 | init_waitqueue_head(&state->fw_wait); | ||
401 | q = create_singlethread_workqueue("cx25840_fw"); | ||
402 | prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE); | ||
403 | queue_work(q, &state->fw_work); | ||
404 | schedule(); | ||
405 | finish_wait(&state->fw_wait, &wait); | ||
406 | destroy_workqueue(q); | ||
407 | |||
408 | cx25840_std_setup(client); | ||
409 | |||
410 | /* (re)set input */ | ||
411 | set_input(client, state->vid_input, state->aud_input); | ||
412 | |||
413 | /* start microcontroller */ | ||
414 | cx25840_and_or(client, 0x803, ~0x10, 0x10); | ||
415 | } | ||
416 | |||
417 | /* ----------------------------------------------------------------------- */ | ||
418 | |||
348 | void cx25840_std_setup(struct i2c_client *client) | 419 | void cx25840_std_setup(struct i2c_client *client) |
349 | { | 420 | { |
350 | struct cx25840_state *state = to_state(i2c_get_clientdata(client)); | 421 | struct cx25840_state *state = to_state(i2c_get_clientdata(client)); |
@@ -414,39 +485,41 @@ void cx25840_std_setup(struct i2c_client *client) | |||
414 | } | 485 | } |
415 | 486 | ||
416 | /* DEBUG: Displays configured PLL frequency */ | 487 | /* DEBUG: Displays configured PLL frequency */ |
417 | pll_int = cx25840_read(client, 0x108); | 488 | if (!state->is_cx231xx) { |
418 | pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff; | 489 | pll_int = cx25840_read(client, 0x108); |
419 | pll_post = cx25840_read(client, 0x109); | 490 | pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff; |
420 | v4l_dbg(1, cx25840_debug, client, | 491 | pll_post = cx25840_read(client, 0x109); |
421 | "PLL regs = int: %u, frac: %u, post: %u\n", | ||
422 | pll_int, pll_frac, pll_post); | ||
423 | |||
424 | if (pll_post) { | ||
425 | int fin, fsc; | ||
426 | int pll = (28636363L * ((((u64)pll_int) << 25L) + pll_frac)) >> 25L; | ||
427 | |||
428 | pll /= pll_post; | ||
429 | v4l_dbg(1, cx25840_debug, client, "PLL = %d.%06d MHz\n", | ||
430 | pll / 1000000, pll % 1000000); | ||
431 | v4l_dbg(1, cx25840_debug, client, "PLL/8 = %d.%06d MHz\n", | ||
432 | pll / 8000000, (pll / 8) % 1000000); | ||
433 | |||
434 | fin = ((u64)src_decimation * pll) >> 12; | ||
435 | v4l_dbg(1, cx25840_debug, client, | ||
436 | "ADC Sampling freq = %d.%06d MHz\n", | ||
437 | fin / 1000000, fin % 1000000); | ||
438 | |||
439 | fsc = (((u64)sc) * pll) >> 24L; | ||
440 | v4l_dbg(1, cx25840_debug, client, | 492 | v4l_dbg(1, cx25840_debug, client, |
441 | "Chroma sub-carrier freq = %d.%06d MHz\n", | 493 | "PLL regs = int: %u, frac: %u, post: %u\n", |
442 | fsc / 1000000, fsc % 1000000); | 494 | pll_int, pll_frac, pll_post); |
443 | 495 | ||
444 | v4l_dbg(1, cx25840_debug, client, "hblank %i, hactive %i, " | 496 | if (pll_post) { |
445 | "vblank %i, vactive %i, vblank656 %i, src_dec %i, " | 497 | int fin, fsc; |
446 | "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, " | 498 | int pll = (28636363L * ((((u64)pll_int) << 25L) + pll_frac)) >> 25L; |
447 | "sc 0x%06x\n", | 499 | |
448 | hblank, hactive, vblank, vactive, vblank656, | 500 | pll /= pll_post; |
449 | src_decimation, burst, luma_lpf, uv_lpf, comb, sc); | 501 | v4l_dbg(1, cx25840_debug, client, "PLL = %d.%06d MHz\n", |
502 | pll / 1000000, pll % 1000000); | ||
503 | v4l_dbg(1, cx25840_debug, client, "PLL/8 = %d.%06d MHz\n", | ||
504 | pll / 8000000, (pll / 8) % 1000000); | ||
505 | |||
506 | fin = ((u64)src_decimation * pll) >> 12; | ||
507 | v4l_dbg(1, cx25840_debug, client, | ||
508 | "ADC Sampling freq = %d.%06d MHz\n", | ||
509 | fin / 1000000, fin % 1000000); | ||
510 | |||
511 | fsc = (((u64)sc) * pll) >> 24L; | ||
512 | v4l_dbg(1, cx25840_debug, client, | ||
513 | "Chroma sub-carrier freq = %d.%06d MHz\n", | ||
514 | fsc / 1000000, fsc % 1000000); | ||
515 | |||
516 | v4l_dbg(1, cx25840_debug, client, "hblank %i, hactive %i, " | ||
517 | "vblank %i, vactive %i, vblank656 %i, src_dec %i, " | ||
518 | "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, " | ||
519 | "sc 0x%06x\n", | ||
520 | hblank, hactive, vblank, vactive, vblank656, | ||
521 | src_decimation, burst, luma_lpf, uv_lpf, comb, sc); | ||
522 | } | ||
450 | } | 523 | } |
451 | 524 | ||
452 | /* Sets horizontal blanking delay and active lines */ | 525 | /* Sets horizontal blanking delay and active lines */ |
@@ -596,7 +669,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp | |||
596 | * configuration in reg (for the cx23885) so we have no | 669 | * configuration in reg (for the cx23885) so we have no |
597 | * need to attempt to flip bits for earlier av decoders. | 670 | * need to attempt to flip bits for earlier av decoders. |
598 | */ | 671 | */ |
599 | if (!state->is_cx23885) { | 672 | if (!state->is_cx23885 && !state->is_cx231xx) { |
600 | switch (aud_input) { | 673 | switch (aud_input) { |
601 | case CX25840_AUDIO_SERIAL: | 674 | case CX25840_AUDIO_SERIAL: |
602 | /* do nothing, use serial audio input */ | 675 | /* do nothing, use serial audio input */ |
@@ -619,7 +692,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp | |||
619 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ | 692 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ |
620 | cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); | 693 | cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); |
621 | 694 | ||
622 | if (!state->is_cx23885) { | 695 | if (!state->is_cx23885 && !state->is_cx231xx) { |
623 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ | 696 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ |
624 | cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); | 697 | cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); |
625 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */ | 698 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */ |
@@ -659,6 +732,19 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp | |||
659 | */ | 732 | */ |
660 | cx25840_write(client, 0x918, 0xa0); | 733 | cx25840_write(client, 0x918, 0xa0); |
661 | cx25840_write(client, 0x919, 0x01); | 734 | cx25840_write(client, 0x919, 0x01); |
735 | } else if (state->is_cx231xx) { | ||
736 | /* Audio channel 1 src : Parallel 1 */ | ||
737 | cx25840_write(client, 0x124, 0x03); | ||
738 | |||
739 | /* I2S_IN_CTL: I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1 */ | ||
740 | cx25840_write(client, 0x914, 0xa0); | ||
741 | |||
742 | /* I2S_OUT_CTL: | ||
743 | * I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1 | ||
744 | * I2S_OUT_MASTER_MODE = Master | ||
745 | */ | ||
746 | cx25840_write(client, 0x918, 0xa0); | ||
747 | cx25840_write(client, 0x919, 0x01); | ||
662 | } | 748 | } |
663 | 749 | ||
664 | return 0; | 750 | return 0; |
@@ -1096,7 +1182,7 @@ static void log_audio_status(struct i2c_client *client) | |||
1096 | 1182 | ||
1097 | /* ----------------------------------------------------------------------- */ | 1183 | /* ----------------------------------------------------------------------- */ |
1098 | 1184 | ||
1099 | /* This init operation must be called to load the driver's firmware. | 1185 | /* This load_fw operation must be called to load the driver's firmware. |
1100 | Without this the audio standard detection will fail and you will | 1186 | Without this the audio standard detection will fail and you will |
1101 | only get mono. | 1187 | only get mono. |
1102 | 1188 | ||
@@ -1106,18 +1192,20 @@ static void log_audio_status(struct i2c_client *client) | |||
1106 | postponing it is that loading this firmware takes a long time (seconds) | 1192 | postponing it is that loading this firmware takes a long time (seconds) |
1107 | due to the slow i2c bus speed. So it will speed up the boot process if | 1193 | due to the slow i2c bus speed. So it will speed up the boot process if |
1108 | you can avoid loading the fw as long as the video device isn't used. */ | 1194 | you can avoid loading the fw as long as the video device isn't used. */ |
1109 | static int cx25840_init(struct v4l2_subdev *sd, u32 val) | 1195 | static int cx25840_load_fw(struct v4l2_subdev *sd) |
1110 | { | 1196 | { |
1111 | struct cx25840_state *state = to_state(sd); | 1197 | struct cx25840_state *state = to_state(sd); |
1112 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1198 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1113 | 1199 | ||
1114 | if (!state->is_initialized) { | 1200 | if (!state->is_initialized) { |
1115 | /* initialize on first use */ | 1201 | /* initialize and load firmware */ |
1116 | state->is_initialized = 1; | 1202 | state->is_initialized = 1; |
1117 | if (state->is_cx25836) | 1203 | if (state->is_cx25836) |
1118 | cx25836_initialize(client); | 1204 | cx25836_initialize(client); |
1119 | else if (state->is_cx23885) | 1205 | else if (state->is_cx23885) |
1120 | cx23885_initialize(client); | 1206 | cx23885_initialize(client); |
1207 | else if (state->is_cx231xx) | ||
1208 | cx231xx_initialize(client); | ||
1121 | else | 1209 | else |
1122 | cx25840_initialize(client); | 1210 | cx25840_initialize(client); |
1123 | } | 1211 | } |
@@ -1159,7 +1247,7 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable) | |||
1159 | v4l_dbg(1, cx25840_debug, client, "%s output\n", | 1247 | v4l_dbg(1, cx25840_debug, client, "%s output\n", |
1160 | enable ? "enable" : "disable"); | 1248 | enable ? "enable" : "disable"); |
1161 | if (enable) { | 1249 | if (enable) { |
1162 | if (state->is_cx23885) { | 1250 | if (state->is_cx23885 || state->is_cx231xx) { |
1163 | u8 v = (cx25840_read(client, 0x421) | 0x0b); | 1251 | u8 v = (cx25840_read(client, 0x421) | 0x0b); |
1164 | cx25840_write(client, 0x421, v); | 1252 | cx25840_write(client, 0x421, v); |
1165 | } else { | 1253 | } else { |
@@ -1169,7 +1257,7 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable) | |||
1169 | state->is_cx25836 ? 0x04 : 0x07); | 1257 | state->is_cx25836 ? 0x04 : 0x07); |
1170 | } | 1258 | } |
1171 | } else { | 1259 | } else { |
1172 | if (state->is_cx23885) { | 1260 | if (state->is_cx23885 || state->is_cx231xx) { |
1173 | u8 v = cx25840_read(client, 0x421) & ~(0x0b); | 1261 | u8 v = cx25840_read(client, 0x421) & ~(0x0b); |
1174 | cx25840_write(client, 0x421, v); | 1262 | cx25840_write(client, 0x421, v); |
1175 | } else { | 1263 | } else { |
@@ -1234,22 +1322,24 @@ static int cx25840_s_radio(struct v4l2_subdev *sd) | |||
1234 | return 0; | 1322 | return 0; |
1235 | } | 1323 | } |
1236 | 1324 | ||
1237 | static int cx25840_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 1325 | static int cx25840_s_video_routing(struct v4l2_subdev *sd, |
1326 | u32 input, u32 output, u32 config) | ||
1238 | { | 1327 | { |
1239 | struct cx25840_state *state = to_state(sd); | 1328 | struct cx25840_state *state = to_state(sd); |
1240 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1329 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1241 | 1330 | ||
1242 | return set_input(client, route->input, state->aud_input); | 1331 | return set_input(client, input, state->aud_input); |
1243 | } | 1332 | } |
1244 | 1333 | ||
1245 | static int cx25840_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 1334 | static int cx25840_s_audio_routing(struct v4l2_subdev *sd, |
1335 | u32 input, u32 output, u32 config) | ||
1246 | { | 1336 | { |
1247 | struct cx25840_state *state = to_state(sd); | 1337 | struct cx25840_state *state = to_state(sd); |
1248 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1338 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1249 | 1339 | ||
1250 | if (state->is_cx25836) | 1340 | if (state->is_cx25836) |
1251 | return -EINVAL; | 1341 | return -EINVAL; |
1252 | return set_input(client, state->vid_input, route->input); | 1342 | return set_input(client, state->vid_input, input); |
1253 | } | 1343 | } |
1254 | 1344 | ||
1255 | static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq) | 1345 | static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq) |
@@ -1350,6 +1440,8 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val) | |||
1350 | cx25836_initialize(client); | 1440 | cx25836_initialize(client); |
1351 | else if (state->is_cx23885) | 1441 | else if (state->is_cx23885) |
1352 | cx23885_initialize(client); | 1442 | cx23885_initialize(client); |
1443 | else if (state->is_cx231xx) | ||
1444 | cx231xx_initialize(client); | ||
1353 | else | 1445 | else |
1354 | cx25840_initialize(client); | 1446 | cx25840_initialize(client); |
1355 | return 0; | 1447 | return 0; |
@@ -1382,8 +1474,9 @@ static const struct v4l2_subdev_core_ops cx25840_core_ops = { | |||
1382 | .g_ctrl = cx25840_g_ctrl, | 1474 | .g_ctrl = cx25840_g_ctrl, |
1383 | .s_ctrl = cx25840_s_ctrl, | 1475 | .s_ctrl = cx25840_s_ctrl, |
1384 | .queryctrl = cx25840_queryctrl, | 1476 | .queryctrl = cx25840_queryctrl, |
1477 | .s_std = cx25840_s_std, | ||
1385 | .reset = cx25840_reset, | 1478 | .reset = cx25840_reset, |
1386 | .init = cx25840_init, | 1479 | .load_fw = cx25840_load_fw, |
1387 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1480 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1388 | .g_register = cx25840_g_register, | 1481 | .g_register = cx25840_g_register, |
1389 | .s_register = cx25840_s_register, | 1482 | .s_register = cx25840_s_register, |
@@ -1392,7 +1485,6 @@ static const struct v4l2_subdev_core_ops cx25840_core_ops = { | |||
1392 | 1485 | ||
1393 | static const struct v4l2_subdev_tuner_ops cx25840_tuner_ops = { | 1486 | static const struct v4l2_subdev_tuner_ops cx25840_tuner_ops = { |
1394 | .s_frequency = cx25840_s_frequency, | 1487 | .s_frequency = cx25840_s_frequency, |
1395 | .s_std = cx25840_s_std, | ||
1396 | .s_radio = cx25840_s_radio, | 1488 | .s_radio = cx25840_s_radio, |
1397 | .g_tuner = cx25840_g_tuner, | 1489 | .g_tuner = cx25840_g_tuner, |
1398 | .s_tuner = cx25840_s_tuner, | 1490 | .s_tuner = cx25840_s_tuner, |
@@ -1449,6 +1541,8 @@ static int cx25840_probe(struct i2c_client *client, | |||
1449 | id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6; | 1541 | id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6; |
1450 | } else if (device_id == 0x1313) { | 1542 | } else if (device_id == 0x1313) { |
1451 | id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6; | 1543 | id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6; |
1544 | } else if ((device_id & 0xfff0) == 0x5A30) { | ||
1545 | id = V4L2_IDENT_CX25840 + ((device_id >> 4) & 0xf); | ||
1452 | } | 1546 | } |
1453 | else { | 1547 | else { |
1454 | v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n"); | 1548 | v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n"); |
@@ -1471,6 +1565,7 @@ static int cx25840_probe(struct i2c_client *client, | |||
1471 | state->c = client; | 1565 | state->c = client; |
1472 | state->is_cx25836 = ((device_id & 0xff00) == 0x8300); | 1566 | state->is_cx25836 = ((device_id & 0xff00) == 0x8300); |
1473 | state->is_cx23885 = (device_id == 0x0000) || (device_id == 0x1313); | 1567 | state->is_cx23885 = (device_id == 0x0000) || (device_id == 0x1313); |
1568 | state->is_cx231xx = (device_id == 0x5a3e); | ||
1474 | state->vid_input = CX25840_COMPOSITE7; | 1569 | state->vid_input = CX25840_COMPOSITE7; |
1475 | state->aud_input = CX25840_AUDIO8; | 1570 | state->aud_input = CX25840_AUDIO8; |
1476 | state->audclk_freq = 48000; | 1571 | state->audclk_freq = 48000; |
diff --git a/drivers/media/video/cx25840/cx25840-core.h b/drivers/media/video/cx25840/cx25840-core.h index 9ad0eb86ecfd..814b56536994 100644 --- a/drivers/media/video/cx25840/cx25840-core.h +++ b/drivers/media/video/cx25840/cx25840-core.h | |||
@@ -50,6 +50,7 @@ struct cx25840_state { | |||
50 | u32 rev; | 50 | u32 rev; |
51 | int is_cx25836; | 51 | int is_cx25836; |
52 | int is_cx23885; | 52 | int is_cx23885; |
53 | int is_cx231xx; | ||
53 | int is_initialized; | 54 | int is_initialized; |
54 | wait_queue_head_t fw_wait; /* wake up when the fw load is finished */ | 55 | wait_queue_head_t fw_wait; /* wake up when the fw load is finished */ |
55 | struct work_struct fw_work; /* work entry for fw load */ | 56 | struct work_struct fw_work; /* work entry for fw load */ |
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c index 0b2dceb74108..0df53b0d75d9 100644 --- a/drivers/media/video/cx25840/cx25840-firmware.c +++ b/drivers/media/video/cx25840/cx25840-firmware.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #define FWFILE "v4l-cx25840.fw" | 26 | #define FWFILE "v4l-cx25840.fw" |
27 | #define FWFILE_CX23885 "v4l-cx23885-avcore-01.fw" | 27 | #define FWFILE_CX23885 "v4l-cx23885-avcore-01.fw" |
28 | #define FWFILE_CX231XX "v4l-cx231xx-avcore-01.fw" | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * Mike Isely <isely@pobox.com> - The FWSEND parameter controls the | 31 | * Mike Isely <isely@pobox.com> - The FWSEND parameter controls the |
@@ -96,9 +97,17 @@ int cx25840_loadfw(struct i2c_client *client) | |||
96 | u8 buffer[FWSEND]; | 97 | u8 buffer[FWSEND]; |
97 | const u8 *ptr; | 98 | const u8 *ptr; |
98 | int size, retval; | 99 | int size, retval; |
100 | int MAX_BUF_SIZE = FWSEND; | ||
99 | 101 | ||
100 | if (state->is_cx23885) | 102 | if (state->is_cx23885) |
101 | firmware = FWFILE_CX23885; | 103 | firmware = FWFILE_CX23885; |
104 | else if (state->is_cx231xx) | ||
105 | firmware = FWFILE_CX231XX; | ||
106 | |||
107 | if ((state->is_cx231xx) && MAX_BUF_SIZE > 16) { | ||
108 | v4l_err(client, " Firmware download size changed to 16 bytes max length\n"); | ||
109 | MAX_BUF_SIZE = 16; /* cx231xx cannot accept more than 16 bytes at a time */ | ||
110 | } | ||
102 | 111 | ||
103 | if (request_firmware(&fw, firmware, FWDEV(client)) != 0) { | 112 | if (request_firmware(&fw, firmware, FWDEV(client)) != 0) { |
104 | v4l_err(client, "unable to open firmware %s\n", firmware); | 113 | v4l_err(client, "unable to open firmware %s\n", firmware); |
@@ -113,7 +122,7 @@ int cx25840_loadfw(struct i2c_client *client) | |||
113 | size = fw->size; | 122 | size = fw->size; |
114 | ptr = fw->data; | 123 | ptr = fw->data; |
115 | while (size > 0) { | 124 | while (size > 0) { |
116 | int len = min(FWSEND - 2, size); | 125 | int len = min(MAX_BUF_SIZE - 2, size); |
117 | 126 | ||
118 | memcpy(buffer + 2, ptr, len); | 127 | memcpy(buffer + 2, ptr, len); |
119 | 128 | ||
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 0363971a23a8..6bbbfc66bb4b 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
@@ -3049,7 +3049,7 @@ static void cx88_card_setup(struct cx88_core *core) | |||
3049 | ctl.fname); | 3049 | ctl.fname); |
3050 | call_all(core, tuner, s_config, &xc2028_cfg); | 3050 | call_all(core, tuner, s_config, &xc2028_cfg); |
3051 | } | 3051 | } |
3052 | call_all(core, core, s_standby, 0); | 3052 | call_all(core, tuner, s_standby); |
3053 | } | 3053 | } |
3054 | 3054 | ||
3055 | /* ------------------------------------------------------------------ */ | 3055 | /* ------------------------------------------------------------------ */ |
@@ -3221,16 +3221,19 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3221 | The radio_type is sometimes missing, or set to UNSET but | 3221 | The radio_type is sometimes missing, or set to UNSET but |
3222 | later code configures a tea5767. | 3222 | later code configures a tea5767. |
3223 | */ | 3223 | */ |
3224 | v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", "tuner", | 3224 | v4l2_i2c_new_probed_subdev(&core->v4l2_dev, &core->i2c_adap, |
3225 | "tuner", "tuner", | ||
3225 | v4l2_i2c_tuner_addrs(ADDRS_RADIO)); | 3226 | v4l2_i2c_tuner_addrs(ADDRS_RADIO)); |
3226 | if (has_demod) | 3227 | if (has_demod) |
3227 | v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", | 3228 | v4l2_i2c_new_probed_subdev(&core->v4l2_dev, |
3228 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 3229 | &core->i2c_adap, "tuner", "tuner", |
3230 | v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
3229 | if (core->board.tuner_addr == ADDR_UNSET) { | 3231 | if (core->board.tuner_addr == ADDR_UNSET) { |
3230 | v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", | 3232 | v4l2_i2c_new_probed_subdev(&core->v4l2_dev, |
3231 | "tuner", has_demod ? tv_addrs + 4 : tv_addrs); | 3233 | &core->i2c_adap, "tuner", "tuner", |
3234 | has_demod ? tv_addrs + 4 : tv_addrs); | ||
3232 | } else { | 3235 | } else { |
3233 | v4l2_i2c_new_subdev(&core->i2c_adap, | 3236 | v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, |
3234 | "tuner", "tuner", core->board.tuner_addr); | 3237 | "tuner", "tuner", core->board.tuner_addr); |
3235 | } | 3238 | } |
3236 | } | 3239 | } |
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index f2fb9f30bfc1..0e149b22bd19 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
@@ -991,7 +991,7 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) | |||
991 | set_tvaudio(core); | 991 | set_tvaudio(core); |
992 | 992 | ||
993 | // tell i2c chips | 993 | // tell i2c chips |
994 | call_all(core, tuner, s_std, norm); | 994 | call_all(core, core, s_std, norm); |
995 | 995 | ||
996 | // done | 996 | // done |
997 | return 0; | 997 | return 0; |
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 4ff4d9fe0355..9389cf290c1b 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
@@ -1168,7 +1168,7 @@ static int dvb_register(struct cx8802_dev *dev) | |||
1168 | fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; | 1168 | fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; |
1169 | 1169 | ||
1170 | /* Put the analog decoder in standby to keep it quiet */ | 1170 | /* Put the analog decoder in standby to keep it quiet */ |
1171 | call_all(core, core, s_standby, 0); | 1171 | call_all(core, tuner, s_standby); |
1172 | 1172 | ||
1173 | /* register everything */ | 1173 | /* register everything */ |
1174 | return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, | 1174 | return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 434237af5184..ec0425d9043a 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -428,10 +428,8 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input) | |||
428 | routes for different inputs. HVR-1300 surely does */ | 428 | routes for different inputs. HVR-1300 surely does */ |
429 | if (core->board.audio_chip && | 429 | if (core->board.audio_chip && |
430 | core->board.audio_chip == V4L2_IDENT_WM8775) { | 430 | core->board.audio_chip == V4L2_IDENT_WM8775) { |
431 | struct v4l2_routing route; | 431 | call_all(core, audio, s_routing, |
432 | 432 | INPUT(input).audioroute, 0, 0); | |
433 | route.input = INPUT(input).audioroute; | ||
434 | call_all(core, audio, s_routing, &route); | ||
435 | } | 433 | } |
436 | /* cx2388's C-ADC is connected to the tuner only. | 434 | /* cx2388's C-ADC is connected to the tuner only. |
437 | When used with S-Video, that ADC is busy dealing with | 435 | When used with S-Video, that ADC is busy dealing with |
@@ -823,10 +821,8 @@ static int video_open(struct file *file) | |||
823 | if (core->board.radio.audioroute) { | 821 | if (core->board.radio.audioroute) { |
824 | if(core->board.audio_chip && | 822 | if(core->board.audio_chip && |
825 | core->board.audio_chip == V4L2_IDENT_WM8775) { | 823 | core->board.audio_chip == V4L2_IDENT_WM8775) { |
826 | struct v4l2_routing route; | 824 | call_all(core, audio, s_routing, |
827 | 825 | core->board.radio.audioroute, 0, 0); | |
828 | route.input = core->board.radio.audioroute; | ||
829 | call_all(core, audio, s_routing, &route); | ||
830 | } | 826 | } |
831 | /* "I2S ADC mode" */ | 827 | /* "I2S ADC mode" */ |
832 | core->tvaudio = WW_I2SADC; | 828 | core->tvaudio = WW_I2SADC; |
@@ -931,7 +927,7 @@ static int video_release(struct file *file) | |||
931 | kfree(fh); | 927 | kfree(fh); |
932 | 928 | ||
933 | if(atomic_dec_and_test(&dev->core->users)) | 929 | if(atomic_dec_and_test(&dev->core->users)) |
934 | call_all(dev->core, core, s_standby, 0); | 930 | call_all(dev->core, tuner, s_standby); |
935 | 931 | ||
936 | return 0; | 932 | return 0; |
937 | } | 933 | } |
@@ -1882,18 +1878,15 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1882 | /* load and configure helper modules */ | 1878 | /* load and configure helper modules */ |
1883 | 1879 | ||
1884 | if (core->board.audio_chip == V4L2_IDENT_WM8775) | 1880 | if (core->board.audio_chip == V4L2_IDENT_WM8775) |
1885 | v4l2_i2c_new_subdev(&core->i2c_adap, | 1881 | v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, |
1886 | "wm8775", "wm8775", 0x36 >> 1); | 1882 | "wm8775", "wm8775", 0x36 >> 1); |
1887 | 1883 | ||
1888 | if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { | 1884 | if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { |
1889 | /* This probes for a tda9874 as is used on some | 1885 | /* This probes for a tda9874 as is used on some |
1890 | Pixelview Ultra boards. */ | 1886 | Pixelview Ultra boards. */ |
1891 | static const unsigned short i2c_addr[] = { | 1887 | v4l2_i2c_new_probed_subdev_addr(&core->v4l2_dev, |
1892 | 0xb0 >> 1, I2C_CLIENT_END | 1888 | &core->i2c_adap, |
1893 | }; | 1889 | "tvaudio", "tvaudio", 0xb0 >> 1); |
1894 | |||
1895 | v4l2_i2c_new_probed_subdev(&core->i2c_adap, | ||
1896 | "tvaudio", "tvaudio", i2c_addr); | ||
1897 | } | 1890 | } |
1898 | 1891 | ||
1899 | switch (core->boardnr) { | 1892 | switch (core->boardnr) { |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 9a43fdf20fae..7724d168fc04 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -41,7 +41,7 @@ | |||
41 | 41 | ||
42 | #include <linux/version.h> | 42 | #include <linux/version.h> |
43 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
44 | #define CX88_VERSION_CODE KERNEL_VERSION(0,0,6) | 44 | #define CX88_VERSION_CODE KERNEL_VERSION(0,0,7) |
45 | 45 | ||
46 | #define UNSET (-1U) | 46 | #define UNSET (-1U) |
47 | 47 | ||
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 0f48c0ff5ac3..7c70738479dd 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <media/msp3400.h> | 31 | #include <media/msp3400.h> |
32 | #include <media/saa7115.h> | 32 | #include <media/saa7115.h> |
33 | #include <media/tvp5150.h> | 33 | #include <media/tvp5150.h> |
34 | #include <media/tvaudio.h> | ||
35 | #include <media/i2c-addr.h> | ||
34 | #include <media/tveeprom.h> | 36 | #include <media/tveeprom.h> |
35 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
36 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
@@ -1240,6 +1242,7 @@ struct em28xx_board em28xx_boards[] = { | |||
1240 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { | 1242 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { |
1241 | .name = "Compro VideoMate ForYou/Stereo", | 1243 | .name = "Compro VideoMate ForYou/Stereo", |
1242 | .tuner_type = TUNER_LG_PAL_NEW_TAPC, | 1244 | .tuner_type = TUNER_LG_PAL_NEW_TAPC, |
1245 | .tvaudio_addr = 0xb0, | ||
1243 | .tda9887_conf = TDA9887_PRESENT, | 1246 | .tda9887_conf = TDA9887_PRESENT, |
1244 | .decoder = EM28XX_TVP5150, | 1247 | .decoder = EM28XX_TVP5150, |
1245 | .adecoder = EM28XX_TVAUDIO, | 1248 | .adecoder = EM28XX_TVAUDIO, |
@@ -1444,6 +1447,24 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
1444 | {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC}, | 1447 | {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC}, |
1445 | }; | 1448 | }; |
1446 | 1449 | ||
1450 | /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ | ||
1451 | static unsigned short saa711x_addrs[] = { | ||
1452 | 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ | ||
1453 | 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ | ||
1454 | I2C_CLIENT_END }; | ||
1455 | |||
1456 | static unsigned short tvp5150_addrs[] = { | ||
1457 | 0xb8 >> 1, | ||
1458 | 0xba >> 1, | ||
1459 | I2C_CLIENT_END | ||
1460 | }; | ||
1461 | |||
1462 | static unsigned short msp3400_addrs[] = { | ||
1463 | 0x80 >> 1, | ||
1464 | 0x88 >> 1, | ||
1465 | I2C_CLIENT_END | ||
1466 | }; | ||
1467 | |||
1447 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) | 1468 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) |
1448 | { | 1469 | { |
1449 | int rc = 0; | 1470 | int rc = 0; |
@@ -1672,31 +1693,55 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl) | |||
1672 | } | 1693 | } |
1673 | } | 1694 | } |
1674 | 1695 | ||
1675 | static void em28xx_config_tuner(struct em28xx *dev) | 1696 | static void em28xx_tuner_setup(struct em28xx *dev) |
1676 | { | 1697 | { |
1677 | struct v4l2_priv_tun_config xc2028_cfg; | ||
1678 | struct tuner_setup tun_setup; | 1698 | struct tuner_setup tun_setup; |
1679 | struct v4l2_frequency f; | 1699 | struct v4l2_frequency f; |
1680 | 1700 | ||
1681 | if (dev->tuner_type == TUNER_ABSENT) | 1701 | if (dev->tuner_type == TUNER_ABSENT) |
1682 | return; | 1702 | return; |
1683 | 1703 | ||
1704 | memset(&tun_setup, 0, sizeof(tun_setup)); | ||
1705 | |||
1684 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | 1706 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; |
1685 | tun_setup.type = dev->tuner_type; | ||
1686 | tun_setup.addr = dev->tuner_addr; | ||
1687 | tun_setup.tuner_callback = em28xx_tuner_callback; | 1707 | tun_setup.tuner_callback = em28xx_tuner_callback; |
1688 | 1708 | ||
1689 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 1709 | if (dev->board.radio.type) { |
1710 | tun_setup.type = dev->board.radio.type; | ||
1711 | tun_setup.addr = dev->board.radio_addr; | ||
1712 | |||
1713 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); | ||
1714 | } | ||
1715 | |||
1716 | if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type)) { | ||
1717 | tun_setup.type = dev->tuner_type; | ||
1718 | tun_setup.addr = dev->tuner_addr; | ||
1719 | |||
1720 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); | ||
1721 | } | ||
1722 | |||
1723 | if (dev->tda9887_conf) { | ||
1724 | struct v4l2_priv_tun_config tda9887_cfg; | ||
1725 | |||
1726 | tda9887_cfg.tuner = TUNER_TDA9887; | ||
1727 | tda9887_cfg.priv = &dev->tda9887_conf; | ||
1728 | |||
1729 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &tda9887_cfg); | ||
1730 | } | ||
1690 | 1731 | ||
1691 | if (dev->tuner_type == TUNER_XC2028) { | 1732 | if (dev->tuner_type == TUNER_XC2028) { |
1733 | struct v4l2_priv_tun_config xc2028_cfg; | ||
1692 | struct xc2028_ctrl ctl; | 1734 | struct xc2028_ctrl ctl; |
1693 | 1735 | ||
1736 | memset(&xc2028_cfg, 0, sizeof(xc2028_cfg)); | ||
1737 | memset(&ctl, 0, sizeof(ctl)); | ||
1738 | |||
1694 | em28xx_setup_xc3028(dev, &ctl); | 1739 | em28xx_setup_xc3028(dev, &ctl); |
1695 | 1740 | ||
1696 | xc2028_cfg.tuner = TUNER_XC2028; | 1741 | xc2028_cfg.tuner = TUNER_XC2028; |
1697 | xc2028_cfg.priv = &ctl; | 1742 | xc2028_cfg.priv = &ctl; |
1698 | 1743 | ||
1699 | em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); | 1744 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &xc2028_cfg); |
1700 | } | 1745 | } |
1701 | 1746 | ||
1702 | /* configure tuner */ | 1747 | /* configure tuner */ |
@@ -1704,7 +1749,7 @@ static void em28xx_config_tuner(struct em28xx *dev) | |||
1704 | f.type = V4L2_TUNER_ANALOG_TV; | 1749 | f.type = V4L2_TUNER_ANALOG_TV; |
1705 | f.frequency = 9076; /* just a magic number */ | 1750 | f.frequency = 9076; /* just a magic number */ |
1706 | dev->ctl_freq = f.frequency; | 1751 | dev->ctl_freq = f.frequency; |
1707 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); | 1752 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); |
1708 | } | 1753 | } |
1709 | 1754 | ||
1710 | static int em28xx_hint_board(struct em28xx *dev) | 1755 | static int em28xx_hint_board(struct em28xx *dev) |
@@ -1911,22 +1956,52 @@ void em28xx_card_setup(struct em28xx *dev) | |||
1911 | if (tuner >= 0) | 1956 | if (tuner >= 0) |
1912 | dev->tuner_type = tuner; | 1957 | dev->tuner_type = tuner; |
1913 | 1958 | ||
1914 | #ifdef CONFIG_MODULES | ||
1915 | /* request some modules */ | 1959 | /* request some modules */ |
1916 | if (dev->board.has_msp34xx) | 1960 | if (dev->board.has_msp34xx) |
1917 | request_module("msp3400"); | 1961 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
1962 | "msp3400", "msp3400", msp3400_addrs); | ||
1963 | |||
1918 | if (dev->board.decoder == EM28XX_SAA711X) | 1964 | if (dev->board.decoder == EM28XX_SAA711X) |
1919 | request_module("saa7115"); | 1965 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
1966 | "saa7115", "saa7115_auto", saa711x_addrs); | ||
1967 | |||
1920 | if (dev->board.decoder == EM28XX_TVP5150) | 1968 | if (dev->board.decoder == EM28XX_TVP5150) |
1921 | request_module("tvp5150"); | 1969 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
1922 | if (dev->board.tuner_type != TUNER_ABSENT) | 1970 | "tvp5150", "tvp5150", tvp5150_addrs); |
1923 | request_module("tuner"); | ||
1924 | if (dev->board.adecoder == EM28XX_TVAUDIO) | ||
1925 | request_module("tvaudio"); | ||
1926 | #endif | ||
1927 | 1971 | ||
1928 | em28xx_config_tuner(dev); | 1972 | if (dev->board.adecoder == EM28XX_TVAUDIO) |
1973 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, | ||
1974 | "tvaudio", "tvaudio", dev->board.tvaudio_addr); | ||
1975 | |||
1976 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
1977 | int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); | ||
1978 | |||
1979 | if (dev->board.radio.type) | ||
1980 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, | ||
1981 | "tuner", "tuner", dev->board.radio_addr); | ||
1982 | |||
1983 | if (has_demod) | ||
1984 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, | ||
1985 | &dev->i2c_adap, "tuner", "tuner", | ||
1986 | v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
1987 | if (dev->tuner_addr == 0) { | ||
1988 | enum v4l2_i2c_tuner_type type = | ||
1989 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | ||
1990 | struct v4l2_subdev *sd; | ||
1991 | |||
1992 | sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, | ||
1993 | &dev->i2c_adap, "tuner", "tuner", | ||
1994 | v4l2_i2c_tuner_addrs(type)); | ||
1995 | |||
1996 | if (sd) | ||
1997 | dev->tuner_addr = v4l2_i2c_subdev_addr(sd); | ||
1998 | } else { | ||
1999 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, | ||
2000 | "tuner", "tuner", dev->tuner_addr); | ||
2001 | } | ||
2002 | } | ||
1929 | 2003 | ||
2004 | em28xx_tuner_setup(dev); | ||
1930 | em28xx_ir_init(dev); | 2005 | em28xx_ir_init(dev); |
1931 | } | 2006 | } |
1932 | 2007 | ||
@@ -1975,6 +2050,9 @@ void em28xx_release_resources(struct em28xx *dev) | |||
1975 | em28xx_remove_from_devlist(dev); | 2050 | em28xx_remove_from_devlist(dev); |
1976 | 2051 | ||
1977 | em28xx_i2c_unregister(dev); | 2052 | em28xx_i2c_unregister(dev); |
2053 | |||
2054 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2055 | |||
1978 | usb_put_dev(dev->udev); | 2056 | usb_put_dev(dev->udev); |
1979 | 2057 | ||
1980 | /* Mark device as unused */ | 2058 | /* Mark device as unused */ |
@@ -1986,6 +2064,7 @@ void em28xx_release_resources(struct em28xx *dev) | |||
1986 | * allocates and inits the device structs, registers i2c bus and v4l device | 2064 | * allocates and inits the device structs, registers i2c bus and v4l device |
1987 | */ | 2065 | */ |
1988 | static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | 2066 | static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, |
2067 | struct usb_interface *interface, | ||
1989 | int minor) | 2068 | int minor) |
1990 | { | 2069 | { |
1991 | struct em28xx *dev = *devhandle; | 2070 | struct em28xx *dev = *devhandle; |
@@ -2019,9 +2098,16 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2019 | } | 2098 | } |
2020 | } | 2099 | } |
2021 | 2100 | ||
2101 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | ||
2102 | if (retval < 0) { | ||
2103 | em28xx_errdev("Call to v4l2_device_register() failed!\n"); | ||
2104 | return retval; | ||
2105 | } | ||
2106 | |||
2022 | /* register i2c bus */ | 2107 | /* register i2c bus */ |
2023 | errCode = em28xx_i2c_register(dev); | 2108 | errCode = em28xx_i2c_register(dev); |
2024 | if (errCode < 0) { | 2109 | if (errCode < 0) { |
2110 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2025 | em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n", | 2111 | em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n", |
2026 | __func__, errCode); | 2112 | __func__, errCode); |
2027 | return errCode; | 2113 | return errCode; |
@@ -2033,6 +2119,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2033 | /* Configure audio */ | 2119 | /* Configure audio */ |
2034 | errCode = em28xx_audio_setup(dev); | 2120 | errCode = em28xx_audio_setup(dev); |
2035 | if (errCode < 0) { | 2121 | if (errCode < 0) { |
2122 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2036 | em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n", | 2123 | em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n", |
2037 | __func__, errCode); | 2124 | __func__, errCode); |
2038 | } | 2125 | } |
@@ -2077,7 +2164,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2077 | em28xx_init_extension(dev); | 2164 | em28xx_init_extension(dev); |
2078 | 2165 | ||
2079 | /* Save some power by putting tuner to sleep */ | 2166 | /* Save some power by putting tuner to sleep */ |
2080 | em28xx_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 2167 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_standby); |
2081 | 2168 | ||
2082 | return 0; | 2169 | return 0; |
2083 | 2170 | ||
@@ -2096,7 +2183,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2096 | struct usb_device *udev; | 2183 | struct usb_device *udev; |
2097 | struct usb_interface *uif; | 2184 | struct usb_interface *uif; |
2098 | struct em28xx *dev = NULL; | 2185 | struct em28xx *dev = NULL; |
2099 | int retval = -ENODEV; | 2186 | int retval; |
2100 | int i, nr, ifnum, isoc_pipe; | 2187 | int i, nr, ifnum, isoc_pipe; |
2101 | char *speed; | 2188 | char *speed; |
2102 | char descr[255] = ""; | 2189 | char descr[255] = ""; |
@@ -2118,7 +2205,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2118 | interface->altsetting[0].desc.bInterfaceClass); | 2205 | interface->altsetting[0].desc.bInterfaceClass); |
2119 | 2206 | ||
2120 | em28xx_devused &= ~(1<<nr); | 2207 | em28xx_devused &= ~(1<<nr); |
2121 | return -ENODEV; | 2208 | retval = -ENODEV; |
2209 | goto err; | ||
2122 | } | 2210 | } |
2123 | 2211 | ||
2124 | endpoint = &interface->cur_altsetting->endpoint[0].desc; | 2212 | endpoint = &interface->cur_altsetting->endpoint[0].desc; |
@@ -2151,7 +2239,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2151 | "interface not used by the driver\n"); | 2239 | "interface not used by the driver\n"); |
2152 | 2240 | ||
2153 | em28xx_devused &= ~(1<<nr); | 2241 | em28xx_devused &= ~(1<<nr); |
2154 | return -ENODEV; | 2242 | retval = -ENODEV; |
2243 | goto err; | ||
2155 | } | 2244 | } |
2156 | } | 2245 | } |
2157 | 2246 | ||
@@ -2194,7 +2283,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2194 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", | 2283 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", |
2195 | EM28XX_MAXBOARDS); | 2284 | EM28XX_MAXBOARDS); |
2196 | em28xx_devused &= ~(1<<nr); | 2285 | em28xx_devused &= ~(1<<nr); |
2197 | return -ENOMEM; | 2286 | retval = -ENOMEM; |
2287 | goto err; | ||
2198 | } | 2288 | } |
2199 | 2289 | ||
2200 | /* allocate memory for our device state and initialize it */ | 2290 | /* allocate memory for our device state and initialize it */ |
@@ -2202,7 +2292,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2202 | if (dev == NULL) { | 2292 | if (dev == NULL) { |
2203 | em28xx_err(DRIVER_NAME ": out of memory!\n"); | 2293 | em28xx_err(DRIVER_NAME ": out of memory!\n"); |
2204 | em28xx_devused &= ~(1<<nr); | 2294 | em28xx_devused &= ~(1<<nr); |
2205 | return -ENOMEM; | 2295 | retval = -ENOMEM; |
2296 | goto err; | ||
2206 | } | 2297 | } |
2207 | 2298 | ||
2208 | snprintf(dev->name, 29, "em28xx #%d", nr); | 2299 | snprintf(dev->name, 29, "em28xx #%d", nr); |
@@ -2229,7 +2320,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2229 | em28xx_errdev("out of memory!\n"); | 2320 | em28xx_errdev("out of memory!\n"); |
2230 | em28xx_devused &= ~(1<<nr); | 2321 | em28xx_devused &= ~(1<<nr); |
2231 | kfree(dev); | 2322 | kfree(dev); |
2232 | return -ENOMEM; | 2323 | retval = -ENOMEM; |
2324 | goto err; | ||
2233 | } | 2325 | } |
2234 | 2326 | ||
2235 | for (i = 0; i < dev->num_alt ; i++) { | 2327 | for (i = 0; i < dev->num_alt ; i++) { |
@@ -2244,12 +2336,11 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2244 | /* allocate device struct */ | 2336 | /* allocate device struct */ |
2245 | mutex_init(&dev->lock); | 2337 | mutex_init(&dev->lock); |
2246 | mutex_lock(&dev->lock); | 2338 | mutex_lock(&dev->lock); |
2247 | retval = em28xx_init_dev(&dev, udev, nr); | 2339 | retval = em28xx_init_dev(&dev, udev, interface, nr); |
2248 | if (retval) { | 2340 | if (retval) { |
2249 | em28xx_devused &= ~(1<<dev->devno); | 2341 | em28xx_devused &= ~(1<<dev->devno); |
2250 | kfree(dev); | 2342 | kfree(dev); |
2251 | 2343 | goto err; | |
2252 | return retval; | ||
2253 | } | 2344 | } |
2254 | 2345 | ||
2255 | /* save our data pointer in this interface device */ | 2346 | /* save our data pointer in this interface device */ |
@@ -2263,6 +2354,9 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2263 | mutex_unlock(&dev->lock); | 2354 | mutex_unlock(&dev->lock); |
2264 | 2355 | ||
2265 | return 0; | 2356 | return 0; |
2357 | |||
2358 | err: | ||
2359 | return retval; | ||
2266 | } | 2360 | } |
2267 | 2361 | ||
2268 | /* | 2362 | /* |
@@ -2288,6 +2382,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
2288 | 2382 | ||
2289 | wake_up_interruptible_all(&dev->open); | 2383 | wake_up_interruptible_all(&dev->open); |
2290 | 2384 | ||
2385 | v4l2_device_disconnect(&dev->v4l2_dev); | ||
2386 | |||
2291 | if (dev->users) { | 2387 | if (dev->users) { |
2292 | em28xx_warn | 2388 | em28xx_warn |
2293 | ("device /dev/video%d is open! Deregistration and memory " | 2389 | ("device /dev/video%d is open! Deregistration and memory " |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 8f1999ca4803..192b76cdd5d7 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -1018,14 +1018,10 @@ EXPORT_SYMBOL_GPL(em28xx_init_isoc); | |||
1018 | */ | 1018 | */ |
1019 | void em28xx_wake_i2c(struct em28xx *dev) | 1019 | void em28xx_wake_i2c(struct em28xx *dev) |
1020 | { | 1020 | { |
1021 | struct v4l2_routing route; | 1021 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, 0); |
1022 | int zero = 0; | 1022 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, |
1023 | 1023 | INPUT(dev->ctl_input)->vmux, 0, 0); | |
1024 | route.input = INPUT(dev->ctl_input)->vmux; | 1024 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0); |
1025 | route.output = 0; | ||
1026 | em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, &zero); | ||
1027 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1028 | em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); | ||
1029 | } | 1025 | } |
1030 | 1026 | ||
1031 | /* | 1027 | /* |
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 02c12fe6361b..f0bf1d960c75 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
@@ -459,70 +459,15 @@ static u32 functionality(struct i2c_adapter *adap) | |||
459 | static int attach_inform(struct i2c_client *client) | 459 | static int attach_inform(struct i2c_client *client) |
460 | { | 460 | { |
461 | struct em28xx *dev = client->adapter->algo_data; | 461 | struct em28xx *dev = client->adapter->algo_data; |
462 | struct IR_i2c *ir = i2c_get_clientdata(client); | ||
462 | 463 | ||
463 | switch (client->addr << 1) { | 464 | switch (client->addr << 1) { |
464 | case 0x86: | ||
465 | case 0x84: | ||
466 | case 0x96: | ||
467 | case 0x94: | ||
468 | { | ||
469 | struct v4l2_priv_tun_config tda9887_cfg; | ||
470 | |||
471 | struct tuner_setup tun_setup; | ||
472 | |||
473 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | ||
474 | tun_setup.type = TUNER_TDA9887; | ||
475 | tun_setup.addr = client->addr; | ||
476 | |||
477 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, | ||
478 | &tun_setup); | ||
479 | |||
480 | tda9887_cfg.tuner = TUNER_TDA9887; | ||
481 | tda9887_cfg.priv = &dev->tda9887_conf; | ||
482 | em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, | ||
483 | &tda9887_cfg); | ||
484 | break; | ||
485 | } | ||
486 | case 0x42: | ||
487 | dprintk1(1, "attach_inform: saa7114 detected.\n"); | ||
488 | break; | ||
489 | case 0x4a: | ||
490 | dprintk1(1, "attach_inform: saa7113 detected.\n"); | ||
491 | break; | ||
492 | case 0xa0: | ||
493 | dprintk1(1, "attach_inform: eeprom detected.\n"); | ||
494 | break; | ||
495 | case 0x60: | 465 | case 0x60: |
496 | case 0x8e: | 466 | case 0x8e: |
497 | { | 467 | dprintk1(1, "attach_inform: IR detected (%s).\n", ir->phys); |
498 | struct IR_i2c *ir = i2c_get_clientdata(client); | ||
499 | dprintk1(1, "attach_inform: IR detected (%s).\n", | ||
500 | ir->phys); | ||
501 | em28xx_set_ir(dev, ir); | 468 | em28xx_set_ir(dev, ir); |
502 | break; | 469 | break; |
503 | } | 470 | } |
504 | case 0x80: | ||
505 | case 0x88: | ||
506 | dprintk1(1, "attach_inform: msp34xx detected.\n"); | ||
507 | break; | ||
508 | case 0xb8: | ||
509 | case 0xba: | ||
510 | dprintk1(1, "attach_inform: tvp5150 detected.\n"); | ||
511 | break; | ||
512 | |||
513 | case 0xb0: | ||
514 | dprintk1(1, "attach_inform: tda9874 detected\n"); | ||
515 | break; | ||
516 | |||
517 | default: | ||
518 | if (!dev->tuner_addr) | ||
519 | dev->tuner_addr = client->addr; | ||
520 | |||
521 | dprintk1(1, "attach inform: detected I2C address %x\n", | ||
522 | client->addr << 1); | ||
523 | dprintk1(1, "driver id %d\n", client->driver->id); | ||
524 | |||
525 | } | ||
526 | 471 | ||
527 | return 0; | 472 | return 0; |
528 | } | 473 | } |
@@ -534,7 +479,6 @@ static struct i2c_algorithm em28xx_algo = { | |||
534 | 479 | ||
535 | static struct i2c_adapter em28xx_adap_template = { | 480 | static struct i2c_adapter em28xx_adap_template = { |
536 | .owner = THIS_MODULE, | 481 | .owner = THIS_MODULE, |
537 | .class = I2C_CLASS_TV_ANALOG, | ||
538 | .name = "em28xx", | 482 | .name = "em28xx", |
539 | .id = I2C_HW_B_EM28XX, | 483 | .id = I2C_HW_B_EM28XX, |
540 | .algo = &em28xx_algo, | 484 | .algo = &em28xx_algo, |
@@ -595,16 +539,6 @@ void em28xx_do_i2c_scan(struct em28xx *dev) | |||
595 | } | 539 | } |
596 | 540 | ||
597 | /* | 541 | /* |
598 | * em28xx_i2c_call_clients() | ||
599 | * send commands to all attached i2c devices | ||
600 | */ | ||
601 | void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg) | ||
602 | { | ||
603 | BUG_ON(NULL == dev->i2c_adap.algo_data); | ||
604 | i2c_clients_command(&dev->i2c_adap, cmd, arg); | ||
605 | } | ||
606 | |||
607 | /* | ||
608 | * em28xx_i2c_register() | 542 | * em28xx_i2c_register() |
609 | * register i2c bus | 543 | * register i2c bus |
610 | */ | 544 | */ |
@@ -618,6 +552,7 @@ int em28xx_i2c_register(struct em28xx *dev) | |||
618 | dev->i2c_adap.dev.parent = &dev->udev->dev; | 552 | dev->i2c_adap.dev.parent = &dev->udev->dev; |
619 | strcpy(dev->i2c_adap.name, dev->name); | 553 | strcpy(dev->i2c_adap.name, dev->name); |
620 | dev->i2c_adap.algo_data = dev; | 554 | dev->i2c_adap.algo_data = dev; |
555 | i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); | ||
621 | 556 | ||
622 | retval = i2c_add_adapter(&dev->i2c_adap); | 557 | retval = i2c_add_adapter(&dev->i2c_adap); |
623 | if (retval < 0) { | 558 | if (retval < 0) { |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 575472f1e702..882796e84dbc 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -49,7 +49,7 @@ | |||
49 | "Sascha Sommer <saschasommer@freenet.de>" | 49 | "Sascha Sommer <saschasommer@freenet.de>" |
50 | 50 | ||
51 | #define DRIVER_DESC "Empia em28xx based USB video device driver" | 51 | #define DRIVER_DESC "Empia em28xx based USB video device driver" |
52 | #define EM28XX_VERSION_CODE KERNEL_VERSION(0, 1, 1) | 52 | #define EM28XX_VERSION_CODE KERNEL_VERSION(0, 1, 2) |
53 | 53 | ||
54 | #define em28xx_videodbg(fmt, arg...) do {\ | 54 | #define em28xx_videodbg(fmt, arg...) do {\ |
55 | if (video_debug) \ | 55 | if (video_debug) \ |
@@ -400,7 +400,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | |||
400 | f.frequency = dev->ctl_freq; | 400 | f.frequency = dev->ctl_freq; |
401 | f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 401 | f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
402 | 402 | ||
403 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); | 403 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); |
404 | 404 | ||
405 | return 0; | 405 | return 0; |
406 | } | 406 | } |
@@ -515,10 +515,6 @@ static struct videobuf_queue_ops em28xx_video_qops = { | |||
515 | 515 | ||
516 | static void video_mux(struct em28xx *dev, int index) | 516 | static void video_mux(struct em28xx *dev, int index) |
517 | { | 517 | { |
518 | struct v4l2_routing route; | ||
519 | |||
520 | route.input = INPUT(index)->vmux; | ||
521 | route.output = 0; | ||
522 | dev->ctl_input = index; | 518 | dev->ctl_input = index; |
523 | dev->ctl_ainput = INPUT(index)->amux; | 519 | dev->ctl_ainput = INPUT(index)->amux; |
524 | dev->ctl_aoutput = INPUT(index)->aout; | 520 | dev->ctl_aoutput = INPUT(index)->aout; |
@@ -526,25 +522,22 @@ static void video_mux(struct em28xx *dev, int index) | |||
526 | if (!dev->ctl_aoutput) | 522 | if (!dev->ctl_aoutput) |
527 | dev->ctl_aoutput = EM28XX_AOUT_MASTER; | 523 | dev->ctl_aoutput = EM28XX_AOUT_MASTER; |
528 | 524 | ||
529 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 525 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, |
526 | INPUT(index)->vmux, 0, 0); | ||
530 | 527 | ||
531 | if (dev->board.has_msp34xx) { | 528 | if (dev->board.has_msp34xx) { |
532 | if (dev->i2s_speed) { | 529 | if (dev->i2s_speed) { |
533 | em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, | 530 | v4l2_device_call_all(&dev->v4l2_dev, 0, audio, |
534 | &dev->i2s_speed); | 531 | s_i2s_clock_freq, dev->i2s_speed); |
535 | } | 532 | } |
536 | route.input = dev->ctl_ainput; | ||
537 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | ||
538 | /* Note: this is msp3400 specific */ | 533 | /* Note: this is msp3400 specific */ |
539 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, | 534 | v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, |
540 | &route); | 535 | dev->ctl_ainput, MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0); |
541 | } | 536 | } |
542 | 537 | ||
543 | if (dev->board.adecoder != EM28XX_NOADECODER) { | 538 | if (dev->board.adecoder != EM28XX_NOADECODER) { |
544 | route.input = dev->ctl_ainput; | 539 | v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, |
545 | route.output = dev->ctl_aoutput; | 540 | dev->ctl_ainput, dev->ctl_aoutput, 0); |
546 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, | ||
547 | &route); | ||
548 | } | 541 | } |
549 | 542 | ||
550 | em28xx_audio_analog_set(dev); | 543 | em28xx_audio_analog_set(dev); |
@@ -829,7 +822,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
829 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | 822 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); |
830 | 823 | ||
831 | em28xx_resolution_set(dev); | 824 | em28xx_resolution_set(dev); |
832 | em28xx_i2c_call_clients(dev, VIDIOC_S_STD, &dev->norm); | 825 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm); |
833 | 826 | ||
834 | mutex_unlock(&dev->lock); | 827 | mutex_unlock(&dev->lock); |
835 | return 0; | 828 | return 0; |
@@ -995,8 +988,9 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
995 | } | 988 | } |
996 | } | 989 | } |
997 | } | 990 | } |
991 | |||
998 | mutex_lock(&dev->lock); | 992 | mutex_lock(&dev->lock); |
999 | em28xx_i2c_call_clients(dev, VIDIOC_QUERYCTRL, qc); | 993 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc); |
1000 | mutex_unlock(&dev->lock); | 994 | mutex_unlock(&dev->lock); |
1001 | 995 | ||
1002 | if (qc->type) | 996 | if (qc->type) |
@@ -1020,11 +1014,11 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
1020 | mutex_lock(&dev->lock); | 1014 | mutex_lock(&dev->lock); |
1021 | 1015 | ||
1022 | if (dev->board.has_msp34xx) | 1016 | if (dev->board.has_msp34xx) |
1023 | em28xx_i2c_call_clients(dev, VIDIOC_G_CTRL, ctrl); | 1017 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl); |
1024 | else { | 1018 | else { |
1025 | rc = em28xx_get_ctrl(dev, ctrl); | 1019 | rc = em28xx_get_ctrl(dev, ctrl); |
1026 | if (rc < 0) { | 1020 | if (rc < 0) { |
1027 | em28xx_i2c_call_clients(dev, VIDIOC_G_CTRL, ctrl); | 1021 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl); |
1028 | rc = 0; | 1022 | rc = 0; |
1029 | } | 1023 | } |
1030 | } | 1024 | } |
@@ -1048,7 +1042,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1048 | mutex_lock(&dev->lock); | 1042 | mutex_lock(&dev->lock); |
1049 | 1043 | ||
1050 | if (dev->board.has_msp34xx) | 1044 | if (dev->board.has_msp34xx) |
1051 | em28xx_i2c_call_clients(dev, VIDIOC_S_CTRL, ctrl); | 1045 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); |
1052 | else { | 1046 | else { |
1053 | rc = 1; | 1047 | rc = 1; |
1054 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { | 1048 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { |
@@ -1067,7 +1061,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1067 | 1061 | ||
1068 | /* Control not found - try to send it to the attached devices */ | 1062 | /* Control not found - try to send it to the attached devices */ |
1069 | if (rc == 1) { | 1063 | if (rc == 1) { |
1070 | em28xx_i2c_call_clients(dev, VIDIOC_S_CTRL, ctrl); | 1064 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); |
1071 | rc = 0; | 1065 | rc = 0; |
1072 | } | 1066 | } |
1073 | 1067 | ||
@@ -1092,10 +1086,9 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
1092 | strcpy(t->name, "Tuner"); | 1086 | strcpy(t->name, "Tuner"); |
1093 | 1087 | ||
1094 | mutex_lock(&dev->lock); | 1088 | mutex_lock(&dev->lock); |
1095 | 1089 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); | |
1096 | em28xx_i2c_call_clients(dev, VIDIOC_G_TUNER, t); | ||
1097 | |||
1098 | mutex_unlock(&dev->lock); | 1090 | mutex_unlock(&dev->lock); |
1091 | |||
1099 | return 0; | 1092 | return 0; |
1100 | } | 1093 | } |
1101 | 1094 | ||
@@ -1114,10 +1107,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, | |||
1114 | return -EINVAL; | 1107 | return -EINVAL; |
1115 | 1108 | ||
1116 | mutex_lock(&dev->lock); | 1109 | mutex_lock(&dev->lock); |
1117 | 1110 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); | |
1118 | em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, t); | ||
1119 | |||
1120 | mutex_unlock(&dev->lock); | 1111 | mutex_unlock(&dev->lock); |
1112 | |||
1121 | return 0; | 1113 | return 0; |
1122 | } | 1114 | } |
1123 | 1115 | ||
@@ -1157,7 +1149,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1157 | mutex_lock(&dev->lock); | 1149 | mutex_lock(&dev->lock); |
1158 | 1150 | ||
1159 | dev->ctl_freq = f->frequency; | 1151 | dev->ctl_freq = f->frequency; |
1160 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); | 1152 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f); |
1161 | 1153 | ||
1162 | mutex_unlock(&dev->lock); | 1154 | mutex_unlock(&dev->lock); |
1163 | 1155 | ||
@@ -1186,7 +1178,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv, | |||
1186 | chip->ident = V4L2_IDENT_NONE; | 1178 | chip->ident = V4L2_IDENT_NONE; |
1187 | chip->revision = 0; | 1179 | chip->revision = 0; |
1188 | 1180 | ||
1189 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); | 1181 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip); |
1190 | 1182 | ||
1191 | return 0; | 1183 | return 0; |
1192 | } | 1184 | } |
@@ -1211,7 +1203,7 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1211 | reg->size = 1; | 1203 | reg->size = 1; |
1212 | return 0; | 1204 | return 0; |
1213 | case V4L2_CHIP_MATCH_I2C_DRIVER: | 1205 | case V4L2_CHIP_MATCH_I2C_DRIVER: |
1214 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg); | 1206 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); |
1215 | return 0; | 1207 | return 0; |
1216 | case V4L2_CHIP_MATCH_I2C_ADDR: | 1208 | case V4L2_CHIP_MATCH_I2C_ADDR: |
1217 | /* Not supported yet */ | 1209 | /* Not supported yet */ |
@@ -1263,7 +1255,7 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1263 | 1255 | ||
1264 | return rc; | 1256 | return rc; |
1265 | case V4L2_CHIP_MATCH_I2C_DRIVER: | 1257 | case V4L2_CHIP_MATCH_I2C_DRIVER: |
1266 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_S_REGISTER, reg); | 1258 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); |
1267 | return 0; | 1259 | return 0; |
1268 | case V4L2_CHIP_MATCH_I2C_ADDR: | 1260 | case V4L2_CHIP_MATCH_I2C_ADDR: |
1269 | /* Not supported yet */ | 1261 | /* Not supported yet */ |
@@ -1406,13 +1398,13 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | |||
1406 | mutex_lock(&dev->lock); | 1398 | mutex_lock(&dev->lock); |
1407 | 1399 | ||
1408 | f->fmt.sliced.service_set = 0; | 1400 | f->fmt.sliced.service_set = 0; |
1409 | 1401 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, g_fmt, f); | |
1410 | em28xx_i2c_call_clients(dev, VIDIOC_G_FMT, f); | ||
1411 | 1402 | ||
1412 | if (f->fmt.sliced.service_set == 0) | 1403 | if (f->fmt.sliced.service_set == 0) |
1413 | rc = -EINVAL; | 1404 | rc = -EINVAL; |
1414 | 1405 | ||
1415 | mutex_unlock(&dev->lock); | 1406 | mutex_unlock(&dev->lock); |
1407 | |||
1416 | return rc; | 1408 | return rc; |
1417 | } | 1409 | } |
1418 | 1410 | ||
@@ -1428,7 +1420,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, | |||
1428 | return rc; | 1420 | return rc; |
1429 | 1421 | ||
1430 | mutex_lock(&dev->lock); | 1422 | mutex_lock(&dev->lock); |
1431 | em28xx_i2c_call_clients(dev, VIDIOC_G_FMT, f); | 1423 | v4l2_device_call_all(&dev->v4l2_dev, 0, video, g_fmt, f); |
1432 | mutex_unlock(&dev->lock); | 1424 | mutex_unlock(&dev->lock); |
1433 | 1425 | ||
1434 | if (f->fmt.sliced.service_set == 0) | 1426 | if (f->fmt.sliced.service_set == 0) |
@@ -1532,7 +1524,7 @@ static int radio_g_tuner(struct file *file, void *priv, | |||
1532 | t->type = V4L2_TUNER_RADIO; | 1524 | t->type = V4L2_TUNER_RADIO; |
1533 | 1525 | ||
1534 | mutex_lock(&dev->lock); | 1526 | mutex_lock(&dev->lock); |
1535 | em28xx_i2c_call_clients(dev, VIDIOC_G_TUNER, t); | 1527 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); |
1536 | mutex_unlock(&dev->lock); | 1528 | mutex_unlock(&dev->lock); |
1537 | 1529 | ||
1538 | return 0; | 1530 | return 0; |
@@ -1567,7 +1559,7 @@ static int radio_s_tuner(struct file *file, void *priv, | |||
1567 | return -EINVAL; | 1559 | return -EINVAL; |
1568 | 1560 | ||
1569 | mutex_lock(&dev->lock); | 1561 | mutex_lock(&dev->lock); |
1570 | em28xx_i2c_call_clients(dev, VIDIOC_S_TUNER, t); | 1562 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); |
1571 | mutex_unlock(&dev->lock); | 1563 | mutex_unlock(&dev->lock); |
1572 | 1564 | ||
1573 | return 0; | 1565 | return 0; |
@@ -1655,7 +1647,7 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1655 | } | 1647 | } |
1656 | if (fh->radio) { | 1648 | if (fh->radio) { |
1657 | em28xx_videodbg("video_open: setting radio device\n"); | 1649 | em28xx_videodbg("video_open: setting radio device\n"); |
1658 | em28xx_i2c_call_clients(dev, AUDC_SET_RADIO, NULL); | 1650 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); |
1659 | } | 1651 | } |
1660 | 1652 | ||
1661 | dev->users++; | 1653 | dev->users++; |
@@ -1738,7 +1730,7 @@ static int em28xx_v4l2_close(struct file *filp) | |||
1738 | } | 1730 | } |
1739 | 1731 | ||
1740 | /* Save some power by putting tuner to sleep */ | 1732 | /* Save some power by putting tuner to sleep */ |
1741 | em28xx_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 1733 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_standby); |
1742 | 1734 | ||
1743 | /* do this before setting alternate! */ | 1735 | /* do this before setting alternate! */ |
1744 | em28xx_uninit_isoc(dev); | 1736 | em28xx_uninit_isoc(dev); |
@@ -1959,11 +1951,12 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
1959 | vfd = video_device_alloc(); | 1951 | vfd = video_device_alloc(); |
1960 | if (NULL == vfd) | 1952 | if (NULL == vfd) |
1961 | return NULL; | 1953 | return NULL; |
1962 | *vfd = *template; | 1954 | |
1963 | vfd->minor = -1; | 1955 | *vfd = *template; |
1964 | vfd->parent = &dev->udev->dev; | 1956 | vfd->minor = -1; |
1965 | vfd->release = video_device_release; | 1957 | vfd->v4l2_dev = &dev->v4l2_dev; |
1966 | vfd->debug = video_debug; | 1958 | vfd->release = video_device_release; |
1959 | vfd->debug = video_debug; | ||
1967 | 1960 | ||
1968 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", | 1961 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", |
1969 | dev->name, type_name); | 1962 | dev->name, type_name); |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index a33a58da016e..4c4e58004f54 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/videodev2.h> | 28 | #include <linux/videodev2.h> |
29 | #include <media/videobuf-vmalloc.h> | 29 | #include <media/videobuf-vmalloc.h> |
30 | #include <media/v4l2-device.h> | ||
30 | 31 | ||
31 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
32 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
@@ -385,6 +386,8 @@ struct em28xx_board { | |||
385 | unsigned int valid:1; | 386 | unsigned int valid:1; |
386 | 387 | ||
387 | unsigned char xclk, i2c_speed; | 388 | unsigned char xclk, i2c_speed; |
389 | unsigned char radio_addr; | ||
390 | unsigned short tvaudio_addr; | ||
388 | 391 | ||
389 | enum em28xx_decoder decoder; | 392 | enum em28xx_decoder decoder; |
390 | enum em28xx_adecoder adecoder; | 393 | enum em28xx_adecoder adecoder; |
@@ -460,6 +463,7 @@ struct em28xx { | |||
460 | int devno; /* marks the number of this device */ | 463 | int devno; /* marks the number of this device */ |
461 | enum em28xx_chip_id chip_id; | 464 | enum em28xx_chip_id chip_id; |
462 | 465 | ||
466 | struct v4l2_device v4l2_dev; | ||
463 | struct em28xx_board board; | 467 | struct em28xx_board board; |
464 | 468 | ||
465 | unsigned int stream_on:1; /* Locks streams */ | 469 | unsigned int stream_on:1; /* Locks streams */ |
@@ -577,11 +581,9 @@ struct em28xx_ops { | |||
577 | }; | 581 | }; |
578 | 582 | ||
579 | /* Provided by em28xx-i2c.c */ | 583 | /* Provided by em28xx-i2c.c */ |
580 | |||
581 | void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg); | ||
582 | void em28xx_do_i2c_scan(struct em28xx *dev); | 584 | void em28xx_do_i2c_scan(struct em28xx *dev); |
583 | int em28xx_i2c_register(struct em28xx *dev); | 585 | int em28xx_i2c_register(struct em28xx *dev); |
584 | int em28xx_i2c_unregister(struct em28xx *dev); | 586 | int em28xx_i2c_unregister(struct em28xx *dev); |
585 | 587 | ||
586 | /* Provided by em28xx-core.c */ | 588 | /* Provided by em28xx-core.c */ |
587 | 589 | ||
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index a75c1ca2db41..a2741d7dccfe 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -1132,6 +1132,7 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1132 | if (input->index != 0) | 1132 | if (input->index != 0) |
1133 | return -EINVAL; | 1133 | return -EINVAL; |
1134 | input->type = V4L2_INPUT_TYPE_CAMERA; | 1134 | input->type = V4L2_INPUT_TYPE_CAMERA; |
1135 | input->status = gspca_dev->cam.input_flags; | ||
1135 | strncpy(input->name, gspca_dev->sd_desc->name, | 1136 | strncpy(input->name, gspca_dev->sd_desc->name, |
1136 | sizeof input->name); | 1137 | sizeof input->name); |
1137 | return 0; | 1138 | return 0; |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index e4d4cf6ce05a..58e8ff02136a 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -56,6 +56,7 @@ struct cam { | |||
56 | * - cannot be > MAX_NURBS | 56 | * - cannot be > MAX_NURBS |
57 | * - when 0 and bulk_size != 0 means | 57 | * - when 0 and bulk_size != 0 means |
58 | * 1 URB and submit done by subdriver */ | 58 | * 1 URB and submit done by subdriver */ |
59 | u32 input_flags; /* value for ENUM_INPUT status flags */ | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | struct gspca_dev; | 62 | struct gspca_dev; |
diff --git a/drivers/media/video/gspca/m5602/Makefile b/drivers/media/video/gspca/m5602/Makefile index 226ab4fc9d60..9fa3644f4869 100644 --- a/drivers/media/video/gspca/m5602/Makefile +++ b/drivers/media/video/gspca/m5602/Makefile | |||
@@ -7,5 +7,4 @@ gspca_m5602-objs := m5602_core.o \ | |||
7 | m5602_s5k83a.o \ | 7 | m5602_s5k83a.o \ |
8 | m5602_s5k4aa.o | 8 | m5602_s5k4aa.o |
9 | 9 | ||
10 | EXTRA_CFLAGS += -Idrivers/media/video/gspca | 10 | EXTRA_CFLAGS += -Idrivers/media/video/gspca \ No newline at end of file |
11 | |||
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h index a3f3b7a0c7e7..8f1cea6fd3bf 100644 --- a/drivers/media/video/gspca/m5602/m5602_bridge.h +++ b/drivers/media/video/gspca/m5602/m5602_bridge.h | |||
@@ -112,14 +112,14 @@ static const unsigned char sensor_urb_skeleton[] = { | |||
112 | struct sd { | 112 | struct sd { |
113 | struct gspca_dev gspca_dev; | 113 | struct gspca_dev gspca_dev; |
114 | 114 | ||
115 | /* The name of the m5602 camera */ | ||
116 | char *name; | ||
117 | |||
118 | /* A pointer to the currently connected sensor */ | 115 | /* A pointer to the currently connected sensor */ |
119 | struct m5602_sensor *sensor; | 116 | const struct m5602_sensor *sensor; |
120 | 117 | ||
121 | struct sd_desc *desc; | 118 | struct sd_desc *desc; |
122 | 119 | ||
120 | /* Sensor private data */ | ||
121 | void *sensor_priv; | ||
122 | |||
123 | /* The current frame's id, used to detect frame boundaries */ | 123 | /* The current frame's id, used to detect frame boundaries */ |
124 | u8 frame_id; | 124 | u8 frame_id; |
125 | 125 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c index b35e4838a6e5..1aac2985fee6 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c | |||
@@ -51,7 +51,7 @@ int m5602_read_bridge(struct sd *sd, u8 address, u8 *i2c_data) | |||
51 | address, *i2c_data); | 51 | address, *i2c_data); |
52 | 52 | ||
53 | /* usb_control_msg(...) returns the number of bytes sent upon success, | 53 | /* usb_control_msg(...) returns the number of bytes sent upon success, |
54 | mask that and return zero upon success instead*/ | 54 | mask that and return zero instead*/ |
55 | return (err < 0) ? err : 0; | 55 | return (err < 0) ? err : 0; |
56 | } | 56 | } |
57 | 57 | ||
@@ -76,7 +76,7 @@ int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data) | |||
76 | 4, M5602_URB_MSG_TIMEOUT); | 76 | 4, M5602_URB_MSG_TIMEOUT); |
77 | 77 | ||
78 | /* usb_control_msg(...) returns the number of bytes sent upon success, | 78 | /* usb_control_msg(...) returns the number of bytes sent upon success, |
79 | mask that and return zero upon success instead */ | 79 | mask that and return zero instead */ |
80 | return (err < 0) ? err : 0; | 80 | return (err < 0) ? err : 0; |
81 | } | 81 | } |
82 | 82 | ||
@@ -92,29 +92,29 @@ int m5602_read_sensor(struct sd *sd, const u8 address, | |||
92 | err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, i2c_data); | 92 | err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, i2c_data); |
93 | } while ((*i2c_data & I2C_BUSY) && !err); | 93 | } while ((*i2c_data & I2C_BUSY) && !err); |
94 | if (err < 0) | 94 | if (err < 0) |
95 | goto out; | 95 | return err; |
96 | 96 | ||
97 | err = m5602_write_bridge(sd, M5602_XB_I2C_DEV_ADDR, | 97 | err = m5602_write_bridge(sd, M5602_XB_I2C_DEV_ADDR, |
98 | sd->sensor->i2c_slave_id); | 98 | sd->sensor->i2c_slave_id); |
99 | if (err < 0) | 99 | if (err < 0) |
100 | goto out; | 100 | return err; |
101 | 101 | ||
102 | err = m5602_write_bridge(sd, M5602_XB_I2C_REG_ADDR, address); | 102 | err = m5602_write_bridge(sd, M5602_XB_I2C_REG_ADDR, address); |
103 | if (err < 0) | 103 | if (err < 0) |
104 | goto out; | 104 | return err; |
105 | 105 | ||
106 | if (sd->sensor->i2c_regW == 1) { | 106 | if (sd->sensor->i2c_regW == 1) { |
107 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, len); | 107 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, len); |
108 | if (err < 0) | 108 | if (err < 0) |
109 | goto out; | 109 | return err; |
110 | 110 | ||
111 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x08); | 111 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x08); |
112 | if (err < 0) | 112 | if (err < 0) |
113 | goto out; | 113 | return err; |
114 | } else { | 114 | } else { |
115 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x18 + len); | 115 | err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x18 + len); |
116 | if (err < 0) | 116 | if (err < 0) |
117 | goto out; | 117 | return err; |
118 | } | 118 | } |
119 | 119 | ||
120 | for (i = 0; (i < len) && !err; i++) { | 120 | for (i = 0; (i < len) && !err; i++) { |
@@ -123,7 +123,6 @@ int m5602_read_sensor(struct sd *sd, const u8 address, | |||
123 | PDEBUG(D_CONF, "Reading sensor register " | 123 | PDEBUG(D_CONF, "Reading sensor register " |
124 | "0x%x containing 0x%x ", address, *i2c_data); | 124 | "0x%x containing 0x%x ", address, *i2c_data); |
125 | } | 125 | } |
126 | out: | ||
127 | return err; | 126 | return err; |
128 | } | 127 | } |
129 | 128 | ||
@@ -310,7 +309,11 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, | |||
310 | 309 | ||
311 | static void m5602_stop_transfer(struct gspca_dev *gspca_dev) | 310 | static void m5602_stop_transfer(struct gspca_dev *gspca_dev) |
312 | { | 311 | { |
313 | /* Is there are a command to stop a data transfer? */ | 312 | struct sd *sd = (struct sd *) gspca_dev; |
313 | |||
314 | /* Run the sensor specific end transfer sequence */ | ||
315 | if (sd->sensor->stop) | ||
316 | sd->sensor->stop(sd); | ||
314 | } | 317 | } |
315 | 318 | ||
316 | /* sub-driver description, the ctrl and nctrl is filled at probe time */ | 319 | /* sub-driver description, the ctrl and nctrl is filled at probe time */ |
@@ -359,6 +362,17 @@ static int m5602_probe(struct usb_interface *intf, | |||
359 | THIS_MODULE); | 362 | THIS_MODULE); |
360 | } | 363 | } |
361 | 364 | ||
365 | void m5602_disconnect(struct usb_interface *intf) | ||
366 | { | ||
367 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); | ||
368 | struct sd *sd = (struct sd *) gspca_dev; | ||
369 | |||
370 | if (sd->sensor->disconnect) | ||
371 | sd->sensor->disconnect(sd); | ||
372 | |||
373 | gspca_disconnect(intf); | ||
374 | } | ||
375 | |||
362 | static struct usb_driver sd_driver = { | 376 | static struct usb_driver sd_driver = { |
363 | .name = MODULE_NAME, | 377 | .name = MODULE_NAME, |
364 | .id_table = m5602_table, | 378 | .id_table = m5602_table, |
@@ -367,7 +381,7 @@ static struct usb_driver sd_driver = { | |||
367 | .suspend = gspca_suspend, | 381 | .suspend = gspca_suspend, |
368 | .resume = gspca_resume, | 382 | .resume = gspca_resume, |
369 | #endif | 383 | #endif |
370 | .disconnect = gspca_disconnect | 384 | .disconnect = m5602_disconnect |
371 | }; | 385 | }; |
372 | 386 | ||
373 | /* -- module insert / remove -- */ | 387 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c index c0e71c331454..7d3f9e348ef4 100644 --- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c +++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c | |||
@@ -18,6 +18,61 @@ | |||
18 | 18 | ||
19 | #include "m5602_mt9m111.h" | 19 | #include "m5602_mt9m111.h" |
20 | 20 | ||
21 | static struct v4l2_pix_format mt9m111_modes[] = { | ||
22 | { | ||
23 | 640, | ||
24 | 480, | ||
25 | V4L2_PIX_FMT_SBGGR8, | ||
26 | V4L2_FIELD_NONE, | ||
27 | .sizeimage = 640 * 480, | ||
28 | .bytesperline = 640, | ||
29 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
30 | .priv = 0 | ||
31 | } | ||
32 | }; | ||
33 | |||
34 | const static struct ctrl mt9m111_ctrls[] = { | ||
35 | { | ||
36 | { | ||
37 | .id = V4L2_CID_VFLIP, | ||
38 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
39 | .name = "vertical flip", | ||
40 | .minimum = 0, | ||
41 | .maximum = 1, | ||
42 | .step = 1, | ||
43 | .default_value = 0 | ||
44 | }, | ||
45 | .set = mt9m111_set_vflip, | ||
46 | .get = mt9m111_get_vflip | ||
47 | }, { | ||
48 | { | ||
49 | .id = V4L2_CID_HFLIP, | ||
50 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
51 | .name = "horizontal flip", | ||
52 | .minimum = 0, | ||
53 | .maximum = 1, | ||
54 | .step = 1, | ||
55 | .default_value = 0 | ||
56 | }, | ||
57 | .set = mt9m111_set_hflip, | ||
58 | .get = mt9m111_get_hflip | ||
59 | }, { | ||
60 | { | ||
61 | .id = V4L2_CID_GAIN, | ||
62 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
63 | .name = "gain", | ||
64 | .minimum = 0, | ||
65 | .maximum = (INITIAL_MAX_GAIN - 1) * 2 * 2 * 2, | ||
66 | .step = 1, | ||
67 | .default_value = DEFAULT_GAIN, | ||
68 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
69 | }, | ||
70 | .set = mt9m111_set_gain, | ||
71 | .get = mt9m111_get_gain | ||
72 | } | ||
73 | }; | ||
74 | |||
75 | |||
21 | static void mt9m111_dump_registers(struct sd *sd); | 76 | static void mt9m111_dump_registers(struct sd *sd); |
22 | 77 | ||
23 | int mt9m111_probe(struct sd *sd) | 78 | int mt9m111_probe(struct sd *sd) |
@@ -62,10 +117,10 @@ int mt9m111_probe(struct sd *sd) | |||
62 | return -ENODEV; | 117 | return -ENODEV; |
63 | 118 | ||
64 | sensor_found: | 119 | sensor_found: |
65 | sd->gspca_dev.cam.cam_mode = mt9m111.modes; | 120 | sd->gspca_dev.cam.cam_mode = mt9m111_modes; |
66 | sd->gspca_dev.cam.nmodes = mt9m111.nmodes; | 121 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(mt9m111_modes); |
67 | sd->desc->ctrls = mt9m111.ctrls; | 122 | sd->desc->ctrls = mt9m111_ctrls; |
68 | sd->desc->nctrls = mt9m111.nctrls; | 123 | sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls); |
69 | return 0; | 124 | return 0; |
70 | } | 125 | } |
71 | 126 | ||
@@ -125,16 +180,15 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
125 | /* Set the correct page map */ | 180 | /* Set the correct page map */ |
126 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); | 181 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); |
127 | if (err < 0) | 182 | if (err < 0) |
128 | goto out; | 183 | return err; |
129 | 184 | ||
130 | err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, data, 2); | 185 | err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, data, 2); |
131 | if (err < 0) | 186 | if (err < 0) |
132 | goto out; | 187 | return err; |
133 | 188 | ||
134 | data[0] = (data[0] & 0xfe) | val; | 189 | data[0] = (data[0] & 0xfe) | val; |
135 | err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, | 190 | err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, |
136 | data, 2); | 191 | data, 2); |
137 | out: | ||
138 | return err; | 192 | return err; |
139 | } | 193 | } |
140 | 194 | ||
@@ -163,16 +217,15 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
163 | /* Set the correct page map */ | 217 | /* Set the correct page map */ |
164 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); | 218 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); |
165 | if (err < 0) | 219 | if (err < 0) |
166 | goto out; | 220 | return err; |
167 | 221 | ||
168 | err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, data, 2); | 222 | err = m5602_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, data, 2); |
169 | if (err < 0) | 223 | if (err < 0) |
170 | goto out; | 224 | return err; |
171 | 225 | ||
172 | data[0] = (data[0] & 0xfd) | ((val << 1) & 0x02); | 226 | data[0] = (data[0] & 0xfd) | ((val << 1) & 0x02); |
173 | err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, | 227 | err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, |
174 | data, 2); | 228 | data, 2); |
175 | out: | ||
176 | return err; | 229 | return err; |
177 | } | 230 | } |
178 | 231 | ||
@@ -204,7 +257,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
204 | /* Set the correct page map */ | 257 | /* Set the correct page map */ |
205 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); | 258 | err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); |
206 | if (err < 0) | 259 | if (err < 0) |
207 | goto out; | 260 | return err; |
208 | 261 | ||
209 | if (val >= INITIAL_MAX_GAIN * 2 * 2 * 2) | 262 | if (val >= INITIAL_MAX_GAIN * 2 * 2 * 2) |
210 | return -EINVAL; | 263 | return -EINVAL; |
@@ -229,7 +282,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
229 | 282 | ||
230 | err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, | 283 | err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, |
231 | data, 2); | 284 | data, 2); |
232 | out: | 285 | |
233 | return err; | 286 | return err; |
234 | } | 287 | } |
235 | 288 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h index e795ab7a36c9..00c6db02bdb7 100644 --- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h +++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h | |||
@@ -94,7 +94,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | |||
94 | int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | 94 | int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val); |
95 | int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val); | 95 | int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val); |
96 | 96 | ||
97 | static struct m5602_sensor mt9m111 = { | 97 | const static struct m5602_sensor mt9m111 = { |
98 | .name = "MT9M111", | 98 | .name = "MT9M111", |
99 | 99 | ||
100 | .i2c_slave_id = 0xba, | 100 | .i2c_slave_id = 0xba, |
@@ -102,64 +102,7 @@ static struct m5602_sensor mt9m111 = { | |||
102 | 102 | ||
103 | .probe = mt9m111_probe, | 103 | .probe = mt9m111_probe, |
104 | .init = mt9m111_init, | 104 | .init = mt9m111_init, |
105 | .power_down = mt9m111_power_down, | 105 | .power_down = mt9m111_power_down |
106 | |||
107 | .nctrls = 3, | ||
108 | .ctrls = { | ||
109 | { | ||
110 | { | ||
111 | .id = V4L2_CID_VFLIP, | ||
112 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
113 | .name = "vertical flip", | ||
114 | .minimum = 0, | ||
115 | .maximum = 1, | ||
116 | .step = 1, | ||
117 | .default_value = 0 | ||
118 | }, | ||
119 | .set = mt9m111_set_vflip, | ||
120 | .get = mt9m111_get_vflip | ||
121 | }, { | ||
122 | { | ||
123 | .id = V4L2_CID_HFLIP, | ||
124 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
125 | .name = "horizontal flip", | ||
126 | .minimum = 0, | ||
127 | .maximum = 1, | ||
128 | .step = 1, | ||
129 | .default_value = 0 | ||
130 | }, | ||
131 | .set = mt9m111_set_hflip, | ||
132 | .get = mt9m111_get_hflip | ||
133 | }, { | ||
134 | { | ||
135 | .id = V4L2_CID_GAIN, | ||
136 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
137 | .name = "gain", | ||
138 | .minimum = 0, | ||
139 | .maximum = (INITIAL_MAX_GAIN - 1) * 2 * 2 * 2, | ||
140 | .step = 1, | ||
141 | .default_value = DEFAULT_GAIN, | ||
142 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
143 | }, | ||
144 | .set = mt9m111_set_gain, | ||
145 | .get = mt9m111_get_gain | ||
146 | } | ||
147 | }, | ||
148 | |||
149 | .nmodes = 1, | ||
150 | .modes = { | ||
151 | { | ||
152 | M5602_DEFAULT_FRAME_WIDTH, | ||
153 | M5602_DEFAULT_FRAME_HEIGHT, | ||
154 | V4L2_PIX_FMT_SBGGR8, | ||
155 | V4L2_FIELD_NONE, | ||
156 | .sizeimage = | ||
157 | M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT, | ||
158 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, | ||
159 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
160 | .priv = 1 | ||
161 | } | ||
162 | } | ||
163 | }; | 106 | }; |
164 | 107 | ||
165 | static const unsigned char preinit_mt9m111[][4] = | 108 | static const unsigned char preinit_mt9m111[][4] = |
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c index c908a8d6970a..fc4548fd441d 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov9650.c +++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c | |||
@@ -65,14 +65,177 @@ static | |||
65 | DMI_MATCH(DMI_PRODUCT_NAME, "Aurora m9700") | 65 | DMI_MATCH(DMI_PRODUCT_NAME, "Aurora m9700") |
66 | } | 66 | } |
67 | }, | 67 | }, |
68 | { } | 68 | {} |
69 | }; | ||
70 | |||
71 | const static struct ctrl ov9650_ctrls[] = { | ||
72 | #define EXPOSURE_IDX 0 | ||
73 | { | ||
74 | { | ||
75 | .id = V4L2_CID_EXPOSURE, | ||
76 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
77 | .name = "exposure", | ||
78 | .minimum = 0x00, | ||
79 | .maximum = 0x1ff, | ||
80 | .step = 0x4, | ||
81 | .default_value = EXPOSURE_DEFAULT, | ||
82 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
83 | }, | ||
84 | .set = ov9650_set_exposure, | ||
85 | .get = ov9650_get_exposure | ||
86 | }, | ||
87 | #define GAIN_IDX 1 | ||
88 | { | ||
89 | { | ||
90 | .id = V4L2_CID_GAIN, | ||
91 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
92 | .name = "gain", | ||
93 | .minimum = 0x00, | ||
94 | .maximum = 0x3ff, | ||
95 | .step = 0x1, | ||
96 | .default_value = GAIN_DEFAULT, | ||
97 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
98 | }, | ||
99 | .set = ov9650_set_gain, | ||
100 | .get = ov9650_get_gain | ||
101 | }, | ||
102 | #define RED_BALANCE_IDX 2 | ||
103 | { | ||
104 | { | ||
105 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
106 | .name = "red balance", | ||
107 | .minimum = 0x00, | ||
108 | .maximum = 0xff, | ||
109 | .step = 0x1, | ||
110 | .default_value = RED_GAIN_DEFAULT, | ||
111 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
112 | }, | ||
113 | .set = ov9650_set_red_balance, | ||
114 | .get = ov9650_get_red_balance | ||
115 | }, | ||
116 | #define BLUE_BALANCE_IDX 3 | ||
117 | { | ||
118 | { | ||
119 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
120 | .name = "blue balance", | ||
121 | .minimum = 0x00, | ||
122 | .maximum = 0xff, | ||
123 | .step = 0x1, | ||
124 | .default_value = BLUE_GAIN_DEFAULT, | ||
125 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
126 | }, | ||
127 | .set = ov9650_set_blue_balance, | ||
128 | .get = ov9650_get_blue_balance | ||
129 | }, | ||
130 | #define HFLIP_IDX 4 | ||
131 | { | ||
132 | { | ||
133 | .id = V4L2_CID_HFLIP, | ||
134 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
135 | .name = "horizontal flip", | ||
136 | .minimum = 0, | ||
137 | .maximum = 1, | ||
138 | .step = 1, | ||
139 | .default_value = 0 | ||
140 | }, | ||
141 | .set = ov9650_set_hflip, | ||
142 | .get = ov9650_get_hflip | ||
143 | }, | ||
144 | #define VFLIP_IDX 5 | ||
145 | { | ||
146 | { | ||
147 | .id = V4L2_CID_VFLIP, | ||
148 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
149 | .name = "vertical flip", | ||
150 | .minimum = 0, | ||
151 | .maximum = 1, | ||
152 | .step = 1, | ||
153 | .default_value = 0 | ||
154 | }, | ||
155 | .set = ov9650_set_vflip, | ||
156 | .get = ov9650_get_vflip | ||
157 | }, | ||
158 | #define AUTO_WHITE_BALANCE_IDX 6 | ||
159 | { | ||
160 | { | ||
161 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | ||
162 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
163 | .name = "auto white balance", | ||
164 | .minimum = 0, | ||
165 | .maximum = 1, | ||
166 | .step = 1, | ||
167 | .default_value = 1 | ||
168 | }, | ||
169 | .set = ov9650_set_auto_white_balance, | ||
170 | .get = ov9650_get_auto_white_balance | ||
171 | }, | ||
172 | #define AUTO_GAIN_CTRL_IDX 7 | ||
173 | { | ||
174 | { | ||
175 | .id = V4L2_CID_AUTOGAIN, | ||
176 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
177 | .name = "auto gain control", | ||
178 | .minimum = 0, | ||
179 | .maximum = 1, | ||
180 | .step = 1, | ||
181 | .default_value = 1 | ||
182 | }, | ||
183 | .set = ov9650_set_auto_gain, | ||
184 | .get = ov9650_get_auto_gain | ||
185 | } | ||
186 | }; | ||
187 | |||
188 | static struct v4l2_pix_format ov9650_modes[] = { | ||
189 | { | ||
190 | 176, | ||
191 | 144, | ||
192 | V4L2_PIX_FMT_SBGGR8, | ||
193 | V4L2_FIELD_NONE, | ||
194 | .sizeimage = | ||
195 | 176 * 144, | ||
196 | .bytesperline = 176, | ||
197 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
198 | .priv = 9 | ||
199 | }, { | ||
200 | 320, | ||
201 | 240, | ||
202 | V4L2_PIX_FMT_SBGGR8, | ||
203 | V4L2_FIELD_NONE, | ||
204 | .sizeimage = | ||
205 | 320 * 240, | ||
206 | .bytesperline = 320, | ||
207 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
208 | .priv = 8 | ||
209 | }, { | ||
210 | 352, | ||
211 | 288, | ||
212 | V4L2_PIX_FMT_SBGGR8, | ||
213 | V4L2_FIELD_NONE, | ||
214 | .sizeimage = | ||
215 | 352 * 288, | ||
216 | .bytesperline = 352, | ||
217 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
218 | .priv = 9 | ||
219 | }, { | ||
220 | 640, | ||
221 | 480, | ||
222 | V4L2_PIX_FMT_SBGGR8, | ||
223 | V4L2_FIELD_NONE, | ||
224 | .sizeimage = | ||
225 | 640 * 480, | ||
226 | .bytesperline = 640, | ||
227 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
228 | .priv = 9 | ||
229 | } | ||
69 | }; | 230 | }; |
70 | 231 | ||
71 | static void ov9650_dump_registers(struct sd *sd); | 232 | static void ov9650_dump_registers(struct sd *sd); |
72 | 233 | ||
73 | int ov9650_probe(struct sd *sd) | 234 | int ov9650_probe(struct sd *sd) |
74 | { | 235 | { |
236 | int err = 0; | ||
75 | u8 prod_id = 0, ver_id = 0, i; | 237 | u8 prod_id = 0, ver_id = 0, i; |
238 | s32 *sensor_settings; | ||
76 | 239 | ||
77 | if (force_sensor) { | 240 | if (force_sensor) { |
78 | if (force_sensor == OV9650_SENSOR) { | 241 | if (force_sensor == OV9650_SENSOR) { |
@@ -86,16 +249,20 @@ int ov9650_probe(struct sd *sd) | |||
86 | 249 | ||
87 | info("Probing for an ov9650 sensor"); | 250 | info("Probing for an ov9650 sensor"); |
88 | 251 | ||
89 | /* Run the pre-init to actually probe the unit */ | 252 | /* Run the pre-init before probing the sensor */ |
90 | for (i = 0; i < ARRAY_SIZE(preinit_ov9650); i++) { | 253 | for (i = 0; i < ARRAY_SIZE(preinit_ov9650) && !err; i++) { |
91 | u8 data = preinit_ov9650[i][2]; | 254 | u8 data = preinit_ov9650[i][2]; |
92 | if (preinit_ov9650[i][0] == SENSOR) | 255 | if (preinit_ov9650[i][0] == SENSOR) |
93 | m5602_write_sensor(sd, | 256 | err = m5602_write_sensor(sd, |
94 | preinit_ov9650[i][1], &data, 1); | 257 | preinit_ov9650[i][1], &data, 1); |
95 | else | 258 | else |
96 | m5602_write_bridge(sd, preinit_ov9650[i][1], data); | 259 | err = m5602_write_bridge(sd, |
260 | preinit_ov9650[i][1], data); | ||
97 | } | 261 | } |
98 | 262 | ||
263 | if (err < 0) | ||
264 | return err; | ||
265 | |||
99 | if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1)) | 266 | if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1)) |
100 | return -ENODEV; | 267 | return -ENODEV; |
101 | 268 | ||
@@ -106,14 +273,28 @@ int ov9650_probe(struct sd *sd) | |||
106 | info("Detected an ov9650 sensor"); | 273 | info("Detected an ov9650 sensor"); |
107 | goto sensor_found; | 274 | goto sensor_found; |
108 | } | 275 | } |
109 | |||
110 | return -ENODEV; | 276 | return -ENODEV; |
111 | 277 | ||
112 | sensor_found: | 278 | sensor_found: |
113 | sd->gspca_dev.cam.cam_mode = ov9650.modes; | 279 | sensor_settings = kmalloc( |
114 | sd->gspca_dev.cam.nmodes = ov9650.nmodes; | 280 | ARRAY_SIZE(ov9650_ctrls) * sizeof(s32), GFP_KERNEL); |
115 | sd->desc->ctrls = ov9650.ctrls; | 281 | if (!sensor_settings) |
116 | sd->desc->nctrls = ov9650.nctrls; | 282 | return -ENOMEM; |
283 | |||
284 | sd->gspca_dev.cam.cam_mode = ov9650_modes; | ||
285 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov9650_modes); | ||
286 | sd->desc->ctrls = ov9650_ctrls; | ||
287 | sd->desc->nctrls = ARRAY_SIZE(ov9650_ctrls); | ||
288 | |||
289 | for (i = 0; i < ARRAY_SIZE(ov9650_ctrls); i++) | ||
290 | sensor_settings[i] = ov9650_ctrls[i].qctrl.default_value; | ||
291 | sd->sensor_priv = sensor_settings; | ||
292 | |||
293 | if (dmi_check_system(ov9650_flip_dmi_table) && !err) { | ||
294 | info("vflip quirk active"); | ||
295 | sensor_settings[VFLIP_IDX] = 1; | ||
296 | } | ||
297 | |||
117 | return 0; | 298 | return 0; |
118 | } | 299 | } |
119 | 300 | ||
@@ -121,6 +302,7 @@ int ov9650_init(struct sd *sd) | |||
121 | { | 302 | { |
122 | int i, err = 0; | 303 | int i, err = 0; |
123 | u8 data; | 304 | u8 data; |
305 | s32 *sensor_settings = sd->sensor_priv; | ||
124 | 306 | ||
125 | if (dump_sensor) | 307 | if (dump_sensor) |
126 | ov9650_dump_registers(sd); | 308 | ov9650_dump_registers(sd); |
@@ -134,70 +316,157 @@ int ov9650_init(struct sd *sd) | |||
134 | err = m5602_write_bridge(sd, init_ov9650[i][1], data); | 316 | err = m5602_write_bridge(sd, init_ov9650[i][1], data); |
135 | } | 317 | } |
136 | 318 | ||
137 | if (dmi_check_system(ov9650_flip_dmi_table) && !err) { | 319 | err = ov9650_set_exposure(&sd->gspca_dev, sensor_settings[EXPOSURE_IDX]); |
138 | info("vflip quirk active"); | 320 | if (err < 0) |
139 | data = 0x30; | 321 | return err; |
140 | err = m5602_write_sensor(sd, OV9650_MVFP, &data, 1); | 322 | |
141 | } | 323 | err = ov9650_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); |
324 | if (err < 0) | ||
325 | return err; | ||
326 | |||
327 | err = ov9650_set_red_balance(&sd->gspca_dev, sensor_settings[RED_BALANCE_IDX]); | ||
328 | if (err < 0) | ||
329 | return err; | ||
330 | |||
331 | err = ov9650_set_blue_balance(&sd->gspca_dev, sensor_settings[BLUE_BALANCE_IDX]); | ||
332 | if (err < 0) | ||
333 | return err; | ||
334 | |||
335 | err = ov9650_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); | ||
336 | if (err < 0) | ||
337 | return err; | ||
338 | |||
339 | err = ov9650_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); | ||
340 | if (err < 0) | ||
341 | return err; | ||
342 | |||
343 | err = ov9650_set_auto_white_balance(&sd->gspca_dev, sensor_settings[AUTO_WHITE_BALANCE_IDX]); | ||
344 | if (err < 0) | ||
345 | return err; | ||
346 | |||
347 | err = ov9650_set_auto_gain(&sd->gspca_dev, sensor_settings[AUTO_GAIN_CTRL_IDX]); | ||
142 | return err; | 348 | return err; |
143 | } | 349 | } |
144 | 350 | ||
145 | int ov9650_start(struct sd *sd) | 351 | int ov9650_start(struct sd *sd) |
146 | { | 352 | { |
353 | u8 data; | ||
147 | int i, err = 0; | 354 | int i, err = 0; |
148 | struct cam *cam = &sd->gspca_dev.cam; | 355 | struct cam *cam = &sd->gspca_dev.cam; |
356 | s32 *sensor_settings = sd->sensor_priv; | ||
357 | |||
358 | int width = cam->cam_mode[sd->gspca_dev.curr_mode].width; | ||
359 | int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; | ||
360 | int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv; | ||
361 | int hor_offs = OV9650_LEFT_OFFSET; | ||
362 | |||
363 | if (sensor_settings[VFLIP_IDX]) | ||
364 | ver_offs--; | ||
149 | 365 | ||
366 | if (width <= 320) | ||
367 | hor_offs /= 2; | ||
368 | |||
369 | /* Synthesize the vsync/hsync setup */ | ||
150 | for (i = 0; i < ARRAY_SIZE(res_init_ov9650) && !err; i++) { | 370 | for (i = 0; i < ARRAY_SIZE(res_init_ov9650) && !err; i++) { |
151 | u8 data = res_init_ov9650[i][1]; | 371 | if (res_init_ov9650[i][0] == BRIDGE) |
152 | err = m5602_write_bridge(sd, res_init_ov9650[i][0], data); | 372 | err = m5602_write_bridge(sd, res_init_ov9650[i][1], |
373 | res_init_ov9650[i][2]); | ||
374 | else if (res_init_ov9650[i][0] == SENSOR) { | ||
375 | u8 data = res_init_ov9650[i][2]; | ||
376 | err = m5602_write_sensor(sd, | ||
377 | res_init_ov9650[i][1], &data, 1); | ||
378 | } | ||
153 | } | 379 | } |
154 | if (err < 0) | 380 | if (err < 0) |
155 | return err; | 381 | return err; |
156 | 382 | ||
157 | switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) | 383 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, |
158 | { | 384 | ((ver_offs >> 8) & 0xff)); |
385 | if (err < 0) | ||
386 | return err; | ||
387 | |||
388 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (ver_offs & 0xff)); | ||
389 | if (err < 0) | ||
390 | return err; | ||
391 | |||
392 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); | ||
393 | if (err < 0) | ||
394 | return err; | ||
395 | |||
396 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff); | ||
397 | if (err < 0) | ||
398 | return err; | ||
399 | |||
400 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff)); | ||
401 | if (err < 0) | ||
402 | return err; | ||
403 | |||
404 | for (i = 0; i < 2 && !err; i++) | ||
405 | err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); | ||
406 | if (err < 0) | ||
407 | return err; | ||
408 | |||
409 | err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, | ||
410 | (hor_offs >> 8) & 0xff); | ||
411 | if (err < 0) | ||
412 | return err; | ||
413 | |||
414 | err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, hor_offs & 0xff); | ||
415 | if (err < 0) | ||
416 | return err; | ||
417 | |||
418 | err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, | ||
419 | ((width + hor_offs) >> 8) & 0xff); | ||
420 | if (err < 0) | ||
421 | return err; | ||
422 | |||
423 | err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, | ||
424 | ((width + hor_offs) & 0xff)); | ||
425 | if (err < 0) | ||
426 | return err; | ||
427 | |||
428 | switch (width) { | ||
159 | case 640: | 429 | case 640: |
160 | PDEBUG(D_V4L2, "Configuring camera for VGA mode"); | 430 | PDEBUG(D_V4L2, "Configuring camera for VGA mode"); |
161 | 431 | ||
162 | for (i = 0; i < ARRAY_SIZE(VGA_ov9650) && !err; i++) { | 432 | data = OV9650_VGA_SELECT | OV9650_RGB_SELECT | |
163 | u8 data = VGA_ov9650[i][2]; | 433 | OV9650_RAW_RGB_SELECT; |
164 | if (VGA_ov9650[i][0] == SENSOR) | 434 | err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); |
165 | err = m5602_write_sensor(sd, | ||
166 | VGA_ov9650[i][1], &data, 1); | ||
167 | else | ||
168 | err = m5602_write_bridge(sd, VGA_ov9650[i][1], data); | ||
169 | } | ||
170 | break; | 435 | break; |
171 | 436 | ||
172 | case 352: | 437 | case 352: |
173 | PDEBUG(D_V4L2, "Configuring camera for CIF mode"); | 438 | PDEBUG(D_V4L2, "Configuring camera for CIF mode"); |
174 | 439 | ||
175 | for (i = 0; i < ARRAY_SIZE(CIF_ov9650) && !err; i++) { | 440 | data = OV9650_CIF_SELECT | OV9650_RGB_SELECT | |
176 | u8 data = CIF_ov9650[i][2]; | 441 | OV9650_RAW_RGB_SELECT; |
177 | if (CIF_ov9650[i][0] == SENSOR) | 442 | err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); |
178 | err = m5602_write_sensor(sd, | ||
179 | CIF_ov9650[i][1], &data, 1); | ||
180 | else | ||
181 | err = m5602_write_bridge(sd, CIF_ov9650[i][1], data); | ||
182 | } | ||
183 | break; | 443 | break; |
184 | 444 | ||
185 | case 320: | 445 | case 320: |
186 | PDEBUG(D_V4L2, "Configuring camera for QVGA mode"); | 446 | PDEBUG(D_V4L2, "Configuring camera for QVGA mode"); |
187 | 447 | ||
188 | for (i = 0; i < ARRAY_SIZE(QVGA_ov9650) && !err; i++) { | 448 | data = OV9650_QVGA_SELECT | OV9650_RGB_SELECT | |
189 | u8 data = QVGA_ov9650[i][2]; | 449 | OV9650_RAW_RGB_SELECT; |
190 | if (QVGA_ov9650[i][0] == SENSOR) | 450 | err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); |
191 | err = m5602_write_sensor(sd, | 451 | break; |
192 | QVGA_ov9650[i][1], &data, 1); | 452 | |
193 | else | 453 | case 176: |
194 | err = m5602_write_bridge(sd, QVGA_ov9650[i][1], data); | 454 | PDEBUG(D_V4L2, "Configuring camera for QCIF mode"); |
195 | } | 455 | |
456 | data = OV9650_QCIF_SELECT | OV9650_RGB_SELECT | | ||
457 | OV9650_RAW_RGB_SELECT; | ||
458 | err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); | ||
196 | break; | 459 | break; |
197 | } | 460 | } |
198 | return err; | 461 | return err; |
199 | } | 462 | } |
200 | 463 | ||
464 | int ov9650_stop(struct sd *sd) | ||
465 | { | ||
466 | u8 data = OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X; | ||
467 | return m5602_write_sensor(sd, OV9650_COM2, &data, 1); | ||
468 | } | ||
469 | |||
201 | int ov9650_power_down(struct sd *sd) | 470 | int ov9650_power_down(struct sd *sd) |
202 | { | 471 | { |
203 | int i, err = 0; | 472 | int i, err = 0; |
@@ -214,76 +483,63 @@ int ov9650_power_down(struct sd *sd) | |||
214 | return err; | 483 | return err; |
215 | } | 484 | } |
216 | 485 | ||
217 | int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | 486 | void ov9650_disconnect(struct sd *sd) |
218 | { | 487 | { |
219 | struct sd *sd = (struct sd *) gspca_dev; | 488 | ov9650_stop(sd); |
220 | u8 i2c_data; | 489 | ov9650_power_down(sd); |
221 | int err; | ||
222 | |||
223 | err = m5602_read_sensor(sd, OV9650_COM1, &i2c_data, 1); | ||
224 | if (err < 0) | ||
225 | goto out; | ||
226 | *val = i2c_data & 0x03; | ||
227 | 490 | ||
228 | err = m5602_read_sensor(sd, OV9650_AECH, &i2c_data, 1); | 491 | sd->sensor = NULL; |
229 | if (err < 0) | 492 | kfree(sd->sensor_priv); |
230 | goto out; | 493 | } |
231 | *val |= (i2c_data << 2); | ||
232 | 494 | ||
233 | err = m5602_read_sensor(sd, OV9650_AECHM, &i2c_data, 1); | 495 | int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) |
234 | if (err < 0) | 496 | { |
235 | goto out; | 497 | struct sd *sd = (struct sd *) gspca_dev; |
236 | *val |= (i2c_data & 0x3f) << 10; | 498 | s32 *sensor_settings = sd->sensor_priv; |
237 | 499 | ||
500 | *val = sensor_settings[EXPOSURE_IDX]; | ||
238 | PDEBUG(D_V4L2, "Read exposure %d", *val); | 501 | PDEBUG(D_V4L2, "Read exposure %d", *val); |
239 | out: | 502 | return 0; |
240 | return err; | ||
241 | } | 503 | } |
242 | 504 | ||
243 | int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | 505 | int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val) |
244 | { | 506 | { |
245 | struct sd *sd = (struct sd *) gspca_dev; | 507 | struct sd *sd = (struct sd *) gspca_dev; |
508 | s32 *sensor_settings = sd->sensor_priv; | ||
246 | u8 i2c_data; | 509 | u8 i2c_data; |
247 | int err; | 510 | int err; |
248 | 511 | ||
249 | PDEBUG(D_V4L2, "Set exposure to %d", | 512 | PDEBUG(D_V4L2, "Set exposure to %d", val); |
250 | val & 0xffff); | ||
251 | 513 | ||
514 | sensor_settings[EXPOSURE_IDX] = val; | ||
252 | /* The 6 MSBs */ | 515 | /* The 6 MSBs */ |
253 | i2c_data = (val >> 10) & 0x3f; | 516 | i2c_data = (val >> 10) & 0x3f; |
254 | err = m5602_write_sensor(sd, OV9650_AECHM, | 517 | err = m5602_write_sensor(sd, OV9650_AECHM, |
255 | &i2c_data, 1); | 518 | &i2c_data, 1); |
256 | if (err < 0) | 519 | if (err < 0) |
257 | goto out; | 520 | return err; |
258 | 521 | ||
259 | /* The 8 middle bits */ | 522 | /* The 8 middle bits */ |
260 | i2c_data = (val >> 2) & 0xff; | 523 | i2c_data = (val >> 2) & 0xff; |
261 | err = m5602_write_sensor(sd, OV9650_AECH, | 524 | err = m5602_write_sensor(sd, OV9650_AECH, |
262 | &i2c_data, 1); | 525 | &i2c_data, 1); |
263 | if (err < 0) | 526 | if (err < 0) |
264 | goto out; | 527 | return err; |
265 | 528 | ||
266 | /* The 2 LSBs */ | 529 | /* The 2 LSBs */ |
267 | i2c_data = val & 0x03; | 530 | i2c_data = val & 0x03; |
268 | err = m5602_write_sensor(sd, OV9650_COM1, &i2c_data, 1); | 531 | err = m5602_write_sensor(sd, OV9650_COM1, &i2c_data, 1); |
269 | |||
270 | out: | ||
271 | return err; | 532 | return err; |
272 | } | 533 | } |
273 | 534 | ||
274 | int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | 535 | int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val) |
275 | { | 536 | { |
276 | int err; | ||
277 | u8 i2c_data; | ||
278 | struct sd *sd = (struct sd *) gspca_dev; | 537 | struct sd *sd = (struct sd *) gspca_dev; |
538 | s32 *sensor_settings = sd->sensor_priv; | ||
279 | 539 | ||
280 | m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); | 540 | *val = sensor_settings[GAIN_IDX]; |
281 | *val = (i2c_data & 0x03) << 8; | ||
282 | |||
283 | err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); | ||
284 | *val |= i2c_data; | ||
285 | PDEBUG(D_V4L2, "Read gain %d", *val); | 541 | PDEBUG(D_V4L2, "Read gain %d", *val); |
286 | return err; | 542 | return 0; |
287 | } | 543 | } |
288 | 544 | ||
289 | int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) | 545 | int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) |
@@ -291,15 +547,25 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
291 | int err; | 547 | int err; |
292 | u8 i2c_data; | 548 | u8 i2c_data; |
293 | struct sd *sd = (struct sd *) gspca_dev; | 549 | struct sd *sd = (struct sd *) gspca_dev; |
550 | s32 *sensor_settings = sd->sensor_priv; | ||
551 | |||
552 | PDEBUG(D_V4L2, "Setting gain to %d", val); | ||
553 | |||
554 | sensor_settings[GAIN_IDX] = val; | ||
294 | 555 | ||
295 | /* The 2 MSB */ | 556 | /* The 2 MSB */ |
296 | /* Read the OV9650_VREF register first to avoid | 557 | /* Read the OV9650_VREF register first to avoid |
297 | corrupting the VREF high and low bits */ | 558 | corrupting the VREF high and low bits */ |
298 | m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); | 559 | err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); |
560 | if (err < 0) | ||
561 | return err; | ||
562 | |||
299 | /* Mask away all uninteresting bits */ | 563 | /* Mask away all uninteresting bits */ |
300 | i2c_data = ((val & 0x0300) >> 2) | | 564 | i2c_data = ((val & 0x0300) >> 2) | |
301 | (i2c_data & 0x3F); | 565 | (i2c_data & 0x3F); |
302 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); | 566 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); |
567 | if (err < 0) | ||
568 | return err; | ||
303 | 569 | ||
304 | /* The 8 LSBs */ | 570 | /* The 8 LSBs */ |
305 | i2c_data = val & 0xff; | 571 | i2c_data = val & 0xff; |
@@ -309,16 +575,12 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
309 | 575 | ||
310 | int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val) | 576 | int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val) |
311 | { | 577 | { |
312 | int err; | ||
313 | u8 i2c_data; | ||
314 | struct sd *sd = (struct sd *) gspca_dev; | 578 | struct sd *sd = (struct sd *) gspca_dev; |
579 | s32 *sensor_settings = sd->sensor_priv; | ||
315 | 580 | ||
316 | err = m5602_read_sensor(sd, OV9650_RED, &i2c_data, 1); | 581 | *val = sensor_settings[RED_BALANCE_IDX]; |
317 | *val = i2c_data; | ||
318 | |||
319 | PDEBUG(D_V4L2, "Read red gain %d", *val); | 582 | PDEBUG(D_V4L2, "Read red gain %d", *val); |
320 | 583 | return 0; | |
321 | return err; | ||
322 | } | 584 | } |
323 | 585 | ||
324 | int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) | 586 | int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) |
@@ -326,28 +588,26 @@ int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
326 | int err; | 588 | int err; |
327 | u8 i2c_data; | 589 | u8 i2c_data; |
328 | struct sd *sd = (struct sd *) gspca_dev; | 590 | struct sd *sd = (struct sd *) gspca_dev; |
591 | s32 *sensor_settings = sd->sensor_priv; | ||
329 | 592 | ||
330 | PDEBUG(D_V4L2, "Set red gain to %d", | 593 | PDEBUG(D_V4L2, "Set red gain to %d", val); |
331 | val & 0xff); | 594 | |
595 | sensor_settings[RED_BALANCE_IDX] = val; | ||
332 | 596 | ||
333 | i2c_data = val & 0xff; | 597 | i2c_data = val & 0xff; |
334 | err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1); | 598 | err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1); |
335 | |||
336 | return err; | 599 | return err; |
337 | } | 600 | } |
338 | 601 | ||
339 | int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val) | 602 | int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val) |
340 | { | 603 | { |
341 | int err; | ||
342 | u8 i2c_data; | ||
343 | struct sd *sd = (struct sd *) gspca_dev; | 604 | struct sd *sd = (struct sd *) gspca_dev; |
605 | s32 *sensor_settings = sd->sensor_priv; | ||
344 | 606 | ||
345 | err = m5602_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); | 607 | *val = sensor_settings[BLUE_BALANCE_IDX]; |
346 | *val = i2c_data; | ||
347 | |||
348 | PDEBUG(D_V4L2, "Read blue gain %d", *val); | 608 | PDEBUG(D_V4L2, "Read blue gain %d", *val); |
349 | 609 | ||
350 | return err; | 610 | return 0; |
351 | } | 611 | } |
352 | 612 | ||
353 | int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) | 613 | int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) |
@@ -355,30 +615,25 @@ int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
355 | int err; | 615 | int err; |
356 | u8 i2c_data; | 616 | u8 i2c_data; |
357 | struct sd *sd = (struct sd *) gspca_dev; | 617 | struct sd *sd = (struct sd *) gspca_dev; |
618 | s32 *sensor_settings = sd->sensor_priv; | ||
619 | |||
620 | PDEBUG(D_V4L2, "Set blue gain to %d", val); | ||
358 | 621 | ||
359 | PDEBUG(D_V4L2, "Set blue gain to %d", | 622 | sensor_settings[BLUE_BALANCE_IDX] = val; |
360 | val & 0xff); | ||
361 | 623 | ||
362 | i2c_data = val & 0xff; | 624 | i2c_data = val & 0xff; |
363 | err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); | 625 | err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); |
364 | |||
365 | return err; | 626 | return err; |
366 | } | 627 | } |
367 | 628 | ||
368 | int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | 629 | int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) |
369 | { | 630 | { |
370 | int err; | ||
371 | u8 i2c_data; | ||
372 | struct sd *sd = (struct sd *) gspca_dev; | 631 | struct sd *sd = (struct sd *) gspca_dev; |
632 | s32 *sensor_settings = sd->sensor_priv; | ||
373 | 633 | ||
374 | err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 634 | *val = sensor_settings[HFLIP_IDX]; |
375 | if (dmi_check_system(ov9650_flip_dmi_table)) | ||
376 | *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; | ||
377 | else | ||
378 | *val = (i2c_data & OV9650_HFLIP) >> 5; | ||
379 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); | 635 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
380 | 636 | return 0; | |
381 | return err; | ||
382 | } | 637 | } |
383 | 638 | ||
384 | int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | 639 | int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val) |
@@ -386,38 +641,26 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
386 | int err; | 641 | int err; |
387 | u8 i2c_data; | 642 | u8 i2c_data; |
388 | struct sd *sd = (struct sd *) gspca_dev; | 643 | struct sd *sd = (struct sd *) gspca_dev; |
644 | s32 *sensor_settings = sd->sensor_priv; | ||
389 | 645 | ||
390 | PDEBUG(D_V4L2, "Set horizontal flip to %d", val); | 646 | PDEBUG(D_V4L2, "Set horizontal flip to %d", val); |
391 | err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | ||
392 | if (err < 0) | ||
393 | goto out; | ||
394 | |||
395 | if (dmi_check_system(ov9650_flip_dmi_table)) | ||
396 | i2c_data = ((i2c_data & 0xdf) | | ||
397 | (((val ? 0 : 1) & 0x01) << 5)); | ||
398 | else | ||
399 | i2c_data = ((i2c_data & 0xdf) | | ||
400 | ((val & 0x01) << 5)); | ||
401 | 647 | ||
648 | sensor_settings[HFLIP_IDX] = val; | ||
649 | i2c_data = ((val & 0x01) << 5) | (sensor_settings[VFLIP_IDX] << 4); | ||
402 | err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 650 | err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); |
403 | out: | 651 | |
404 | return err; | 652 | return err; |
405 | } | 653 | } |
406 | 654 | ||
407 | int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | 655 | int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) |
408 | { | 656 | { |
409 | int err; | ||
410 | u8 i2c_data; | ||
411 | struct sd *sd = (struct sd *) gspca_dev; | 657 | struct sd *sd = (struct sd *) gspca_dev; |
658 | s32 *sensor_settings = sd->sensor_priv; | ||
412 | 659 | ||
413 | err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 660 | *val = sensor_settings[VFLIP_IDX]; |
414 | if (dmi_check_system(ov9650_flip_dmi_table)) | ||
415 | *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; | ||
416 | else | ||
417 | *val = (i2c_data & 0x10) >> 4; | ||
418 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); | 661 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
419 | 662 | ||
420 | return err; | 663 | return 0; |
421 | } | 664 | } |
422 | 665 | ||
423 | int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | 666 | int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val) |
@@ -425,40 +668,32 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
425 | int err; | 668 | int err; |
426 | u8 i2c_data; | 669 | u8 i2c_data; |
427 | struct sd *sd = (struct sd *) gspca_dev; | 670 | struct sd *sd = (struct sd *) gspca_dev; |
671 | s32 *sensor_settings = sd->sensor_priv; | ||
428 | 672 | ||
429 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); | 673 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
430 | err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 674 | sensor_settings[VFLIP_IDX] = val; |
675 | |||
676 | i2c_data = ((val & 0x01) << 4) | (sensor_settings[VFLIP_IDX] << 5); | ||
677 | err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); | ||
431 | if (err < 0) | 678 | if (err < 0) |
432 | goto out; | 679 | return err; |
433 | 680 | ||
434 | if (dmi_check_system(ov9650_flip_dmi_table)) | 681 | /* When vflip is toggled we need to readjust the bridge hsync/vsync */ |
435 | i2c_data = ((i2c_data & 0xef) | | 682 | if (gspca_dev->streaming) |
436 | (((val ? 0 : 1) & 0x01) << 4)); | 683 | err = ov9650_start(sd); |
437 | else | ||
438 | i2c_data = ((i2c_data & 0xef) | | ||
439 | ((val & 0x01) << 4)); | ||
440 | 684 | ||
441 | err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); | ||
442 | out: | ||
443 | return err; | 685 | return err; |
444 | } | 686 | } |
445 | 687 | ||
446 | int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | 688 | int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) |
447 | { | 689 | { |
448 | int err; | ||
449 | u8 i2c_data; | ||
450 | struct sd *sd = (struct sd *) gspca_dev; | 690 | struct sd *sd = (struct sd *) gspca_dev; |
691 | s32 *sensor_settings = sd->sensor_priv; | ||
451 | 692 | ||
452 | err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); | 693 | *val = sensor_settings[GAIN_IDX]; |
453 | if (err < 0) | ||
454 | goto out; | ||
455 | *val = (i2c_data & 0x03) << 8; | ||
456 | |||
457 | err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); | ||
458 | *val |= i2c_data; | ||
459 | PDEBUG(D_V4L2, "Read gain %d", *val); | 694 | PDEBUG(D_V4L2, "Read gain %d", *val); |
460 | out: | 695 | |
461 | return err; | 696 | return 0; |
462 | } | 697 | } |
463 | 698 | ||
464 | int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | 699 | int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val) |
@@ -466,40 +701,38 @@ int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | |||
466 | int err; | 701 | int err; |
467 | u8 i2c_data; | 702 | u8 i2c_data; |
468 | struct sd *sd = (struct sd *) gspca_dev; | 703 | struct sd *sd = (struct sd *) gspca_dev; |
704 | s32 *sensor_settings = sd->sensor_priv; | ||
469 | 705 | ||
470 | PDEBUG(D_V4L2, "Set gain to %d", val & 0x3ff); | 706 | PDEBUG(D_V4L2, "Set gain to %d", val); |
707 | |||
708 | sensor_settings[GAIN_IDX] = val; | ||
471 | 709 | ||
472 | /* Read the OV9650_VREF register first to avoid | 710 | /* Read the OV9650_VREF register first to avoid |
473 | corrupting the VREF high and low bits */ | 711 | corrupting the VREF high and low bits */ |
474 | err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); | 712 | err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); |
475 | if (err < 0) | 713 | if (err < 0) |
476 | goto out; | 714 | return err; |
477 | 715 | ||
478 | /* Mask away all uninteresting bits */ | 716 | /* Mask away all uninteresting bits */ |
479 | i2c_data = ((val & 0x0300) >> 2) | (i2c_data & 0x3F); | 717 | i2c_data = ((val & 0x0300) >> 2) | (i2c_data & 0x3F); |
480 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); | 718 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); |
481 | if (err < 0) | 719 | if (err < 0) |
482 | goto out; | 720 | return err; |
483 | 721 | ||
484 | /* The 8 LSBs */ | 722 | /* The 8 LSBs */ |
485 | i2c_data = val & 0xff; | 723 | i2c_data = val & 0xff; |
486 | err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1); | 724 | err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1); |
487 | 725 | ||
488 | out: | ||
489 | return err; | 726 | return err; |
490 | } | 727 | } |
491 | 728 | ||
492 | int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val) | 729 | int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val) |
493 | { | 730 | { |
494 | int err; | ||
495 | u8 i2c_data; | ||
496 | struct sd *sd = (struct sd *) gspca_dev; | 731 | struct sd *sd = (struct sd *) gspca_dev; |
732 | s32 *sensor_settings = sd->sensor_priv; | ||
497 | 733 | ||
498 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 734 | *val = sensor_settings[AUTO_WHITE_BALANCE_IDX]; |
499 | *val = (i2c_data & OV9650_AWB_EN) >> 1; | 735 | return 0; |
500 | PDEBUG(D_V4L2, "Read auto white balance %d", *val); | ||
501 | |||
502 | return err; | ||
503 | } | 736 | } |
504 | 737 | ||
505 | int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val) | 738 | int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val) |
@@ -507,29 +740,29 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
507 | int err; | 740 | int err; |
508 | u8 i2c_data; | 741 | u8 i2c_data; |
509 | struct sd *sd = (struct sd *) gspca_dev; | 742 | struct sd *sd = (struct sd *) gspca_dev; |
743 | s32 *sensor_settings = sd->sensor_priv; | ||
510 | 744 | ||
511 | PDEBUG(D_V4L2, "Set auto white balance to %d", val); | 745 | PDEBUG(D_V4L2, "Set auto white balance to %d", val); |
746 | |||
747 | sensor_settings[AUTO_WHITE_BALANCE_IDX] = val; | ||
512 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 748 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
513 | if (err < 0) | 749 | if (err < 0) |
514 | goto out; | 750 | return err; |
515 | 751 | ||
516 | i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1)); | 752 | i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1)); |
517 | err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); | 753 | err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); |
518 | out: | 754 | |
519 | return err; | 755 | return err; |
520 | } | 756 | } |
521 | 757 | ||
522 | int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val) | 758 | int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val) |
523 | { | 759 | { |
524 | int err; | ||
525 | u8 i2c_data; | ||
526 | struct sd *sd = (struct sd *) gspca_dev; | 760 | struct sd *sd = (struct sd *) gspca_dev; |
761 | s32 *sensor_settings = sd->sensor_priv; | ||
527 | 762 | ||
528 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 763 | *val = sensor_settings[AUTO_GAIN_CTRL_IDX]; |
529 | *val = (i2c_data & OV9650_AGC_EN) >> 2; | ||
530 | PDEBUG(D_V4L2, "Read auto gain control %d", *val); | 764 | PDEBUG(D_V4L2, "Read auto gain control %d", *val); |
531 | 765 | return 0; | |
532 | return err; | ||
533 | } | 766 | } |
534 | 767 | ||
535 | int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) | 768 | int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) |
@@ -537,15 +770,18 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
537 | int err; | 770 | int err; |
538 | u8 i2c_data; | 771 | u8 i2c_data; |
539 | struct sd *sd = (struct sd *) gspca_dev; | 772 | struct sd *sd = (struct sd *) gspca_dev; |
773 | s32 *sensor_settings = sd->sensor_priv; | ||
540 | 774 | ||
541 | PDEBUG(D_V4L2, "Set auto gain control to %d", val); | 775 | PDEBUG(D_V4L2, "Set auto gain control to %d", val); |
776 | |||
777 | sensor_settings[AUTO_GAIN_CTRL_IDX] = val; | ||
542 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 778 | err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
543 | if (err < 0) | 779 | if (err < 0) |
544 | goto out; | 780 | return err; |
545 | 781 | ||
546 | i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2)); | 782 | i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2)); |
547 | err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); | 783 | err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); |
548 | out: | 784 | |
549 | return err; | 785 | return err; |
550 | } | 786 | } |
551 | 787 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h index f4b33b8e8dae..fcc54e4c0f4f 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov9650.h +++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define OV9650_BAVE 0x05 | 32 | #define OV9650_BAVE 0x05 |
33 | #define OV9650_GEAVE 0x06 | 33 | #define OV9650_GEAVE 0x06 |
34 | #define OV9650_RSVD7 0x07 | 34 | #define OV9650_RSVD7 0x07 |
35 | #define OV9650_COM2 0x09 | ||
35 | #define OV9650_PID 0x0a | 36 | #define OV9650_PID 0x0a |
36 | #define OV9650_VER 0x0b | 37 | #define OV9650_VER 0x0b |
37 | #define OV9650_COM3 0x0c | 38 | #define OV9650_COM3 0x0c |
@@ -96,6 +97,7 @@ | |||
96 | #define OV9650_VGA_SELECT (1 << 6) | 97 | #define OV9650_VGA_SELECT (1 << 6) |
97 | #define OV9650_CIF_SELECT (1 << 5) | 98 | #define OV9650_CIF_SELECT (1 << 5) |
98 | #define OV9650_QVGA_SELECT (1 << 4) | 99 | #define OV9650_QVGA_SELECT (1 << 4) |
100 | #define OV9650_QCIF_SELECT (1 << 3) | ||
99 | #define OV9650_RGB_SELECT (1 << 2) | 101 | #define OV9650_RGB_SELECT (1 << 2) |
100 | #define OV9650_RAW_RGB_SELECT (1 << 0) | 102 | #define OV9650_RAW_RGB_SELECT (1 << 0) |
101 | 103 | ||
@@ -115,10 +117,15 @@ | |||
115 | #define OV9650_VFLIP (1 << 4) | 117 | #define OV9650_VFLIP (1 << 4) |
116 | #define OV9650_HFLIP (1 << 5) | 118 | #define OV9650_HFLIP (1 << 5) |
117 | 119 | ||
120 | #define OV9650_SOFT_SLEEP (1 << 4) | ||
121 | #define OV9650_OUTPUT_DRIVE_2X (1 << 0) | ||
122 | |||
123 | #define OV9650_LEFT_OFFSET 0x62 | ||
124 | |||
118 | #define GAIN_DEFAULT 0x14 | 125 | #define GAIN_DEFAULT 0x14 |
119 | #define RED_GAIN_DEFAULT 0x70 | 126 | #define RED_GAIN_DEFAULT 0x70 |
120 | #define BLUE_GAIN_DEFAULT 0x20 | 127 | #define BLUE_GAIN_DEFAULT 0x20 |
121 | #define EXPOSURE_DEFAULT 0x5003 | 128 | #define EXPOSURE_DEFAULT 0x1ff |
122 | 129 | ||
123 | /*****************************************************************************/ | 130 | /*****************************************************************************/ |
124 | 131 | ||
@@ -129,7 +136,9 @@ extern int dump_sensor; | |||
129 | int ov9650_probe(struct sd *sd); | 136 | int ov9650_probe(struct sd *sd); |
130 | int ov9650_init(struct sd *sd); | 137 | int ov9650_init(struct sd *sd); |
131 | int ov9650_start(struct sd *sd); | 138 | int ov9650_start(struct sd *sd); |
139 | int ov9650_stop(struct sd *sd); | ||
132 | int ov9650_power_down(struct sd *sd); | 140 | int ov9650_power_down(struct sd *sd); |
141 | void ov9650_disconnect(struct sd *sd); | ||
133 | 142 | ||
134 | int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val); | 143 | int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val); |
135 | int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); | 144 | int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); |
@@ -150,152 +159,16 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val); | |||
150 | int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val); | 159 | int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val); |
151 | int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); | 160 | int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val); |
152 | 161 | ||
153 | static struct m5602_sensor ov9650 = { | 162 | const static struct m5602_sensor ov9650 = { |
154 | .name = "OV9650", | 163 | .name = "OV9650", |
155 | .i2c_slave_id = 0x60, | 164 | .i2c_slave_id = 0x60, |
156 | .i2c_regW = 1, | 165 | .i2c_regW = 1, |
157 | .probe = ov9650_probe, | 166 | .probe = ov9650_probe, |
158 | .init = ov9650_init, | 167 | .init = ov9650_init, |
159 | .start = ov9650_start, | 168 | .start = ov9650_start, |
169 | .stop = ov9650_stop, | ||
160 | .power_down = ov9650_power_down, | 170 | .power_down = ov9650_power_down, |
161 | 171 | .disconnect = ov9650_disconnect, | |
162 | .nctrls = 8, | ||
163 | .ctrls = { | ||
164 | { | ||
165 | { | ||
166 | .id = V4L2_CID_EXPOSURE, | ||
167 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
168 | .name = "exposure", | ||
169 | .minimum = 0x00, | ||
170 | .maximum = 0xffff, | ||
171 | .step = 0x1, | ||
172 | .default_value = EXPOSURE_DEFAULT, | ||
173 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
174 | }, | ||
175 | .set = ov9650_set_exposure, | ||
176 | .get = ov9650_get_exposure | ||
177 | }, { | ||
178 | { | ||
179 | .id = V4L2_CID_GAIN, | ||
180 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
181 | .name = "gain", | ||
182 | .minimum = 0x00, | ||
183 | .maximum = 0x3ff, | ||
184 | .step = 0x1, | ||
185 | .default_value = GAIN_DEFAULT, | ||
186 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
187 | }, | ||
188 | .set = ov9650_set_gain, | ||
189 | .get = ov9650_get_gain | ||
190 | }, { | ||
191 | { | ||
192 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
193 | .name = "red balance", | ||
194 | .minimum = 0x00, | ||
195 | .maximum = 0xff, | ||
196 | .step = 0x1, | ||
197 | .default_value = RED_GAIN_DEFAULT, | ||
198 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
199 | }, | ||
200 | .set = ov9650_set_red_balance, | ||
201 | .get = ov9650_get_red_balance | ||
202 | }, { | ||
203 | { | ||
204 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
205 | .name = "blue balance", | ||
206 | .minimum = 0x00, | ||
207 | .maximum = 0xff, | ||
208 | .step = 0x1, | ||
209 | .default_value = BLUE_GAIN_DEFAULT, | ||
210 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
211 | }, | ||
212 | .set = ov9650_set_blue_balance, | ||
213 | .get = ov9650_get_blue_balance | ||
214 | }, { | ||
215 | { | ||
216 | .id = V4L2_CID_HFLIP, | ||
217 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
218 | .name = "horizontal flip", | ||
219 | .minimum = 0, | ||
220 | .maximum = 1, | ||
221 | .step = 1, | ||
222 | .default_value = 0 | ||
223 | }, | ||
224 | .set = ov9650_set_hflip, | ||
225 | .get = ov9650_get_hflip | ||
226 | }, { | ||
227 | { | ||
228 | .id = V4L2_CID_VFLIP, | ||
229 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
230 | .name = "vertical flip", | ||
231 | .minimum = 0, | ||
232 | .maximum = 1, | ||
233 | .step = 1, | ||
234 | .default_value = 0 | ||
235 | }, | ||
236 | .set = ov9650_set_vflip, | ||
237 | .get = ov9650_get_vflip | ||
238 | }, { | ||
239 | { | ||
240 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | ||
241 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
242 | .name = "auto white balance", | ||
243 | .minimum = 0, | ||
244 | .maximum = 1, | ||
245 | .step = 1, | ||
246 | .default_value = 0 | ||
247 | }, | ||
248 | .set = ov9650_set_auto_white_balance, | ||
249 | .get = ov9650_get_auto_white_balance | ||
250 | }, { | ||
251 | { | ||
252 | .id = V4L2_CID_AUTOGAIN, | ||
253 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
254 | .name = "auto gain control", | ||
255 | .minimum = 0, | ||
256 | .maximum = 1, | ||
257 | .step = 1, | ||
258 | .default_value = 0 | ||
259 | }, | ||
260 | .set = ov9650_set_auto_gain, | ||
261 | .get = ov9650_get_auto_gain | ||
262 | } | ||
263 | }, | ||
264 | |||
265 | .nmodes = 3, | ||
266 | .modes = { | ||
267 | { | ||
268 | 320, | ||
269 | 240, | ||
270 | V4L2_PIX_FMT_SBGGR8, | ||
271 | V4L2_FIELD_NONE, | ||
272 | .sizeimage = | ||
273 | 320 * 240, | ||
274 | .bytesperline = 320, | ||
275 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
276 | .priv = 0 | ||
277 | }, { | ||
278 | 352, | ||
279 | 288, | ||
280 | V4L2_PIX_FMT_SBGGR8, | ||
281 | V4L2_FIELD_NONE, | ||
282 | .sizeimage = | ||
283 | 352 * 288, | ||
284 | .bytesperline = 352, | ||
285 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
286 | .priv = 0 | ||
287 | }, { | ||
288 | 640, | ||
289 | 480, | ||
290 | V4L2_PIX_FMT_SBGGR8, | ||
291 | V4L2_FIELD_NONE, | ||
292 | .sizeimage = | ||
293 | 640 * 480, | ||
294 | .bytesperline = 640, | ||
295 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
296 | .priv = 0 | ||
297 | } | ||
298 | } | ||
299 | }; | 172 | }; |
300 | 173 | ||
301 | static const unsigned char preinit_ov9650[][3] = | 174 | static const unsigned char preinit_ov9650[][3] = |
@@ -345,6 +218,10 @@ static const unsigned char init_ov9650[][3] = | |||
345 | 218 | ||
346 | /* Reset chip */ | 219 | /* Reset chip */ |
347 | {SENSOR, OV9650_COM7, OV9650_REGISTER_RESET}, | 220 | {SENSOR, OV9650_COM7, OV9650_REGISTER_RESET}, |
221 | /* One extra reset is needed in order to make the sensor behave | ||
222 | properly when resuming from ram */ | ||
223 | {SENSOR, OV9650_COM7, OV9650_REGISTER_RESET}, | ||
224 | |||
348 | /* Enable double clock */ | 225 | /* Enable double clock */ |
349 | {SENSOR, OV9650_CLKRC, 0x80}, | 226 | {SENSOR, OV9650_CLKRC, 0x80}, |
350 | /* Do something out of spec with the power */ | 227 | /* Do something out of spec with the power */ |
@@ -427,18 +304,12 @@ static const unsigned char init_ov9650[][3] = | |||
427 | /* Enable denoise, and white-pixel erase */ | 304 | /* Enable denoise, and white-pixel erase */ |
428 | {SENSOR, OV9650_COM22, 0x23}, | 305 | {SENSOR, OV9650_COM22, 0x23}, |
429 | 306 | ||
430 | /* Set the high bits of the exposure value */ | ||
431 | {SENSOR, OV9650_AECH, ((EXPOSURE_DEFAULT & 0xff00) >> 8)}, | ||
432 | |||
433 | /* Enable VARIOPIXEL */ | 307 | /* Enable VARIOPIXEL */ |
434 | {SENSOR, OV9650_COM3, OV9650_VARIOPIXEL}, | 308 | {SENSOR, OV9650_COM3, OV9650_VARIOPIXEL}, |
435 | {SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL}, | 309 | {SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL}, |
436 | 310 | ||
437 | /* Set the low bits of the exposure value */ | 311 | /* Put the sensor in soft sleep mode */ |
438 | {SENSOR, OV9650_COM1, (EXPOSURE_DEFAULT & 0xff)}, | 312 | {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X}, |
439 | {SENSOR, OV9650_GAIN, GAIN_DEFAULT}, | ||
440 | {SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT}, | ||
441 | {SENSOR, OV9650_RED, RED_GAIN_DEFAULT}, | ||
442 | }; | 313 | }; |
443 | 314 | ||
444 | static const unsigned char power_down_ov9650[][3] = | 315 | static const unsigned char power_down_ov9650[][3] = |
@@ -461,73 +332,15 @@ static const unsigned char power_down_ov9650[][3] = | |||
461 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, | 332 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, |
462 | }; | 333 | }; |
463 | 334 | ||
464 | static const unsigned char res_init_ov9650[][2] = | 335 | static const unsigned char res_init_ov9650[][3] = |
465 | { | ||
466 | {M5602_XB_LINE_OF_FRAME_H, 0x82}, | ||
467 | {M5602_XB_LINE_OF_FRAME_L, 0x00}, | ||
468 | {M5602_XB_PIX_OF_LINE_H, 0x82}, | ||
469 | {M5602_XB_PIX_OF_LINE_L, 0x00}, | ||
470 | {M5602_XB_SIG_INI, 0x01} | ||
471 | }; | ||
472 | |||
473 | static const unsigned char VGA_ov9650[][3] = | ||
474 | { | 336 | { |
475 | /* Moves the view window in a vertical orientation */ | 337 | {SENSOR, OV9650_COM2, OV9650_OUTPUT_DRIVE_2X}, |
476 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
477 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x09}, | ||
478 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
479 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x01}, | ||
480 | {BRIDGE, M5602_XB_VSYNC_PARA, 0xe0}, /* 480 */ | ||
481 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
482 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
483 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x00}, | ||
484 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x62}, /* 98 */ | ||
485 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x02}, /* 640 + 98 */ | ||
486 | {BRIDGE, M5602_XB_HSYNC_PARA, 0xe2}, | ||
487 | |||
488 | {SENSOR, OV9650_COM7, OV9650_VGA_SELECT | | ||
489 | OV9650_RGB_SELECT | | ||
490 | OV9650_RAW_RGB_SELECT}, | ||
491 | }; | ||
492 | 338 | ||
493 | static const unsigned char CIF_ov9650[][3] = | 339 | {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x82}, |
494 | { | 340 | {BRIDGE, M5602_XB_LINE_OF_FRAME_L, 0x00}, |
495 | /* Moves the view window in a vertical orientation */ | 341 | {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82}, |
496 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | 342 | {BRIDGE, M5602_XB_PIX_OF_LINE_L, 0x00}, |
497 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x09}, | 343 | {BRIDGE, M5602_XB_SIG_INI, 0x01} |
498 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
499 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x01}, | ||
500 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x20}, /* 288 */ | ||
501 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
502 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
503 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x00}, | ||
504 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x62}, /* 98 */ | ||
505 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x01}, /* 352 + 98 */ | ||
506 | {BRIDGE, M5602_XB_HSYNC_PARA, 0xc2}, | ||
507 | |||
508 | {SENSOR, OV9650_COM7, OV9650_CIF_SELECT | | ||
509 | OV9650_RGB_SELECT | | ||
510 | OV9650_RAW_RGB_SELECT}, | ||
511 | }; | ||
512 | |||
513 | static const unsigned char QVGA_ov9650[][3] = | ||
514 | { | ||
515 | /* Moves the view window in a vertical orientation */ | ||
516 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
517 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x08}, | ||
518 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
519 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
520 | {BRIDGE, M5602_XB_VSYNC_PARA, 0xf0}, /* 240 */ | ||
521 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
522 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00}, | ||
523 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x00}, | ||
524 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x31}, /* 50 */ | ||
525 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x01}, /* 320 + 50 */ | ||
526 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x71}, | ||
527 | |||
528 | {SENSOR, OV9650_COM7, OV9650_QVGA_SELECT | | ||
529 | OV9650_RGB_SELECT | | ||
530 | OV9650_RAW_RGB_SELECT}, | ||
531 | }; | 344 | }; |
532 | 345 | ||
533 | #endif | 346 | #endif |
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c index 2e7fb91673cf..eaddf488bad1 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.c +++ b/drivers/media/video/gspca/m5602/m5602_po1030.c | |||
@@ -18,6 +18,99 @@ | |||
18 | 18 | ||
19 | #include "m5602_po1030.h" | 19 | #include "m5602_po1030.h" |
20 | 20 | ||
21 | static struct v4l2_pix_format po1030_modes[] = { | ||
22 | { | ||
23 | 640, | ||
24 | 480, | ||
25 | V4L2_PIX_FMT_SBGGR8, | ||
26 | V4L2_FIELD_NONE, | ||
27 | .sizeimage = 640 * 480, | ||
28 | .bytesperline = 640, | ||
29 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
30 | .priv = 0 | ||
31 | } | ||
32 | }; | ||
33 | |||
34 | const static struct ctrl po1030_ctrls[] = { | ||
35 | { | ||
36 | { | ||
37 | .id = V4L2_CID_GAIN, | ||
38 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
39 | .name = "gain", | ||
40 | .minimum = 0x00, | ||
41 | .maximum = 0x4f, | ||
42 | .step = 0x1, | ||
43 | .default_value = PO1030_GLOBAL_GAIN_DEFAULT, | ||
44 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
45 | }, | ||
46 | .set = po1030_set_gain, | ||
47 | .get = po1030_get_gain | ||
48 | }, { | ||
49 | { | ||
50 | .id = V4L2_CID_EXPOSURE, | ||
51 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
52 | .name = "exposure", | ||
53 | .minimum = 0x00, | ||
54 | .maximum = 0x02ff, | ||
55 | .step = 0x1, | ||
56 | .default_value = PO1030_EXPOSURE_DEFAULT, | ||
57 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
58 | }, | ||
59 | .set = po1030_set_exposure, | ||
60 | .get = po1030_get_exposure | ||
61 | }, { | ||
62 | { | ||
63 | .id = V4L2_CID_RED_BALANCE, | ||
64 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
65 | .name = "red balance", | ||
66 | .minimum = 0x00, | ||
67 | .maximum = 0xff, | ||
68 | .step = 0x1, | ||
69 | .default_value = PO1030_RED_GAIN_DEFAULT, | ||
70 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
71 | }, | ||
72 | .set = po1030_set_red_balance, | ||
73 | .get = po1030_get_red_balance | ||
74 | }, { | ||
75 | { | ||
76 | .id = V4L2_CID_BLUE_BALANCE, | ||
77 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
78 | .name = "blue balance", | ||
79 | .minimum = 0x00, | ||
80 | .maximum = 0xff, | ||
81 | .step = 0x1, | ||
82 | .default_value = PO1030_BLUE_GAIN_DEFAULT, | ||
83 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
84 | }, | ||
85 | .set = po1030_set_blue_balance, | ||
86 | .get = po1030_get_blue_balance | ||
87 | }, { | ||
88 | { | ||
89 | .id = V4L2_CID_HFLIP, | ||
90 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
91 | .name = "horizontal flip", | ||
92 | .minimum = 0, | ||
93 | .maximum = 1, | ||
94 | .step = 1, | ||
95 | .default_value = 0, | ||
96 | }, | ||
97 | .set = po1030_set_hflip, | ||
98 | .get = po1030_get_hflip | ||
99 | }, { | ||
100 | { | ||
101 | .id = V4L2_CID_VFLIP, | ||
102 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
103 | .name = "vertical flip", | ||
104 | .minimum = 0, | ||
105 | .maximum = 1, | ||
106 | .step = 1, | ||
107 | .default_value = 0, | ||
108 | }, | ||
109 | .set = po1030_set_vflip, | ||
110 | .get = po1030_get_vflip | ||
111 | } | ||
112 | }; | ||
113 | |||
21 | static void po1030_dump_registers(struct sd *sd); | 114 | static void po1030_dump_registers(struct sd *sd); |
22 | 115 | ||
23 | int po1030_probe(struct sd *sd) | 116 | int po1030_probe(struct sd *sd) |
@@ -59,10 +152,10 @@ int po1030_probe(struct sd *sd) | |||
59 | return -ENODEV; | 152 | return -ENODEV; |
60 | 153 | ||
61 | sensor_found: | 154 | sensor_found: |
62 | sd->gspca_dev.cam.cam_mode = po1030.modes; | 155 | sd->gspca_dev.cam.cam_mode = po1030_modes; |
63 | sd->gspca_dev.cam.nmodes = po1030.nmodes; | 156 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes); |
64 | sd->desc->ctrls = po1030.ctrls; | 157 | sd->desc->ctrls = po1030_ctrls; |
65 | sd->desc->nctrls = po1030.nctrls; | 158 | sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls); |
66 | return 0; | 159 | return 0; |
67 | } | 160 | } |
68 | 161 | ||
@@ -108,7 +201,7 @@ int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
108 | err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_H, | 201 | err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_H, |
109 | &i2c_data, 1); | 202 | &i2c_data, 1); |
110 | if (err < 0) | 203 | if (err < 0) |
111 | goto out; | 204 | return err; |
112 | *val = (i2c_data << 8); | 205 | *val = (i2c_data << 8); |
113 | 206 | ||
114 | err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_M, | 207 | err = m5602_read_sensor(sd, PO1030_REG_INTEGLINES_M, |
@@ -116,7 +209,7 @@ int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
116 | *val |= i2c_data; | 209 | *val |= i2c_data; |
117 | 210 | ||
118 | PDEBUG(D_V4L2, "Exposure read as %d", *val); | 211 | PDEBUG(D_V4L2, "Exposure read as %d", *val); |
119 | out: | 212 | |
120 | return err; | 213 | return err; |
121 | } | 214 | } |
122 | 215 | ||
@@ -135,7 +228,7 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
135 | err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_H, | 228 | err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_H, |
136 | &i2c_data, 1); | 229 | &i2c_data, 1); |
137 | if (err < 0) | 230 | if (err < 0) |
138 | goto out; | 231 | return err; |
139 | 232 | ||
140 | i2c_data = (val & 0xff); | 233 | i2c_data = (val & 0xff); |
141 | PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", | 234 | PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", |
@@ -143,7 +236,6 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
143 | err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_M, | 236 | err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_M, |
144 | &i2c_data, 1); | 237 | &i2c_data, 1); |
145 | 238 | ||
146 | out: | ||
147 | return err; | 239 | return err; |
148 | } | 240 | } |
149 | 241 | ||
@@ -186,14 +278,13 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
186 | PDEBUG(D_V4L2, "Set hflip %d", val); | 278 | PDEBUG(D_V4L2, "Set hflip %d", val); |
187 | err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1); | 279 | err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1); |
188 | if (err < 0) | 280 | if (err < 0) |
189 | goto out; | 281 | return err; |
190 | 282 | ||
191 | i2c_data = (0x7f & i2c_data) | ((val & 0x01) << 7); | 283 | i2c_data = (0x7f & i2c_data) | ((val & 0x01) << 7); |
192 | 284 | ||
193 | err = m5602_write_sensor(sd, PO1030_REG_CONTROL2, | 285 | err = m5602_write_sensor(sd, PO1030_REG_CONTROL2, |
194 | &i2c_data, 1); | 286 | &i2c_data, 1); |
195 | 287 | ||
196 | out: | ||
197 | return err; | 288 | return err; |
198 | } | 289 | } |
199 | 290 | ||
@@ -222,14 +313,13 @@ int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
222 | PDEBUG(D_V4L2, "Set vflip %d", val); | 313 | PDEBUG(D_V4L2, "Set vflip %d", val); |
223 | err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1); | 314 | err = m5602_read_sensor(sd, PO1030_REG_CONTROL2, &i2c_data, 1); |
224 | if (err < 0) | 315 | if (err < 0) |
225 | goto out; | 316 | return err; |
226 | 317 | ||
227 | i2c_data = (i2c_data & 0xbf) | ((val & 0x01) << 6); | 318 | i2c_data = (i2c_data & 0xbf) | ((val & 0x01) << 6); |
228 | 319 | ||
229 | err = m5602_write_sensor(sd, PO1030_REG_CONTROL2, | 320 | err = m5602_write_sensor(sd, PO1030_REG_CONTROL2, |
230 | &i2c_data, 1); | 321 | &i2c_data, 1); |
231 | 322 | ||
232 | out: | ||
233 | return err; | 323 | return err; |
234 | } | 324 | } |
235 | 325 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h index def39d5bcec6..c10b12335818 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.h +++ b/drivers/media/video/gspca/m5602/m5602_po1030.h | |||
@@ -141,7 +141,7 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | |||
141 | int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); | 141 | int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); |
142 | int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); | 142 | int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); |
143 | 143 | ||
144 | static struct m5602_sensor po1030 = { | 144 | static const struct m5602_sensor po1030 = { |
145 | .name = "PO1030", | 145 | .name = "PO1030", |
146 | 146 | ||
147 | .i2c_slave_id = 0xdc, | 147 | .i2c_slave_id = 0xdc, |
@@ -150,102 +150,6 @@ static struct m5602_sensor po1030 = { | |||
150 | .probe = po1030_probe, | 150 | .probe = po1030_probe, |
151 | .init = po1030_init, | 151 | .init = po1030_init, |
152 | .power_down = po1030_power_down, | 152 | .power_down = po1030_power_down, |
153 | |||
154 | .nctrls = 6, | ||
155 | .ctrls = { | ||
156 | { | ||
157 | { | ||
158 | .id = V4L2_CID_GAIN, | ||
159 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
160 | .name = "gain", | ||
161 | .minimum = 0x00, | ||
162 | .maximum = 0x4f, | ||
163 | .step = 0x1, | ||
164 | .default_value = PO1030_GLOBAL_GAIN_DEFAULT, | ||
165 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
166 | }, | ||
167 | .set = po1030_set_gain, | ||
168 | .get = po1030_get_gain | ||
169 | }, { | ||
170 | { | ||
171 | .id = V4L2_CID_EXPOSURE, | ||
172 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
173 | .name = "exposure", | ||
174 | .minimum = 0x00, | ||
175 | .maximum = 0x02ff, | ||
176 | .step = 0x1, | ||
177 | .default_value = PO1030_EXPOSURE_DEFAULT, | ||
178 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
179 | }, | ||
180 | .set = po1030_set_exposure, | ||
181 | .get = po1030_get_exposure | ||
182 | }, { | ||
183 | { | ||
184 | .id = V4L2_CID_RED_BALANCE, | ||
185 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
186 | .name = "red balance", | ||
187 | .minimum = 0x00, | ||
188 | .maximum = 0xff, | ||
189 | .step = 0x1, | ||
190 | .default_value = PO1030_RED_GAIN_DEFAULT, | ||
191 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
192 | }, | ||
193 | .set = po1030_set_red_balance, | ||
194 | .get = po1030_get_red_balance | ||
195 | }, { | ||
196 | { | ||
197 | .id = V4L2_CID_BLUE_BALANCE, | ||
198 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
199 | .name = "blue balance", | ||
200 | .minimum = 0x00, | ||
201 | .maximum = 0xff, | ||
202 | .step = 0x1, | ||
203 | .default_value = PO1030_BLUE_GAIN_DEFAULT, | ||
204 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
205 | }, | ||
206 | .set = po1030_set_blue_balance, | ||
207 | .get = po1030_get_blue_balance | ||
208 | }, { | ||
209 | { | ||
210 | .id = V4L2_CID_HFLIP, | ||
211 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
212 | .name = "horizontal flip", | ||
213 | .minimum = 0, | ||
214 | .maximum = 1, | ||
215 | .step = 1, | ||
216 | .default_value = 0, | ||
217 | }, | ||
218 | .set = po1030_set_hflip, | ||
219 | .get = po1030_get_hflip | ||
220 | }, { | ||
221 | { | ||
222 | .id = V4L2_CID_VFLIP, | ||
223 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
224 | .name = "vertical flip", | ||
225 | .minimum = 0, | ||
226 | .maximum = 1, | ||
227 | .step = 1, | ||
228 | .default_value = 0, | ||
229 | }, | ||
230 | .set = po1030_set_vflip, | ||
231 | .get = po1030_get_vflip | ||
232 | } | ||
233 | }, | ||
234 | |||
235 | .nmodes = 1, | ||
236 | .modes = { | ||
237 | { | ||
238 | M5602_DEFAULT_FRAME_WIDTH, | ||
239 | M5602_DEFAULT_FRAME_HEIGHT, | ||
240 | V4L2_PIX_FMT_SBGGR8, | ||
241 | V4L2_FIELD_NONE, | ||
242 | .sizeimage = | ||
243 | M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT, | ||
244 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, | ||
245 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
246 | .priv = 1 | ||
247 | } | ||
248 | } | ||
249 | }; | 153 | }; |
250 | 154 | ||
251 | static const unsigned char preinit_po1030[][3] = | 155 | static const unsigned char preinit_po1030[][3] = |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c index 48892b5715d5..4306d596056d 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |||
@@ -50,6 +50,76 @@ static | |||
50 | { } | 50 | { } |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static struct v4l2_pix_format s5k4aa_modes[] = { | ||
54 | { | ||
55 | 640, | ||
56 | 480, | ||
57 | V4L2_PIX_FMT_SBGGR8, | ||
58 | V4L2_FIELD_NONE, | ||
59 | .sizeimage = | ||
60 | 640 * 480, | ||
61 | .bytesperline = 640, | ||
62 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
63 | .priv = 0 | ||
64 | } | ||
65 | }; | ||
66 | |||
67 | const static struct ctrl s5k4aa_ctrls[] = { | ||
68 | { | ||
69 | { | ||
70 | .id = V4L2_CID_VFLIP, | ||
71 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
72 | .name = "vertical flip", | ||
73 | .minimum = 0, | ||
74 | .maximum = 1, | ||
75 | .step = 1, | ||
76 | .default_value = 0 | ||
77 | }, | ||
78 | .set = s5k4aa_set_vflip, | ||
79 | .get = s5k4aa_get_vflip | ||
80 | |||
81 | }, { | ||
82 | { | ||
83 | .id = V4L2_CID_HFLIP, | ||
84 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
85 | .name = "horizontal flip", | ||
86 | .minimum = 0, | ||
87 | .maximum = 1, | ||
88 | .step = 1, | ||
89 | .default_value = 0 | ||
90 | }, | ||
91 | .set = s5k4aa_set_hflip, | ||
92 | .get = s5k4aa_get_hflip | ||
93 | |||
94 | }, { | ||
95 | { | ||
96 | .id = V4L2_CID_GAIN, | ||
97 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
98 | .name = "Gain", | ||
99 | .minimum = 0, | ||
100 | .maximum = 127, | ||
101 | .step = 1, | ||
102 | .default_value = 0xa0, | ||
103 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
104 | }, | ||
105 | .set = s5k4aa_set_gain, | ||
106 | .get = s5k4aa_get_gain | ||
107 | }, { | ||
108 | { | ||
109 | .id = V4L2_CID_EXPOSURE, | ||
110 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
111 | .name = "Exposure", | ||
112 | .minimum = 13, | ||
113 | .maximum = 0xfff, | ||
114 | .step = 1, | ||
115 | .default_value = 0x100, | ||
116 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
117 | }, | ||
118 | .set = s5k4aa_set_exposure, | ||
119 | .get = s5k4aa_get_exposure | ||
120 | } | ||
121 | }; | ||
122 | |||
53 | static void s5k4aa_dump_registers(struct sd *sd); | 123 | static void s5k4aa_dump_registers(struct sd *sd); |
54 | 124 | ||
55 | int s5k4aa_probe(struct sd *sd) | 125 | int s5k4aa_probe(struct sd *sd) |
@@ -115,14 +185,56 @@ int s5k4aa_probe(struct sd *sd) | |||
115 | info("Detected a s5k4aa sensor"); | 185 | info("Detected a s5k4aa sensor"); |
116 | 186 | ||
117 | sensor_found: | 187 | sensor_found: |
118 | sd->gspca_dev.cam.cam_mode = s5k4aa.modes; | 188 | sd->gspca_dev.cam.cam_mode = s5k4aa_modes; |
119 | sd->gspca_dev.cam.nmodes = s5k4aa.nmodes; | 189 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k4aa_modes); |
120 | sd->desc->ctrls = s5k4aa.ctrls; | 190 | sd->desc->ctrls = s5k4aa_ctrls; |
121 | sd->desc->nctrls = s5k4aa.nctrls; | 191 | sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls); |
122 | |||
123 | return 0; | 192 | return 0; |
124 | } | 193 | } |
125 | 194 | ||
195 | int s5k4aa_start(struct sd *sd) | ||
196 | { | ||
197 | int i, err = 0; | ||
198 | u8 data[2]; | ||
199 | struct cam *cam = &sd->gspca_dev.cam; | ||
200 | |||
201 | switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) | ||
202 | { | ||
203 | case 640: | ||
204 | PDEBUG(D_V4L2, "Configuring camera for VGA mode"); | ||
205 | |||
206 | for (i = 0; i < ARRAY_SIZE(VGA_s5k4aa); i++) { | ||
207 | switch (VGA_s5k4aa[i][0]) { | ||
208 | case BRIDGE: | ||
209 | err = m5602_write_bridge(sd, | ||
210 | VGA_s5k4aa[i][1], | ||
211 | VGA_s5k4aa[i][2]); | ||
212 | break; | ||
213 | |||
214 | case SENSOR: | ||
215 | data[0] = VGA_s5k4aa[i][2]; | ||
216 | err = m5602_write_sensor(sd, | ||
217 | VGA_s5k4aa[i][1], | ||
218 | data, 1); | ||
219 | break; | ||
220 | |||
221 | case SENSOR_LONG: | ||
222 | data[0] = VGA_s5k4aa[i][2]; | ||
223 | data[1] = VGA_s5k4aa[i][3]; | ||
224 | err = m5602_write_sensor(sd, | ||
225 | VGA_s5k4aa[i][1], | ||
226 | data, 2); | ||
227 | break; | ||
228 | |||
229 | default: | ||
230 | err("Invalid stream command, exiting init"); | ||
231 | return -EINVAL; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | return err; | ||
236 | } | ||
237 | |||
126 | int s5k4aa_init(struct sd *sd) | 238 | int s5k4aa_init(struct sd *sd) |
127 | { | 239 | { |
128 | int i, err = 0; | 240 | int i, err = 0; |
@@ -194,17 +306,17 @@ int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
194 | 306 | ||
195 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 307 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
196 | if (err < 0) | 308 | if (err < 0) |
197 | goto out; | 309 | return err; |
198 | 310 | ||
199 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); | 311 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); |
200 | if (err < 0) | 312 | if (err < 0) |
201 | goto out; | 313 | return err; |
202 | 314 | ||
203 | *val = data << 8; | 315 | *val = data << 8; |
204 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); | 316 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); |
205 | *val |= data; | 317 | *val |= data; |
206 | PDEBUG(D_V4L2, "Read exposure %d", *val); | 318 | PDEBUG(D_V4L2, "Read exposure %d", *val); |
207 | out: | 319 | |
208 | return err; | 320 | return err; |
209 | } | 321 | } |
210 | 322 | ||
@@ -217,14 +329,14 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
217 | PDEBUG(D_V4L2, "Set exposure to %d", val); | 329 | PDEBUG(D_V4L2, "Set exposure to %d", val); |
218 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 330 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
219 | if (err < 0) | 331 | if (err < 0) |
220 | goto out; | 332 | return err; |
221 | data = (val >> 8) & 0xff; | 333 | data = (val >> 8) & 0xff; |
222 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); | 334 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); |
223 | if (err < 0) | 335 | if (err < 0) |
224 | goto out; | 336 | return err; |
225 | data = val & 0xff; | 337 | data = val & 0xff; |
226 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); | 338 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); |
227 | out: | 339 | |
228 | return err; | 340 | return err; |
229 | } | 341 | } |
230 | 342 | ||
@@ -236,13 +348,12 @@ int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
236 | 348 | ||
237 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 349 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
238 | if (err < 0) | 350 | if (err < 0) |
239 | goto out; | 351 | return err; |
240 | 352 | ||
241 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 353 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
242 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; | 354 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; |
243 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); | 355 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
244 | 356 | ||
245 | out: | ||
246 | return err; | 357 | return err; |
247 | } | 358 | } |
248 | 359 | ||
@@ -255,32 +366,32 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
255 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); | 366 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
256 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 367 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
257 | if (err < 0) | 368 | if (err < 0) |
258 | goto out; | 369 | return err; |
259 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 370 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
260 | if (err < 0) | 371 | if (err < 0) |
261 | goto out; | 372 | return err; |
262 | data = ((data & ~S5K4AA_RM_V_FLIP) | 373 | data = ((data & ~S5K4AA_RM_V_FLIP) |
263 | | ((val & 0x01) << 7)); | 374 | | ((val & 0x01) << 7)); |
264 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 375 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
265 | if (err < 0) | 376 | if (err < 0) |
266 | goto out; | 377 | return err; |
267 | 378 | ||
268 | if (val) { | 379 | if (val) { |
269 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 380 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
270 | if (err < 0) | 381 | if (err < 0) |
271 | goto out; | 382 | return err; |
272 | 383 | ||
273 | data++; | 384 | data++; |
274 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 385 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
275 | } else { | 386 | } else { |
276 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 387 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
277 | if (err < 0) | 388 | if (err < 0) |
278 | goto out; | 389 | return err; |
279 | 390 | ||
280 | data--; | 391 | data--; |
281 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 392 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
282 | } | 393 | } |
283 | out: | 394 | |
284 | return err; | 395 | return err; |
285 | } | 396 | } |
286 | 397 | ||
@@ -292,12 +403,12 @@ int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
292 | 403 | ||
293 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 404 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
294 | if (err < 0) | 405 | if (err < 0) |
295 | goto out; | 406 | return err; |
296 | 407 | ||
297 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 408 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
298 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; | 409 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; |
299 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); | 410 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
300 | out: | 411 | |
301 | return err; | 412 | return err; |
302 | } | 413 | } |
303 | 414 | ||
@@ -311,32 +422,32 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
311 | val); | 422 | val); |
312 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 423 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
313 | if (err < 0) | 424 | if (err < 0) |
314 | goto out; | 425 | return err; |
315 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 426 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
316 | if (err < 0) | 427 | if (err < 0) |
317 | goto out; | 428 | return err; |
318 | 429 | ||
319 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); | 430 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); |
320 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 431 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
321 | if (err < 0) | 432 | if (err < 0) |
322 | goto out; | 433 | return err; |
323 | 434 | ||
324 | if (val) { | 435 | if (val) { |
325 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 436 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
326 | if (err < 0) | 437 | if (err < 0) |
327 | goto out; | 438 | return err; |
328 | data++; | 439 | data++; |
329 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 440 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
330 | if (err < 0) | 441 | if (err < 0) |
331 | goto out; | 442 | return err; |
332 | } else { | 443 | } else { |
333 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 444 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
334 | if (err < 0) | 445 | if (err < 0) |
335 | goto out; | 446 | return err; |
336 | data--; | 447 | data--; |
337 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 448 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
338 | } | 449 | } |
339 | out: | 450 | |
340 | return err; | 451 | return err; |
341 | } | 452 | } |
342 | 453 | ||
@@ -348,13 +459,12 @@ int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
348 | 459 | ||
349 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 460 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
350 | if (err < 0) | 461 | if (err < 0) |
351 | goto out; | 462 | return err; |
352 | 463 | ||
353 | err = m5602_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 464 | err = m5602_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); |
354 | *val = data; | 465 | *val = data; |
355 | PDEBUG(D_V4L2, "Read gain %d", *val); | 466 | PDEBUG(D_V4L2, "Read gain %d", *val); |
356 | 467 | ||
357 | out: | ||
358 | return err; | 468 | return err; |
359 | } | 469 | } |
360 | 470 | ||
@@ -367,12 +477,11 @@ int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
367 | PDEBUG(D_V4L2, "Set gain to %d", val); | 477 | PDEBUG(D_V4L2, "Set gain to %d", val); |
368 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 478 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
369 | if (err < 0) | 479 | if (err < 0) |
370 | goto out; | 480 | return err; |
371 | 481 | ||
372 | data = val & 0xff; | 482 | data = val & 0xff; |
373 | err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 483 | err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); |
374 | 484 | ||
375 | out: | ||
376 | return err; | 485 | return err; |
377 | } | 486 | } |
378 | 487 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h index 1f88b0d040c4..ca854d4f9475 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h | |||
@@ -65,6 +65,7 @@ extern int dump_sensor; | |||
65 | 65 | ||
66 | int s5k4aa_probe(struct sd *sd); | 66 | int s5k4aa_probe(struct sd *sd); |
67 | int s5k4aa_init(struct sd *sd); | 67 | int s5k4aa_init(struct sd *sd); |
68 | int s5k4aa_start(struct sd *sd); | ||
68 | int s5k4aa_power_down(struct sd *sd); | 69 | int s5k4aa_power_down(struct sd *sd); |
69 | 70 | ||
70 | int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); | 71 | int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); |
@@ -76,84 +77,14 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | |||
76 | int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | 77 | int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val); |
77 | int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); | 78 | int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); |
78 | 79 | ||
79 | static struct m5602_sensor s5k4aa = { | 80 | static const struct m5602_sensor s5k4aa = { |
80 | .name = "S5K4AA", | 81 | .name = "S5K4AA", |
81 | .probe = s5k4aa_probe, | 82 | .probe = s5k4aa_probe, |
82 | .init = s5k4aa_init, | 83 | .init = s5k4aa_init, |
84 | .start = s5k4aa_start, | ||
83 | .power_down = s5k4aa_power_down, | 85 | .power_down = s5k4aa_power_down, |
84 | .i2c_slave_id = 0x5a, | 86 | .i2c_slave_id = 0x5a, |
85 | .i2c_regW = 2, | 87 | .i2c_regW = 2, |
86 | .nctrls = 4, | ||
87 | .ctrls = { | ||
88 | { | ||
89 | { | ||
90 | .id = V4L2_CID_VFLIP, | ||
91 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
92 | .name = "vertical flip", | ||
93 | .minimum = 0, | ||
94 | .maximum = 1, | ||
95 | .step = 1, | ||
96 | .default_value = 0 | ||
97 | }, | ||
98 | .set = s5k4aa_set_vflip, | ||
99 | .get = s5k4aa_get_vflip | ||
100 | |||
101 | }, { | ||
102 | { | ||
103 | .id = V4L2_CID_HFLIP, | ||
104 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
105 | .name = "horizontal flip", | ||
106 | .minimum = 0, | ||
107 | .maximum = 1, | ||
108 | .step = 1, | ||
109 | .default_value = 0 | ||
110 | }, | ||
111 | .set = s5k4aa_set_hflip, | ||
112 | .get = s5k4aa_get_hflip | ||
113 | |||
114 | }, { | ||
115 | { | ||
116 | .id = V4L2_CID_GAIN, | ||
117 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
118 | .name = "Gain", | ||
119 | .minimum = 0, | ||
120 | .maximum = 127, | ||
121 | .step = 1, | ||
122 | .default_value = 0xa0, | ||
123 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
124 | }, | ||
125 | .set = s5k4aa_set_gain, | ||
126 | .get = s5k4aa_get_gain | ||
127 | }, { | ||
128 | { | ||
129 | .id = V4L2_CID_EXPOSURE, | ||
130 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
131 | .name = "Exposure", | ||
132 | .minimum = 13, | ||
133 | .maximum = 0xfff, | ||
134 | .step = 1, | ||
135 | .default_value = 0x100, | ||
136 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
137 | }, | ||
138 | .set = s5k4aa_set_exposure, | ||
139 | .get = s5k4aa_get_exposure | ||
140 | } | ||
141 | }, | ||
142 | |||
143 | .nmodes = 1, | ||
144 | .modes = { | ||
145 | { | ||
146 | M5602_DEFAULT_FRAME_WIDTH, | ||
147 | M5602_DEFAULT_FRAME_HEIGHT, | ||
148 | V4L2_PIX_FMT_SBGGR8, | ||
149 | V4L2_FIELD_NONE, | ||
150 | .sizeimage = | ||
151 | M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT, | ||
152 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, | ||
153 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
154 | .priv = 1 | ||
155 | } | ||
156 | } | ||
157 | }; | 88 | }; |
158 | 89 | ||
159 | static const unsigned char preinit_s5k4aa[][4] = | 90 | static const unsigned char preinit_s5k4aa[][4] = |
@@ -329,4 +260,63 @@ static const unsigned char init_s5k4aa[][4] = | |||
329 | {SENSOR, S5K4AA_GAIN_2, 0xa0, 0x00} | 260 | {SENSOR, S5K4AA_GAIN_2, 0xa0, 0x00} |
330 | }; | 261 | }; |
331 | 262 | ||
263 | static const unsigned char VGA_s5k4aa[][4] = | ||
264 | { | ||
265 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00}, | ||
266 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, | ||
267 | {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00}, | ||
268 | {BRIDGE, M5602_XB_SENSOR_TYPE, 0x08, 0x00}, | ||
269 | {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00}, | ||
270 | {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00}, | ||
271 | {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00}, | ||
272 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
273 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
274 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
275 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
276 | /* VSYNC_PARA, VSYNC_PARA : img height 480 = 0x01e0 */ | ||
277 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00}, | ||
278 | {BRIDGE, M5602_XB_VSYNC_PARA, 0xe0, 0x00}, | ||
279 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
280 | {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, | ||
281 | {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00}, | ||
282 | {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00}, | ||
283 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00}, | ||
284 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00}, | ||
285 | /* HSYNC_PARA, HSYNC_PARA : img width 640 = 0x0280 */ | ||
286 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00}, | ||
287 | {BRIDGE, M5602_XB_HSYNC_PARA, 0x80, 0x00}, | ||
288 | {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00}, | ||
289 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, | ||
290 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xa0, 0x00}, /* 48 MHz */ | ||
291 | |||
292 | {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00}, | ||
293 | {SENSOR, S5K4AA_READ_MODE, S5K4AA_RM_H_FLIP | S5K4AA_RM_ROW_SKIP_2X | ||
294 | | S5K4AA_RM_COL_SKIP_2X, 0x00}, | ||
295 | /* 0x37 : Fix image stability when light is too bright and improves | ||
296 | * image quality in 640x480, but worsens it in 1280x1024 */ | ||
297 | {SENSOR, 0x37, 0x01, 0x00}, | ||
298 | /* ROWSTART_HI, ROWSTART_LO : 10 + (1024-960)/2 = 42 = 0x002a */ | ||
299 | {SENSOR, S5K4AA_ROWSTART_HI, 0x00, 0x00}, | ||
300 | {SENSOR, S5K4AA_ROWSTART_LO, 0x2a, 0x00}, | ||
301 | {SENSOR, S5K4AA_COLSTART_HI, 0x00, 0x00}, | ||
302 | {SENSOR, S5K4AA_COLSTART_LO, 0x0c, 0x00}, | ||
303 | /* window_height_hi, window_height_lo : 960 = 0x03c0 */ | ||
304 | {SENSOR, S5K4AA_WINDOW_HEIGHT_HI, 0x03, 0x00}, | ||
305 | {SENSOR, S5K4AA_WINDOW_HEIGHT_LO, 0xc0, 0x00}, | ||
306 | /* window_width_hi, window_width_lo : 1280 = 0x0500 */ | ||
307 | {SENSOR, S5K4AA_WINDOW_WIDTH_HI, 0x05, 0x00}, | ||
308 | {SENSOR, S5K4AA_WINDOW_WIDTH_LO, 0x00, 0x00}, | ||
309 | {SENSOR, S5K4AA_H_BLANK_HI__, 0x00, 0x00}, | ||
310 | {SENSOR, S5K4AA_H_BLANK_LO__, 0xa8, 0x00}, /* helps to sync... */ | ||
311 | {SENSOR, S5K4AA_EXPOSURE_HI, 0x01, 0x00}, | ||
312 | {SENSOR, S5K4AA_EXPOSURE_LO, 0x00, 0x00}, | ||
313 | {SENSOR, 0x11, 0x04, 0x00}, | ||
314 | {SENSOR, 0x12, 0xc3, 0x00}, | ||
315 | {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00}, | ||
316 | {SENSOR, 0x02, 0x0e, 0x00}, | ||
317 | {SENSOR_LONG, S5K4AA_GLOBAL_GAIN__, 0x0f, 0x00}, | ||
318 | {SENSOR, S5K4AA_GAIN_1, 0x0b, 0x00}, | ||
319 | {SENSOR, S5K4AA_GAIN_2, 0xa0, 0x00} | ||
320 | }; | ||
321 | |||
332 | #endif | 322 | #endif |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c index ccea4a758464..42c86aa4dc8d 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c | |||
@@ -18,6 +18,88 @@ | |||
18 | 18 | ||
19 | #include "m5602_s5k83a.h" | 19 | #include "m5602_s5k83a.h" |
20 | 20 | ||
21 | static struct v4l2_pix_format s5k83a_modes[] = { | ||
22 | { | ||
23 | 640, | ||
24 | 480, | ||
25 | V4L2_PIX_FMT_SBGGR8, | ||
26 | V4L2_FIELD_NONE, | ||
27 | .sizeimage = | ||
28 | 640 * 480, | ||
29 | .bytesperline = 640, | ||
30 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
31 | .priv = 0 | ||
32 | } | ||
33 | }; | ||
34 | |||
35 | const static struct ctrl s5k83a_ctrls[] = { | ||
36 | { | ||
37 | { | ||
38 | .id = V4L2_CID_BRIGHTNESS, | ||
39 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
40 | .name = "brightness", | ||
41 | .minimum = 0x00, | ||
42 | .maximum = 0xff, | ||
43 | .step = 0x01, | ||
44 | .default_value = S5K83A_DEFAULT_BRIGHTNESS, | ||
45 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
46 | }, | ||
47 | .set = s5k83a_set_brightness, | ||
48 | .get = s5k83a_get_brightness | ||
49 | |||
50 | }, { | ||
51 | { | ||
52 | .id = V4L2_CID_WHITENESS, | ||
53 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
54 | .name = "whiteness", | ||
55 | .minimum = 0x00, | ||
56 | .maximum = 0xff, | ||
57 | .step = 0x01, | ||
58 | .default_value = S5K83A_DEFAULT_WHITENESS, | ||
59 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
60 | }, | ||
61 | .set = s5k83a_set_whiteness, | ||
62 | .get = s5k83a_get_whiteness, | ||
63 | }, { | ||
64 | { | ||
65 | .id = V4L2_CID_GAIN, | ||
66 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
67 | .name = "gain", | ||
68 | .minimum = 0x00, | ||
69 | .maximum = S5K83A_MAXIMUM_GAIN, | ||
70 | .step = 0x01, | ||
71 | .default_value = S5K83A_DEFAULT_GAIN, | ||
72 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
73 | }, | ||
74 | .set = s5k83a_set_gain, | ||
75 | .get = s5k83a_get_gain | ||
76 | }, { | ||
77 | { | ||
78 | .id = V4L2_CID_HFLIP, | ||
79 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
80 | .name = "horizontal flip", | ||
81 | .minimum = 0, | ||
82 | .maximum = 1, | ||
83 | .step = 1, | ||
84 | .default_value = 0 | ||
85 | }, | ||
86 | .set = s5k83a_set_hflip, | ||
87 | .get = s5k83a_get_hflip | ||
88 | }, { | ||
89 | { | ||
90 | .id = V4L2_CID_VFLIP, | ||
91 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
92 | .name = "vertical flip", | ||
93 | .minimum = 0, | ||
94 | .maximum = 1, | ||
95 | .step = 1, | ||
96 | .default_value = 0 | ||
97 | }, | ||
98 | .set = s5k83a_set_vflip, | ||
99 | .get = s5k83a_get_vflip | ||
100 | } | ||
101 | }; | ||
102 | |||
21 | static void s5k83a_dump_registers(struct sd *sd); | 103 | static void s5k83a_dump_registers(struct sd *sd); |
22 | 104 | ||
23 | int s5k83a_probe(struct sd *sd) | 105 | int s5k83a_probe(struct sd *sd) |
@@ -63,10 +145,10 @@ int s5k83a_probe(struct sd *sd) | |||
63 | info("Detected a s5k83a sensor"); | 145 | info("Detected a s5k83a sensor"); |
64 | 146 | ||
65 | sensor_found: | 147 | sensor_found: |
66 | sd->gspca_dev.cam.cam_mode = s5k83a.modes; | 148 | sd->gspca_dev.cam.cam_mode = s5k83a_modes; |
67 | sd->gspca_dev.cam.nmodes = s5k83a.nmodes; | 149 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes); |
68 | sd->desc->ctrls = s5k83a.ctrls; | 150 | sd->desc->ctrls = s5k83a_ctrls; |
69 | sd->desc->nctrls = s5k83a.nctrls; | 151 | sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls); |
70 | return 0; | 152 | return 0; |
71 | } | 153 | } |
72 | 154 | ||
@@ -108,6 +190,16 @@ int s5k83a_init(struct sd *sd) | |||
108 | return (err < 0) ? err : 0; | 190 | return (err < 0) ? err : 0; |
109 | } | 191 | } |
110 | 192 | ||
193 | int s5k83a_start(struct sd *sd) | ||
194 | { | ||
195 | return s5k83a_set_led_indication(sd, 1); | ||
196 | } | ||
197 | |||
198 | int s5k83a_stop(struct sd *sd) | ||
199 | { | ||
200 | return s5k83a_set_led_indication(sd, 0); | ||
201 | } | ||
202 | |||
111 | int s5k83a_power_down(struct sd *sd) | 203 | int s5k83a_power_down(struct sd *sd) |
112 | { | 204 | { |
113 | return 0; | 205 | return 0; |
@@ -163,12 +255,11 @@ int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
163 | 255 | ||
164 | err = m5602_read_sensor(sd, S5K83A_BRIGHTNESS, data, 2); | 256 | err = m5602_read_sensor(sd, S5K83A_BRIGHTNESS, data, 2); |
165 | if (err < 0) | 257 | if (err < 0) |
166 | goto out; | 258 | return err; |
167 | 259 | ||
168 | data[1] = data[1] << 1; | 260 | data[1] = data[1] << 1; |
169 | *val = data[1]; | 261 | *val = data[1]; |
170 | 262 | ||
171 | out: | ||
172 | return err; | 263 | return err; |
173 | } | 264 | } |
174 | 265 | ||
@@ -182,13 +273,13 @@ int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | |||
182 | data[1] = 0x20; | 273 | data[1] = 0x20; |
183 | err = m5602_write_sensor(sd, 0x14, data, 2); | 274 | err = m5602_write_sensor(sd, 0x14, data, 2); |
184 | if (err < 0) | 275 | if (err < 0) |
185 | goto out; | 276 | return err; |
186 | 277 | ||
187 | data[0] = 0x01; | 278 | data[0] = 0x01; |
188 | data[1] = 0x00; | 279 | data[1] = 0x00; |
189 | err = m5602_write_sensor(sd, 0x0d, data, 2); | 280 | err = m5602_write_sensor(sd, 0x0d, data, 2); |
190 | if (err < 0) | 281 | if (err < 0) |
191 | goto out; | 282 | return err; |
192 | 283 | ||
193 | /* FIXME: This is not sane, we need to figure out the composition | 284 | /* FIXME: This is not sane, we need to figure out the composition |
194 | of these registers */ | 285 | of these registers */ |
@@ -196,7 +287,6 @@ int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | |||
196 | data[1] = val >> 1; /* brightness, high 7 bits */ | 287 | data[1] = val >> 1; /* brightness, high 7 bits */ |
197 | err = m5602_write_sensor(sd, S5K83A_BRIGHTNESS, data, 2); | 288 | err = m5602_write_sensor(sd, S5K83A_BRIGHTNESS, data, 2); |
198 | 289 | ||
199 | out: | ||
200 | return err; | 290 | return err; |
201 | } | 291 | } |
202 | 292 | ||
@@ -208,11 +298,10 @@ int s5k83a_get_whiteness(struct gspca_dev *gspca_dev, __s32 *val) | |||
208 | 298 | ||
209 | err = m5602_read_sensor(sd, S5K83A_WHITENESS, &data, 1); | 299 | err = m5602_read_sensor(sd, S5K83A_WHITENESS, &data, 1); |
210 | if (err < 0) | 300 | if (err < 0) |
211 | goto out; | 301 | return err; |
212 | 302 | ||
213 | *val = data; | 303 | *val = data; |
214 | 304 | ||
215 | out: | ||
216 | return err; | 305 | return err; |
217 | } | 306 | } |
218 | 307 | ||
@@ -236,7 +325,7 @@ int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
236 | 325 | ||
237 | err = m5602_read_sensor(sd, S5K83A_GAIN, data, 2); | 326 | err = m5602_read_sensor(sd, S5K83A_GAIN, data, 2); |
238 | if (err < 0) | 327 | if (err < 0) |
239 | goto out; | 328 | return err; |
240 | 329 | ||
241 | data[1] = data[1] & 0x3f; | 330 | data[1] = data[1] & 0x3f; |
242 | if (data[1] > S5K83A_MAXIMUM_GAIN) | 331 | if (data[1] > S5K83A_MAXIMUM_GAIN) |
@@ -244,7 +333,6 @@ int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
244 | 333 | ||
245 | *val = data[1]; | 334 | *val = data[1]; |
246 | 335 | ||
247 | out: | ||
248 | return err; | 336 | return err; |
249 | } | 337 | } |
250 | 338 | ||
@@ -269,12 +357,11 @@ int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
269 | data[0] = 0x05; | 357 | data[0] = 0x05; |
270 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | 358 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); |
271 | if (err < 0) | 359 | if (err < 0) |
272 | goto out; | 360 | return err; |
273 | 361 | ||
274 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); | 362 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); |
275 | *val = (data[0] | 0x40) ? 1 : 0; | 363 | *val = (data[0] | 0x40) ? 1 : 0; |
276 | 364 | ||
277 | out: | ||
278 | return err; | 365 | return err; |
279 | } | 366 | } |
280 | 367 | ||
@@ -287,23 +374,22 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
287 | data[0] = 0x05; | 374 | data[0] = 0x05; |
288 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | 375 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); |
289 | if (err < 0) | 376 | if (err < 0) |
290 | goto out; | 377 | return err; |
291 | 378 | ||
292 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); | 379 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); |
293 | if (err < 0) | 380 | if (err < 0) |
294 | goto out; | 381 | return err; |
295 | 382 | ||
296 | /* set or zero six bit, seven is hflip */ | 383 | /* set or zero six bit, seven is hflip */ |
297 | data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK | 384 | data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK |
298 | : (data[0] & 0x80) | S5K83A_FLIP_MASK; | 385 | : (data[0] & 0x80) | S5K83A_FLIP_MASK; |
299 | err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1); | 386 | err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1); |
300 | if (err < 0) | 387 | if (err < 0) |
301 | goto out; | 388 | return err; |
302 | 389 | ||
303 | data[0] = (val) ? 0x0b : 0x0a; | 390 | data[0] = (val) ? 0x0b : 0x0a; |
304 | err = m5602_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1); | 391 | err = m5602_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1); |
305 | 392 | ||
306 | out: | ||
307 | return err; | 393 | return err; |
308 | } | 394 | } |
309 | 395 | ||
@@ -316,12 +402,11 @@ int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
316 | data[0] = 0x05; | 402 | data[0] = 0x05; |
317 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | 403 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); |
318 | if (err < 0) | 404 | if (err < 0) |
319 | goto out; | 405 | return err; |
320 | 406 | ||
321 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); | 407 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); |
322 | *val = (data[0] | 0x80) ? 1 : 0; | 408 | *val = (data[0] | 0x80) ? 1 : 0; |
323 | 409 | ||
324 | out: | ||
325 | return err; | 410 | return err; |
326 | } | 411 | } |
327 | 412 | ||
@@ -334,21 +419,40 @@ int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
334 | data[0] = 0x05; | 419 | data[0] = 0x05; |
335 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | 420 | err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); |
336 | if (err < 0) | 421 | if (err < 0) |
337 | goto out; | 422 | return err; |
338 | 423 | ||
339 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); | 424 | err = m5602_read_sensor(sd, S5K83A_FLIP, data, 1); |
340 | if (err < 0) | 425 | if (err < 0) |
341 | goto out; | 426 | return err; |
342 | 427 | ||
343 | /* set or zero seven bit, six is vflip */ | 428 | /* set or zero seven bit, six is vflip */ |
344 | data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK | 429 | data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK |
345 | : (data[0] & 0x40) | S5K83A_FLIP_MASK; | 430 | : (data[0] & 0x40) | S5K83A_FLIP_MASK; |
346 | err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1); | 431 | err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1); |
347 | if (err < 0) | 432 | if (err < 0) |
348 | goto out; | 433 | return err; |
349 | 434 | ||
350 | data[0] = (val) ? 0x0a : 0x0b; | 435 | data[0] = (val) ? 0x0a : 0x0b; |
351 | err = m5602_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1); | 436 | err = m5602_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1); |
352 | out: | 437 | |
353 | return err; | 438 | return err; |
354 | } | 439 | } |
440 | |||
441 | int s5k83a_set_led_indication(struct sd *sd, u8 val) | ||
442 | { | ||
443 | int err = 0; | ||
444 | u8 data[1]; | ||
445 | |||
446 | err = m5602_read_bridge(sd, M5602_XB_GPIO_DAT, data); | ||
447 | if (err < 0) | ||
448 | return err; | ||
449 | |||
450 | if (val) | ||
451 | data[0] = data[0] | S5K83A_GPIO_LED_MASK; | ||
452 | else | ||
453 | data[0] = data[0] & ~S5K83A_GPIO_LED_MASK; | ||
454 | |||
455 | err = m5602_write_bridge(sd, M5602_XB_GPIO_DAT, data[0]); | ||
456 | |||
457 | return (err < 0) ? err : 0; | ||
458 | } | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h index 05ccb5b57a88..819ab25272be 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h | |||
@@ -34,7 +34,7 @@ | |||
34 | #define S5K83A_DEFAULT_GAIN 0x00 | 34 | #define S5K83A_DEFAULT_GAIN 0x00 |
35 | #define S5K83A_MAXIMUM_GAIN 0x3c | 35 | #define S5K83A_MAXIMUM_GAIN 0x3c |
36 | #define S5K83A_FLIP_MASK 0x10 | 36 | #define S5K83A_FLIP_MASK 0x10 |
37 | 37 | #define S5K83A_GPIO_LED_MASK 0x10 | |
38 | 38 | ||
39 | /*****************************************************************************/ | 39 | /*****************************************************************************/ |
40 | 40 | ||
@@ -44,8 +44,12 @@ extern int dump_sensor; | |||
44 | 44 | ||
45 | int s5k83a_probe(struct sd *sd); | 45 | int s5k83a_probe(struct sd *sd); |
46 | int s5k83a_init(struct sd *sd); | 46 | int s5k83a_init(struct sd *sd); |
47 | int s5k83a_start(struct sd *sd); | ||
48 | int s5k83a_stop(struct sd *sd); | ||
47 | int s5k83a_power_down(struct sd *sd); | 49 | int s5k83a_power_down(struct sd *sd); |
48 | 50 | ||
51 | int s5k83a_set_led_indication(struct sd *sd, u8 val); | ||
52 | |||
49 | int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val); | 53 | int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val); |
50 | int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val); | 54 | int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val); |
51 | int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val); | 55 | int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val); |
@@ -57,95 +61,15 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val); | |||
57 | int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); | 61 | int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); |
58 | int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | 62 | int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val); |
59 | 63 | ||
60 | static struct m5602_sensor s5k83a = { | 64 | static const struct m5602_sensor s5k83a = { |
61 | .name = "S5K83A", | 65 | .name = "S5K83A", |
62 | .probe = s5k83a_probe, | 66 | .probe = s5k83a_probe, |
63 | .init = s5k83a_init, | 67 | .init = s5k83a_init, |
68 | .start = s5k83a_start, | ||
69 | .stop = s5k83a_stop, | ||
64 | .power_down = s5k83a_power_down, | 70 | .power_down = s5k83a_power_down, |
65 | .i2c_slave_id = 0x5a, | 71 | .i2c_slave_id = 0x5a, |
66 | .i2c_regW = 2, | 72 | .i2c_regW = 2, |
67 | .nctrls = 5, | ||
68 | .ctrls = { | ||
69 | { | ||
70 | { | ||
71 | .id = V4L2_CID_BRIGHTNESS, | ||
72 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
73 | .name = "brightness", | ||
74 | .minimum = 0x00, | ||
75 | .maximum = 0xff, | ||
76 | .step = 0x01, | ||
77 | .default_value = S5K83A_DEFAULT_BRIGHTNESS, | ||
78 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
79 | }, | ||
80 | .set = s5k83a_set_brightness, | ||
81 | .get = s5k83a_get_brightness | ||
82 | |||
83 | }, { | ||
84 | { | ||
85 | .id = V4L2_CID_WHITENESS, | ||
86 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
87 | .name = "whiteness", | ||
88 | .minimum = 0x00, | ||
89 | .maximum = 0xff, | ||
90 | .step = 0x01, | ||
91 | .default_value = S5K83A_DEFAULT_WHITENESS, | ||
92 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
93 | }, | ||
94 | .set = s5k83a_set_whiteness, | ||
95 | .get = s5k83a_get_whiteness, | ||
96 | }, { | ||
97 | { | ||
98 | .id = V4L2_CID_GAIN, | ||
99 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
100 | .name = "gain", | ||
101 | .minimum = 0x00, | ||
102 | .maximum = S5K83A_MAXIMUM_GAIN, | ||
103 | .step = 0x01, | ||
104 | .default_value = S5K83A_DEFAULT_GAIN, | ||
105 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
106 | }, | ||
107 | .set = s5k83a_set_gain, | ||
108 | .get = s5k83a_get_gain | ||
109 | }, { | ||
110 | { | ||
111 | .id = V4L2_CID_HFLIP, | ||
112 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
113 | .name = "horizontal flip", | ||
114 | .minimum = 0, | ||
115 | .maximum = 1, | ||
116 | .step = 1, | ||
117 | .default_value = 0 | ||
118 | }, | ||
119 | .set = s5k83a_set_hflip, | ||
120 | .get = s5k83a_get_hflip | ||
121 | }, { | ||
122 | { | ||
123 | .id = V4L2_CID_VFLIP, | ||
124 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
125 | .name = "vertical flip", | ||
126 | .minimum = 0, | ||
127 | .maximum = 1, | ||
128 | .step = 1, | ||
129 | .default_value = 0 | ||
130 | }, | ||
131 | .set = s5k83a_set_vflip, | ||
132 | .get = s5k83a_get_vflip | ||
133 | } | ||
134 | }, | ||
135 | .nmodes = 1, | ||
136 | .modes = { | ||
137 | { | ||
138 | M5602_DEFAULT_FRAME_WIDTH, | ||
139 | M5602_DEFAULT_FRAME_HEIGHT, | ||
140 | V4L2_PIX_FMT_SBGGR8, | ||
141 | V4L2_FIELD_NONE, | ||
142 | .sizeimage = | ||
143 | M5602_DEFAULT_FRAME_WIDTH * M5602_DEFAULT_FRAME_HEIGHT, | ||
144 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, | ||
145 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
146 | .priv = 1 | ||
147 | } | ||
148 | } | ||
149 | }; | 73 | }; |
150 | 74 | ||
151 | static const unsigned char preinit_s5k83a[][4] = | 75 | static const unsigned char preinit_s5k83a[][4] = |
@@ -381,7 +305,7 @@ static const unsigned char init_s5k83a[][4] = | |||
381 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, | 305 | {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, |
382 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00}, | 306 | {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00}, |
383 | {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00}, | 307 | {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00}, |
384 | {BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00}, | 308 | {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00}, |
385 | {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00}, | 309 | {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00}, |
386 | {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00}, | 310 | {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00}, |
387 | {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00}, | 311 | {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00}, |
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h index 261623f0da48..0d3026936f2e 100644 --- a/drivers/media/video/gspca/m5602/m5602_sensor.h +++ b/drivers/media/video/gspca/m5602/m5602_sensor.h | |||
@@ -21,11 +21,6 @@ | |||
21 | 21 | ||
22 | #include "m5602_bridge.h" | 22 | #include "m5602_bridge.h" |
23 | 23 | ||
24 | #define M5602_DEFAULT_FRAME_WIDTH 640 | ||
25 | #define M5602_DEFAULT_FRAME_HEIGHT 480 | ||
26 | |||
27 | #define M5602_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10) | ||
28 | |||
29 | /* Enumerates all supported sensors */ | 24 | /* Enumerates all supported sensors */ |
30 | enum sensors { | 25 | enum sensors { |
31 | OV9650_SENSOR = 1, | 26 | OV9650_SENSOR = 1, |
@@ -61,14 +56,14 @@ struct m5602_sensor { | |||
61 | /* Executed when the camera starts to send data */ | 56 | /* Executed when the camera starts to send data */ |
62 | int (*start)(struct sd *sd); | 57 | int (*start)(struct sd *sd); |
63 | 58 | ||
64 | /* Performs a power down sequence */ | 59 | /* Executed when the camera ends to send data */ |
65 | int (*power_down)(struct sd *sd); | 60 | int (*stop)(struct sd *sd); |
66 | 61 | ||
67 | int nctrls; | 62 | /* Executed when the device is disconnected */ |
68 | struct ctrl ctrls[M5602_MAX_CTRLS]; | 63 | void (*disconnect)(struct sd *sd); |
69 | 64 | ||
70 | char nmodes; | 65 | /* Performs a power down sequence */ |
71 | struct v4l2_pix_format modes[]; | 66 | int (*power_down)(struct sd *sd); |
72 | }; | 67 | }; |
73 | 68 | ||
74 | #endif | 69 | #endif |
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c index 04e3ae57a2e3..2e1cdf068fda 100644 --- a/drivers/media/video/gspca/sq905.c +++ b/drivers/media/video/gspca/sq905.c | |||
@@ -360,6 +360,12 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
360 | gspca_dev->cam.nmodes = ARRAY_SIZE(sq905_mode); | 360 | gspca_dev->cam.nmodes = ARRAY_SIZE(sq905_mode); |
361 | if (!(ident & SQ905_HIRES_MASK)) | 361 | if (!(ident & SQ905_HIRES_MASK)) |
362 | gspca_dev->cam.nmodes--; | 362 | gspca_dev->cam.nmodes--; |
363 | |||
364 | if (ident & SQ905_ORIENTATION_MASK) | ||
365 | gspca_dev->cam.input_flags = V4L2_IN_ST_VFLIP; | ||
366 | else | ||
367 | gspca_dev->cam.input_flags = V4L2_IN_ST_VFLIP | | ||
368 | V4L2_IN_ST_HFLIP; | ||
363 | return 0; | 369 | return 0; |
364 | } | 370 | } |
365 | 371 | ||
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index 4c802fb12cd6..e4e933c400bc 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c | |||
@@ -159,37 +159,16 @@ static const struct v4l2_pix_format vc0323_mode[] = { | |||
159 | .priv = 2}, | 159 | .priv = 2}, |
160 | }; | 160 | }; |
161 | static const struct v4l2_pix_format bi_mode[] = { | 161 | static const struct v4l2_pix_format bi_mode[] = { |
162 | /*fixme: jeg does not work | ||
163 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
164 | .bytesperline = 320, | ||
165 | .sizeimage = 320 * 240 * 3 / 8 + 590, | ||
166 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
167 | .priv = 5}, | ||
168 | */ | ||
169 | {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, | 162 | {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, |
170 | .bytesperline = 320, | 163 | .bytesperline = 320, |
171 | .sizeimage = 320 * 240 * 2, | 164 | .sizeimage = 320 * 240 * 2, |
172 | .colorspace = V4L2_COLORSPACE_SRGB, | 165 | .colorspace = V4L2_COLORSPACE_SRGB, |
173 | .priv = 4}, | 166 | .priv = 2}, |
174 | /* | ||
175 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
176 | .bytesperline = 640, | ||
177 | .sizeimage = 640 * 480 * 3 / 8 + 590, | ||
178 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
179 | .priv = 3}, | ||
180 | */ | ||
181 | {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, | 167 | {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, |
182 | .bytesperline = 640, | 168 | .bytesperline = 640, |
183 | .sizeimage = 640 * 480 * 2, | 169 | .sizeimage = 640 * 480 * 2, |
184 | .colorspace = V4L2_COLORSPACE_SRGB, | 170 | .colorspace = V4L2_COLORSPACE_SRGB, |
185 | .priv = 2}, | ||
186 | /* | ||
187 | {1280, 1024, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
188 | .bytesperline = 1280, | ||
189 | .sizeimage = 1280 * 1024 * 1 / 4 + 590, | ||
190 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
191 | .priv = 1}, | 171 | .priv = 1}, |
192 | */ | ||
193 | {1280, 1024, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, | 172 | {1280, 1024, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, |
194 | .bytesperline = 1280, | 173 | .bytesperline = 1280, |
195 | .sizeimage = 1280 * 1024 * 2, | 174 | .sizeimage = 1280 * 1024 * 2, |
@@ -1034,121 +1013,6 @@ static const u8 mi1320_soc_InitVGA[][4] = { | |||
1034 | {0xb3, 0x5c, 0x01, 0xcc}, | 1013 | {0xb3, 0x5c, 0x01, 0xcc}, |
1035 | {} | 1014 | {} |
1036 | }; | 1015 | }; |
1037 | static const u8 mi1320_soc_InitVGA_JPG[][4] = { | ||
1038 | {0xb3, 0x01, 0x01, 0xcc}, | ||
1039 | {0xb0, 0x03, 0x19, 0xcc}, | ||
1040 | {0xb0, 0x04, 0x02, 0xcc}, | ||
1041 | {0x00, 0x00, 0x30, 0xdd}, | ||
1042 | {0xb3, 0x00, 0x64, 0xcc}, | ||
1043 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1044 | {0xb3, 0x05, 0x01, 0xcc}, | ||
1045 | {0xb3, 0x06, 0x01, 0xcc}, | ||
1046 | {0xb3, 0x08, 0x01, 0xcc}, | ||
1047 | {0xb3, 0x09, 0x0c, 0xcc}, | ||
1048 | {0xb3, 0x34, 0x02, 0xcc}, | ||
1049 | {0xb3, 0x35, 0xc8, 0xcc}, | ||
1050 | {0xb3, 0x02, 0x00, 0xcc}, | ||
1051 | {0xb3, 0x03, 0x0a, 0xcc}, | ||
1052 | {0xb3, 0x04, 0x05, 0xcc}, | ||
1053 | {0xb3, 0x20, 0x00, 0xcc}, | ||
1054 | {0xb3, 0x21, 0x00, 0xcc}, | ||
1055 | {0xb3, 0x22, 0x01, 0xcc}, | ||
1056 | {0xb3, 0x23, 0xe0, 0xcc}, | ||
1057 | {0xb3, 0x14, 0x00, 0xcc}, | ||
1058 | {0xb3, 0x15, 0x00, 0xcc}, | ||
1059 | {0xb3, 0x16, 0x02, 0xcc}, | ||
1060 | {0xb3, 0x17, 0x7f, 0xcc}, | ||
1061 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1062 | {0xb8, 0x00, 0x00, 0xcc}, | ||
1063 | {0xbc, 0x00, 0x71, 0xcc}, | ||
1064 | {0xbc, 0x01, 0x01, 0xcc}, | ||
1065 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1066 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1067 | {0x00, 0x00, 0x10, 0xdd}, | ||
1068 | {0xc8, 0x00, 0x00, 0xbb}, | ||
1069 | {0x00, 0x00, 0x30, 0xdd}, | ||
1070 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1071 | {0x00, 0x00, 0x10, 0xdd}, | ||
1072 | {0x07, 0x00, 0xe0, 0xbb}, | ||
1073 | {0x08, 0x00, 0x0b, 0xbb}, | ||
1074 | {0x21, 0x00, 0x0c, 0xbb}, | ||
1075 | {0x20, 0x01, 0x03, 0xbb}, | ||
1076 | {0xb6, 0x00, 0x00, 0xcc}, | ||
1077 | {0xb6, 0x03, 0x02, 0xcc}, | ||
1078 | {0xb6, 0x02, 0x80, 0xcc}, | ||
1079 | {0xb6, 0x05, 0x01, 0xcc}, | ||
1080 | {0xb6, 0x04, 0xe0, 0xcc}, | ||
1081 | {0xb6, 0x12, 0xf8, 0xcc}, | ||
1082 | {0xb6, 0x13, 0x05, 0xcc}, | ||
1083 | {0xb6, 0x18, 0x02, 0xcc}, | ||
1084 | {0xb6, 0x17, 0x58, 0xcc}, | ||
1085 | {0xb6, 0x16, 0x00, 0xcc}, | ||
1086 | {0xb6, 0x22, 0x12, 0xcc}, | ||
1087 | {0xb6, 0x23, 0x0b, 0xcc}, | ||
1088 | {0xbf, 0xc0, 0x39, 0xcc}, | ||
1089 | {0xbf, 0xc1, 0x04, 0xcc}, | ||
1090 | {0xbf, 0xcc, 0x00, 0xcc}, | ||
1091 | {0xb3, 0x01, 0x41, 0xcc}, | ||
1092 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1093 | {0x05, 0x01, 0x78, 0xbb}, | ||
1094 | {0x06, 0x00, 0x11, 0xbb}, | ||
1095 | {0x07, 0x01, 0x42, 0xbb}, | ||
1096 | {0x08, 0x00, 0x11, 0xbb}, | ||
1097 | {0x20, 0x01, 0x03, 0xbb}, | ||
1098 | {0x21, 0x80, 0x00, 0xbb}, | ||
1099 | {0x22, 0x0d, 0x0f, 0xbb}, | ||
1100 | {0x24, 0x80, 0x00, 0xbb}, | ||
1101 | {0x59, 0x00, 0xff, 0xbb}, | ||
1102 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1103 | {0x39, 0x03, 0xca, 0xbb}, | ||
1104 | {0x3a, 0x06, 0x80, 0xbb}, | ||
1105 | {0x3b, 0x01, 0x52, 0xbb}, | ||
1106 | {0x3c, 0x05, 0x40, 0xbb}, | ||
1107 | {0x57, 0x01, 0x9c, 0xbb}, | ||
1108 | {0x58, 0x01, 0xee, 0xbb}, | ||
1109 | {0x59, 0x00, 0xf0, 0xbb}, | ||
1110 | {0x5a, 0x01, 0x20, 0xbb}, | ||
1111 | {0x5c, 0x1d, 0x17, 0xbb}, | ||
1112 | {0x5d, 0x22, 0x1c, 0xbb}, | ||
1113 | {0x64, 0x1e, 0x1c, 0xbb}, | ||
1114 | {0x5b, 0x00, 0x00, 0xbb}, | ||
1115 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1116 | {0x22, 0xa0, 0x78, 0xbb}, | ||
1117 | {0x23, 0xa0, 0x78, 0xbb}, | ||
1118 | {0x24, 0x7f, 0x00, 0xbb}, | ||
1119 | {0x28, 0xea, 0x02, 0xbb}, | ||
1120 | {0x29, 0x86, 0x7a, 0xbb}, | ||
1121 | {0x5e, 0x52, 0x4c, 0xbb}, | ||
1122 | {0x5f, 0x20, 0x24, 0xbb}, | ||
1123 | {0x60, 0x00, 0x02, 0xbb}, | ||
1124 | {0x02, 0x00, 0xee, 0xbb}, | ||
1125 | {0x03, 0x39, 0x23, 0xbb}, | ||
1126 | {0x04, 0x07, 0x24, 0xbb}, | ||
1127 | {0x09, 0x00, 0xc0, 0xbb}, | ||
1128 | {0x0a, 0x00, 0x79, 0xbb}, | ||
1129 | {0x0b, 0x00, 0x04, 0xbb}, | ||
1130 | {0x0c, 0x00, 0x5c, 0xbb}, | ||
1131 | {0x0d, 0x00, 0xd9, 0xbb}, | ||
1132 | {0x0e, 0x00, 0x53, 0xbb}, | ||
1133 | {0x0f, 0x00, 0x21, 0xbb}, | ||
1134 | {0x10, 0x00, 0xa4, 0xbb}, | ||
1135 | {0x11, 0x00, 0xe5, 0xbb}, | ||
1136 | {0x15, 0x00, 0x00, 0xbb}, | ||
1137 | {0x16, 0x00, 0x00, 0xbb}, | ||
1138 | {0x17, 0x00, 0x00, 0xbb}, | ||
1139 | {0x18, 0x00, 0x00, 0xbb}, | ||
1140 | {0x19, 0x00, 0x00, 0xbb}, | ||
1141 | {0x1a, 0x00, 0x00, 0xbb}, | ||
1142 | {0x1b, 0x00, 0x00, 0xbb}, | ||
1143 | {0x1c, 0x00, 0x00, 0xbb}, | ||
1144 | {0x1d, 0x00, 0x00, 0xbb}, | ||
1145 | {0x1e, 0x00, 0x00, 0xbb}, | ||
1146 | {0xf0, 0x00, 0x01, 0xbb}, | ||
1147 | {0x06, 0xe0, 0x0e, 0xbb}, | ||
1148 | {0x06, 0x60, 0x0e, 0xbb}, | ||
1149 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1150 | {} | ||
1151 | }; | ||
1152 | static const u8 mi1320_soc_InitQVGA[][4] = { | 1016 | static const u8 mi1320_soc_InitQVGA[][4] = { |
1153 | {0xb3, 0x01, 0x01, 0xcc}, | 1017 | {0xb3, 0x01, 0x01, 0xcc}, |
1154 | {0xb0, 0x03, 0x19, 0xcc}, | 1018 | {0xb0, 0x03, 0x19, 0xcc}, |
@@ -1262,268 +1126,6 @@ static const u8 mi1320_soc_InitQVGA[][4] = { | |||
1262 | {0xb3, 0x5c, 0x01, 0xcc}, | 1126 | {0xb3, 0x5c, 0x01, 0xcc}, |
1263 | {} | 1127 | {} |
1264 | }; | 1128 | }; |
1265 | static const u8 mi1320_soc_InitQVGA_JPG[][4] = { | ||
1266 | {0xb3, 0x01, 0x01, 0xcc}, | ||
1267 | {0xb0, 0x03, 0x19, 0xcc}, | ||
1268 | {0xb0, 0x04, 0x02, 0xcc}, | ||
1269 | {0x00, 0x00, 0x30, 0xdd}, | ||
1270 | {0xb3, 0x00, 0x64, 0xcc}, | ||
1271 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1272 | {0xb3, 0x05, 0x01, 0xcc}, | ||
1273 | {0xb3, 0x06, 0x01, 0xcc}, | ||
1274 | {0xb3, 0x08, 0x01, 0xcc}, | ||
1275 | {0xb3, 0x09, 0x0c, 0xcc}, | ||
1276 | {0xb3, 0x34, 0x02, 0xcc}, | ||
1277 | {0xb3, 0x35, 0xc8, 0xcc}, | ||
1278 | {0xb3, 0x02, 0x00, 0xcc}, | ||
1279 | {0xb3, 0x03, 0x0a, 0xcc}, | ||
1280 | {0xb3, 0x04, 0x05, 0xcc}, | ||
1281 | {0xb3, 0x20, 0x00, 0xcc}, | ||
1282 | {0xb3, 0x21, 0x00, 0xcc}, | ||
1283 | {0xb3, 0x22, 0x01, 0xcc}, | ||
1284 | {0xb3, 0x23, 0xe0, 0xcc}, | ||
1285 | {0xb3, 0x14, 0x00, 0xcc}, | ||
1286 | {0xb3, 0x15, 0x00, 0xcc}, | ||
1287 | {0xb3, 0x16, 0x02, 0xcc}, | ||
1288 | {0xb3, 0x17, 0x7f, 0xcc}, | ||
1289 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1290 | {0xb8, 0x00, 0x00, 0xcc}, | ||
1291 | {0xbc, 0x00, 0xd1, 0xcc}, | ||
1292 | {0xbc, 0x01, 0x01, 0xcc}, | ||
1293 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1294 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1295 | {0x00, 0x00, 0x10, 0xdd}, | ||
1296 | {0xc8, 0x00, 0x00, 0xbb}, | ||
1297 | {0x00, 0x00, 0x30, 0xdd}, | ||
1298 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1299 | {0x00, 0x00, 0x10, 0xdd}, | ||
1300 | {0x07, 0x00, 0xe0, 0xbb}, | ||
1301 | {0x08, 0x00, 0x0b, 0xbb}, | ||
1302 | {0x21, 0x00, 0x0c, 0xbb}, | ||
1303 | {0x20, 0x01, 0x03, 0xbb}, | ||
1304 | {0xb6, 0x00, 0x00, 0xcc}, | ||
1305 | {0xb6, 0x03, 0x01, 0xcc}, | ||
1306 | {0xb6, 0x02, 0x40, 0xcc}, | ||
1307 | {0xb6, 0x05, 0x00, 0xcc}, | ||
1308 | {0xb6, 0x04, 0xf0, 0xcc}, | ||
1309 | {0xb6, 0x12, 0xf8, 0xcc}, | ||
1310 | {0xb6, 0x13, 0x05, 0xcc}, | ||
1311 | {0xb6, 0x18, 0x00, 0xcc}, | ||
1312 | {0xb6, 0x17, 0x96, 0xcc}, | ||
1313 | {0xb6, 0x16, 0x00, 0xcc}, | ||
1314 | {0xb6, 0x22, 0x12, 0xcc}, | ||
1315 | {0xb6, 0x23, 0x0b, 0xcc}, | ||
1316 | {0xbf, 0xc0, 0x39, 0xcc}, | ||
1317 | {0xbf, 0xc1, 0x04, 0xcc}, | ||
1318 | {0xbf, 0xcc, 0x00, 0xcc}, | ||
1319 | {0xbc, 0x02, 0x18, 0xcc}, | ||
1320 | {0xbc, 0x03, 0x50, 0xcc}, | ||
1321 | {0xbc, 0x04, 0x18, 0xcc}, | ||
1322 | {0xbc, 0x05, 0x00, 0xcc}, | ||
1323 | {0xbc, 0x06, 0x00, 0xcc}, | ||
1324 | {0xbc, 0x08, 0x30, 0xcc}, | ||
1325 | {0xbc, 0x09, 0x40, 0xcc}, | ||
1326 | {0xbc, 0x0a, 0x10, 0xcc}, | ||
1327 | {0xbc, 0x0b, 0x00, 0xcc}, | ||
1328 | {0xbc, 0x0c, 0x00, 0xcc}, | ||
1329 | {0xb3, 0x01, 0x41, 0xcc}, | ||
1330 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1331 | {0x05, 0x01, 0x78, 0xbb}, | ||
1332 | {0x06, 0x00, 0x11, 0xbb}, | ||
1333 | {0x07, 0x01, 0x42, 0xbb}, | ||
1334 | {0x08, 0x00, 0x11, 0xbb}, | ||
1335 | {0x20, 0x01, 0x03, 0xbb}, | ||
1336 | {0x21, 0x80, 0x00, 0xbb}, | ||
1337 | {0x22, 0x0d, 0x0f, 0xbb}, | ||
1338 | {0x24, 0x80, 0x00, 0xbb}, | ||
1339 | {0x59, 0x00, 0xff, 0xbb}, | ||
1340 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1341 | {0x39, 0x03, 0xca, 0xbb}, | ||
1342 | {0x3a, 0x06, 0x80, 0xbb}, | ||
1343 | {0x3b, 0x01, 0x52, 0xbb}, | ||
1344 | {0x3c, 0x05, 0x40, 0xbb}, | ||
1345 | {0x57, 0x01, 0x9c, 0xbb}, | ||
1346 | {0x58, 0x01, 0xee, 0xbb}, | ||
1347 | {0x59, 0x00, 0xf0, 0xbb}, | ||
1348 | {0x5a, 0x01, 0x20, 0xbb}, | ||
1349 | {0x5c, 0x1d, 0x17, 0xbb}, | ||
1350 | {0x5d, 0x22, 0x1c, 0xbb}, | ||
1351 | {0x64, 0x1e, 0x1c, 0xbb}, | ||
1352 | {0x5b, 0x00, 0x00, 0xbb}, | ||
1353 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1354 | {0x22, 0xa0, 0x78, 0xbb}, | ||
1355 | {0x23, 0xa0, 0x78, 0xbb}, | ||
1356 | {0x24, 0x7f, 0x00, 0xbb}, | ||
1357 | {0x28, 0xea, 0x02, 0xbb}, | ||
1358 | {0x29, 0x86, 0x7a, 0xbb}, | ||
1359 | {0x5e, 0x52, 0x4c, 0xbb}, | ||
1360 | {0x5f, 0x20, 0x24, 0xbb}, | ||
1361 | {0x60, 0x00, 0x02, 0xbb}, | ||
1362 | {0x02, 0x00, 0xee, 0xbb}, | ||
1363 | {0x03, 0x39, 0x23, 0xbb}, | ||
1364 | {0x04, 0x07, 0x24, 0xbb}, | ||
1365 | {0x09, 0x00, 0xc0, 0xbb}, | ||
1366 | {0x0a, 0x00, 0x79, 0xbb}, | ||
1367 | {0x0b, 0x00, 0x04, 0xbb}, | ||
1368 | {0x0c, 0x00, 0x5c, 0xbb}, | ||
1369 | {0x0d, 0x00, 0xd9, 0xbb}, | ||
1370 | {0x0e, 0x00, 0x53, 0xbb}, | ||
1371 | {0x0f, 0x00, 0x21, 0xbb}, | ||
1372 | {0x10, 0x00, 0xa4, 0xbb}, | ||
1373 | {0x11, 0x00, 0xe5, 0xbb}, | ||
1374 | {0x15, 0x00, 0x00, 0xbb}, | ||
1375 | {0x16, 0x00, 0x00, 0xbb}, | ||
1376 | {0x17, 0x00, 0x00, 0xbb}, | ||
1377 | {0x18, 0x00, 0x00, 0xbb}, | ||
1378 | {0x19, 0x00, 0x00, 0xbb}, | ||
1379 | {0x1a, 0x00, 0x00, 0xbb}, | ||
1380 | {0x1b, 0x00, 0x00, 0xbb}, | ||
1381 | {0x1c, 0x00, 0x00, 0xbb}, | ||
1382 | {0x1d, 0x00, 0x00, 0xbb}, | ||
1383 | {0x1e, 0x00, 0x00, 0xbb}, | ||
1384 | {0xf0, 0x00, 0x01, 0xbb}, | ||
1385 | {0x06, 0xe0, 0x0e, 0xbb}, | ||
1386 | {0x06, 0x60, 0x0e, 0xbb}, | ||
1387 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1388 | {} | ||
1389 | }; | ||
1390 | static const u8 mi1320_soc_InitSXGA_JPG[][4] = { | ||
1391 | {0xb3, 0x01, 0x01, 0xcc}, | ||
1392 | {0xb0, 0x03, 0x19, 0xcc}, | ||
1393 | {0xb0, 0x04, 0x02, 0xcc}, | ||
1394 | {0x00, 0x00, 0x33, 0xdd}, | ||
1395 | {0xb3, 0x00, 0x64, 0xcc}, | ||
1396 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1397 | {0xb3, 0x05, 0x00, 0xcc}, | ||
1398 | {0xb3, 0x06, 0x00, 0xcc}, | ||
1399 | {0xb3, 0x08, 0x01, 0xcc}, | ||
1400 | {0xb3, 0x09, 0x0c, 0xcc}, | ||
1401 | {0xb3, 0x34, 0x02, 0xcc}, | ||
1402 | {0xb3, 0x35, 0xc8, 0xcc}, | ||
1403 | {0xb3, 0x02, 0x00, 0xcc}, | ||
1404 | {0xb3, 0x03, 0x0a, 0xcc}, | ||
1405 | {0xb3, 0x04, 0x05, 0xcc}, | ||
1406 | {0xb3, 0x20, 0x00, 0xcc}, | ||
1407 | {0xb3, 0x21, 0x00, 0xcc}, | ||
1408 | {0xb3, 0x22, 0x04, 0xcc}, | ||
1409 | {0xb3, 0x23, 0x00, 0xcc}, | ||
1410 | {0xb3, 0x14, 0x00, 0xcc}, | ||
1411 | {0xb3, 0x15, 0x00, 0xcc}, | ||
1412 | {0xb3, 0x16, 0x04, 0xcc}, | ||
1413 | {0xb3, 0x17, 0xff, 0xcc}, | ||
1414 | {0xb3, 0x00, 0x67, 0xcc}, | ||
1415 | {0xbc, 0x00, 0x71, 0xcc}, | ||
1416 | {0xbc, 0x01, 0x01, 0xcc}, | ||
1417 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1418 | {0x00, 0x00, 0x30, 0xdd}, | ||
1419 | {0xc8, 0x9f, 0x0b, 0xbb}, | ||
1420 | {0x00, 0x00, 0x20, 0xdd}, | ||
1421 | {0x5b, 0x00, 0x01, 0xbb}, | ||
1422 | {0x00, 0x00, 0x20, 0xdd}, | ||
1423 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1424 | {0x00, 0x00, 0x30, 0xdd}, | ||
1425 | {0x20, 0x01, 0x03, 0xbb}, | ||
1426 | {0x00, 0x00, 0x20, 0xdd}, | ||
1427 | {0xb6, 0x00, 0x00, 0xcc}, | ||
1428 | {0xb6, 0x03, 0x05, 0xcc}, | ||
1429 | {0xb6, 0x02, 0x00, 0xcc}, | ||
1430 | {0xb6, 0x05, 0x04, 0xcc}, | ||
1431 | {0xb6, 0x04, 0x00, 0xcc}, | ||
1432 | {0xb6, 0x12, 0xf8, 0xcc}, | ||
1433 | {0xb6, 0x13, 0x29, 0xcc}, | ||
1434 | {0xb6, 0x18, 0x0a, 0xcc}, | ||
1435 | {0xb6, 0x17, 0x00, 0xcc}, | ||
1436 | {0xb6, 0x16, 0x00, 0xcc}, | ||
1437 | {0xb6, 0x22, 0x12, 0xcc}, | ||
1438 | {0xb6, 0x23, 0x0b, 0xcc}, | ||
1439 | {0xbf, 0xc0, 0x39, 0xcc}, | ||
1440 | {0xbf, 0xc1, 0x04, 0xcc}, | ||
1441 | {0xbf, 0xcc, 0x00, 0xcc}, | ||
1442 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1443 | {0xb3, 0x01, 0x41, 0xcc}, | ||
1444 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1445 | {0x05, 0x01, 0x78, 0xbb}, | ||
1446 | {0x06, 0x00, 0x11, 0xbb}, | ||
1447 | {0x07, 0x01, 0x42, 0xbb}, | ||
1448 | {0x08, 0x00, 0x11, 0xbb}, | ||
1449 | {0x20, 0x01, 0x03, 0xbb}, | ||
1450 | {0x21, 0x80, 0x00, 0xbb}, | ||
1451 | {0x22, 0x0d, 0x0f, 0xbb}, | ||
1452 | {0x24, 0x80, 0x00, 0xbb}, | ||
1453 | {0x59, 0x00, 0xff, 0xbb}, | ||
1454 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1455 | {0x39, 0x03, 0xca, 0xbb}, | ||
1456 | {0x3a, 0x06, 0x80, 0xbb}, | ||
1457 | {0x3b, 0x01, 0x52, 0xbb}, | ||
1458 | {0x3c, 0x05, 0x40, 0xbb}, | ||
1459 | {0x57, 0x01, 0x9c, 0xbb}, | ||
1460 | {0x58, 0x01, 0xee, 0xbb}, | ||
1461 | {0x59, 0x00, 0xf0, 0xbb}, | ||
1462 | {0x5a, 0x01, 0x20, 0xbb}, | ||
1463 | {0x5c, 0x1d, 0x17, 0xbb}, | ||
1464 | {0x5d, 0x22, 0x1c, 0xbb}, | ||
1465 | {0x64, 0x1e, 0x1c, 0xbb}, | ||
1466 | {0x5b, 0x00, 0x00, 0xbb}, | ||
1467 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1468 | {0x22, 0xa0, 0x78, 0xbb}, | ||
1469 | {0x23, 0xa0, 0x78, 0xbb}, | ||
1470 | {0x24, 0x7f, 0x00, 0xbb}, | ||
1471 | {0x28, 0xea, 0x02, 0xbb}, | ||
1472 | {0x29, 0x86, 0x7a, 0xbb}, | ||
1473 | {0x5e, 0x52, 0x4c, 0xbb}, | ||
1474 | {0x5f, 0x20, 0x24, 0xbb}, | ||
1475 | {0x60, 0x00, 0x02, 0xbb}, | ||
1476 | {0x02, 0x00, 0xee, 0xbb}, | ||
1477 | {0x03, 0x39, 0x23, 0xbb}, | ||
1478 | {0x04, 0x07, 0x24, 0xbb}, | ||
1479 | {0x09, 0x00, 0xc0, 0xbb}, | ||
1480 | {0x0a, 0x00, 0x79, 0xbb}, | ||
1481 | {0x0b, 0x00, 0x04, 0xbb}, | ||
1482 | {0x0c, 0x00, 0x5c, 0xbb}, | ||
1483 | {0x0d, 0x00, 0xd9, 0xbb}, | ||
1484 | {0x0e, 0x00, 0x53, 0xbb}, | ||
1485 | {0x0f, 0x00, 0x21, 0xbb}, | ||
1486 | {0x10, 0x00, 0xa4, 0xbb}, | ||
1487 | {0x11, 0x00, 0xe5, 0xbb}, | ||
1488 | {0x15, 0x00, 0x00, 0xbb}, | ||
1489 | {0x16, 0x00, 0x00, 0xbb}, | ||
1490 | {0x17, 0x00, 0x00, 0xbb}, | ||
1491 | {0x18, 0x00, 0x00, 0xbb}, | ||
1492 | {0x19, 0x00, 0x00, 0xbb}, | ||
1493 | {0x1a, 0x00, 0x00, 0xbb}, | ||
1494 | {0x1b, 0x00, 0x00, 0xbb}, | ||
1495 | {0x1c, 0x00, 0x00, 0xbb}, | ||
1496 | {0x1d, 0x00, 0x00, 0xbb}, | ||
1497 | {0x1e, 0x00, 0x00, 0xbb}, | ||
1498 | {0xf0, 0x00, 0x01, 0xbb}, | ||
1499 | {0x06, 0xe0, 0x0e, 0xbb}, | ||
1500 | {0x06, 0x60, 0x0e, 0xbb}, | ||
1501 | {0xb3, 0x5c, 0x01, 0xcc}, | ||
1502 | {0xf0, 0x00, 0x00, 0xbb}, | ||
1503 | {0x05, 0x01, 0x13, 0xbb}, | ||
1504 | {0x06, 0x00, 0x11, 0xbb}, | ||
1505 | {0x07, 0x00, 0x85, 0xbb}, | ||
1506 | {0x08, 0x00, 0x27, 0xbb}, | ||
1507 | {0x20, 0x01, 0x03, 0xbb}, | ||
1508 | {0x21, 0x80, 0x00, 0xbb}, | ||
1509 | {0x22, 0x0d, 0x0f, 0xbb}, | ||
1510 | {0x24, 0x80, 0x00, 0xbb}, | ||
1511 | {0x59, 0x00, 0xff, 0xbb}, | ||
1512 | {0xf0, 0x00, 0x02, 0xbb}, | ||
1513 | {0x39, 0x03, 0x0d, 0xbb}, | ||
1514 | {0x3a, 0x06, 0x1b, 0xbb}, | ||
1515 | {0x3b, 0x00, 0x95, 0xbb}, | ||
1516 | {0x3c, 0x04, 0xdb, 0xbb}, | ||
1517 | {0x57, 0x02, 0x00, 0xbb}, | ||
1518 | {0x58, 0x02, 0x66, 0xbb}, | ||
1519 | {0x59, 0x00, 0xff, 0xbb}, | ||
1520 | {0x5a, 0x01, 0x33, 0xbb}, | ||
1521 | {0x5c, 0x12, 0x0d, 0xbb}, | ||
1522 | {0x5d, 0x16, 0x11, 0xbb}, | ||
1523 | {0x64, 0x5e, 0x1c, 0xbb}, | ||
1524 | {0x2f, 0x90, 0x00, 0xbb}, | ||
1525 | {} | ||
1526 | }; | ||
1527 | static const u8 mi1320_soc_InitSXGA[][4] = { | 1129 | static const u8 mi1320_soc_InitSXGA[][4] = { |
1528 | {0xb3, 0x01, 0x01, 0xcc}, | 1130 | {0xb3, 0x01, 0x01, 0xcc}, |
1529 | {0xb0, 0x03, 0x19, 0xcc}, | 1131 | {0xb0, 0x03, 0x19, 0xcc}, |
@@ -3015,11 +2617,8 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
3015 | int mode; | 2617 | int mode; |
3016 | static const u8 (*mi1320_soc_init[])[4] = { | 2618 | static const u8 (*mi1320_soc_init[])[4] = { |
3017 | mi1320_soc_InitSXGA, | 2619 | mi1320_soc_InitSXGA, |
3018 | mi1320_soc_InitSXGA_JPG, | ||
3019 | mi1320_soc_InitVGA, | 2620 | mi1320_soc_InitVGA, |
3020 | mi1320_soc_InitVGA_JPG, | ||
3021 | mi1320_soc_InitQVGA, | 2621 | mi1320_soc_InitQVGA, |
3022 | mi1320_soc_InitQVGA_JPG | ||
3023 | }; | 2622 | }; |
3024 | 2623 | ||
3025 | /* Assume start use the good resolution from gspca_dev->mode */ | 2624 | /* Assume start use the good resolution from gspca_dev->mode */ |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index eca8bf92a225..b0195e8ee4d1 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -884,12 +884,9 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
884 | } | 884 | } |
885 | else if (itv->card->type == IVTV_CARD_GV_MVPRX || | 885 | else if (itv->card->type == IVTV_CARD_GV_MVPRX || |
886 | itv->card->type == IVTV_CARD_GV_MVPRX2E) { | 886 | itv->card->type == IVTV_CARD_GV_MVPRX2E) { |
887 | struct v4l2_crystal_freq crystal_freq; | ||
888 | |||
889 | /* The crystal frequency of GVMVPRX is 24.576MHz */ | 887 | /* The crystal frequency of GVMVPRX is 24.576MHz */ |
890 | crystal_freq.freq = SAA7115_FREQ_24_576_MHZ; | 888 | v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, |
891 | crystal_freq.flags = SAA7115_FREQ_FL_UCGC; | 889 | SAA7115_FREQ_24_576_MHZ, SAA7115_FREQ_FL_UCGC); |
892 | v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, &crystal_freq); | ||
893 | } | 890 | } |
894 | 891 | ||
895 | if (hw & IVTV_HW_CX25840) { | 892 | if (hw & IVTV_HW_CX25840) { |
@@ -1234,7 +1231,7 @@ int ivtv_init_on_first_open(struct ivtv *itv) | |||
1234 | if (itv->card->hw_all & IVTV_HW_CX25840) { | 1231 | if (itv->card->hw_all & IVTV_HW_CX25840) { |
1235 | struct v4l2_control ctrl; | 1232 | struct v4l2_control ctrl; |
1236 | 1233 | ||
1237 | v4l2_subdev_call(itv->sd_video, core, init, 0); | 1234 | v4l2_subdev_call(itv->sd_video, core, load_fw); |
1238 | /* CX25840_CID_ENABLE_PVR150_WORKAROUND */ | 1235 | /* CX25840_CID_ENABLE_PVR150_WORKAROUND */ |
1239 | ctrl.id = V4L2_CID_PRIVATE_BASE; | 1236 | ctrl.id = V4L2_CID_PRIVATE_BASE; |
1240 | ctrl.value = itv->pvr150_workaround; | 1237 | ctrl.value = itv->pvr150_workaround; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index cfaacf6096d0..e707ef3086b2 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -857,15 +857,12 @@ int ivtv_v4l2_close(struct file *filp) | |||
857 | /* Mark that the radio is no longer in use */ | 857 | /* Mark that the radio is no longer in use */ |
858 | clear_bit(IVTV_F_I_RADIO_USER, &itv->i_flags); | 858 | clear_bit(IVTV_F_I_RADIO_USER, &itv->i_flags); |
859 | /* Switch tuner to TV */ | 859 | /* Switch tuner to TV */ |
860 | ivtv_call_all(itv, tuner, s_std, itv->std); | 860 | ivtv_call_all(itv, core, s_std, itv->std); |
861 | /* Select correct audio input (i.e. TV tuner or Line in) */ | 861 | /* Select correct audio input (i.e. TV tuner or Line in) */ |
862 | ivtv_audio_set_io(itv); | 862 | ivtv_audio_set_io(itv); |
863 | if (itv->hw_flags & IVTV_HW_SAA711X) | 863 | if (itv->hw_flags & IVTV_HW_SAA711X) { |
864 | { | 864 | ivtv_call_hw(itv, IVTV_HW_SAA711X, video, s_crystal_freq, |
865 | struct v4l2_crystal_freq crystal_freq; | 865 | SAA7115_FREQ_32_11_MHZ, 0); |
866 | crystal_freq.freq = SAA7115_FREQ_32_11_MHZ; | ||
867 | crystal_freq.flags = 0; | ||
868 | ivtv_call_hw(itv, IVTV_HW_SAA711X, video, s_crystal_freq, &crystal_freq); | ||
869 | } | 866 | } |
870 | if (atomic_read(&itv->capturing) > 0) { | 867 | if (atomic_read(&itv->capturing) > 0) { |
871 | /* Undo video mute */ | 868 | /* Undo video mute */ |
@@ -956,10 +953,8 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp) | |||
956 | /* Select the correct audio input (i.e. radio tuner) */ | 953 | /* Select the correct audio input (i.e. radio tuner) */ |
957 | ivtv_audio_set_io(itv); | 954 | ivtv_audio_set_io(itv); |
958 | if (itv->hw_flags & IVTV_HW_SAA711X) { | 955 | if (itv->hw_flags & IVTV_HW_SAA711X) { |
959 | struct v4l2_crystal_freq crystal_freq; | 956 | ivtv_call_hw(itv, IVTV_HW_SAA711X, video, s_crystal_freq, |
960 | crystal_freq.freq = SAA7115_FREQ_32_11_MHZ; | 957 | SAA7115_FREQ_32_11_MHZ, SAA7115_FREQ_FL_APLL); |
961 | crystal_freq.flags = SAA7115_FREQ_FL_APLL; | ||
962 | ivtv_call_hw(itv, IVTV_HW_SAA711X, video, s_crystal_freq, &crystal_freq); | ||
963 | } | 958 | } |
964 | /* Done! Unmute and continue. */ | 959 | /* Done! Unmute and continue. */ |
965 | ivtv_unmute(itv); | 960 | ivtv_unmute(itv); |
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c b/drivers/media/video/ivtv/ivtv-gpio.c index 3321983d89e5..ceb05bdcaf62 100644 --- a/drivers/media/video/ivtv/ivtv-gpio.c +++ b/drivers/media/video/ivtv/ivtv-gpio.c | |||
@@ -248,15 +248,16 @@ static int subdev_s_std(struct v4l2_subdev *sd, v4l2_std_id std) | |||
248 | return 0; | 248 | return 0; |
249 | } | 249 | } |
250 | 250 | ||
251 | static int subdev_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 251 | static int subdev_s_audio_routing(struct v4l2_subdev *sd, |
252 | u32 input, u32 output, u32 config) | ||
252 | { | 253 | { |
253 | struct ivtv *itv = sd_to_ivtv(sd); | 254 | struct ivtv *itv = sd_to_ivtv(sd); |
254 | u16 mask, data; | 255 | u16 mask, data; |
255 | 256 | ||
256 | if (route->input > 2) | 257 | if (input > 2) |
257 | return -EINVAL; | 258 | return -EINVAL; |
258 | mask = itv->card->gpio_audio_input.mask; | 259 | mask = itv->card->gpio_audio_input.mask; |
259 | switch (route->input) { | 260 | switch (input) { |
260 | case 0: | 261 | case 0: |
261 | data = itv->card->gpio_audio_input.tuner; | 262 | data = itv->card->gpio_audio_input.tuner; |
262 | break; | 263 | break; |
@@ -318,17 +319,18 @@ static int subdev_log_status(struct v4l2_subdev *sd) | |||
318 | return 0; | 319 | return 0; |
319 | } | 320 | } |
320 | 321 | ||
321 | static int subdev_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 322 | static int subdev_s_video_routing(struct v4l2_subdev *sd, |
323 | u32 input, u32 output, u32 config) | ||
322 | { | 324 | { |
323 | struct ivtv *itv = sd_to_ivtv(sd); | 325 | struct ivtv *itv = sd_to_ivtv(sd); |
324 | u16 mask, data; | 326 | u16 mask, data; |
325 | 327 | ||
326 | if (route->input > 2) /* 0:Tuner 1:Composite 2:S-Video */ | 328 | if (input > 2) /* 0:Tuner 1:Composite 2:S-Video */ |
327 | return -EINVAL; | 329 | return -EINVAL; |
328 | mask = itv->card->gpio_video_input.mask; | 330 | mask = itv->card->gpio_video_input.mask; |
329 | if (route->input == 0) | 331 | if (input == 0) |
330 | data = itv->card->gpio_video_input.tuner; | 332 | data = itv->card->gpio_video_input.tuner; |
331 | else if (route->input == 1) | 333 | else if (input == 1) |
332 | data = itv->card->gpio_video_input.composite; | 334 | data = itv->card->gpio_video_input.composite; |
333 | else | 335 | else |
334 | data = itv->card->gpio_video_input.svideo; | 336 | data = itv->card->gpio_video_input.svideo; |
@@ -342,10 +344,10 @@ static const struct v4l2_subdev_core_ops subdev_core_ops = { | |||
342 | .g_ctrl = subdev_g_ctrl, | 344 | .g_ctrl = subdev_g_ctrl, |
343 | .s_ctrl = subdev_s_ctrl, | 345 | .s_ctrl = subdev_s_ctrl, |
344 | .queryctrl = subdev_queryctrl, | 346 | .queryctrl = subdev_queryctrl, |
347 | .s_std = subdev_s_std, | ||
345 | }; | 348 | }; |
346 | 349 | ||
347 | static const struct v4l2_subdev_tuner_ops subdev_tuner_ops = { | 350 | static const struct v4l2_subdev_tuner_ops subdev_tuner_ops = { |
348 | .s_std = subdev_s_std, | ||
349 | .s_radio = subdev_s_radio, | 351 | .s_radio = subdev_s_radio, |
350 | .g_tuner = subdev_g_tuner, | 352 | .g_tuner = subdev_g_tuner, |
351 | .s_tuner = subdev_s_tuner, | 353 | .s_tuner = subdev_s_tuner, |
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c index e73a196ecc7a..9e3d32b8004c 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.c +++ b/drivers/media/video/ivtv/ivtv-i2c.c | |||
@@ -161,15 +161,18 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) | |||
161 | return -1; | 161 | return -1; |
162 | if (hw == IVTV_HW_TUNER) { | 162 | if (hw == IVTV_HW_TUNER) { |
163 | /* special tuner handling */ | 163 | /* special tuner handling */ |
164 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 164 | sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev, |
165 | adap, mod, type, | ||
165 | itv->card_i2c->radio); | 166 | itv->card_i2c->radio); |
166 | if (sd) | 167 | if (sd) |
167 | sd->grp_id = 1 << idx; | 168 | sd->grp_id = 1 << idx; |
168 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 169 | sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev, |
170 | adap, mod, type, | ||
169 | itv->card_i2c->demod); | 171 | itv->card_i2c->demod); |
170 | if (sd) | 172 | if (sd) |
171 | sd->grp_id = 1 << idx; | 173 | sd->grp_id = 1 << idx; |
172 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, | 174 | sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev, |
175 | adap, mod, type, | ||
173 | itv->card_i2c->tv); | 176 | itv->card_i2c->tv); |
174 | if (sd) | 177 | if (sd) |
175 | sd->grp_id = 1 << idx; | 178 | sd->grp_id = 1 << idx; |
@@ -178,11 +181,11 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) | |||
178 | if (!hw_addrs[idx]) | 181 | if (!hw_addrs[idx]) |
179 | return -1; | 182 | return -1; |
180 | if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) { | 183 | if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) { |
181 | unsigned short addrs[2] = { hw_addrs[idx], I2C_CLIENT_END }; | 184 | sd = v4l2_i2c_new_probed_subdev_addr(&itv->v4l2_dev, |
182 | 185 | adap, mod, type, hw_addrs[idx]); | |
183 | sd = v4l2_i2c_new_probed_subdev(adap, mod, type, addrs); | ||
184 | } else { | 186 | } else { |
185 | sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]); | 187 | sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, |
188 | adap, mod, type, hw_addrs[idx]); | ||
186 | } | 189 | } |
187 | if (sd) | 190 | if (sd) |
188 | sd->grp_id = 1 << idx; | 191 | sd->grp_id = 1 << idx; |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 9a0424298af1..4a2d464f055e 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -1033,7 +1033,6 @@ static int ivtv_g_output(struct file *file, void *fh, unsigned int *i) | |||
1033 | static int ivtv_s_output(struct file *file, void *fh, unsigned int outp) | 1033 | static int ivtv_s_output(struct file *file, void *fh, unsigned int outp) |
1034 | { | 1034 | { |
1035 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 1035 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
1036 | struct v4l2_routing route; | ||
1037 | 1036 | ||
1038 | if (outp >= itv->card->nof_outputs) | 1037 | if (outp >= itv->card->nof_outputs) |
1039 | return -EINVAL; | 1038 | return -EINVAL; |
@@ -1046,9 +1045,9 @@ static int ivtv_s_output(struct file *file, void *fh, unsigned int outp) | |||
1046 | itv->active_output, outp); | 1045 | itv->active_output, outp); |
1047 | 1046 | ||
1048 | itv->active_output = outp; | 1047 | itv->active_output = outp; |
1049 | route.input = SAA7127_INPUT_TYPE_NORMAL; | 1048 | ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, |
1050 | route.output = itv->card->video_outputs[outp].video_output; | 1049 | SAA7127_INPUT_TYPE_NORMAL, |
1051 | ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, &route); | 1050 | itv->card->video_outputs[outp].video_output, 0); |
1052 | 1051 | ||
1053 | return 0; | 1052 | return 0; |
1054 | } | 1053 | } |
@@ -1121,7 +1120,7 @@ int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std) | |||
1121 | IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std); | 1120 | IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std); |
1122 | 1121 | ||
1123 | /* Tuner */ | 1122 | /* Tuner */ |
1124 | ivtv_call_all(itv, tuner, s_std, itv->std); | 1123 | ivtv_call_all(itv, core, s_std, itv->std); |
1125 | 1124 | ||
1126 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { | 1125 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { |
1127 | /* set display standard */ | 1126 | /* set display standard */ |
@@ -1735,13 +1734,6 @@ static long ivtv_default(struct file *file, void *fh, int cmd, void *arg) | |||
1735 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 1734 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
1736 | 1735 | ||
1737 | switch (cmd) { | 1736 | switch (cmd) { |
1738 | case VIDIOC_INT_S_AUDIO_ROUTING: { | ||
1739 | struct v4l2_routing *route = arg; | ||
1740 | |||
1741 | ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, route); | ||
1742 | break; | ||
1743 | } | ||
1744 | |||
1745 | case VIDIOC_INT_RESET: { | 1737 | case VIDIOC_INT_RESET: { |
1746 | u32 val = *(u32 *)arg; | 1738 | u32 val = *(u32 *)arg; |
1747 | 1739 | ||
diff --git a/drivers/media/video/ivtv/ivtv-routing.c b/drivers/media/video/ivtv/ivtv-routing.c index 3fd302294497..8898c569a1c9 100644 --- a/drivers/media/video/ivtv/ivtv-routing.c +++ b/drivers/media/video/ivtv/ivtv-routing.c | |||
@@ -34,7 +34,7 @@ | |||
34 | void ivtv_audio_set_io(struct ivtv *itv) | 34 | void ivtv_audio_set_io(struct ivtv *itv) |
35 | { | 35 | { |
36 | const struct ivtv_card_audio_input *in; | 36 | const struct ivtv_card_audio_input *in; |
37 | struct v4l2_routing route; | 37 | u32 input, output = 0; |
38 | 38 | ||
39 | /* Determine which input to use */ | 39 | /* Determine which input to use */ |
40 | if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) | 40 | if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) |
@@ -43,73 +43,77 @@ void ivtv_audio_set_io(struct ivtv *itv) | |||
43 | in = &itv->card->audio_inputs[itv->audio_input]; | 43 | in = &itv->card->audio_inputs[itv->audio_input]; |
44 | 44 | ||
45 | /* handle muxer chips */ | 45 | /* handle muxer chips */ |
46 | route.input = in->muxer_input; | 46 | input = in->muxer_input; |
47 | route.output = 0; | ||
48 | if (itv->card->hw_muxer & IVTV_HW_M52790) | 47 | if (itv->card->hw_muxer & IVTV_HW_M52790) |
49 | route.output = M52790_OUT_STEREO; | 48 | output = M52790_OUT_STEREO; |
50 | v4l2_subdev_call(itv->sd_muxer, audio, s_routing, &route); | 49 | v4l2_subdev_call(itv->sd_muxer, audio, s_routing, |
50 | input, output, 0); | ||
51 | 51 | ||
52 | route.input = in->audio_input; | 52 | input = in->audio_input; |
53 | route.output = 0; | 53 | output = 0; |
54 | if (itv->card->hw_audio & IVTV_HW_MSP34XX) | 54 | if (itv->card->hw_audio & IVTV_HW_MSP34XX) |
55 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | 55 | output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); |
56 | ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, &route); | 56 | ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, |
57 | input, output, 0); | ||
57 | } | 58 | } |
58 | 59 | ||
59 | /* Selects the video input and output according to the current | 60 | /* Selects the video input and output according to the current |
60 | settings. */ | 61 | settings. */ |
61 | void ivtv_video_set_io(struct ivtv *itv) | 62 | void ivtv_video_set_io(struct ivtv *itv) |
62 | { | 63 | { |
63 | struct v4l2_routing route; | ||
64 | int inp = itv->active_input; | 64 | int inp = itv->active_input; |
65 | u32 input; | ||
65 | u32 type; | 66 | u32 type; |
66 | 67 | ||
67 | route.input = itv->card->video_inputs[inp].video_input; | 68 | v4l2_subdev_call(itv->sd_video, video, s_routing, |
68 | route.output = 0; | 69 | itv->card->video_inputs[inp].video_input, 0, 0); |
69 | v4l2_subdev_call(itv->sd_video, video, s_routing, &route); | ||
70 | 70 | ||
71 | type = itv->card->video_inputs[inp].video_type; | 71 | type = itv->card->video_inputs[inp].video_type; |
72 | 72 | ||
73 | if (type == IVTV_CARD_INPUT_VID_TUNER) { | 73 | if (type == IVTV_CARD_INPUT_VID_TUNER) { |
74 | route.input = 0; /* Tuner */ | 74 | input = 0; /* Tuner */ |
75 | } else if (type < IVTV_CARD_INPUT_COMPOSITE1) { | 75 | } else if (type < IVTV_CARD_INPUT_COMPOSITE1) { |
76 | route.input = 2; /* S-Video */ | 76 | input = 2; /* S-Video */ |
77 | } else { | 77 | } else { |
78 | route.input = 1; /* Composite */ | 78 | input = 1; /* Composite */ |
79 | } | 79 | } |
80 | 80 | ||
81 | if (itv->card->hw_video & IVTV_HW_GPIO) | 81 | if (itv->card->hw_video & IVTV_HW_GPIO) |
82 | ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing, &route); | 82 | ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing, |
83 | input, 0, 0); | ||
83 | 84 | ||
84 | if (itv->card->hw_video & IVTV_HW_UPD64031A) { | 85 | if (itv->card->hw_video & IVTV_HW_UPD64031A) { |
85 | if (type == IVTV_CARD_INPUT_VID_TUNER || | 86 | if (type == IVTV_CARD_INPUT_VID_TUNER || |
86 | type >= IVTV_CARD_INPUT_COMPOSITE1) { | 87 | type >= IVTV_CARD_INPUT_COMPOSITE1) { |
87 | /* Composite: GR on, connect to 3DYCS */ | 88 | /* Composite: GR on, connect to 3DYCS */ |
88 | route.input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE; | 89 | input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE; |
89 | } else { | 90 | } else { |
90 | /* S-Video: GR bypassed, turn it off */ | 91 | /* S-Video: GR bypassed, turn it off */ |
91 | route.input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE; | 92 | input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE; |
92 | } | 93 | } |
93 | route.input |= itv->card->gr_config; | 94 | input |= itv->card->gr_config; |
94 | 95 | ||
95 | ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing, &route); | 96 | ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing, |
97 | input, 0, 0); | ||
96 | } | 98 | } |
97 | 99 | ||
98 | if (itv->card->hw_video & IVTV_HW_UPD6408X) { | 100 | if (itv->card->hw_video & IVTV_HW_UPD6408X) { |
99 | route.input = UPD64083_YCS_MODE; | 101 | input = UPD64083_YCS_MODE; |
100 | if (type > IVTV_CARD_INPUT_VID_TUNER && | 102 | if (type > IVTV_CARD_INPUT_VID_TUNER && |
101 | type < IVTV_CARD_INPUT_COMPOSITE1) { | 103 | type < IVTV_CARD_INPUT_COMPOSITE1) { |
102 | /* S-Video uses YCNR mode and internal Y-ADC, the upd64031a | 104 | /* S-Video uses YCNR mode and internal Y-ADC, the |
103 | is not used. */ | 105 | upd64031a is not used. */ |
104 | route.input |= UPD64083_YCNR_MODE; | 106 | input |= UPD64083_YCNR_MODE; |
105 | } | 107 | } |
106 | else if (itv->card->hw_video & IVTV_HW_UPD64031A) { | 108 | else if (itv->card->hw_video & IVTV_HW_UPD64031A) { |
107 | /* Use upd64031a output for tuner and composite(CX23416GYC only) inputs */ | 109 | /* Use upd64031a output for tuner and |
108 | if ((type == IVTV_CARD_INPUT_VID_TUNER)|| | 110 | composite(CX23416GYC only) inputs */ |
109 | (itv->card->type == IVTV_CARD_CX23416GYC)) { | 111 | if (type == IVTV_CARD_INPUT_VID_TUNER || |
110 | route.input |= UPD64083_EXT_Y_ADC; | 112 | itv->card->type == IVTV_CARD_CX23416GYC) { |
111 | } | 113 | input |= UPD64083_EXT_Y_ADC; |
114 | } | ||
112 | } | 115 | } |
113 | ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing, &route); | 116 | ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing, |
117 | input, 0, 0); | ||
114 | } | 118 | } |
115 | } | 119 | } |
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c index 841024b6bcdf..fab8e0254bbc 100644 --- a/drivers/media/video/ks0127.c +++ b/drivers/media/video/ks0127.c | |||
@@ -409,11 +409,12 @@ static void ks0127_init(struct v4l2_subdev *sd) | |||
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 412 | static int ks0127_s_routing(struct v4l2_subdev *sd, |
413 | u32 input, u32 output, u32 config) | ||
413 | { | 414 | { |
414 | struct ks0127 *ks = to_ks0127(sd); | 415 | struct ks0127 *ks = to_ks0127(sd); |
415 | 416 | ||
416 | switch (route->input) { | 417 | switch (input) { |
417 | case KS_INPUT_COMPOSITE_1: | 418 | case KS_INPUT_COMPOSITE_1: |
418 | case KS_INPUT_COMPOSITE_2: | 419 | case KS_INPUT_COMPOSITE_2: |
419 | case KS_INPUT_COMPOSITE_3: | 420 | case KS_INPUT_COMPOSITE_3: |
@@ -421,13 +422,13 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
421 | case KS_INPUT_COMPOSITE_5: | 422 | case KS_INPUT_COMPOSITE_5: |
422 | case KS_INPUT_COMPOSITE_6: | 423 | case KS_INPUT_COMPOSITE_6: |
423 | v4l2_dbg(1, debug, sd, | 424 | v4l2_dbg(1, debug, sd, |
424 | "s_routing %d: Composite\n", route->input); | 425 | "s_routing %d: Composite\n", input); |
425 | /* autodetect 50/60 Hz */ | 426 | /* autodetect 50/60 Hz */ |
426 | ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); | 427 | ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); |
427 | /* VSE=0 */ | 428 | /* VSE=0 */ |
428 | ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); | 429 | ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); |
429 | /* set input line */ | 430 | /* set input line */ |
430 | ks0127_and_or(sd, KS_CMDB, 0xb0, route->input); | 431 | ks0127_and_or(sd, KS_CMDB, 0xb0, input); |
431 | /* non-freerunning mode */ | 432 | /* non-freerunning mode */ |
432 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); | 433 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); |
433 | /* analog input */ | 434 | /* analog input */ |
@@ -455,13 +456,13 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
455 | case KS_INPUT_SVIDEO_2: | 456 | case KS_INPUT_SVIDEO_2: |
456 | case KS_INPUT_SVIDEO_3: | 457 | case KS_INPUT_SVIDEO_3: |
457 | v4l2_dbg(1, debug, sd, | 458 | v4l2_dbg(1, debug, sd, |
458 | "s_routing %d: S-Video\n", route->input); | 459 | "s_routing %d: S-Video\n", input); |
459 | /* autodetect 50/60 Hz */ | 460 | /* autodetect 50/60 Hz */ |
460 | ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); | 461 | ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); |
461 | /* VSE=0 */ | 462 | /* VSE=0 */ |
462 | ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); | 463 | ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); |
463 | /* set input line */ | 464 | /* set input line */ |
464 | ks0127_and_or(sd, KS_CMDB, 0xb0, route->input); | 465 | ks0127_and_or(sd, KS_CMDB, 0xb0, input); |
465 | /* non-freerunning mode */ | 466 | /* non-freerunning mode */ |
466 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); | 467 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); |
467 | /* analog input */ | 468 | /* analog input */ |
@@ -496,7 +497,7 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
496 | 497 | ||
497 | ks0127_and_or(sd, KS_CMDA, 0xff, 0x40); /* VSE=1 */ | 498 | ks0127_and_or(sd, KS_CMDA, 0xff, 0x40); /* VSE=1 */ |
498 | /* set input line and VALIGN */ | 499 | /* set input line and VALIGN */ |
499 | ks0127_and_or(sd, KS_CMDB, 0xb0, (route->input | 0x40)); | 500 | ks0127_and_or(sd, KS_CMDB, 0xb0, (input | 0x40)); |
500 | /* freerunning mode, */ | 501 | /* freerunning mode, */ |
501 | /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ | 502 | /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ |
502 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x87); | 503 | ks0127_and_or(sd, KS_CMDC, 0x70, 0x87); |
@@ -531,7 +532,7 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
531 | 532 | ||
532 | default: | 533 | default: |
533 | v4l2_dbg(1, debug, sd, | 534 | v4l2_dbg(1, debug, sd, |
534 | "s_routing: Unknown input %d\n", route->input); | 535 | "s_routing: Unknown input %d\n", input); |
535 | break; | 536 | break; |
536 | } | 537 | } |
537 | 538 | ||
@@ -648,9 +649,6 @@ static int ks0127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_iden | |||
648 | 649 | ||
649 | static const struct v4l2_subdev_core_ops ks0127_core_ops = { | 650 | static const struct v4l2_subdev_core_ops ks0127_core_ops = { |
650 | .g_chip_ident = ks0127_g_chip_ident, | 651 | .g_chip_ident = ks0127_g_chip_ident, |
651 | }; | ||
652 | |||
653 | static const struct v4l2_subdev_tuner_ops ks0127_tuner_ops = { | ||
654 | .s_std = ks0127_s_std, | 652 | .s_std = ks0127_s_std, |
655 | }; | 653 | }; |
656 | 654 | ||
@@ -663,7 +661,6 @@ static const struct v4l2_subdev_video_ops ks0127_video_ops = { | |||
663 | 661 | ||
664 | static const struct v4l2_subdev_ops ks0127_ops = { | 662 | static const struct v4l2_subdev_ops ks0127_ops = { |
665 | .core = &ks0127_core_ops, | 663 | .core = &ks0127_core_ops, |
666 | .tuner = &ks0127_tuner_ops, | ||
667 | .video = &ks0127_video_ops, | 664 | .video = &ks0127_video_ops, |
668 | }; | 665 | }; |
669 | 666 | ||
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c index 1f340fefc49d..d7317e798cc4 100644 --- a/drivers/media/video/m52790.c +++ b/drivers/media/video/m52790.c | |||
@@ -69,12 +69,13 @@ static int m52790_write(struct v4l2_subdev *sd) | |||
69 | part of the audio output routing. The normal case is that another | 69 | part of the audio output routing. The normal case is that another |
70 | chip takes care of the actual muting so making it part of the | 70 | chip takes care of the actual muting so making it part of the |
71 | output routing seems to be the right thing to do for now. */ | 71 | output routing seems to be the right thing to do for now. */ |
72 | static int m52790_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 72 | static int m52790_s_routing(struct v4l2_subdev *sd, |
73 | u32 input, u32 output, u32 config) | ||
73 | { | 74 | { |
74 | struct m52790_state *state = to_state(sd); | 75 | struct m52790_state *state = to_state(sd); |
75 | 76 | ||
76 | state->input = route->input; | 77 | state->input = input; |
77 | state->output = route->output; | 78 | state->output = output; |
78 | m52790_write(sd); | 79 | m52790_write(sd); |
79 | return 0; | 80 | return 0; |
80 | } | 81 | } |
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c index 9e8e06cfe5c6..e9df3cb02cc1 100644 --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/videodev2.h> | 56 | #include <linux/videodev2.h> |
57 | #include <media/v4l2-device.h> | 57 | #include <media/v4l2-device.h> |
58 | #include <media/v4l2-ioctl.h> | 58 | #include <media/v4l2-ioctl.h> |
59 | #include <media/v4l2-i2c-drv-legacy.h> | 59 | #include <media/v4l2-i2c-drv.h> |
60 | #include <media/msp3400.h> | 60 | #include <media/msp3400.h> |
61 | #include <media/tvaudio.h> | 61 | #include <media/tvaudio.h> |
62 | #include "msp3400-driver.h" | 62 | #include "msp3400-driver.h" |
@@ -108,10 +108,6 @@ MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); | |||
108 | /* DSP unit subaddress */ | 108 | /* DSP unit subaddress */ |
109 | #define I2C_MSP_DSP 0x12 | 109 | #define I2C_MSP_DSP 0x12 |
110 | 110 | ||
111 | /* Addresses to scan */ | ||
112 | static unsigned short normal_i2c[] = { 0x80 >> 1, 0x88 >> 1, I2C_CLIENT_END }; | ||
113 | |||
114 | I2C_CLIENT_INSMOD; | ||
115 | 111 | ||
116 | /* ----------------------------------------------------------------------- */ | 112 | /* ----------------------------------------------------------------------- */ |
117 | /* functions for talking to the MSP3400C Sound processor */ | 113 | /* functions for talking to the MSP3400C Sound processor */ |
@@ -509,25 +505,26 @@ static int msp_s_std(struct v4l2_subdev *sd, v4l2_std_id id) | |||
509 | return 0; | 505 | return 0; |
510 | } | 506 | } |
511 | 507 | ||
512 | static int msp_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt) | 508 | static int msp_s_routing(struct v4l2_subdev *sd, |
509 | u32 input, u32 output, u32 config) | ||
513 | { | 510 | { |
514 | struct msp_state *state = to_state(sd); | 511 | struct msp_state *state = to_state(sd); |
515 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 512 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
516 | int tuner = (rt->input >> 3) & 1; | 513 | int tuner = (input >> 3) & 1; |
517 | int sc_in = rt->input & 0x7; | 514 | int sc_in = input & 0x7; |
518 | int sc1_out = rt->output & 0xf; | 515 | int sc1_out = output & 0xf; |
519 | int sc2_out = (rt->output >> 4) & 0xf; | 516 | int sc2_out = (output >> 4) & 0xf; |
520 | u16 val, reg; | 517 | u16 val, reg; |
521 | int i; | 518 | int i; |
522 | int extern_input = 1; | 519 | int extern_input = 1; |
523 | 520 | ||
524 | if (state->routing.input == rt->input && | 521 | if (state->route_in == input && state->route_out == output) |
525 | state->routing.output == rt->output) | ||
526 | return 0; | 522 | return 0; |
527 | state->routing = *rt; | 523 | state->route_in = input; |
524 | state->route_out = output; | ||
528 | /* check if the tuner input is used */ | 525 | /* check if the tuner input is used */ |
529 | for (i = 0; i < 5; i++) { | 526 | for (i = 0; i < 5; i++) { |
530 | if (((rt->input >> (4 + i * 4)) & 0xf) == 0) | 527 | if (((input >> (4 + i * 4)) & 0xf) == 0) |
531 | extern_input = 0; | 528 | extern_input = 0; |
532 | } | 529 | } |
533 | state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT; | 530 | state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT; |
@@ -677,7 +674,7 @@ static int msp_log_status(struct v4l2_subdev *sd) | |||
677 | } | 674 | } |
678 | v4l_info(client, "Audmode: 0x%04x\n", state->audmode); | 675 | v4l_info(client, "Audmode: 0x%04x\n", state->audmode); |
679 | v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n", | 676 | v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n", |
680 | state->routing.input, state->routing.output); | 677 | state->route_in, state->route_out); |
681 | v4l_info(client, "ACB: 0x%04x\n", state->acb); | 678 | v4l_info(client, "ACB: 0x%04x\n", state->acb); |
682 | return 0; | 679 | return 0; |
683 | } | 680 | } |
@@ -696,11 +693,6 @@ static int msp_resume(struct i2c_client *client) | |||
696 | return 0; | 693 | return 0; |
697 | } | 694 | } |
698 | 695 | ||
699 | static int msp_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
700 | { | ||
701 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
702 | } | ||
703 | |||
704 | /* ----------------------------------------------------------------------- */ | 696 | /* ----------------------------------------------------------------------- */ |
705 | 697 | ||
706 | static const struct v4l2_subdev_core_ops msp_core_ops = { | 698 | static const struct v4l2_subdev_core_ops msp_core_ops = { |
@@ -709,6 +701,7 @@ static const struct v4l2_subdev_core_ops msp_core_ops = { | |||
709 | .g_ctrl = msp_g_ctrl, | 701 | .g_ctrl = msp_g_ctrl, |
710 | .s_ctrl = msp_s_ctrl, | 702 | .s_ctrl = msp_s_ctrl, |
711 | .queryctrl = msp_queryctrl, | 703 | .queryctrl = msp_queryctrl, |
704 | .s_std = msp_s_std, | ||
712 | }; | 705 | }; |
713 | 706 | ||
714 | static const struct v4l2_subdev_tuner_ops msp_tuner_ops = { | 707 | static const struct v4l2_subdev_tuner_ops msp_tuner_ops = { |
@@ -716,7 +709,6 @@ static const struct v4l2_subdev_tuner_ops msp_tuner_ops = { | |||
716 | .g_tuner = msp_g_tuner, | 709 | .g_tuner = msp_g_tuner, |
717 | .s_tuner = msp_s_tuner, | 710 | .s_tuner = msp_s_tuner, |
718 | .s_radio = msp_s_radio, | 711 | .s_radio = msp_s_radio, |
719 | .s_std = msp_s_std, | ||
720 | }; | 712 | }; |
721 | 713 | ||
722 | static const struct v4l2_subdev_audio_ops msp_audio_ops = { | 714 | static const struct v4l2_subdev_audio_ops msp_audio_ops = { |
@@ -770,8 +762,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
770 | state->i2s_mode = 0; | 762 | state->i2s_mode = 0; |
771 | init_waitqueue_head(&state->wq); | 763 | init_waitqueue_head(&state->wq); |
772 | /* These are the reset input/output positions */ | 764 | /* These are the reset input/output positions */ |
773 | state->routing.input = MSP_INPUT_DEFAULT; | 765 | state->route_in = MSP_INPUT_DEFAULT; |
774 | state->routing.output = MSP_OUTPUT_DEFAULT; | 766 | state->route_out = MSP_OUTPUT_DEFAULT; |
775 | 767 | ||
776 | state->rev1 = msp_read_dsp(client, 0x1e); | 768 | state->rev1 = msp_read_dsp(client, 0x1e); |
777 | if (state->rev1 != -1) | 769 | if (state->rev1 != -1) |
@@ -925,8 +917,6 @@ MODULE_DEVICE_TABLE(i2c, msp_id); | |||
925 | 917 | ||
926 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 918 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
927 | .name = "msp3400", | 919 | .name = "msp3400", |
928 | .driverid = I2C_DRIVERID_MSP3400, | ||
929 | .command = msp_command, | ||
930 | .probe = msp_probe, | 920 | .probe = msp_probe, |
931 | .remove = msp_remove, | 921 | .remove = msp_remove, |
932 | .suspend = msp_suspend, | 922 | .suspend = msp_suspend, |
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h index 3fe1c1b10f53..d6b3e6d0eef7 100644 --- a/drivers/media/video/msp3400-driver.h +++ b/drivers/media/video/msp3400-driver.h | |||
@@ -80,7 +80,8 @@ struct msp_state { | |||
80 | int i2s_mode; | 80 | int i2s_mode; |
81 | int main, second; /* sound carrier */ | 81 | int main, second; /* sound carrier */ |
82 | int input; | 82 | int input; |
83 | struct v4l2_routing routing; | 83 | u32 route_in; |
84 | u32 route_out; | ||
84 | 85 | ||
85 | /* v4l2 */ | 86 | /* v4l2 */ |
86 | int audmode; | 87 | int audmode; |
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c index a655e9c30146..168bca703614 100644 --- a/drivers/media/video/msp3400-kthreads.c +++ b/drivers/media/video/msp3400-kthreads.c | |||
@@ -188,7 +188,7 @@ void msp3400c_set_mode(struct i2c_client *client, int mode) | |||
188 | { | 188 | { |
189 | struct msp_state *state = to_state(i2c_get_clientdata(client)); | 189 | struct msp_state *state = to_state(i2c_get_clientdata(client)); |
190 | struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode]; | 190 | struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode]; |
191 | int tuner = (state->routing.input >> 3) & 1; | 191 | int tuner = (state->route_in >> 3) & 1; |
192 | int i; | 192 | int i; |
193 | 193 | ||
194 | v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode); | 194 | v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode); |
@@ -896,7 +896,7 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) | |||
896 | static void msp34xxg_set_sources(struct i2c_client *client) | 896 | static void msp34xxg_set_sources(struct i2c_client *client) |
897 | { | 897 | { |
898 | struct msp_state *state = to_state(i2c_get_clientdata(client)); | 898 | struct msp_state *state = to_state(i2c_get_clientdata(client)); |
899 | u32 in = state->routing.input; | 899 | u32 in = state->route_in; |
900 | 900 | ||
901 | msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf); | 901 | msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf); |
902 | /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */ | 902 | /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */ |
@@ -912,7 +912,7 @@ static void msp34xxg_set_sources(struct i2c_client *client) | |||
912 | static void msp34xxg_reset(struct i2c_client *client) | 912 | static void msp34xxg_reset(struct i2c_client *client) |
913 | { | 913 | { |
914 | struct msp_state *state = to_state(i2c_get_clientdata(client)); | 914 | struct msp_state *state = to_state(i2c_get_clientdata(client)); |
915 | int tuner = (state->routing.input >> 3) & 1; | 915 | int tuner = (state->route_in >> 3) & 1; |
916 | int modus; | 916 | int modus; |
917 | 917 | ||
918 | /* initialize std to 1 (autodetect) to signal that no standard is | 918 | /* initialize std to 1 (autodetect) to signal that no standard is |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index fa7e5093edeb..684f62fa7897 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -207,7 +207,7 @@ static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd) | |||
207 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 207 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
208 | struct soc_camera_link *icl = mt9m001->client->dev.platform_data; | 208 | struct soc_camera_link *icl = mt9m001->client->dev.platform_data; |
209 | /* MT9M001 has all capture_format parameters fixed */ | 209 | /* MT9M001 has all capture_format parameters fixed */ |
210 | unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | | 210 | unsigned long flags = SOCAM_PCLK_SAMPLE_FALLING | |
211 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH | | 211 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH | |
212 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_MASTER; | 212 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_MASTER; |
213 | 213 | ||
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index 23f9ce9d67ef..2b0927bfd217 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
@@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd, u32 *data) | |||
141 | 141 | ||
142 | static int mt9t031_init(struct soc_camera_device *icd) | 142 | static int mt9t031_init(struct soc_camera_device *icd) |
143 | { | 143 | { |
144 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); | ||
145 | struct soc_camera_link *icl = mt9t031->client->dev.platform_data; | ||
144 | int ret; | 146 | int ret; |
145 | 147 | ||
148 | if (icl->power) { | ||
149 | ret = icl->power(&mt9t031->client->dev, 1); | ||
150 | if (ret < 0) { | ||
151 | dev_err(icd->vdev->parent, | ||
152 | "Platform failed to power-on the camera.\n"); | ||
153 | return ret; | ||
154 | } | ||
155 | } | ||
156 | |||
146 | /* Disable chip output, synchronous option update */ | 157 | /* Disable chip output, synchronous option update */ |
147 | ret = reg_write(icd, MT9T031_RESET, 1); | 158 | ret = reg_write(icd, MT9T031_RESET, 1); |
148 | if (ret >= 0) | 159 | if (ret >= 0) |
@@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd) | |||
150 | if (ret >= 0) | 161 | if (ret >= 0) |
151 | ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); | 162 | ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); |
152 | 163 | ||
164 | if (ret < 0 && icl->power) | ||
165 | icl->power(&mt9t031->client->dev, 0); | ||
166 | |||
153 | return ret >= 0 ? 0 : -EIO; | 167 | return ret >= 0 ? 0 : -EIO; |
154 | } | 168 | } |
155 | 169 | ||
156 | static int mt9t031_release(struct soc_camera_device *icd) | 170 | static int mt9t031_release(struct soc_camera_device *icd) |
157 | { | 171 | { |
172 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); | ||
173 | struct soc_camera_link *icl = mt9t031->client->dev.platform_data; | ||
174 | |||
158 | /* Disable the chip */ | 175 | /* Disable the chip */ |
159 | reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); | 176 | reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); |
177 | |||
178 | if (icl->power) | ||
179 | icl->power(&mt9t031->client->dev, 0); | ||
180 | |||
160 | return 0; | 181 | return 0; |
161 | } | 182 | } |
162 | 183 | ||
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c new file mode 100644 index 000000000000..86fab56c5a20 --- /dev/null +++ b/drivers/media/video/mx1_camera.c | |||
@@ -0,0 +1,827 @@ | |||
1 | /* | ||
2 | * V4L2 Driver for i.MXL/i.MXL camera (CSI) host | ||
3 | * | ||
4 | * Copyright (C) 2008, Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | ||
5 | * Copyright (C) 2009, Darius Augulis <augulis.darius@gmail.com> | ||
6 | * | ||
7 | * Based on PXA SoC camera driver | ||
8 | * Copyright (C) 2006, Sascha Hauer, Pengutronix | ||
9 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/clk.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/dma-mapping.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/fs.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/mm.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/moduleparam.h> | ||
29 | #include <linux/mutex.h> | ||
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/time.h> | ||
32 | #include <linux/version.h> | ||
33 | #include <linux/videodev2.h> | ||
34 | |||
35 | #include <media/soc_camera.h> | ||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-dev.h> | ||
38 | #include <media/videobuf-dma-contig.h> | ||
39 | |||
40 | #include <asm/dma.h> | ||
41 | #include <asm/fiq.h> | ||
42 | #include <mach/dma-mx1-mx2.h> | ||
43 | #include <mach/hardware.h> | ||
44 | #include <mach/mx1_camera.h> | ||
45 | |||
46 | /* | ||
47 | * CSI registers | ||
48 | */ | ||
49 | #define DMA_CCR(x) (0x8c + ((x) << 6)) /* Control Registers */ | ||
50 | #define DMA_DIMR 0x08 /* Interrupt mask Register */ | ||
51 | #define CSICR1 0x00 /* CSI Control Register 1 */ | ||
52 | #define CSISR 0x08 /* CSI Status Register */ | ||
53 | #define CSIRXR 0x10 /* CSI RxFIFO Register */ | ||
54 | |||
55 | #define CSICR1_RXFF_LEVEL(x) (((x) & 0x3) << 19) | ||
56 | #define CSICR1_SOF_POL (1 << 17) | ||
57 | #define CSICR1_SOF_INTEN (1 << 16) | ||
58 | #define CSICR1_MCLKDIV(x) (((x) & 0xf) << 12) | ||
59 | #define CSICR1_MCLKEN (1 << 9) | ||
60 | #define CSICR1_FCC (1 << 8) | ||
61 | #define CSICR1_BIG_ENDIAN (1 << 7) | ||
62 | #define CSICR1_CLR_RXFIFO (1 << 5) | ||
63 | #define CSICR1_GCLK_MODE (1 << 4) | ||
64 | #define CSICR1_DATA_POL (1 << 2) | ||
65 | #define CSICR1_REDGE (1 << 1) | ||
66 | #define CSICR1_EN (1 << 0) | ||
67 | |||
68 | #define CSISR_SFF_OR_INT (1 << 25) | ||
69 | #define CSISR_RFF_OR_INT (1 << 24) | ||
70 | #define CSISR_STATFF_INT (1 << 21) | ||
71 | #define CSISR_RXFF_INT (1 << 18) | ||
72 | #define CSISR_SOF_INT (1 << 16) | ||
73 | #define CSISR_DRDY (1 << 0) | ||
74 | |||
75 | #define VERSION_CODE KERNEL_VERSION(0, 0, 1) | ||
76 | #define DRIVER_NAME "mx1-camera" | ||
77 | |||
78 | #define CSI_IRQ_MASK (CSISR_SFF_OR_INT | CSISR_RFF_OR_INT | \ | ||
79 | CSISR_STATFF_INT | CSISR_RXFF_INT | CSISR_SOF_INT) | ||
80 | |||
81 | #define CSI_BUS_FLAGS (SOCAM_MASTER | SOCAM_HSYNC_ACTIVE_HIGH | \ | ||
82 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW | \ | ||
83 | SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING | \ | ||
84 | SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW | \ | ||
85 | SOCAM_DATAWIDTH_8) | ||
86 | |||
87 | #define MAX_VIDEO_MEM 16 /* Video memory limit in megabytes */ | ||
88 | |||
89 | /* | ||
90 | * Structures | ||
91 | */ | ||
92 | |||
93 | /* buffer for one video frame */ | ||
94 | struct mx1_buffer { | ||
95 | /* common v4l buffer stuff -- must be first */ | ||
96 | struct videobuf_buffer vb; | ||
97 | const struct soc_camera_data_format *fmt; | ||
98 | int inwork; | ||
99 | }; | ||
100 | |||
101 | /* i.MX1/i.MXL is only supposed to handle one camera on its Camera Sensor | ||
102 | * Interface. If anyone ever builds hardware to enable more than | ||
103 | * one camera, they will have to modify this driver too */ | ||
104 | struct mx1_camera_dev { | ||
105 | struct soc_camera_device *icd; | ||
106 | struct mx1_camera_pdata *pdata; | ||
107 | struct mx1_buffer *active; | ||
108 | struct device *dev; | ||
109 | struct resource *res; | ||
110 | struct clk *clk; | ||
111 | struct list_head capture; | ||
112 | |||
113 | void __iomem *base; | ||
114 | int dma_chan; | ||
115 | unsigned int irq; | ||
116 | unsigned long mclk; | ||
117 | |||
118 | spinlock_t lock; | ||
119 | }; | ||
120 | |||
121 | /* | ||
122 | * Videobuf operations | ||
123 | */ | ||
124 | static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, | ||
125 | unsigned int *size) | ||
126 | { | ||
127 | struct soc_camera_device *icd = vq->priv_data; | ||
128 | |||
129 | *size = icd->width * icd->height * | ||
130 | ((icd->current_fmt->depth + 7) >> 3); | ||
131 | |||
132 | if (!*count) | ||
133 | *count = 32; | ||
134 | |||
135 | while (*size * *count > MAX_VIDEO_MEM * 1024 * 1024) | ||
136 | (*count)--; | ||
137 | |||
138 | dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static void free_buffer(struct videobuf_queue *vq, struct mx1_buffer *buf) | ||
144 | { | ||
145 | struct soc_camera_device *icd = vq->priv_data; | ||
146 | struct videobuf_buffer *vb = &buf->vb; | ||
147 | |||
148 | BUG_ON(in_interrupt()); | ||
149 | |||
150 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
151 | vb, vb->baddr, vb->bsize); | ||
152 | |||
153 | /* This waits until this buffer is out of danger, i.e., until it is no | ||
154 | * longer in STATE_QUEUED or STATE_ACTIVE */ | ||
155 | videobuf_waiton(vb, 0, 0); | ||
156 | videobuf_dma_contig_free(vq, vb); | ||
157 | |||
158 | vb->state = VIDEOBUF_NEEDS_INIT; | ||
159 | } | ||
160 | |||
161 | static int mx1_videobuf_prepare(struct videobuf_queue *vq, | ||
162 | struct videobuf_buffer *vb, enum v4l2_field field) | ||
163 | { | ||
164 | struct soc_camera_device *icd = vq->priv_data; | ||
165 | struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb); | ||
166 | int ret; | ||
167 | |||
168 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
169 | vb, vb->baddr, vb->bsize); | ||
170 | |||
171 | /* Added list head initialization on alloc */ | ||
172 | WARN_ON(!list_empty(&vb->queue)); | ||
173 | |||
174 | BUG_ON(NULL == icd->current_fmt); | ||
175 | |||
176 | /* I think, in buf_prepare you only have to protect global data, | ||
177 | * the actual buffer is yours */ | ||
178 | buf->inwork = 1; | ||
179 | |||
180 | if (buf->fmt != icd->current_fmt || | ||
181 | vb->width != icd->width || | ||
182 | vb->height != icd->height || | ||
183 | vb->field != field) { | ||
184 | buf->fmt = icd->current_fmt; | ||
185 | vb->width = icd->width; | ||
186 | vb->height = icd->height; | ||
187 | vb->field = field; | ||
188 | vb->state = VIDEOBUF_NEEDS_INIT; | ||
189 | } | ||
190 | |||
191 | vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3); | ||
192 | if (0 != vb->baddr && vb->bsize < vb->size) { | ||
193 | ret = -EINVAL; | ||
194 | goto out; | ||
195 | } | ||
196 | |||
197 | if (vb->state == VIDEOBUF_NEEDS_INIT) { | ||
198 | ret = videobuf_iolock(vq, vb, NULL); | ||
199 | if (ret) | ||
200 | goto fail; | ||
201 | |||
202 | vb->state = VIDEOBUF_PREPARED; | ||
203 | } | ||
204 | |||
205 | buf->inwork = 0; | ||
206 | |||
207 | return 0; | ||
208 | |||
209 | fail: | ||
210 | free_buffer(vq, buf); | ||
211 | out: | ||
212 | buf->inwork = 0; | ||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) | ||
217 | { | ||
218 | struct videobuf_buffer *vbuf = &pcdev->active->vb; | ||
219 | int ret; | ||
220 | |||
221 | if (unlikely(!pcdev->active)) { | ||
222 | dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); | ||
223 | return -EFAULT; | ||
224 | } | ||
225 | |||
226 | /* setup sg list for future DMA */ | ||
227 | ret = imx_dma_setup_single(pcdev->dma_chan, | ||
228 | videobuf_to_dma_contig(vbuf), | ||
229 | vbuf->size, pcdev->res->start + | ||
230 | CSIRXR, DMA_MODE_READ); | ||
231 | if (unlikely(ret)) | ||
232 | dev_err(pcdev->dev, "Failed to setup DMA sg list\n"); | ||
233 | |||
234 | return ret; | ||
235 | } | ||
236 | |||
237 | static void mx1_videobuf_queue(struct videobuf_queue *vq, | ||
238 | struct videobuf_buffer *vb) | ||
239 | { | ||
240 | struct soc_camera_device *icd = vq->priv_data; | ||
241 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
242 | struct mx1_camera_dev *pcdev = ici->priv; | ||
243 | struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb); | ||
244 | unsigned long flags; | ||
245 | |||
246 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
247 | vb, vb->baddr, vb->bsize); | ||
248 | |||
249 | spin_lock_irqsave(&pcdev->lock, flags); | ||
250 | |||
251 | list_add_tail(&vb->queue, &pcdev->capture); | ||
252 | |||
253 | vb->state = VIDEOBUF_ACTIVE; | ||
254 | |||
255 | if (!pcdev->active) { | ||
256 | pcdev->active = buf; | ||
257 | |||
258 | /* setup sg list for future DMA */ | ||
259 | if (!mx1_camera_setup_dma(pcdev)) { | ||
260 | unsigned int temp; | ||
261 | /* enable SOF irq */ | ||
262 | temp = __raw_readl(pcdev->base + CSICR1) | | ||
263 | CSICR1_SOF_INTEN; | ||
264 | __raw_writel(temp, pcdev->base + CSICR1); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
269 | } | ||
270 | |||
271 | static void mx1_videobuf_release(struct videobuf_queue *vq, | ||
272 | struct videobuf_buffer *vb) | ||
273 | { | ||
274 | struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb); | ||
275 | #ifdef DEBUG | ||
276 | struct soc_camera_device *icd = vq->priv_data; | ||
277 | |||
278 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
279 | vb, vb->baddr, vb->bsize); | ||
280 | |||
281 | switch (vb->state) { | ||
282 | case VIDEOBUF_ACTIVE: | ||
283 | dev_dbg(&icd->dev, "%s (active)\n", __func__); | ||
284 | break; | ||
285 | case VIDEOBUF_QUEUED: | ||
286 | dev_dbg(&icd->dev, "%s (queued)\n", __func__); | ||
287 | break; | ||
288 | case VIDEOBUF_PREPARED: | ||
289 | dev_dbg(&icd->dev, "%s (prepared)\n", __func__); | ||
290 | break; | ||
291 | default: | ||
292 | dev_dbg(&icd->dev, "%s (unknown)\n", __func__); | ||
293 | break; | ||
294 | } | ||
295 | #endif | ||
296 | |||
297 | free_buffer(vq, buf); | ||
298 | } | ||
299 | |||
300 | static void mx1_camera_wakeup(struct mx1_camera_dev *pcdev, | ||
301 | struct videobuf_buffer *vb, | ||
302 | struct mx1_buffer *buf) | ||
303 | { | ||
304 | /* _init is used to debug races, see comment in mx1_camera_reqbufs() */ | ||
305 | list_del_init(&vb->queue); | ||
306 | vb->state = VIDEOBUF_DONE; | ||
307 | do_gettimeofday(&vb->ts); | ||
308 | vb->field_count++; | ||
309 | wake_up(&vb->done); | ||
310 | |||
311 | if (list_empty(&pcdev->capture)) { | ||
312 | pcdev->active = NULL; | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | pcdev->active = list_entry(pcdev->capture.next, | ||
317 | struct mx1_buffer, vb.queue); | ||
318 | |||
319 | /* setup sg list for future DMA */ | ||
320 | if (likely(!mx1_camera_setup_dma(pcdev))) { | ||
321 | unsigned int temp; | ||
322 | |||
323 | /* enable SOF irq */ | ||
324 | temp = __raw_readl(pcdev->base + CSICR1) | CSICR1_SOF_INTEN; | ||
325 | __raw_writel(temp, pcdev->base + CSICR1); | ||
326 | } | ||
327 | } | ||
328 | |||
329 | static void mx1_camera_dma_irq(int channel, void *data) | ||
330 | { | ||
331 | struct mx1_camera_dev *pcdev = data; | ||
332 | struct mx1_buffer *buf; | ||
333 | struct videobuf_buffer *vb; | ||
334 | unsigned long flags; | ||
335 | |||
336 | spin_lock_irqsave(&pcdev->lock, flags); | ||
337 | |||
338 | imx_dma_disable(channel); | ||
339 | |||
340 | if (unlikely(!pcdev->active)) { | ||
341 | dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); | ||
342 | goto out; | ||
343 | } | ||
344 | |||
345 | vb = &pcdev->active->vb; | ||
346 | buf = container_of(vb, struct mx1_buffer, vb); | ||
347 | WARN_ON(buf->inwork || list_empty(&vb->queue)); | ||
348 | dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
349 | vb, vb->baddr, vb->bsize); | ||
350 | |||
351 | mx1_camera_wakeup(pcdev, vb, buf); | ||
352 | out: | ||
353 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
354 | } | ||
355 | |||
356 | static struct videobuf_queue_ops mx1_videobuf_ops = { | ||
357 | .buf_setup = mx1_videobuf_setup, | ||
358 | .buf_prepare = mx1_videobuf_prepare, | ||
359 | .buf_queue = mx1_videobuf_queue, | ||
360 | .buf_release = mx1_videobuf_release, | ||
361 | }; | ||
362 | |||
363 | static void mx1_camera_init_videobuf(struct videobuf_queue *q, | ||
364 | struct soc_camera_device *icd) | ||
365 | { | ||
366 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
367 | struct mx1_camera_dev *pcdev = ici->priv; | ||
368 | |||
369 | videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, pcdev->dev, | ||
370 | &pcdev->lock, | ||
371 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
372 | V4L2_FIELD_NONE, | ||
373 | sizeof(struct mx1_buffer), icd); | ||
374 | } | ||
375 | |||
376 | static int mclk_get_divisor(struct mx1_camera_dev *pcdev) | ||
377 | { | ||
378 | unsigned int mclk = pcdev->mclk; | ||
379 | unsigned long div; | ||
380 | unsigned long lcdclk; | ||
381 | |||
382 | lcdclk = clk_get_rate(pcdev->clk); | ||
383 | |||
384 | /* We verify platform_mclk_10khz != 0, so if anyone breaks it, here | ||
385 | * they get a nice Oops */ | ||
386 | div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1; | ||
387 | |||
388 | dev_dbg(pcdev->dev, "System clock %lukHz, target freq %dkHz, " | ||
389 | "divisor %lu\n", lcdclk / 1000, mclk / 1000, div); | ||
390 | |||
391 | return div; | ||
392 | } | ||
393 | |||
394 | static void mx1_camera_activate(struct mx1_camera_dev *pcdev) | ||
395 | { | ||
396 | unsigned int csicr1 = CSICR1_EN; | ||
397 | |||
398 | dev_dbg(pcdev->dev, "Activate device\n"); | ||
399 | |||
400 | clk_enable(pcdev->clk); | ||
401 | |||
402 | /* enable CSI before doing anything else */ | ||
403 | __raw_writel(csicr1, pcdev->base + CSICR1); | ||
404 | |||
405 | csicr1 |= CSICR1_MCLKEN | CSICR1_FCC | CSICR1_GCLK_MODE; | ||
406 | csicr1 |= CSICR1_MCLKDIV(mclk_get_divisor(pcdev)); | ||
407 | csicr1 |= CSICR1_RXFF_LEVEL(2); /* 16 words */ | ||
408 | |||
409 | __raw_writel(csicr1, pcdev->base + CSICR1); | ||
410 | } | ||
411 | |||
412 | static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) | ||
413 | { | ||
414 | dev_dbg(pcdev->dev, "Deactivate device\n"); | ||
415 | |||
416 | /* Disable all CSI interface */ | ||
417 | __raw_writel(0x00, pcdev->base + CSICR1); | ||
418 | |||
419 | clk_disable(pcdev->clk); | ||
420 | } | ||
421 | |||
422 | /* The following two functions absolutely depend on the fact, that | ||
423 | * there can be only one camera on i.MX1/i.MXL camera sensor interface */ | ||
424 | static int mx1_camera_add_device(struct soc_camera_device *icd) | ||
425 | { | ||
426 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
427 | struct mx1_camera_dev *pcdev = ici->priv; | ||
428 | int ret; | ||
429 | |||
430 | if (pcdev->icd) { | ||
431 | ret = -EBUSY; | ||
432 | goto ebusy; | ||
433 | } | ||
434 | |||
435 | dev_info(&icd->dev, "MX1 Camera driver attached to camera %d\n", | ||
436 | icd->devnum); | ||
437 | |||
438 | mx1_camera_activate(pcdev); | ||
439 | ret = icd->ops->init(icd); | ||
440 | |||
441 | if (!ret) | ||
442 | pcdev->icd = icd; | ||
443 | |||
444 | ebusy: | ||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | static void mx1_camera_remove_device(struct soc_camera_device *icd) | ||
449 | { | ||
450 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
451 | struct mx1_camera_dev *pcdev = ici->priv; | ||
452 | unsigned int csicr1; | ||
453 | |||
454 | BUG_ON(icd != pcdev->icd); | ||
455 | |||
456 | /* disable interrupts */ | ||
457 | csicr1 = __raw_readl(pcdev->base + CSICR1) & ~CSI_IRQ_MASK; | ||
458 | __raw_writel(csicr1, pcdev->base + CSICR1); | ||
459 | |||
460 | /* Stop DMA engine */ | ||
461 | imx_dma_disable(pcdev->dma_chan); | ||
462 | |||
463 | dev_info(&icd->dev, "MX1 Camera driver detached from camera %d\n", | ||
464 | icd->devnum); | ||
465 | |||
466 | icd->ops->release(icd); | ||
467 | |||
468 | mx1_camera_deactivate(pcdev); | ||
469 | |||
470 | pcdev->icd = NULL; | ||
471 | } | ||
472 | |||
473 | static int mx1_camera_set_crop(struct soc_camera_device *icd, | ||
474 | struct v4l2_rect *rect) | ||
475 | { | ||
476 | return icd->ops->set_crop(icd, rect); | ||
477 | } | ||
478 | |||
479 | static int mx1_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) | ||
480 | { | ||
481 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
482 | struct mx1_camera_dev *pcdev = ici->priv; | ||
483 | unsigned long camera_flags, common_flags; | ||
484 | unsigned int csicr1; | ||
485 | int ret; | ||
486 | |||
487 | camera_flags = icd->ops->query_bus_param(icd); | ||
488 | |||
489 | /* MX1 supports only 8bit buswidth */ | ||
490 | common_flags = soc_camera_bus_param_compatible(camera_flags, | ||
491 | CSI_BUS_FLAGS); | ||
492 | if (!common_flags) | ||
493 | return -EINVAL; | ||
494 | |||
495 | icd->buswidth = 8; | ||
496 | |||
497 | /* Make choises, based on platform choice */ | ||
498 | if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) && | ||
499 | (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) { | ||
500 | if (!pcdev->pdata || | ||
501 | pcdev->pdata->flags & MX1_CAMERA_VSYNC_HIGH) | ||
502 | common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW; | ||
503 | else | ||
504 | common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH; | ||
505 | } | ||
506 | |||
507 | if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) && | ||
508 | (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) { | ||
509 | if (!pcdev->pdata || | ||
510 | pcdev->pdata->flags & MX1_CAMERA_PCLK_RISING) | ||
511 | common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; | ||
512 | else | ||
513 | common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; | ||
514 | } | ||
515 | |||
516 | if ((common_flags & SOCAM_DATA_ACTIVE_HIGH) && | ||
517 | (common_flags & SOCAM_DATA_ACTIVE_LOW)) { | ||
518 | if (!pcdev->pdata || | ||
519 | pcdev->pdata->flags & MX1_CAMERA_DATA_HIGH) | ||
520 | common_flags &= ~SOCAM_DATA_ACTIVE_LOW; | ||
521 | else | ||
522 | common_flags &= ~SOCAM_DATA_ACTIVE_HIGH; | ||
523 | } | ||
524 | |||
525 | ret = icd->ops->set_bus_param(icd, common_flags); | ||
526 | if (ret < 0) | ||
527 | return ret; | ||
528 | |||
529 | csicr1 = __raw_readl(pcdev->base + CSICR1); | ||
530 | |||
531 | if (common_flags & SOCAM_PCLK_SAMPLE_RISING) | ||
532 | csicr1 |= CSICR1_REDGE; | ||
533 | if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH) | ||
534 | csicr1 |= CSICR1_SOF_POL; | ||
535 | if (common_flags & SOCAM_DATA_ACTIVE_LOW) | ||
536 | csicr1 |= CSICR1_DATA_POL; | ||
537 | |||
538 | __raw_writel(csicr1, pcdev->base + CSICR1); | ||
539 | |||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | static int mx1_camera_set_fmt(struct soc_camera_device *icd, | ||
544 | struct v4l2_format *f) | ||
545 | { | ||
546 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
547 | const struct soc_camera_format_xlate *xlate; | ||
548 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
549 | int ret; | ||
550 | |||
551 | xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); | ||
552 | if (!xlate) { | ||
553 | dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat); | ||
554 | return -EINVAL; | ||
555 | } | ||
556 | |||
557 | ret = icd->ops->set_fmt(icd, f); | ||
558 | if (!ret) { | ||
559 | icd->buswidth = xlate->buswidth; | ||
560 | icd->current_fmt = xlate->host_fmt; | ||
561 | } | ||
562 | |||
563 | return ret; | ||
564 | } | ||
565 | |||
566 | static int mx1_camera_try_fmt(struct soc_camera_device *icd, | ||
567 | struct v4l2_format *f) | ||
568 | { | ||
569 | /* TODO: limit to mx1 hardware capabilities */ | ||
570 | |||
571 | /* limit to sensor capabilities */ | ||
572 | return icd->ops->try_fmt(icd, f); | ||
573 | } | ||
574 | |||
575 | static int mx1_camera_reqbufs(struct soc_camera_file *icf, | ||
576 | struct v4l2_requestbuffers *p) | ||
577 | { | ||
578 | int i; | ||
579 | |||
580 | /* This is for locking debugging only. I removed spinlocks and now I | ||
581 | * check whether .prepare is ever called on a linked buffer, or whether | ||
582 | * a dma IRQ can occur for an in-work or unlinked buffer. Until now | ||
583 | * it hadn't triggered */ | ||
584 | for (i = 0; i < p->count; i++) { | ||
585 | struct mx1_buffer *buf = container_of(icf->vb_vidq.bufs[i], | ||
586 | struct mx1_buffer, vb); | ||
587 | buf->inwork = 0; | ||
588 | INIT_LIST_HEAD(&buf->vb.queue); | ||
589 | } | ||
590 | |||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | static unsigned int mx1_camera_poll(struct file *file, poll_table *pt) | ||
595 | { | ||
596 | struct soc_camera_file *icf = file->private_data; | ||
597 | struct mx1_buffer *buf; | ||
598 | |||
599 | buf = list_entry(icf->vb_vidq.stream.next, struct mx1_buffer, | ||
600 | vb.stream); | ||
601 | |||
602 | poll_wait(file, &buf->vb.done, pt); | ||
603 | |||
604 | if (buf->vb.state == VIDEOBUF_DONE || | ||
605 | buf->vb.state == VIDEOBUF_ERROR) | ||
606 | return POLLIN | POLLRDNORM; | ||
607 | |||
608 | return 0; | ||
609 | } | ||
610 | |||
611 | static int mx1_camera_querycap(struct soc_camera_host *ici, | ||
612 | struct v4l2_capability *cap) | ||
613 | { | ||
614 | /* cap->name is set by the friendly caller:-> */ | ||
615 | strlcpy(cap->card, "i.MX1/i.MXL Camera", sizeof(cap->card)); | ||
616 | cap->version = VERSION_CODE; | ||
617 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; | ||
618 | |||
619 | return 0; | ||
620 | } | ||
621 | |||
622 | static struct soc_camera_host_ops mx1_soc_camera_host_ops = { | ||
623 | .owner = THIS_MODULE, | ||
624 | .add = mx1_camera_add_device, | ||
625 | .remove = mx1_camera_remove_device, | ||
626 | .set_bus_param = mx1_camera_set_bus_param, | ||
627 | .set_crop = mx1_camera_set_crop, | ||
628 | .set_fmt = mx1_camera_set_fmt, | ||
629 | .try_fmt = mx1_camera_try_fmt, | ||
630 | .init_videobuf = mx1_camera_init_videobuf, | ||
631 | .reqbufs = mx1_camera_reqbufs, | ||
632 | .poll = mx1_camera_poll, | ||
633 | .querycap = mx1_camera_querycap, | ||
634 | }; | ||
635 | |||
636 | /* Should be allocated dynamically too, but we have only one. */ | ||
637 | static struct soc_camera_host mx1_soc_camera_host = { | ||
638 | .drv_name = DRIVER_NAME, | ||
639 | .ops = &mx1_soc_camera_host_ops, | ||
640 | }; | ||
641 | |||
642 | static struct fiq_handler fh = { | ||
643 | .name = "csi_sof" | ||
644 | }; | ||
645 | |||
646 | static int __init mx1_camera_probe(struct platform_device *pdev) | ||
647 | { | ||
648 | struct mx1_camera_dev *pcdev; | ||
649 | struct resource *res; | ||
650 | struct pt_regs regs; | ||
651 | struct clk *clk; | ||
652 | void __iomem *base; | ||
653 | unsigned int irq; | ||
654 | int err = 0; | ||
655 | |||
656 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
657 | irq = platform_get_irq(pdev, 0); | ||
658 | if (!res || !irq) { | ||
659 | err = -ENODEV; | ||
660 | goto exit; | ||
661 | } | ||
662 | |||
663 | clk = clk_get(&pdev->dev, "csi_clk"); | ||
664 | if (IS_ERR(clk)) { | ||
665 | err = PTR_ERR(clk); | ||
666 | goto exit; | ||
667 | } | ||
668 | |||
669 | pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL); | ||
670 | if (!pcdev) { | ||
671 | dev_err(&pdev->dev, "Could not allocate pcdev\n"); | ||
672 | err = -ENOMEM; | ||
673 | goto exit_put_clk; | ||
674 | } | ||
675 | |||
676 | dev_set_drvdata(&pdev->dev, pcdev); | ||
677 | pcdev->res = res; | ||
678 | pcdev->clk = clk; | ||
679 | |||
680 | pcdev->pdata = pdev->dev.platform_data; | ||
681 | |||
682 | if (pcdev->pdata) | ||
683 | pcdev->mclk = pcdev->pdata->mclk_10khz * 10000; | ||
684 | |||
685 | if (!pcdev->mclk) { | ||
686 | dev_warn(&pdev->dev, | ||
687 | "mclk_10khz == 0! Please, fix your platform data. " | ||
688 | "Using default 20MHz\n"); | ||
689 | pcdev->mclk = 20000000; | ||
690 | } | ||
691 | |||
692 | INIT_LIST_HEAD(&pcdev->capture); | ||
693 | spin_lock_init(&pcdev->lock); | ||
694 | |||
695 | /* | ||
696 | * Request the regions. | ||
697 | */ | ||
698 | if (!request_mem_region(res->start, resource_size(res), DRIVER_NAME)) { | ||
699 | err = -EBUSY; | ||
700 | goto exit_kfree; | ||
701 | } | ||
702 | |||
703 | base = ioremap(res->start, resource_size(res)); | ||
704 | if (!base) { | ||
705 | err = -ENOMEM; | ||
706 | goto exit_release; | ||
707 | } | ||
708 | pcdev->irq = irq; | ||
709 | pcdev->base = base; | ||
710 | pcdev->dev = &pdev->dev; | ||
711 | |||
712 | /* request dma */ | ||
713 | pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH); | ||
714 | if (pcdev->dma_chan < 0) { | ||
715 | dev_err(pcdev->dev, "Can't request DMA for MX1 CSI\n"); | ||
716 | err = -EBUSY; | ||
717 | goto exit_iounmap; | ||
718 | } | ||
719 | dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chan); | ||
720 | |||
721 | imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL, | ||
722 | pcdev); | ||
723 | |||
724 | imx_dma_config_channel(pcdev->dma_chan, IMX_DMA_TYPE_FIFO, | ||
725 | IMX_DMA_MEMSIZE_32, DMA_REQ_CSI_R, 0); | ||
726 | /* burst length : 16 words = 64 bytes */ | ||
727 | imx_dma_config_burstlen(pcdev->dma_chan, 0); | ||
728 | |||
729 | /* request irq */ | ||
730 | err = claim_fiq(&fh); | ||
731 | if (err) { | ||
732 | dev_err(pcdev->dev, "Camera interrupt register failed \n"); | ||
733 | goto exit_free_dma; | ||
734 | } | ||
735 | |||
736 | set_fiq_handler(&mx1_camera_sof_fiq_start, &mx1_camera_sof_fiq_end - | ||
737 | &mx1_camera_sof_fiq_start); | ||
738 | |||
739 | regs.ARM_r8 = DMA_BASE + DMA_DIMR; | ||
740 | regs.ARM_r9 = DMA_BASE + DMA_CCR(pcdev->dma_chan); | ||
741 | regs.ARM_r10 = (long)pcdev->base + CSICR1; | ||
742 | regs.ARM_fp = (long)pcdev->base + CSISR; | ||
743 | regs.ARM_sp = 1 << pcdev->dma_chan; | ||
744 | set_fiq_regs(®s); | ||
745 | |||
746 | mxc_set_irq_fiq(irq, 1); | ||
747 | enable_fiq(irq); | ||
748 | |||
749 | mx1_soc_camera_host.priv = pcdev; | ||
750 | mx1_soc_camera_host.dev.parent = &pdev->dev; | ||
751 | mx1_soc_camera_host.nr = pdev->id; | ||
752 | err = soc_camera_host_register(&mx1_soc_camera_host); | ||
753 | if (err) | ||
754 | goto exit_free_irq; | ||
755 | |||
756 | dev_info(&pdev->dev, "MX1 Camera driver loaded\n"); | ||
757 | |||
758 | return 0; | ||
759 | |||
760 | exit_free_irq: | ||
761 | disable_fiq(irq); | ||
762 | mxc_set_irq_fiq(irq, 0); | ||
763 | release_fiq(&fh); | ||
764 | exit_free_dma: | ||
765 | imx_dma_free(pcdev->dma_chan); | ||
766 | exit_iounmap: | ||
767 | iounmap(base); | ||
768 | exit_release: | ||
769 | release_mem_region(res->start, resource_size(res)); | ||
770 | exit_kfree: | ||
771 | kfree(pcdev); | ||
772 | exit_put_clk: | ||
773 | clk_put(clk); | ||
774 | exit: | ||
775 | return err; | ||
776 | } | ||
777 | |||
778 | static int __exit mx1_camera_remove(struct platform_device *pdev) | ||
779 | { | ||
780 | struct mx1_camera_dev *pcdev = platform_get_drvdata(pdev); | ||
781 | struct resource *res; | ||
782 | |||
783 | imx_dma_free(pcdev->dma_chan); | ||
784 | disable_fiq(pcdev->irq); | ||
785 | mxc_set_irq_fiq(pcdev->irq, 0); | ||
786 | release_fiq(&fh); | ||
787 | |||
788 | clk_put(pcdev->clk); | ||
789 | |||
790 | soc_camera_host_unregister(&mx1_soc_camera_host); | ||
791 | |||
792 | iounmap(pcdev->base); | ||
793 | |||
794 | res = pcdev->res; | ||
795 | release_mem_region(res->start, resource_size(res)); | ||
796 | |||
797 | kfree(pcdev); | ||
798 | |||
799 | dev_info(&pdev->dev, "MX1 Camera driver unloaded\n"); | ||
800 | |||
801 | return 0; | ||
802 | } | ||
803 | |||
804 | static struct platform_driver mx1_camera_driver = { | ||
805 | .driver = { | ||
806 | .name = DRIVER_NAME, | ||
807 | }, | ||
808 | .remove = __exit_p(mx1_camera_remove), | ||
809 | }; | ||
810 | |||
811 | static int __init mx1_camera_init(void) | ||
812 | { | ||
813 | return platform_driver_probe(&mx1_camera_driver, mx1_camera_probe); | ||
814 | } | ||
815 | |||
816 | static void __exit mx1_camera_exit(void) | ||
817 | { | ||
818 | return platform_driver_unregister(&mx1_camera_driver); | ||
819 | } | ||
820 | |||
821 | module_init(mx1_camera_init); | ||
822 | module_exit(mx1_camera_exit); | ||
823 | |||
824 | MODULE_DESCRIPTION("i.MX1/i.MXL SoC Camera Host driver"); | ||
825 | MODULE_AUTHOR("Paulius Zaleckas <paulius.zaleckas@teltonika.lt>"); | ||
826 | MODULE_LICENSE("GPL v2"); | ||
827 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index 70629e172e65..c462b811e994 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c | |||
@@ -1100,7 +1100,7 @@ static int mx3_camera_probe(struct platform_device *pdev) | |||
1100 | } | 1100 | } |
1101 | memset(mx3_cam, 0, sizeof(*mx3_cam)); | 1101 | memset(mx3_cam, 0, sizeof(*mx3_cam)); |
1102 | 1102 | ||
1103 | mx3_cam->clk = clk_get(&pdev->dev, "csi_clk"); | 1103 | mx3_cam->clk = clk_get(&pdev->dev, NULL); |
1104 | if (IS_ERR(mx3_cam->clk)) { | 1104 | if (IS_ERR(mx3_cam->clk)) { |
1105 | err = PTR_ERR(mx3_cam->clk); | 1105 | err = PTR_ERR(mx3_cam->clk); |
1106 | goto eclkget; | 1106 | goto eclkget; |
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index 84aec62e8452..3be5a71bdac2 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
@@ -83,9 +83,14 @@ static struct { | |||
83 | static int video_audio_connect[MXB_INPUTS] = | 83 | static int video_audio_connect[MXB_INPUTS] = |
84 | { 0, 1, 3, 3 }; | 84 | { 0, 1, 3, 3 }; |
85 | 85 | ||
86 | struct mxb_routing { | ||
87 | u32 input; | ||
88 | u32 output; | ||
89 | }; | ||
90 | |||
86 | /* These are the necessary input-output-pins for bringing one audio source | 91 | /* These are the necessary input-output-pins for bringing one audio source |
87 | (see above) to the CD-output. Note that gain is set to 0 in this table. */ | 92 | (see above) to the CD-output. Note that gain is set to 0 in this table. */ |
88 | static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { | 93 | static struct mxb_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { |
89 | { { 1, 1 }, { 1, 1 } }, /* Tuner */ | 94 | { { 1, 1 }, { 1, 1 } }, /* Tuner */ |
90 | { { 5, 1 }, { 6, 1 } }, /* AUX 1 */ | 95 | { { 5, 1 }, { 6, 1 } }, /* AUX 1 */ |
91 | { { 4, 1 }, { 6, 1 } }, /* AUX 2 */ | 96 | { { 4, 1 }, { 6, 1 } }, /* AUX 2 */ |
@@ -97,7 +102,7 @@ static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { | |||
97 | 102 | ||
98 | /* These are the necessary input-output-pins for bringing one audio source | 103 | /* These are the necessary input-output-pins for bringing one audio source |
99 | (see above) to the line-output. Note that gain is set to 0 in this table. */ | 104 | (see above) to the line-output. Note that gain is set to 0 in this table. */ |
100 | static struct v4l2_routing TEA6420_line[MXB_AUDIOS + 1][2] = { | 105 | static struct mxb_routing TEA6420_line[MXB_AUDIOS + 1][2] = { |
101 | { { 2, 3 }, { 1, 2 } }, | 106 | { { 2, 3 }, { 1, 2 } }, |
102 | { { 5, 3 }, { 6, 2 } }, | 107 | { { 5, 3 }, { 6, 2 } }, |
103 | { { 4, 3 }, { 6, 2 } }, | 108 | { { 4, 3 }, { 6, 2 } }, |
@@ -134,10 +139,6 @@ struct mxb | |||
134 | 139 | ||
135 | #define saa7111a_call(mxb, o, f, args...) \ | 140 | #define saa7111a_call(mxb, o, f, args...) \ |
136 | v4l2_subdev_call(mxb->saa7111a, o, f, ##args) | 141 | v4l2_subdev_call(mxb->saa7111a, o, f, ##args) |
137 | #define tea6420_1_call(mxb, o, f, args...) \ | ||
138 | v4l2_subdev_call(mxb->tea6420_1, o, f, ##args) | ||
139 | #define tea6420_2_call(mxb, o, f, args...) \ | ||
140 | v4l2_subdev_call(mxb->tea6420_2, o, f, ##args) | ||
141 | #define tda9840_call(mxb, o, f, args...) \ | 142 | #define tda9840_call(mxb, o, f, args...) \ |
142 | v4l2_subdev_call(mxb->tda9840, o, f, ##args) | 143 | v4l2_subdev_call(mxb->tda9840, o, f, ##args) |
143 | #define tea6415c_call(mxb, o, f, args...) \ | 144 | #define tea6415c_call(mxb, o, f, args...) \ |
@@ -147,6 +148,22 @@ struct mxb | |||
147 | #define call_all(dev, o, f, args...) \ | 148 | #define call_all(dev, o, f, args...) \ |
148 | v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) | 149 | v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) |
149 | 150 | ||
151 | static inline void tea6420_route_cd(struct mxb *mxb, int idx) | ||
152 | { | ||
153 | v4l2_subdev_call(mxb->tea6420_1, audio, s_routing, | ||
154 | TEA6420_cd[idx][0].input, TEA6420_cd[idx][0].output, 0); | ||
155 | v4l2_subdev_call(mxb->tea6420_2, audio, s_routing, | ||
156 | TEA6420_cd[idx][1].input, TEA6420_cd[idx][1].output, 0); | ||
157 | } | ||
158 | |||
159 | static inline void tea6420_route_line(struct mxb *mxb, int idx) | ||
160 | { | ||
161 | v4l2_subdev_call(mxb->tea6420_1, audio, s_routing, | ||
162 | TEA6420_line[idx][0].input, TEA6420_line[idx][0].output, 0); | ||
163 | v4l2_subdev_call(mxb->tea6420_2, audio, s_routing, | ||
164 | TEA6420_line[idx][1].input, TEA6420_line[idx][1].output, 0); | ||
165 | } | ||
166 | |||
150 | static struct saa7146_extension extension; | 167 | static struct saa7146_extension extension; |
151 | 168 | ||
152 | static int mxb_probe(struct saa7146_dev *dev) | 169 | static int mxb_probe(struct saa7146_dev *dev) |
@@ -168,13 +185,20 @@ static int mxb_probe(struct saa7146_dev *dev) | |||
168 | return -EFAULT; | 185 | return -EFAULT; |
169 | } | 186 | } |
170 | 187 | ||
171 | mxb->saa7111a = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa7115", "saa7111", I2C_SAA7111A); | 188 | mxb->saa7111a = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, |
172 | mxb->tea6420_1 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_1); | 189 | "saa7115", "saa7111", I2C_SAA7111A); |
173 | mxb->tea6420_2 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_2); | 190 | mxb->tea6420_1 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, |
174 | mxb->tea6415c = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6415c", "tea6415c", I2C_TEA6415C); | 191 | "tea6420", "tea6420", I2C_TEA6420_1); |
175 | mxb->tda9840 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tda9840", "tda9840", I2C_TDA9840); | 192 | mxb->tea6420_2 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, |
176 | mxb->tuner = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tuner", "tuner", I2C_TUNER); | 193 | "tea6420", "tea6420", I2C_TEA6420_2); |
177 | if (v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa5246a", "saa5246a", I2C_SAA5246A)) { | 194 | mxb->tea6415c = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, |
195 | "tea6415c", "tea6415c", I2C_TEA6415C); | ||
196 | mxb->tda9840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, | ||
197 | "tda9840", "tda9840", I2C_TDA9840); | ||
198 | mxb->tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, | ||
199 | "tuner", "tuner", I2C_TUNER); | ||
200 | if (v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, | ||
201 | "saa5246a", "saa5246a", I2C_SAA5246A)) { | ||
178 | printk(KERN_INFO "mxb: found teletext decoder\n"); | 202 | printk(KERN_INFO "mxb: found teletext decoder\n"); |
179 | } | 203 | } |
180 | 204 | ||
@@ -261,18 +285,16 @@ static int mxb_init_done(struct saa7146_dev* dev) | |||
261 | struct i2c_msg msg; | 285 | struct i2c_msg msg; |
262 | struct tuner_setup tun_setup; | 286 | struct tuner_setup tun_setup; |
263 | v4l2_std_id std = V4L2_STD_PAL_BG; | 287 | v4l2_std_id std = V4L2_STD_PAL_BG; |
264 | struct v4l2_routing route; | ||
265 | 288 | ||
266 | int i = 0, err = 0; | 289 | int i = 0, err = 0; |
267 | 290 | ||
268 | /* select video mode in saa7111a */ | 291 | /* select video mode in saa7111a */ |
269 | saa7111a_call(mxb, tuner, s_std, std); | 292 | saa7111a_call(mxb, core, s_std, std); |
270 | 293 | ||
271 | /* select tuner-output on saa7111a */ | 294 | /* select tuner-output on saa7111a */ |
272 | i = 0; | 295 | i = 0; |
273 | route.input = SAA7115_COMPOSITE0; | 296 | saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0, |
274 | route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS; | 297 | SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS, 0); |
275 | saa7111a_call(mxb, video, s_routing, &route); | ||
276 | 298 | ||
277 | /* select a tuner type */ | 299 | /* select a tuner type */ |
278 | tun_setup.mode_mask = T_ANALOG_TV; | 300 | tun_setup.mode_mask = T_ANALOG_TV; |
@@ -286,23 +308,17 @@ static int mxb_init_done(struct saa7146_dev* dev) | |||
286 | tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq); | 308 | tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq); |
287 | 309 | ||
288 | /* set a default video standard */ | 310 | /* set a default video standard */ |
289 | tuner_call(mxb, tuner, s_std, std); | 311 | tuner_call(mxb, core, s_std, std); |
290 | 312 | ||
291 | /* mute audio on tea6420s */ | 313 | /* mute audio on tea6420s */ |
292 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]); | 314 | tea6420_route_line(mxb, 6); |
293 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]); | 315 | tea6420_route_cd(mxb, 6); |
294 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]); | ||
295 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]); | ||
296 | 316 | ||
297 | /* switch to tuner-channel on tea6415c */ | 317 | /* switch to tuner-channel on tea6415c */ |
298 | route.input = 3; | 318 | tea6415c_call(mxb, video, s_routing, 3, 17, 0); |
299 | route.output = 17; | ||
300 | tea6415c_call(mxb, video, s_routing, &route); | ||
301 | 319 | ||
302 | /* select tuner-output on multicable on tea6415c */ | 320 | /* select tuner-output on multicable on tea6415c */ |
303 | route.input = 3; | 321 | tea6415c_call(mxb, video, s_routing, 3, 13, 0); |
304 | route.output = 13; | ||
305 | tea6415c_call(mxb, video, s_routing, &route); | ||
306 | 322 | ||
307 | /* the rest for mxb */ | 323 | /* the rest for mxb */ |
308 | mxb->cur_input = 0; | 324 | mxb->cur_input = 0; |
@@ -426,18 +442,9 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc) | |||
426 | 442 | ||
427 | if (vc->id == V4L2_CID_AUDIO_MUTE) { | 443 | if (vc->id == V4L2_CID_AUDIO_MUTE) { |
428 | mxb->cur_mute = vc->value; | 444 | mxb->cur_mute = vc->value; |
429 | if (!vc->value) { | 445 | /* switch the audio-source */ |
430 | /* switch the audio-source */ | 446 | tea6420_route_line(mxb, vc->value ? 6 : |
431 | tea6420_1_call(mxb, audio, s_routing, | 447 | video_audio_connect[mxb->cur_input]); |
432 | &TEA6420_line[video_audio_connect[mxb->cur_input]][0]); | ||
433 | tea6420_2_call(mxb, audio, s_routing, | ||
434 | &TEA6420_line[video_audio_connect[mxb->cur_input]][1]); | ||
435 | } else { | ||
436 | tea6420_1_call(mxb, audio, s_routing, | ||
437 | &TEA6420_line[6][0]); | ||
438 | tea6420_2_call(mxb, audio, s_routing, | ||
439 | &TEA6420_line[6][1]); | ||
440 | } | ||
441 | DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); | 448 | DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); |
442 | } | 449 | } |
443 | return 0; | 450 | return 0; |
@@ -466,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
466 | { | 473 | { |
467 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | 474 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; |
468 | struct mxb *mxb = (struct mxb *)dev->ext_priv; | 475 | struct mxb *mxb = (struct mxb *)dev->ext_priv; |
469 | struct v4l2_routing route; | 476 | int err = 0; |
470 | int i = 0; | 477 | int i = 0; |
471 | 478 | ||
472 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); | 479 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); |
@@ -484,16 +491,12 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
484 | switch (input) { | 491 | switch (input) { |
485 | case TUNER: | 492 | case TUNER: |
486 | i = SAA7115_COMPOSITE0; | 493 | i = SAA7115_COMPOSITE0; |
487 | route.input = 3; | ||
488 | route.output = 17; | ||
489 | 494 | ||
490 | if (tea6415c_call(mxb, video, s_routing, &route)) { | 495 | err = tea6415c_call(mxb, video, s_routing, 3, 17, 0); |
491 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n"); | 496 | |
492 | return -EFAULT; | ||
493 | } | ||
494 | /* connect tuner-output always to multicable */ | 497 | /* connect tuner-output always to multicable */ |
495 | route.input = 3; | 498 | if (!err) |
496 | route.output = 13; | 499 | err = tea6415c_call(mxb, video, s_routing, 3, 13, 0); |
497 | break; | 500 | break; |
498 | case AUX3_YC: | 501 | case AUX3_YC: |
499 | /* nothing to be done here. aux3_yc is | 502 | /* nothing to be done here. aux3_yc is |
@@ -507,37 +510,20 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
507 | break; | 510 | break; |
508 | case AUX1: | 511 | case AUX1: |
509 | i = SAA7115_COMPOSITE0; | 512 | i = SAA7115_COMPOSITE0; |
510 | route.input = 1; | 513 | err = tea6415c_call(mxb, video, s_routing, 1, 17, 0); |
511 | route.output = 17; | ||
512 | break; | 514 | break; |
513 | } | 515 | } |
514 | 516 | ||
515 | /* switch video in tea6415c only if necessary */ | 517 | if (err) |
516 | switch (input) { | 518 | return err; |
517 | case TUNER: | ||
518 | case AUX1: | ||
519 | if (tea6415c_call(mxb, video, s_routing, &route)) { | ||
520 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n"); | ||
521 | return -EFAULT; | ||
522 | } | ||
523 | break; | ||
524 | default: | ||
525 | break; | ||
526 | } | ||
527 | 519 | ||
528 | /* switch video in saa7111a */ | 520 | /* switch video in saa7111a */ |
529 | route.input = i; | 521 | if (saa7111a_call(mxb, video, s_routing, i, 0, 0)) |
530 | route.output = 0; | ||
531 | if (saa7111a_call(mxb, video, s_routing, &route)) | ||
532 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); | 522 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); |
533 | 523 | ||
534 | /* switch the audio-source only if necessary */ | 524 | /* switch the audio-source only if necessary */ |
535 | if (0 == mxb->cur_mute) { | 525 | if (0 == mxb->cur_mute) |
536 | tea6420_1_call(mxb, audio, s_routing, | 526 | tea6420_route_line(mxb, video_audio_connect[input]); |
537 | &TEA6420_line[video_audio_connect[input]][0]); | ||
538 | tea6420_2_call(mxb, audio, s_routing, | ||
539 | &TEA6420_line[video_audio_connect[input]][1]); | ||
540 | } | ||
541 | 527 | ||
542 | return 0; | 528 | return 0; |
543 | } | 529 | } |
@@ -679,9 +665,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) | |||
679 | 665 | ||
680 | DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); | 666 | DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); |
681 | 667 | ||
682 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[i][0]); | 668 | tea6420_route_cd(mxb, i); |
683 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[i][1]); | ||
684 | |||
685 | return 0; | 669 | return 0; |
686 | } | 670 | } |
687 | case MXB_S_AUDIO_LINE: | 671 | case MXB_S_AUDIO_LINE: |
@@ -694,9 +678,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) | |||
694 | } | 678 | } |
695 | 679 | ||
696 | DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); | 680 | DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); |
697 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[i][0]); | 681 | tea6420_route_line(mxb, i); |
698 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[i][1]); | ||
699 | |||
700 | return 0; | 682 | return 0; |
701 | } | 683 | } |
702 | default: | 684 | default: |
@@ -788,7 +770,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa | |||
788 | saa7146_write(dev, GPIO_CTRL, 0x00404050); | 770 | saa7146_write(dev, GPIO_CTRL, 0x00404050); |
789 | /* unset the 7111 gpio register -- I don't know what this does exactly */ | 771 | /* unset the 7111 gpio register -- I don't know what this does exactly */ |
790 | saa7111a_call(mxb, core, s_gpio, 0); | 772 | saa7111a_call(mxb, core, s_gpio, 0); |
791 | tuner_call(mxb, tuner, s_std, std); | 773 | tuner_call(mxb, core, s_std, std); |
792 | } else { | 774 | } else { |
793 | v4l2_std_id std = V4L2_STD_PAL_BG; | 775 | v4l2_std_id std = V4L2_STD_PAL_BG; |
794 | 776 | ||
@@ -797,7 +779,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa | |||
797 | saa7146_write(dev, GPIO_CTRL, 0x00404050); | 779 | saa7146_write(dev, GPIO_CTRL, 0x00404050); |
798 | /* set the 7111 gpio register -- I don't know what this does exactly */ | 780 | /* set the 7111 gpio register -- I don't know what this does exactly */ |
799 | saa7111a_call(mxb, core, s_gpio, 1); | 781 | saa7111a_call(mxb, core, s_gpio, 1); |
800 | tuner_call(mxb, tuner, s_std, std); | 782 | tuner_call(mxb, core, s_std, std); |
801 | } | 783 | } |
802 | return 0; | 784 | return 0; |
803 | } | 785 | } |
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c index 84b0fc1bb237..c0d911252862 100644 --- a/drivers/media/video/ov772x.c +++ b/drivers/media/video/ov772x.c | |||
@@ -169,11 +169,11 @@ | |||
169 | #define GAM15 0x8C /* Gamma Curve 15th segment input end point */ | 169 | #define GAM15 0x8C /* Gamma Curve 15th segment input end point */ |
170 | #define SLOP 0x8D /* Gamma curve highest segment slope */ | 170 | #define SLOP 0x8D /* Gamma curve highest segment slope */ |
171 | #define DNSTH 0x8E /* De-noise threshold */ | 171 | #define DNSTH 0x8E /* De-noise threshold */ |
172 | #define EDGE0 0x8F /* Edge enhancement control 0 */ | 172 | #define EDGE_STRNGT 0x8F /* Edge strength control when manual mode */ |
173 | #define EDGE1 0x90 /* Edge enhancement control 1 */ | 173 | #define EDGE_TRSHLD 0x90 /* Edge threshold control when manual mode */ |
174 | #define DNSOFF 0x91 /* Auto De-noise threshold control */ | 174 | #define DNSOFF 0x91 /* Auto De-noise threshold control */ |
175 | #define EDGE2 0x92 /* Edge enhancement strength low point control */ | 175 | #define EDGE_UPPER 0x92 /* Edge strength upper limit when Auto mode */ |
176 | #define EDGE3 0x93 /* Edge enhancement strength high point control */ | 176 | #define EDGE_LOWER 0x93 /* Edge strength lower limit when Auto mode */ |
177 | #define MTX1 0x94 /* Matrix coefficient 1 */ | 177 | #define MTX1 0x94 /* Matrix coefficient 1 */ |
178 | #define MTX2 0x95 /* Matrix coefficient 2 */ | 178 | #define MTX2 0x95 /* Matrix coefficient 2 */ |
179 | #define MTX3 0x96 /* Matrix coefficient 3 */ | 179 | #define MTX3 0x96 /* Matrix coefficient 3 */ |
@@ -358,6 +358,14 @@ | |||
358 | #define VOSZ_VGA 0xF0 | 358 | #define VOSZ_VGA 0xF0 |
359 | #define VOSZ_QVGA 0x78 | 359 | #define VOSZ_QVGA 0x78 |
360 | 360 | ||
361 | /* DSPAUTO (DSP Auto Function ON/OFF Control) */ | ||
362 | #define AWB_ACTRL 0x80 /* AWB auto threshold control */ | ||
363 | #define DENOISE_ACTRL 0x40 /* De-noise auto threshold control */ | ||
364 | #define EDGE_ACTRL 0x20 /* Edge enhancement auto strength control */ | ||
365 | #define UV_ACTRL 0x10 /* UV adjust auto slope control */ | ||
366 | #define SCAL0_ACTRL 0x08 /* Auto scaling factor control */ | ||
367 | #define SCAL1_2_ACTRL 0x04 /* Auto scaling factor control */ | ||
368 | |||
361 | /* | 369 | /* |
362 | * ID | 370 | * ID |
363 | */ | 371 | */ |
@@ -670,7 +678,7 @@ static int ov772x_set_bus_param(struct soc_camera_device *icd, | |||
670 | static unsigned long ov772x_query_bus_param(struct soc_camera_device *icd) | 678 | static unsigned long ov772x_query_bus_param(struct soc_camera_device *icd) |
671 | { | 679 | { |
672 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | 680 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); |
673 | struct soc_camera_link *icl = priv->client->dev.platform_data; | 681 | struct soc_camera_link *icl = &priv->info->link; |
674 | unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER | | 682 | unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER | |
675 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH | | 683 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH | |
676 | SOCAM_DATA_ACTIVE_HIGH | priv->info->buswidth; | 684 | SOCAM_DATA_ACTIVE_HIGH | priv->info->buswidth; |
@@ -816,6 +824,53 @@ static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height, | |||
816 | ov772x_reset(priv->client); | 824 | ov772x_reset(priv->client); |
817 | 825 | ||
818 | /* | 826 | /* |
827 | * Edge Ctrl | ||
828 | */ | ||
829 | if (priv->info->edgectrl.strength & OV772X_MANUAL_EDGE_CTRL) { | ||
830 | |||
831 | /* | ||
832 | * Manual Edge Control Mode | ||
833 | * | ||
834 | * Edge auto strength bit is set by default. | ||
835 | * Remove it when manual mode. | ||
836 | */ | ||
837 | |||
838 | ret = ov772x_mask_set(priv->client, DSPAUTO, EDGE_ACTRL, 0x00); | ||
839 | if (ret < 0) | ||
840 | goto ov772x_set_fmt_error; | ||
841 | |||
842 | ret = ov772x_mask_set(priv->client, | ||
843 | EDGE_TRSHLD, EDGE_THRESHOLD_MASK, | ||
844 | priv->info->edgectrl.threshold); | ||
845 | if (ret < 0) | ||
846 | goto ov772x_set_fmt_error; | ||
847 | |||
848 | ret = ov772x_mask_set(priv->client, | ||
849 | EDGE_STRNGT, EDGE_STRENGTH_MASK, | ||
850 | priv->info->edgectrl.strength); | ||
851 | if (ret < 0) | ||
852 | goto ov772x_set_fmt_error; | ||
853 | |||
854 | } else if (priv->info->edgectrl.upper > priv->info->edgectrl.lower) { | ||
855 | /* | ||
856 | * Auto Edge Control Mode | ||
857 | * | ||
858 | * set upper and lower limit | ||
859 | */ | ||
860 | ret = ov772x_mask_set(priv->client, | ||
861 | EDGE_UPPER, EDGE_UPPER_MASK, | ||
862 | priv->info->edgectrl.upper); | ||
863 | if (ret < 0) | ||
864 | goto ov772x_set_fmt_error; | ||
865 | |||
866 | ret = ov772x_mask_set(priv->client, | ||
867 | EDGE_LOWER, EDGE_LOWER_MASK, | ||
868 | priv->info->edgectrl.lower); | ||
869 | if (ret < 0) | ||
870 | goto ov772x_set_fmt_error; | ||
871 | } | ||
872 | |||
873 | /* | ||
819 | * set size format | 874 | * set size format |
820 | */ | 875 | */ |
821 | ret = ov772x_write_array(priv->client, priv->win->regs); | 876 | ret = ov772x_write_array(priv->client, priv->win->regs); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c index ccf2a3c7ad06..10ef1a2c13ea 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-audio.c +++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c | |||
@@ -58,9 +58,9 @@ static const struct routing_scheme routing_schemes[] = { | |||
58 | void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 58 | void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
59 | { | 59 | { |
60 | if (hdw->input_dirty || hdw->force_dirty) { | 60 | if (hdw->input_dirty || hdw->force_dirty) { |
61 | struct v4l2_routing route; | ||
62 | const struct routing_scheme *sp; | 61 | const struct routing_scheme *sp; |
63 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | 62 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
63 | u32 input; | ||
64 | 64 | ||
65 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); | 65 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); |
66 | 66 | ||
@@ -68,7 +68,7 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
68 | ((sp = routing_schemes + sid) != NULL) && | 68 | ((sp = routing_schemes + sid) != NULL) && |
69 | (hdw->input_val >= 0) && | 69 | (hdw->input_val >= 0) && |
70 | (hdw->input_val < sp->cnt)) { | 70 | (hdw->input_val < sp->cnt)) { |
71 | route.input = sp->def[hdw->input_val]; | 71 | input = sp->def[hdw->input_val]; |
72 | } else { | 72 | } else { |
73 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 73 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
74 | "*** WARNING *** subdev msp3400 set_input:" | 74 | "*** WARNING *** subdev msp3400 set_input:" |
@@ -77,8 +77,8 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
77 | sid, hdw->input_val); | 77 | sid, hdw->input_val); |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | 80 | sd->ops->audio->s_routing(sd, input, |
81 | sd->ops->audio->s_routing(sd, &route); | 81 | MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c index b5c3428ebb9f..9023adf3fdcc 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c +++ b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c | |||
@@ -60,16 +60,16 @@ static const struct routing_scheme routing_schemes[] = { | |||
60 | void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 60 | void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
61 | { | 61 | { |
62 | if (hdw->input_dirty || hdw->force_dirty) { | 62 | if (hdw->input_dirty || hdw->force_dirty) { |
63 | struct v4l2_routing route; | ||
64 | const struct routing_scheme *sp; | 63 | const struct routing_scheme *sp; |
65 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | 64 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
65 | u32 input; | ||
66 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", | 66 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", |
67 | hdw->input_val); | 67 | hdw->input_val); |
68 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 68 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
69 | ((sp = routing_schemes + sid) != NULL) && | 69 | ((sp = routing_schemes + sid) != NULL) && |
70 | (hdw->input_val >= 0) && | 70 | (hdw->input_val >= 0) && |
71 | (hdw->input_val < sp->cnt)) { | 71 | (hdw->input_val < sp->cnt)) { |
72 | route.input = sp->def[hdw->input_val]; | 72 | input = sp->def[hdw->input_val]; |
73 | } else { | 73 | } else { |
74 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 74 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
75 | "*** WARNING *** subdev v4l2 set_input:" | 75 | "*** WARNING *** subdev v4l2 set_input:" |
@@ -78,8 +78,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
78 | sid, hdw->input_val); | 78 | sid, hdw->input_val); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | route.output = 0; | 81 | sd->ops->audio->s_routing(sd, input, 0, 0); |
82 | sd->ops->audio->s_routing(sd, &route); | ||
83 | } | 82 | } |
84 | } | 83 | } |
85 | 84 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index 203f54cd18a1..1b992b847198 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c | |||
@@ -137,14 +137,12 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr) | |||
137 | int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr, int *valptr) | 137 | int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr, int *valptr) |
138 | { | 138 | { |
139 | int ret = 0; | 139 | int ret = 0; |
140 | if (!cptr) return 0; | 140 | if (!cptr) return -EINVAL; |
141 | LOCK_TAKE(cptr->hdw->big_lock); do { | 141 | LOCK_TAKE(cptr->hdw->big_lock); do { |
142 | if (cptr->info->type == pvr2_ctl_int) { | 142 | if (cptr->info->get_def_value) { |
143 | if (cptr->info->get_def_value) { | 143 | ret = cptr->info->get_def_value(cptr, valptr); |
144 | ret = cptr->info->get_def_value(cptr, valptr); | 144 | } else { |
145 | } else { | 145 | *valptr = cptr->info->default_value; |
146 | *valptr = cptr->info->default_value; | ||
147 | } | ||
148 | } | 146 | } |
149 | } while(0); LOCK_GIVE(cptr->hdw->big_lock); | 147 | } while(0); LOCK_GIVE(cptr->hdw->big_lock); |
150 | return ret; | 148 | return ret; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c index 4e017ff26c36..05e52358ae49 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c +++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c | |||
@@ -105,14 +105,11 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
105 | { | 105 | { |
106 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update..."); | 106 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update..."); |
107 | if (hdw->input_dirty || hdw->force_dirty) { | 107 | if (hdw->input_dirty || hdw->force_dirty) { |
108 | struct v4l2_routing route; | ||
109 | enum cx25840_video_input vid_input; | 108 | enum cx25840_video_input vid_input; |
110 | enum cx25840_audio_input aud_input; | 109 | enum cx25840_audio_input aud_input; |
111 | const struct routing_scheme *sp; | 110 | const struct routing_scheme *sp; |
112 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | 111 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
113 | 112 | ||
114 | memset(&route, 0, sizeof(route)); | ||
115 | |||
116 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 113 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
117 | ((sp = routing_schemes + sid) != NULL) && | 114 | ((sp = routing_schemes + sid) != NULL) && |
118 | (hdw->input_val >= 0) && | 115 | (hdw->input_val >= 0) && |
@@ -131,10 +128,8 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
131 | pvr2_trace(PVR2_TRACE_CHIPS, | 128 | pvr2_trace(PVR2_TRACE_CHIPS, |
132 | "subdev cx2584x set_input vid=0x%x aud=0x%x", | 129 | "subdev cx2584x set_input vid=0x%x aud=0x%x", |
133 | vid_input, aud_input); | 130 | vid_input, aud_input); |
134 | route.input = (u32)vid_input; | 131 | sd->ops->video->s_routing(sd, (u32)vid_input, 0, 0); |
135 | sd->ops->video->s_routing(sd, &route); | 132 | sd->ops->audio->s_routing(sd, (u32)aud_input, 0, 0); |
136 | route.input = (u32)aud_input; | ||
137 | sd->ops->audio->s_routing(sd, &route); | ||
138 | } | 133 | } |
139 | } | 134 | } |
140 | 135 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 7a65b42a4f53..d9d974a8f52a 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -2039,7 +2039,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, | |||
2039 | "Module ID %u:" | 2039 | "Module ID %u:" |
2040 | " Setting up with specified i2c address 0x%x", | 2040 | " Setting up with specified i2c address 0x%x", |
2041 | mid, i2caddr[0]); | 2041 | mid, i2caddr[0]); |
2042 | sd = v4l2_i2c_new_subdev(&hdw->i2c_adap, | 2042 | sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, |
2043 | fname, fname, | 2043 | fname, fname, |
2044 | i2caddr[0]); | 2044 | i2caddr[0]); |
2045 | } else { | 2045 | } else { |
@@ -2047,7 +2047,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, | |||
2047 | "Module ID %u:" | 2047 | "Module ID %u:" |
2048 | " Setting up with address probe list", | 2048 | " Setting up with address probe list", |
2049 | mid); | 2049 | mid); |
2050 | sd = v4l2_i2c_new_probed_subdev(&hdw->i2c_adap, | 2050 | sd = v4l2_i2c_new_probed_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, |
2051 | fname, fname, | 2051 | fname, fname, |
2052 | i2caddr); | 2052 | i2caddr); |
2053 | } | 2053 | } |
@@ -2185,7 +2185,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) | |||
2185 | pvr2_hdw_load_modules(hdw); | 2185 | pvr2_hdw_load_modules(hdw); |
2186 | if (!pvr2_hdw_dev_ok(hdw)) return; | 2186 | if (!pvr2_hdw_dev_ok(hdw)) return; |
2187 | 2187 | ||
2188 | v4l2_device_call_all(&hdw->v4l2_dev, 0, core, init, 0); | 2188 | v4l2_device_call_all(&hdw->v4l2_dev, 0, core, load_fw); |
2189 | 2189 | ||
2190 | for (idx = 0; idx < CTRLDEF_COUNT; idx++) { | 2190 | for (idx = 0; idx < CTRLDEF_COUNT; idx++) { |
2191 | cptr = hdw->controls + idx; | 2191 | cptr = hdw->controls + idx; |
@@ -2574,7 +2574,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2574 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); | 2574 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); |
2575 | if (!hdw->ctl_read_urb) goto fail; | 2575 | if (!hdw->ctl_read_urb) goto fail; |
2576 | 2576 | ||
2577 | if (v4l2_device_register(&usb_dev->dev, &hdw->v4l2_dev) != 0) { | 2577 | if (v4l2_device_register(&intf->dev, &hdw->v4l2_dev) != 0) { |
2578 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 2578 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
2579 | "Error registering with v4l core, giving up"); | 2579 | "Error registering with v4l core, giving up"); |
2580 | goto fail; | 2580 | goto fail; |
@@ -2926,6 +2926,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) | |||
2926 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev tuner set_type(%d)", | 2926 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev tuner set_type(%d)", |
2927 | hdw->tuner_type); | 2927 | hdw->tuner_type); |
2928 | if (((int)(hdw->tuner_type)) >= 0) { | 2928 | if (((int)(hdw->tuner_type)) >= 0) { |
2929 | memset(&setup, 0, sizeof(setup)); | ||
2929 | setup.addr = ADDR_UNSET; | 2930 | setup.addr = ADDR_UNSET; |
2930 | setup.type = hdw->tuner_type; | 2931 | setup.type = hdw->tuner_type; |
2931 | setup.mode_mask = T_RADIO | T_ANALOG_TV; | 2932 | setup.mode_mask = T_RADIO | T_ANALOG_TV; |
@@ -2943,7 +2944,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) | |||
2943 | v4l2_std_id vs; | 2944 | v4l2_std_id vs; |
2944 | vs = hdw->std_mask_cur; | 2945 | vs = hdw->std_mask_cur; |
2945 | v4l2_device_call_all(&hdw->v4l2_dev, 0, | 2946 | v4l2_device_call_all(&hdw->v4l2_dev, 0, |
2946 | tuner, s_std, vs); | 2947 | core, s_std, vs); |
2947 | } | 2948 | } |
2948 | hdw->tuner_signal_stale = !0; | 2949 | hdw->tuner_signal_stale = !0; |
2949 | hdw->cropcap_stale = !0; | 2950 | hdw->cropcap_stale = !0; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index 9464862745fa..9af282f9e765 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | |||
@@ -520,16 +520,6 @@ static u32 pvr2_i2c_functionality(struct i2c_adapter *adap) | |||
520 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; | 520 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; |
521 | } | 521 | } |
522 | 522 | ||
523 | static int pvr2_i2c_attach_inform(struct i2c_client *client) | ||
524 | { | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static int pvr2_i2c_detach_inform(struct i2c_client *client) | ||
529 | { | ||
530 | return 0; | ||
531 | } | ||
532 | |||
533 | static struct i2c_algorithm pvr2_i2c_algo_template = { | 523 | static struct i2c_algorithm pvr2_i2c_algo_template = { |
534 | .master_xfer = pvr2_i2c_xfer, | 524 | .master_xfer = pvr2_i2c_xfer, |
535 | .functionality = pvr2_i2c_functionality, | 525 | .functionality = pvr2_i2c_functionality, |
@@ -539,8 +529,6 @@ static struct i2c_adapter pvr2_i2c_adap_template = { | |||
539 | .owner = THIS_MODULE, | 529 | .owner = THIS_MODULE, |
540 | .class = 0, | 530 | .class = 0, |
541 | .id = I2C_HW_B_BT848, | 531 | .id = I2C_HW_B_BT848, |
542 | .client_register = pvr2_i2c_attach_inform, | ||
543 | .client_unregister = pvr2_i2c_detach_inform, | ||
544 | }; | 532 | }; |
545 | 533 | ||
546 | 534 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index e20ba1e6e0ea..299c1cbc3832 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
@@ -153,14 +153,16 @@ static ssize_t show_def(struct device *class_dev, | |||
153 | struct pvr2_sysfs_ctl_item *cip; | 153 | struct pvr2_sysfs_ctl_item *cip; |
154 | int val; | 154 | int val; |
155 | int ret; | 155 | int ret; |
156 | unsigned int cnt = 0; | ||
156 | cip = container_of(attr, struct pvr2_sysfs_ctl_item, attr_def); | 157 | cip = container_of(attr, struct pvr2_sysfs_ctl_item, attr_def); |
157 | ret = pvr2_ctrl_get_def(cip->cptr, &val); | 158 | ret = pvr2_ctrl_get_def(cip->cptr, &val); |
158 | pvr2_sysfs_trace("pvr2_sysfs(%p) show_def(cid=%d) is %d, stat=%d", | 159 | if (ret < 0) return ret; |
159 | cip->chptr, cip->ctl_id, val, ret); | 160 | ret = pvr2_ctrl_value_to_sym(cip->cptr, ~0, val, |
160 | if (ret < 0) { | 161 | buf, PAGE_SIZE - 1, &cnt); |
161 | return ret; | 162 | pvr2_sysfs_trace("pvr2_sysfs(%p) show_def(cid=%d) is %.*s (%d)", |
162 | } | 163 | cip->chptr, cip->ctl_id, cnt, buf, val); |
163 | return scnprintf(buf, PAGE_SIZE, "%d\n", val); | 164 | buf[cnt] = '\n'; |
165 | return cnt + 1; | ||
164 | } | 166 | } |
165 | 167 | ||
166 | static ssize_t show_val_norm(struct device *class_dev, | 168 | static ssize_t show_val_norm(struct device *class_dev, |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c index b3862f5554bd..d2fe7c8f2c3a 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c +++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c | |||
@@ -75,16 +75,17 @@ static const struct routing_scheme routing_schemes[] = { | |||
75 | void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 75 | void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
76 | { | 76 | { |
77 | if (hdw->input_dirty || hdw->force_dirty) { | 77 | if (hdw->input_dirty || hdw->force_dirty) { |
78 | struct v4l2_routing route; | ||
79 | const struct routing_scheme *sp; | 78 | const struct routing_scheme *sp; |
80 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | 79 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
80 | u32 input; | ||
81 | |||
81 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", | 82 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", |
82 | hdw->input_val); | 83 | hdw->input_val); |
83 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 84 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
84 | ((sp = routing_schemes + sid) != NULL) && | 85 | ((sp = routing_schemes + sid) != NULL) && |
85 | (hdw->input_val >= 0) && | 86 | (hdw->input_val >= 0) && |
86 | (hdw->input_val < sp->cnt)) { | 87 | (hdw->input_val < sp->cnt)) { |
87 | route.input = sp->def[hdw->input_val]; | 88 | input = sp->def[hdw->input_val]; |
88 | } else { | 89 | } else { |
89 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 90 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
90 | "*** WARNING *** subdev v4l2 set_input:" | 91 | "*** WARNING *** subdev v4l2 set_input:" |
@@ -93,8 +94,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
93 | sid, hdw->input_val); | 94 | sid, hdw->input_val); |
94 | return; | 95 | return; |
95 | } | 96 | } |
96 | route.output = 0; | 97 | sd->ops->video->s_routing(sd, input, 0, 0); |
97 | sd->ops->video->s_routing(sd, &route); | ||
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c index 1670aa4051ce..8c1eae05aa08 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c +++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c | |||
@@ -39,24 +39,22 @@ | |||
39 | void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 39 | void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
40 | { | 40 | { |
41 | if (hdw->input_dirty || hdw->force_dirty) { | 41 | if (hdw->input_dirty || hdw->force_dirty) { |
42 | struct v4l2_routing route; | 42 | u32 input; |
43 | |||
44 | memset(&route, 0, sizeof(route)); | ||
45 | 43 | ||
46 | switch (hdw->input_val) { | 44 | switch (hdw->input_val) { |
47 | case PVR2_CVAL_INPUT_RADIO: | 45 | case PVR2_CVAL_INPUT_RADIO: |
48 | route.input = 1; | 46 | input = 1; |
49 | break; | 47 | break; |
50 | default: | 48 | default: |
51 | /* All other cases just use the second input */ | 49 | /* All other cases just use the second input */ |
52 | route.input = 2; | 50 | input = 2; |
53 | break; | 51 | break; |
54 | } | 52 | } |
55 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775" | 53 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775" |
56 | " set_input(val=%d route=0x%x)", | 54 | " set_input(val=%d route=0x%x)", |
57 | hdw->input_val, route.input); | 55 | hdw->input_val, input); |
58 | 56 | ||
59 | sd->ops->audio->s_routing(sd, &route); | 57 | sd->ops->audio->s_routing(sd, input, 0, 0); |
60 | } | 58 | } |
61 | } | 59 | } |
62 | 60 | ||
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig index 8b9f0aa844a1..340f954aba34 100644 --- a/drivers/media/video/pwc/Kconfig +++ b/drivers/media/video/pwc/Kconfig | |||
@@ -39,7 +39,7 @@ config USB_PWC_DEBUG | |||
39 | config USB_PWC_INPUT_EVDEV | 39 | config USB_PWC_INPUT_EVDEV |
40 | bool "USB Philips Cameras input events device support" | 40 | bool "USB Philips Cameras input events device support" |
41 | default y | 41 | default y |
42 | depends on USB_PWC && INPUT | 42 | depends on USB_PWC=INPUT || INPUT=y |
43 | ---help--- | 43 | ---help--- |
44 | This option makes USB Philips cameras register the snapshot button as | 44 | This option makes USB Philips cameras register the snapshot button as |
45 | an input device to report button events. | 45 | an input device to report button events. |
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index c522616ef38f..c639845460ff 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -163,6 +163,13 @@ | |||
163 | CICR0_EOFM | CICR0_FOM) | 163 | CICR0_EOFM | CICR0_FOM) |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * YUV422P picture size should be a multiple of 16, so the heuristic aligns | ||
167 | * height, width on 4 byte boundaries to reach the 16 multiple for the size. | ||
168 | */ | ||
169 | #define YUV422P_X_Y_ALIGN 4 | ||
170 | #define YUV422P_SIZE_ALIGN YUV422P_X_Y_ALIGN * YUV422P_X_Y_ALIGN | ||
171 | |||
172 | /* | ||
166 | * Structures | 173 | * Structures |
167 | */ | 174 | */ |
168 | enum pxa_camera_active_dma { | 175 | enum pxa_camera_active_dma { |
@@ -236,20 +243,11 @@ static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, | |||
236 | unsigned int *size) | 243 | unsigned int *size) |
237 | { | 244 | { |
238 | struct soc_camera_device *icd = vq->priv_data; | 245 | struct soc_camera_device *icd = vq->priv_data; |
239 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
240 | struct pxa_camera_dev *pcdev = ici->priv; | ||
241 | 246 | ||
242 | dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size); | 247 | dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size); |
243 | 248 | ||
244 | /* planar capture requires Y, U and V buffers to be page aligned */ | 249 | *size = roundup(icd->width * icd->height * |
245 | if (pcdev->channels == 3) { | 250 | ((icd->current_fmt->depth + 7) >> 3), 8); |
246 | *size = PAGE_ALIGN(icd->width * icd->height); /* Y pages */ | ||
247 | *size += PAGE_ALIGN(icd->width * icd->height / 2); /* U pages */ | ||
248 | *size += PAGE_ALIGN(icd->width * icd->height / 2); /* V pages */ | ||
249 | } else { | ||
250 | *size = icd->width * icd->height * | ||
251 | ((icd->current_fmt->depth + 7) >> 3); | ||
252 | } | ||
253 | 251 | ||
254 | if (0 == *count) | 252 | if (0 == *count) |
255 | *count = 32; | 253 | *count = 32; |
@@ -289,19 +287,63 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf) | |||
289 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 287 | buf->vb.state = VIDEOBUF_NEEDS_INIT; |
290 | } | 288 | } |
291 | 289 | ||
290 | static int calculate_dma_sglen(struct scatterlist *sglist, int sglen, | ||
291 | int sg_first_ofs, int size) | ||
292 | { | ||
293 | int i, offset, dma_len, xfer_len; | ||
294 | struct scatterlist *sg; | ||
295 | |||
296 | offset = sg_first_ofs; | ||
297 | for_each_sg(sglist, sg, sglen, i) { | ||
298 | dma_len = sg_dma_len(sg); | ||
299 | |||
300 | /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */ | ||
301 | xfer_len = roundup(min(dma_len - offset, size), 8); | ||
302 | |||
303 | size = max(0, size - xfer_len); | ||
304 | offset = 0; | ||
305 | if (size == 0) | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | BUG_ON(size != 0); | ||
310 | return i + 1; | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * pxa_init_dma_channel - init dma descriptors | ||
315 | * @pcdev: pxa camera device | ||
316 | * @buf: pxa buffer to find pxa dma channel | ||
317 | * @dma: dma video buffer | ||
318 | * @channel: dma channel (0 => 'Y', 1 => 'U', 2 => 'V') | ||
319 | * @cibr: camera Receive Buffer Register | ||
320 | * @size: bytes to transfer | ||
321 | * @sg_first: first element of sg_list | ||
322 | * @sg_first_ofs: offset in first element of sg_list | ||
323 | * | ||
324 | * Prepares the pxa dma descriptors to transfer one camera channel. | ||
325 | * Beware sg_first and sg_first_ofs are both input and output parameters. | ||
326 | * | ||
327 | * Returns 0 or -ENOMEM if no coherent memory is available | ||
328 | */ | ||
292 | static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | 329 | static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, |
293 | struct pxa_buffer *buf, | 330 | struct pxa_buffer *buf, |
294 | struct videobuf_dmabuf *dma, int channel, | 331 | struct videobuf_dmabuf *dma, int channel, |
295 | int sglen, int sg_start, int cibr, | 332 | int cibr, int size, |
296 | unsigned int size) | 333 | struct scatterlist **sg_first, int *sg_first_ofs) |
297 | { | 334 | { |
298 | struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; | 335 | struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; |
299 | int i; | 336 | struct scatterlist *sg; |
337 | int i, offset, sglen; | ||
338 | int dma_len = 0, xfer_len = 0; | ||
300 | 339 | ||
301 | if (pxa_dma->sg_cpu) | 340 | if (pxa_dma->sg_cpu) |
302 | dma_free_coherent(pcdev->dev, pxa_dma->sg_size, | 341 | dma_free_coherent(pcdev->dev, pxa_dma->sg_size, |
303 | pxa_dma->sg_cpu, pxa_dma->sg_dma); | 342 | pxa_dma->sg_cpu, pxa_dma->sg_dma); |
304 | 343 | ||
344 | sglen = calculate_dma_sglen(*sg_first, dma->sglen, | ||
345 | *sg_first_ofs, size); | ||
346 | |||
305 | pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc); | 347 | pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc); |
306 | pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->dev, pxa_dma->sg_size, | 348 | pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->dev, pxa_dma->sg_size, |
307 | &pxa_dma->sg_dma, GFP_KERNEL); | 349 | &pxa_dma->sg_dma, GFP_KERNEL); |
@@ -309,31 +351,75 @@ static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | |||
309 | return -ENOMEM; | 351 | return -ENOMEM; |
310 | 352 | ||
311 | pxa_dma->sglen = sglen; | 353 | pxa_dma->sglen = sglen; |
354 | offset = *sg_first_ofs; | ||
312 | 355 | ||
313 | for (i = 0; i < sglen; i++) { | 356 | dev_dbg(pcdev->dev, "DMA: sg_first=%p, sglen=%d, ofs=%d, dma.desc=%x\n", |
314 | int sg_i = sg_start + i; | 357 | *sg_first, sglen, *sg_first_ofs, pxa_dma->sg_dma); |
315 | struct scatterlist *sg = dma->sglist; | ||
316 | unsigned int dma_len = sg_dma_len(&sg[sg_i]), xfer_len; | ||
317 | 358 | ||
318 | pxa_dma->sg_cpu[i].dsadr = pcdev->res->start + cibr; | 359 | |
319 | pxa_dma->sg_cpu[i].dtadr = sg_dma_address(&sg[sg_i]); | 360 | for_each_sg(*sg_first, sg, sglen, i) { |
361 | dma_len = sg_dma_len(sg); | ||
320 | 362 | ||
321 | /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */ | 363 | /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */ |
322 | xfer_len = (min(dma_len, size) + 7) & ~7; | 364 | xfer_len = roundup(min(dma_len - offset, size), 8); |
323 | 365 | ||
366 | size = max(0, size - xfer_len); | ||
367 | |||
368 | pxa_dma->sg_cpu[i].dsadr = pcdev->res->start + cibr; | ||
369 | pxa_dma->sg_cpu[i].dtadr = sg_dma_address(sg) + offset; | ||
324 | pxa_dma->sg_cpu[i].dcmd = | 370 | pxa_dma->sg_cpu[i].dcmd = |
325 | DCMD_FLOWSRC | DCMD_BURST8 | DCMD_INCTRGADDR | xfer_len; | 371 | DCMD_FLOWSRC | DCMD_BURST8 | DCMD_INCTRGADDR | xfer_len; |
326 | size -= dma_len; | 372 | #ifdef DEBUG |
373 | if (!i) | ||
374 | pxa_dma->sg_cpu[i].dcmd |= DCMD_STARTIRQEN; | ||
375 | #endif | ||
327 | pxa_dma->sg_cpu[i].ddadr = | 376 | pxa_dma->sg_cpu[i].ddadr = |
328 | pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc); | 377 | pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc); |
378 | |||
379 | dev_vdbg(pcdev->dev, "DMA: desc.%08x->@phys=0x%08x, len=%d\n", | ||
380 | pxa_dma->sg_dma + i * sizeof(struct pxa_dma_desc), | ||
381 | sg_dma_address(sg) + offset, xfer_len); | ||
382 | offset = 0; | ||
383 | |||
384 | if (size == 0) | ||
385 | break; | ||
329 | } | 386 | } |
330 | 387 | ||
331 | pxa_dma->sg_cpu[sglen - 1].ddadr = DDADR_STOP; | 388 | pxa_dma->sg_cpu[sglen].ddadr = DDADR_STOP; |
332 | pxa_dma->sg_cpu[sglen - 1].dcmd |= DCMD_ENDIRQEN; | 389 | pxa_dma->sg_cpu[sglen].dcmd = DCMD_FLOWSRC | DCMD_BURST8 | DCMD_ENDIRQEN; |
390 | |||
391 | /* | ||
392 | * Handle 1 special case : | ||
393 | * - in 3 planes (YUV422P format), we might finish with xfer_len equal | ||
394 | * to dma_len (end on PAGE boundary). In this case, the sg element | ||
395 | * for next plane should be the next after the last used to store the | ||
396 | * last scatter gather RAM page | ||
397 | */ | ||
398 | if (xfer_len >= dma_len) { | ||
399 | *sg_first_ofs = xfer_len - dma_len; | ||
400 | *sg_first = sg_next(sg); | ||
401 | } else { | ||
402 | *sg_first_ofs = xfer_len; | ||
403 | *sg_first = sg; | ||
404 | } | ||
333 | 405 | ||
334 | return 0; | 406 | return 0; |
335 | } | 407 | } |
336 | 408 | ||
409 | static void pxa_videobuf_set_actdma(struct pxa_camera_dev *pcdev, | ||
410 | struct pxa_buffer *buf) | ||
411 | { | ||
412 | buf->active_dma = DMA_Y; | ||
413 | if (pcdev->channels == 3) | ||
414 | buf->active_dma |= DMA_U | DMA_V; | ||
415 | } | ||
416 | |||
417 | /* | ||
418 | * Please check the DMA prepared buffer structure in : | ||
419 | * Documentation/video4linux/pxa_camera.txt | ||
420 | * Please check also in pxa_camera_check_link_miss() to understand why DMA chain | ||
421 | * modification while DMA chain is running will work anyway. | ||
422 | */ | ||
337 | static int pxa_videobuf_prepare(struct videobuf_queue *vq, | 423 | static int pxa_videobuf_prepare(struct videobuf_queue *vq, |
338 | struct videobuf_buffer *vb, enum v4l2_field field) | 424 | struct videobuf_buffer *vb, enum v4l2_field field) |
339 | { | 425 | { |
@@ -342,7 +428,6 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
342 | struct pxa_camera_dev *pcdev = ici->priv; | 428 | struct pxa_camera_dev *pcdev = ici->priv; |
343 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | 429 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); |
344 | int ret; | 430 | int ret; |
345 | int sglen_y, sglen_yu = 0, sglen_u = 0, sglen_v = 0; | ||
346 | int size_y, size_u = 0, size_v = 0; | 431 | int size_y, size_u = 0, size_v = 0; |
347 | 432 | ||
348 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | 433 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, |
@@ -381,62 +466,58 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq, | |||
381 | } | 466 | } |
382 | 467 | ||
383 | if (vb->state == VIDEOBUF_NEEDS_INIT) { | 468 | if (vb->state == VIDEOBUF_NEEDS_INIT) { |
384 | unsigned int size = vb->size; | 469 | int size = vb->size; |
470 | int next_ofs = 0; | ||
385 | struct videobuf_dmabuf *dma = videobuf_to_dma(vb); | 471 | struct videobuf_dmabuf *dma = videobuf_to_dma(vb); |
472 | struct scatterlist *sg; | ||
386 | 473 | ||
387 | ret = videobuf_iolock(vq, vb, NULL); | 474 | ret = videobuf_iolock(vq, vb, NULL); |
388 | if (ret) | 475 | if (ret) |
389 | goto fail; | 476 | goto fail; |
390 | 477 | ||
391 | if (pcdev->channels == 3) { | 478 | if (pcdev->channels == 3) { |
392 | /* FIXME the calculations should be more precise */ | ||
393 | sglen_y = dma->sglen / 2; | ||
394 | sglen_u = sglen_v = dma->sglen / 4 + 1; | ||
395 | sglen_yu = sglen_y + sglen_u; | ||
396 | size_y = size / 2; | 479 | size_y = size / 2; |
397 | size_u = size_v = size / 4; | 480 | size_u = size_v = size / 4; |
398 | } else { | 481 | } else { |
399 | sglen_y = dma->sglen; | ||
400 | size_y = size; | 482 | size_y = size; |
401 | } | 483 | } |
402 | 484 | ||
403 | /* init DMA for Y channel */ | 485 | sg = dma->sglist; |
404 | ret = pxa_init_dma_channel(pcdev, buf, dma, 0, sglen_y, | ||
405 | 0, 0x28, size_y); | ||
406 | 486 | ||
487 | /* init DMA for Y channel */ | ||
488 | ret = pxa_init_dma_channel(pcdev, buf, dma, 0, CIBR0, size_y, | ||
489 | &sg, &next_ofs); | ||
407 | if (ret) { | 490 | if (ret) { |
408 | dev_err(pcdev->dev, | 491 | dev_err(pcdev->dev, |
409 | "DMA initialization for Y/RGB failed\n"); | 492 | "DMA initialization for Y/RGB failed\n"); |
410 | goto fail; | 493 | goto fail; |
411 | } | 494 | } |
412 | 495 | ||
413 | if (pcdev->channels == 3) { | 496 | /* init DMA for U channel */ |
414 | /* init DMA for U channel */ | 497 | if (size_u) |
415 | ret = pxa_init_dma_channel(pcdev, buf, dma, 1, sglen_u, | 498 | ret = pxa_init_dma_channel(pcdev, buf, dma, 1, CIBR1, |
416 | sglen_y, 0x30, size_u); | 499 | size_u, &sg, &next_ofs); |
417 | if (ret) { | 500 | if (ret) { |
418 | dev_err(pcdev->dev, | 501 | dev_err(pcdev->dev, |
419 | "DMA initialization for U failed\n"); | 502 | "DMA initialization for U failed\n"); |
420 | goto fail_u; | 503 | goto fail_u; |
421 | } | 504 | } |
422 | 505 | ||
423 | /* init DMA for V channel */ | 506 | /* init DMA for V channel */ |
424 | ret = pxa_init_dma_channel(pcdev, buf, dma, 2, sglen_v, | 507 | if (size_v) |
425 | sglen_yu, 0x38, size_v); | 508 | ret = pxa_init_dma_channel(pcdev, buf, dma, 2, CIBR2, |
426 | if (ret) { | 509 | size_v, &sg, &next_ofs); |
427 | dev_err(pcdev->dev, | 510 | if (ret) { |
428 | "DMA initialization for V failed\n"); | 511 | dev_err(pcdev->dev, |
429 | goto fail_v; | 512 | "DMA initialization for V failed\n"); |
430 | } | 513 | goto fail_v; |
431 | } | 514 | } |
432 | 515 | ||
433 | vb->state = VIDEOBUF_PREPARED; | 516 | vb->state = VIDEOBUF_PREPARED; |
434 | } | 517 | } |
435 | 518 | ||
436 | buf->inwork = 0; | 519 | buf->inwork = 0; |
437 | buf->active_dma = DMA_Y; | 520 | pxa_videobuf_set_actdma(pcdev, buf); |
438 | if (pcdev->channels == 3) | ||
439 | buf->active_dma |= DMA_U | DMA_V; | ||
440 | 521 | ||
441 | return 0; | 522 | return 0; |
442 | 523 | ||
@@ -453,6 +534,92 @@ out: | |||
453 | return ret; | 534 | return ret; |
454 | } | 535 | } |
455 | 536 | ||
537 | /** | ||
538 | * pxa_dma_start_channels - start DMA channel for active buffer | ||
539 | * @pcdev: pxa camera device | ||
540 | * | ||
541 | * Initialize DMA channels to the beginning of the active video buffer, and | ||
542 | * start these channels. | ||
543 | */ | ||
544 | static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev) | ||
545 | { | ||
546 | int i; | ||
547 | struct pxa_buffer *active; | ||
548 | |||
549 | active = pcdev->active; | ||
550 | |||
551 | for (i = 0; i < pcdev->channels; i++) { | ||
552 | dev_dbg(pcdev->dev, "%s (channel=%d) ddadr=%08x\n", __func__, | ||
553 | i, active->dmas[i].sg_dma); | ||
554 | DDADR(pcdev->dma_chans[i]) = active->dmas[i].sg_dma; | ||
555 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
556 | } | ||
557 | } | ||
558 | |||
559 | static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev) | ||
560 | { | ||
561 | int i; | ||
562 | |||
563 | for (i = 0; i < pcdev->channels; i++) { | ||
564 | dev_dbg(pcdev->dev, "%s (channel=%d)\n", __func__, i); | ||
565 | DCSR(pcdev->dma_chans[i]) = 0; | ||
566 | } | ||
567 | } | ||
568 | |||
569 | static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev, | ||
570 | struct pxa_buffer *buf) | ||
571 | { | ||
572 | int i; | ||
573 | struct pxa_dma_desc *buf_last_desc; | ||
574 | |||
575 | for (i = 0; i < pcdev->channels; i++) { | ||
576 | buf_last_desc = buf->dmas[i].sg_cpu + buf->dmas[i].sglen; | ||
577 | buf_last_desc->ddadr = DDADR_STOP; | ||
578 | |||
579 | if (pcdev->sg_tail[i]) | ||
580 | /* Link the new buffer to the old tail */ | ||
581 | pcdev->sg_tail[i]->ddadr = buf->dmas[i].sg_dma; | ||
582 | |||
583 | /* Update the channel tail */ | ||
584 | pcdev->sg_tail[i] = buf_last_desc; | ||
585 | } | ||
586 | } | ||
587 | |||
588 | /** | ||
589 | * pxa_camera_start_capture - start video capturing | ||
590 | * @pcdev: camera device | ||
591 | * | ||
592 | * Launch capturing. DMA channels should not be active yet. They should get | ||
593 | * activated at the end of frame interrupt, to capture only whole frames, and | ||
594 | * never begin the capture of a partial frame. | ||
595 | */ | ||
596 | static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev) | ||
597 | { | ||
598 | unsigned long cicr0, cifr; | ||
599 | |||
600 | dev_dbg(pcdev->dev, "%s\n", __func__); | ||
601 | /* Reset the FIFOs */ | ||
602 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; | ||
603 | __raw_writel(cifr, pcdev->base + CIFR); | ||
604 | /* Enable End-Of-Frame Interrupt */ | ||
605 | cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB; | ||
606 | cicr0 &= ~CICR0_EOFM; | ||
607 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
608 | } | ||
609 | |||
610 | static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev) | ||
611 | { | ||
612 | unsigned long cicr0; | ||
613 | |||
614 | pxa_dma_stop_channels(pcdev); | ||
615 | |||
616 | cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB; | ||
617 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
618 | |||
619 | pcdev->active = NULL; | ||
620 | dev_dbg(pcdev->dev, "%s\n", __func__); | ||
621 | } | ||
622 | |||
456 | static void pxa_videobuf_queue(struct videobuf_queue *vq, | 623 | static void pxa_videobuf_queue(struct videobuf_queue *vq, |
457 | struct videobuf_buffer *vb) | 624 | struct videobuf_buffer *vb) |
458 | { | 625 | { |
@@ -460,81 +627,20 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq, | |||
460 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 627 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
461 | struct pxa_camera_dev *pcdev = ici->priv; | 628 | struct pxa_camera_dev *pcdev = ici->priv; |
462 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | 629 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); |
463 | struct pxa_buffer *active; | ||
464 | unsigned long flags; | 630 | unsigned long flags; |
465 | int i; | ||
466 | 631 | ||
467 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | 632 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d active=%p\n", __func__, |
468 | vb, vb->baddr, vb->bsize); | 633 | vb, vb->baddr, vb->bsize, pcdev->active); |
634 | |||
469 | spin_lock_irqsave(&pcdev->lock, flags); | 635 | spin_lock_irqsave(&pcdev->lock, flags); |
470 | 636 | ||
471 | list_add_tail(&vb->queue, &pcdev->capture); | 637 | list_add_tail(&vb->queue, &pcdev->capture); |
472 | 638 | ||
473 | vb->state = VIDEOBUF_ACTIVE; | 639 | vb->state = VIDEOBUF_ACTIVE; |
474 | active = pcdev->active; | 640 | pxa_dma_add_tail_buf(pcdev, buf); |
475 | 641 | ||
476 | if (!active) { | 642 | if (!pcdev->active) |
477 | unsigned long cifr, cicr0; | 643 | pxa_camera_start_capture(pcdev); |
478 | |||
479 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; | ||
480 | __raw_writel(cifr, pcdev->base + CIFR); | ||
481 | |||
482 | for (i = 0; i < pcdev->channels; i++) { | ||
483 | DDADR(pcdev->dma_chans[i]) = buf->dmas[i].sg_dma; | ||
484 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
485 | pcdev->sg_tail[i] = buf->dmas[i].sg_cpu + buf->dmas[i].sglen - 1; | ||
486 | } | ||
487 | |||
488 | pcdev->active = buf; | ||
489 | |||
490 | cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB; | ||
491 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
492 | } else { | ||
493 | struct pxa_cam_dma *buf_dma; | ||
494 | struct pxa_cam_dma *act_dma; | ||
495 | int nents; | ||
496 | |||
497 | for (i = 0; i < pcdev->channels; i++) { | ||
498 | buf_dma = &buf->dmas[i]; | ||
499 | act_dma = &active->dmas[i]; | ||
500 | nents = buf_dma->sglen; | ||
501 | |||
502 | /* Stop DMA engine */ | ||
503 | DCSR(pcdev->dma_chans[i]) = 0; | ||
504 | |||
505 | /* Add the descriptors we just initialized to | ||
506 | the currently running chain */ | ||
507 | pcdev->sg_tail[i]->ddadr = buf_dma->sg_dma; | ||
508 | pcdev->sg_tail[i] = buf_dma->sg_cpu + buf_dma->sglen - 1; | ||
509 | |||
510 | /* Setup a dummy descriptor with the DMA engines current | ||
511 | * state | ||
512 | */ | ||
513 | buf_dma->sg_cpu[nents].dsadr = | ||
514 | pcdev->res->start + 0x28 + i*8; /* CIBRx */ | ||
515 | buf_dma->sg_cpu[nents].dtadr = | ||
516 | DTADR(pcdev->dma_chans[i]); | ||
517 | buf_dma->sg_cpu[nents].dcmd = | ||
518 | DCMD(pcdev->dma_chans[i]); | ||
519 | |||
520 | if (DDADR(pcdev->dma_chans[i]) == DDADR_STOP) { | ||
521 | /* The DMA engine is on the last | ||
522 | descriptor, set the next descriptors | ||
523 | address to the descriptors we just | ||
524 | initialized */ | ||
525 | buf_dma->sg_cpu[nents].ddadr = buf_dma->sg_dma; | ||
526 | } else { | ||
527 | buf_dma->sg_cpu[nents].ddadr = | ||
528 | DDADR(pcdev->dma_chans[i]); | ||
529 | } | ||
530 | |||
531 | /* The next descriptor is the dummy descriptor */ | ||
532 | DDADR(pcdev->dma_chans[i]) = buf_dma->sg_dma + nents * | ||
533 | sizeof(struct pxa_dma_desc); | ||
534 | |||
535 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
536 | } | ||
537 | } | ||
538 | 644 | ||
539 | spin_unlock_irqrestore(&pcdev->lock, flags); | 645 | spin_unlock_irqrestore(&pcdev->lock, flags); |
540 | } | 646 | } |
@@ -572,7 +678,7 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, | |||
572 | struct videobuf_buffer *vb, | 678 | struct videobuf_buffer *vb, |
573 | struct pxa_buffer *buf) | 679 | struct pxa_buffer *buf) |
574 | { | 680 | { |
575 | unsigned long cicr0; | 681 | int i; |
576 | 682 | ||
577 | /* _init is used to debug races, see comment in pxa_camera_reqbufs() */ | 683 | /* _init is used to debug races, see comment in pxa_camera_reqbufs() */ |
578 | list_del_init(&vb->queue); | 684 | list_del_init(&vb->queue); |
@@ -580,15 +686,12 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, | |||
580 | do_gettimeofday(&vb->ts); | 686 | do_gettimeofday(&vb->ts); |
581 | vb->field_count++; | 687 | vb->field_count++; |
582 | wake_up(&vb->done); | 688 | wake_up(&vb->done); |
689 | dev_dbg(pcdev->dev, "%s dequeud buffer (vb=0x%p)\n", __func__, vb); | ||
583 | 690 | ||
584 | if (list_empty(&pcdev->capture)) { | 691 | if (list_empty(&pcdev->capture)) { |
585 | pcdev->active = NULL; | 692 | pxa_camera_stop_capture(pcdev); |
586 | DCSR(pcdev->dma_chans[0]) = 0; | 693 | for (i = 0; i < pcdev->channels; i++) |
587 | DCSR(pcdev->dma_chans[1]) = 0; | 694 | pcdev->sg_tail[i] = NULL; |
588 | DCSR(pcdev->dma_chans[2]) = 0; | ||
589 | |||
590 | cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB; | ||
591 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
592 | return; | 695 | return; |
593 | } | 696 | } |
594 | 697 | ||
@@ -596,6 +699,35 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, | |||
596 | struct pxa_buffer, vb.queue); | 699 | struct pxa_buffer, vb.queue); |
597 | } | 700 | } |
598 | 701 | ||
702 | /** | ||
703 | * pxa_camera_check_link_miss - check missed DMA linking | ||
704 | * @pcdev: camera device | ||
705 | * | ||
706 | * The DMA chaining is done with DMA running. This means a tiny temporal window | ||
707 | * remains, where a buffer is queued on the chain, while the chain is already | ||
708 | * stopped. This means the tailed buffer would never be transfered by DMA. | ||
709 | * This function restarts the capture for this corner case, where : | ||
710 | * - DADR() == DADDR_STOP | ||
711 | * - a videobuffer is queued on the pcdev->capture list | ||
712 | * | ||
713 | * Please check the "DMA hot chaining timeslice issue" in | ||
714 | * Documentation/video4linux/pxa_camera.txt | ||
715 | * | ||
716 | * Context: should only be called within the dma irq handler | ||
717 | */ | ||
718 | static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev) | ||
719 | { | ||
720 | int i, is_dma_stopped = 1; | ||
721 | |||
722 | for (i = 0; i < pcdev->channels; i++) | ||
723 | if (DDADR(pcdev->dma_chans[i]) != DDADR_STOP) | ||
724 | is_dma_stopped = 0; | ||
725 | dev_dbg(pcdev->dev, "%s : top queued buffer=%p, dma_stopped=%d\n", | ||
726 | __func__, pcdev->active, is_dma_stopped); | ||
727 | if (pcdev->active && is_dma_stopped) | ||
728 | pxa_camera_start_capture(pcdev); | ||
729 | } | ||
730 | |||
599 | static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | 731 | static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, |
600 | enum pxa_camera_active_dma act_dma) | 732 | enum pxa_camera_active_dma act_dma) |
601 | { | 733 | { |
@@ -603,61 +735,70 @@ static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | |||
603 | unsigned long flags; | 735 | unsigned long flags; |
604 | u32 status, camera_status, overrun; | 736 | u32 status, camera_status, overrun; |
605 | struct videobuf_buffer *vb; | 737 | struct videobuf_buffer *vb; |
606 | unsigned long cifr, cicr0; | ||
607 | 738 | ||
608 | spin_lock_irqsave(&pcdev->lock, flags); | 739 | spin_lock_irqsave(&pcdev->lock, flags); |
609 | 740 | ||
610 | status = DCSR(channel); | 741 | status = DCSR(channel); |
611 | DCSR(channel) = status | DCSR_ENDINTR; | 742 | DCSR(channel) = status; |
743 | |||
744 | camera_status = __raw_readl(pcdev->base + CISR); | ||
745 | overrun = CISR_IFO_0; | ||
746 | if (pcdev->channels == 3) | ||
747 | overrun |= CISR_IFO_1 | CISR_IFO_2; | ||
612 | 748 | ||
613 | if (status & DCSR_BUSERR) { | 749 | if (status & DCSR_BUSERR) { |
614 | dev_err(pcdev->dev, "DMA Bus Error IRQ!\n"); | 750 | dev_err(pcdev->dev, "DMA Bus Error IRQ!\n"); |
615 | goto out; | 751 | goto out; |
616 | } | 752 | } |
617 | 753 | ||
618 | if (!(status & DCSR_ENDINTR)) { | 754 | if (!(status & (DCSR_ENDINTR | DCSR_STARTINTR))) { |
619 | dev_err(pcdev->dev, "Unknown DMA IRQ source, " | 755 | dev_err(pcdev->dev, "Unknown DMA IRQ source, " |
620 | "status: 0x%08x\n", status); | 756 | "status: 0x%08x\n", status); |
621 | goto out; | 757 | goto out; |
622 | } | 758 | } |
623 | 759 | ||
624 | if (!pcdev->active) { | 760 | /* |
625 | dev_err(pcdev->dev, "DMA End IRQ with no active buffer!\n"); | 761 | * pcdev->active should not be NULL in DMA irq handler. |
626 | goto out; | 762 | * |
627 | } | 763 | * But there is one corner case : if capture was stopped due to an |
628 | 764 | * overrun of channel 1, and at that same channel 2 was completed. | |
629 | camera_status = __raw_readl(pcdev->base + CISR); | 765 | * |
630 | overrun = CISR_IFO_0; | 766 | * When handling the overrun in DMA irq for channel 1, we'll stop the |
631 | if (pcdev->channels == 3) | 767 | * capture and restart it (and thus set pcdev->active to NULL). But the |
632 | overrun |= CISR_IFO_1 | CISR_IFO_2; | 768 | * DMA irq handler will already be pending for channel 2. So on entering |
633 | if (camera_status & overrun) { | 769 | * the DMA irq handler for channel 2 there will be no active buffer, yet |
634 | dev_dbg(pcdev->dev, "FIFO overrun! CISR: %x\n", camera_status); | 770 | * that is normal. |
635 | /* Stop the Capture Interface */ | 771 | */ |
636 | cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB; | 772 | if (!pcdev->active) |
637 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
638 | |||
639 | /* Stop DMA */ | ||
640 | DCSR(channel) = 0; | ||
641 | /* Reset the FIFOs */ | ||
642 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; | ||
643 | __raw_writel(cifr, pcdev->base + CIFR); | ||
644 | /* Enable End-Of-Frame Interrupt */ | ||
645 | cicr0 &= ~CICR0_EOFM; | ||
646 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
647 | /* Restart the Capture Interface */ | ||
648 | __raw_writel(cicr0 | CICR0_ENB, pcdev->base + CICR0); | ||
649 | goto out; | 773 | goto out; |
650 | } | ||
651 | 774 | ||
652 | vb = &pcdev->active->vb; | 775 | vb = &pcdev->active->vb; |
653 | buf = container_of(vb, struct pxa_buffer, vb); | 776 | buf = container_of(vb, struct pxa_buffer, vb); |
654 | WARN_ON(buf->inwork || list_empty(&vb->queue)); | 777 | WARN_ON(buf->inwork || list_empty(&vb->queue)); |
655 | dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
656 | vb, vb->baddr, vb->bsize); | ||
657 | 778 | ||
658 | buf->active_dma &= ~act_dma; | 779 | dev_dbg(pcdev->dev, "%s channel=%d %s%s(vb=0x%p) dma.desc=%x\n", |
659 | if (!buf->active_dma) | 780 | __func__, channel, status & DCSR_STARTINTR ? "SOF " : "", |
660 | pxa_camera_wakeup(pcdev, vb, buf); | 781 | status & DCSR_ENDINTR ? "EOF " : "", vb, DDADR(channel)); |
782 | |||
783 | if (status & DCSR_ENDINTR) { | ||
784 | /* | ||
785 | * It's normal if the last frame creates an overrun, as there | ||
786 | * are no more DMA descriptors to fetch from QCI fifos | ||
787 | */ | ||
788 | if (camera_status & overrun && | ||
789 | !list_is_last(pcdev->capture.next, &pcdev->capture)) { | ||
790 | dev_dbg(pcdev->dev, "FIFO overrun! CISR: %x\n", | ||
791 | camera_status); | ||
792 | pxa_camera_stop_capture(pcdev); | ||
793 | pxa_camera_start_capture(pcdev); | ||
794 | goto out; | ||
795 | } | ||
796 | buf->active_dma &= ~act_dma; | ||
797 | if (!buf->active_dma) { | ||
798 | pxa_camera_wakeup(pcdev, vb, buf); | ||
799 | pxa_camera_check_link_miss(pcdev); | ||
800 | } | ||
801 | } | ||
661 | 802 | ||
662 | out: | 803 | out: |
663 | spin_unlock_irqrestore(&pcdev->lock, flags); | 804 | spin_unlock_irqrestore(&pcdev->lock, flags); |
@@ -786,6 +927,8 @@ static irqreturn_t pxa_camera_irq(int irq, void *data) | |||
786 | { | 927 | { |
787 | struct pxa_camera_dev *pcdev = data; | 928 | struct pxa_camera_dev *pcdev = data; |
788 | unsigned long status, cicr0; | 929 | unsigned long status, cicr0; |
930 | struct pxa_buffer *buf; | ||
931 | struct videobuf_buffer *vb; | ||
789 | 932 | ||
790 | status = __raw_readl(pcdev->base + CISR); | 933 | status = __raw_readl(pcdev->base + CISR); |
791 | dev_dbg(pcdev->dev, "Camera interrupt status 0x%lx\n", status); | 934 | dev_dbg(pcdev->dev, "Camera interrupt status 0x%lx\n", status); |
@@ -796,12 +939,14 @@ static irqreturn_t pxa_camera_irq(int irq, void *data) | |||
796 | __raw_writel(status, pcdev->base + CISR); | 939 | __raw_writel(status, pcdev->base + CISR); |
797 | 940 | ||
798 | if (status & CISR_EOF) { | 941 | if (status & CISR_EOF) { |
799 | int i; | 942 | pcdev->active = list_first_entry(&pcdev->capture, |
800 | for (i = 0; i < pcdev->channels; i++) { | 943 | struct pxa_buffer, vb.queue); |
801 | DDADR(pcdev->dma_chans[i]) = | 944 | vb = &pcdev->active->vb; |
802 | pcdev->active->dmas[i].sg_dma; | 945 | buf = container_of(vb, struct pxa_buffer, vb); |
803 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | 946 | pxa_videobuf_set_actdma(pcdev, buf); |
804 | } | 947 | |
948 | pxa_dma_start_channels(pcdev); | ||
949 | |||
805 | cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM; | 950 | cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM; |
806 | __raw_writel(cicr0, pcdev->base + CICR0); | 951 | __raw_writel(cicr0, pcdev->base + CICR0); |
807 | } | 952 | } |
@@ -1265,6 +1410,18 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd, | |||
1265 | pix->width = 2048; | 1410 | pix->width = 2048; |
1266 | pix->width &= ~0x01; | 1411 | pix->width &= ~0x01; |
1267 | 1412 | ||
1413 | /* | ||
1414 | * YUV422P planar format requires images size to be a 16 bytes | ||
1415 | * multiple. If not, zeros will be inserted between Y and U planes, and | ||
1416 | * U and V planes, and YUV422P standard would be violated. | ||
1417 | */ | ||
1418 | if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P) { | ||
1419 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | ||
1420 | pix->height = ALIGN(pix->height, YUV422P_X_Y_ALIGN); | ||
1421 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | ||
1422 | pix->width = ALIGN(pix->width, YUV422P_X_Y_ALIGN); | ||
1423 | } | ||
1424 | |||
1268 | pix->bytesperline = pix->width * | 1425 | pix->bytesperline = pix->width * |
1269 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); | 1426 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); |
1270 | pix->sizeimage = pix->height * pix->bytesperline; | 1427 | pix->sizeimage = pix->height * pix->bytesperline; |
@@ -1372,18 +1529,8 @@ static int pxa_camera_resume(struct soc_camera_device *icd) | |||
1372 | ret = pcdev->icd->ops->resume(pcdev->icd); | 1529 | ret = pcdev->icd->ops->resume(pcdev->icd); |
1373 | 1530 | ||
1374 | /* Restart frame capture if active buffer exists */ | 1531 | /* Restart frame capture if active buffer exists */ |
1375 | if (!ret && pcdev->active) { | 1532 | if (!ret && pcdev->active) |
1376 | unsigned long cifr, cicr0; | 1533 | pxa_camera_start_capture(pcdev); |
1377 | |||
1378 | /* Reset the FIFOs */ | ||
1379 | cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F; | ||
1380 | __raw_writel(cifr, pcdev->base + CIFR); | ||
1381 | |||
1382 | cicr0 = __raw_readl(pcdev->base + CICR0); | ||
1383 | cicr0 &= ~CICR0_EOFM; /* Enable End-Of-Frame Interrupt */ | ||
1384 | cicr0 |= CICR0_ENB; /* Restart the Capture Interface */ | ||
1385 | __raw_writel(cicr0, pcdev->base + CICR0); | ||
1386 | } | ||
1387 | 1534 | ||
1388 | return ret; | 1535 | return ret; |
1389 | } | 1536 | } |
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index b5be633e3bb0..5202cadb2aae 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -722,7 +722,6 @@ static void free_buffer(struct videobuf_queue *vq, struct s2255_buffer *buf) | |||
722 | { | 722 | { |
723 | dprintk(4, "%s\n", __func__); | 723 | dprintk(4, "%s\n", __func__); |
724 | 724 | ||
725 | videobuf_waiton(&buf->vb, 0, 0); | ||
726 | videobuf_vmalloc_free(&buf->vb); | 725 | videobuf_vmalloc_free(&buf->vb); |
727 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 726 | buf->vb.state = VIDEOBUF_NEEDS_INIT; |
728 | } | 727 | } |
@@ -1324,7 +1323,6 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
1324 | 1323 | ||
1325 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | 1324 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
1326 | { | 1325 | { |
1327 | int res; | ||
1328 | struct s2255_fh *fh = priv; | 1326 | struct s2255_fh *fh = priv; |
1329 | struct s2255_dev *dev = fh->dev; | 1327 | struct s2255_dev *dev = fh->dev; |
1330 | 1328 | ||
@@ -1338,9 +1336,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
1338 | return -EINVAL; | 1336 | return -EINVAL; |
1339 | } | 1337 | } |
1340 | s2255_stop_acquire(dev, fh->channel); | 1338 | s2255_stop_acquire(dev, fh->channel); |
1341 | res = videobuf_streamoff(&fh->vb_vidq); | 1339 | videobuf_streamoff(&fh->vb_vidq); |
1342 | if (res < 0) | ||
1343 | return res; | ||
1344 | res_free(dev, fh); | 1340 | res_free(dev, fh); |
1345 | return 0; | 1341 | return 0; |
1346 | } | 1342 | } |
@@ -1707,13 +1703,13 @@ static void s2255_destroy(struct kref *kref) | |||
1707 | kfree(dev->fw_data); | 1703 | kfree(dev->fw_data); |
1708 | usb_put_dev(dev->udev); | 1704 | usb_put_dev(dev->udev); |
1709 | dprintk(1, "%s", __func__); | 1705 | dprintk(1, "%s", __func__); |
1710 | kfree(dev); | ||
1711 | 1706 | ||
1712 | while (!list_empty(&s2255_devlist)) { | 1707 | while (!list_empty(&s2255_devlist)) { |
1713 | list = s2255_devlist.next; | 1708 | list = s2255_devlist.next; |
1714 | list_del(list); | 1709 | list_del(list); |
1715 | } | 1710 | } |
1716 | mutex_unlock(&dev->open_lock); | 1711 | mutex_unlock(&dev->open_lock); |
1712 | kfree(dev); | ||
1717 | } | 1713 | } |
1718 | 1714 | ||
1719 | static int s2255_close(struct file *file) | 1715 | static int s2255_close(struct file *file) |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index df4e08d2dceb..5c24c993ac16 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -299,17 +299,18 @@ static int saa7110_s_std(struct v4l2_subdev *sd, v4l2_std_id std) | |||
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | static int saa7110_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 302 | static int saa7110_s_routing(struct v4l2_subdev *sd, |
303 | u32 input, u32 output, u32 config) | ||
303 | { | 304 | { |
304 | struct saa7110 *decoder = to_saa7110(sd); | 305 | struct saa7110 *decoder = to_saa7110(sd); |
305 | 306 | ||
306 | if (route->input < 0 || route->input >= SAA7110_MAX_INPUT) { | 307 | if (input < 0 || input >= SAA7110_MAX_INPUT) { |
307 | v4l2_dbg(1, debug, sd, "input=%d not available\n", route->input); | 308 | v4l2_dbg(1, debug, sd, "input=%d not available\n", input); |
308 | return -EINVAL; | 309 | return -EINVAL; |
309 | } | 310 | } |
310 | if (decoder->input != route->input) { | 311 | if (decoder->input != input) { |
311 | saa7110_selmux(sd, route->input); | 312 | saa7110_selmux(sd, input); |
312 | v4l2_dbg(1, debug, sd, "switched to input=%d\n", route->input); | 313 | v4l2_dbg(1, debug, sd, "switched to input=%d\n", input); |
313 | } | 314 | } |
314 | return 0; | 315 | return 0; |
315 | } | 316 | } |
@@ -414,9 +415,6 @@ static const struct v4l2_subdev_core_ops saa7110_core_ops = { | |||
414 | .g_ctrl = saa7110_g_ctrl, | 415 | .g_ctrl = saa7110_g_ctrl, |
415 | .s_ctrl = saa7110_s_ctrl, | 416 | .s_ctrl = saa7110_s_ctrl, |
416 | .queryctrl = saa7110_queryctrl, | 417 | .queryctrl = saa7110_queryctrl, |
417 | }; | ||
418 | |||
419 | static const struct v4l2_subdev_tuner_ops saa7110_tuner_ops = { | ||
420 | .s_std = saa7110_s_std, | 418 | .s_std = saa7110_s_std, |
421 | }; | 419 | }; |
422 | 420 | ||
@@ -429,7 +427,6 @@ static const struct v4l2_subdev_video_ops saa7110_video_ops = { | |||
429 | 427 | ||
430 | static const struct v4l2_subdev_ops saa7110_ops = { | 428 | static const struct v4l2_subdev_ops saa7110_ops = { |
431 | .core = &saa7110_core_ops, | 429 | .core = &saa7110_core_ops, |
432 | .tuner = &saa7110_tuner_ops, | ||
433 | .video = &saa7110_video_ops, | 430 | .video = &saa7110_video_ops, |
434 | }; | 431 | }; |
435 | 432 | ||
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index cebf159f52cf..44873a016c2c 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/videodev2.h> | 46 | #include <linux/videodev2.h> |
47 | #include <media/v4l2-device.h> | 47 | #include <media/v4l2-device.h> |
48 | #include <media/v4l2-chip-ident.h> | 48 | #include <media/v4l2-chip-ident.h> |
49 | #include <media/v4l2-i2c-drv-legacy.h> | 49 | #include <media/v4l2-i2c-drv.h> |
50 | #include <media/saa7115.h> | 50 | #include <media/saa7115.h> |
51 | #include <asm/div64.h> | 51 | #include <asm/div64.h> |
52 | 52 | ||
@@ -62,12 +62,6 @@ module_param(debug, bool, 0644); | |||
62 | 62 | ||
63 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 63 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
64 | 64 | ||
65 | static unsigned short normal_i2c[] = { | ||
66 | 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ | ||
67 | 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ | ||
68 | I2C_CLIENT_END }; | ||
69 | |||
70 | I2C_CLIENT_INSMOD; | ||
71 | 65 | ||
72 | struct saa711x_state { | 66 | struct saa711x_state { |
73 | struct v4l2_subdev sd; | 67 | struct v4l2_subdev sd; |
@@ -1234,30 +1228,32 @@ static int saa711x_s_radio(struct v4l2_subdev *sd) | |||
1234 | return 0; | 1228 | return 0; |
1235 | } | 1229 | } |
1236 | 1230 | ||
1237 | static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 1231 | static int saa711x_s_routing(struct v4l2_subdev *sd, |
1232 | u32 input, u32 output, u32 config) | ||
1238 | { | 1233 | { |
1239 | struct saa711x_state *state = to_state(sd); | 1234 | struct saa711x_state *state = to_state(sd); |
1240 | u32 input = route->input; | ||
1241 | u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0; | 1235 | u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0; |
1242 | 1236 | ||
1243 | v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", route->input, route->output); | 1237 | v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", |
1238 | input, output); | ||
1239 | |||
1244 | /* saa7111/3 does not have these inputs */ | 1240 | /* saa7111/3 does not have these inputs */ |
1245 | if ((state->ident == V4L2_IDENT_SAA7113 || | 1241 | if ((state->ident == V4L2_IDENT_SAA7113 || |
1246 | state->ident == V4L2_IDENT_SAA7111) && | 1242 | state->ident == V4L2_IDENT_SAA7111) && |
1247 | (route->input == SAA7115_COMPOSITE4 || | 1243 | (input == SAA7115_COMPOSITE4 || |
1248 | route->input == SAA7115_COMPOSITE5)) { | 1244 | input == SAA7115_COMPOSITE5)) { |
1249 | return -EINVAL; | 1245 | return -EINVAL; |
1250 | } | 1246 | } |
1251 | if (route->input > SAA7115_SVIDEO3) | 1247 | if (input > SAA7115_SVIDEO3) |
1252 | return -EINVAL; | 1248 | return -EINVAL; |
1253 | if (route->output > SAA7115_IPORT_ON) | 1249 | if (output > SAA7115_IPORT_ON) |
1254 | return -EINVAL; | 1250 | return -EINVAL; |
1255 | if (state->input == route->input && state->output == route->output) | 1251 | if (state->input == input && state->output == output) |
1256 | return 0; | 1252 | return 0; |
1257 | v4l2_dbg(1, debug, sd, "now setting %s input %s output\n", | 1253 | v4l2_dbg(1, debug, sd, "now setting %s input %s output\n", |
1258 | (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", | 1254 | (input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", |
1259 | (route->output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); | 1255 | (output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); |
1260 | state->input = route->input; | 1256 | state->input = input; |
1261 | 1257 | ||
1262 | /* saa7111 has slightly different input numbering */ | 1258 | /* saa7111 has slightly different input numbering */ |
1263 | if (state->ident == V4L2_IDENT_SAA7111) { | 1259 | if (state->ident == V4L2_IDENT_SAA7111) { |
@@ -1266,10 +1262,10 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing * | |||
1266 | /* saa7111 specific */ | 1262 | /* saa7111 specific */ |
1267 | saa711x_write(sd, R_10_CHROMA_CNTL_2, | 1263 | saa711x_write(sd, R_10_CHROMA_CNTL_2, |
1268 | (saa711x_read(sd, R_10_CHROMA_CNTL_2) & 0x3f) | | 1264 | (saa711x_read(sd, R_10_CHROMA_CNTL_2) & 0x3f) | |
1269 | ((route->output & 0xc0) ^ 0x40)); | 1265 | ((output & 0xc0) ^ 0x40)); |
1270 | saa711x_write(sd, R_13_RT_X_PORT_OUT_CNTL, | 1266 | saa711x_write(sd, R_13_RT_X_PORT_OUT_CNTL, |
1271 | (saa711x_read(sd, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) | | 1267 | (saa711x_read(sd, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) | |
1272 | ((route->output & 2) ? 0x0a : 0)); | 1268 | ((output & 2) ? 0x0a : 0)); |
1273 | } | 1269 | } |
1274 | 1270 | ||
1275 | /* select mode */ | 1271 | /* select mode */ |
@@ -1282,7 +1278,7 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing * | |||
1282 | (saa711x_read(sd, R_09_LUMA_CNTL) & 0x7f) | | 1278 | (saa711x_read(sd, R_09_LUMA_CNTL) & 0x7f) | |
1283 | (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); | 1279 | (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); |
1284 | 1280 | ||
1285 | state->output = route->output; | 1281 | state->output = output; |
1286 | if (state->ident == V4L2_IDENT_SAA7114 || | 1282 | if (state->ident == V4L2_IDENT_SAA7114 || |
1287 | state->ident == V4L2_IDENT_SAA7115) { | 1283 | state->ident == V4L2_IDENT_SAA7115) { |
1288 | saa711x_write(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK, | 1284 | saa711x_write(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK, |
@@ -1319,17 +1315,16 @@ static int saa711x_s_stream(struct v4l2_subdev *sd, int enable) | |||
1319 | return 0; | 1315 | return 0; |
1320 | } | 1316 | } |
1321 | 1317 | ||
1322 | static int saa711x_s_crystal_freq(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq) | 1318 | static int saa711x_s_crystal_freq(struct v4l2_subdev *sd, u32 freq, u32 flags) |
1323 | { | 1319 | { |
1324 | struct saa711x_state *state = to_state(sd); | 1320 | struct saa711x_state *state = to_state(sd); |
1325 | 1321 | ||
1326 | if (freq->freq != SAA7115_FREQ_32_11_MHZ && | 1322 | if (freq != SAA7115_FREQ_32_11_MHZ && freq != SAA7115_FREQ_24_576_MHZ) |
1327 | freq->freq != SAA7115_FREQ_24_576_MHZ) | ||
1328 | return -EINVAL; | 1323 | return -EINVAL; |
1329 | state->crystal_freq = freq->freq; | 1324 | state->crystal_freq = freq; |
1330 | state->cgcdiv = (freq->flags & SAA7115_FREQ_FL_CGCDIV) ? 3 : 4; | 1325 | state->cgcdiv = (flags & SAA7115_FREQ_FL_CGCDIV) ? 3 : 4; |
1331 | state->ucgc = (freq->flags & SAA7115_FREQ_FL_UCGC) ? 1 : 0; | 1326 | state->ucgc = (flags & SAA7115_FREQ_FL_UCGC) ? 1 : 0; |
1332 | state->apll = (freq->flags & SAA7115_FREQ_FL_APLL) ? 1 : 0; | 1327 | state->apll = (flags & SAA7115_FREQ_FL_APLL) ? 1 : 0; |
1333 | saa711x_s_clock_freq(sd, state->audclk_freq); | 1328 | saa711x_s_clock_freq(sd, state->audclk_freq); |
1334 | return 0; | 1329 | return 0; |
1335 | } | 1330 | } |
@@ -1498,11 +1493,6 @@ static int saa711x_log_status(struct v4l2_subdev *sd) | |||
1498 | return 0; | 1493 | return 0; |
1499 | } | 1494 | } |
1500 | 1495 | ||
1501 | static int saa711x_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
1502 | { | ||
1503 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
1504 | } | ||
1505 | |||
1506 | /* ----------------------------------------------------------------------- */ | 1496 | /* ----------------------------------------------------------------------- */ |
1507 | 1497 | ||
1508 | static const struct v4l2_subdev_core_ops saa711x_core_ops = { | 1498 | static const struct v4l2_subdev_core_ops saa711x_core_ops = { |
@@ -1511,6 +1501,7 @@ static const struct v4l2_subdev_core_ops saa711x_core_ops = { | |||
1511 | .g_ctrl = saa711x_g_ctrl, | 1501 | .g_ctrl = saa711x_g_ctrl, |
1512 | .s_ctrl = saa711x_s_ctrl, | 1502 | .s_ctrl = saa711x_s_ctrl, |
1513 | .queryctrl = saa711x_queryctrl, | 1503 | .queryctrl = saa711x_queryctrl, |
1504 | .s_std = saa711x_s_std, | ||
1514 | .reset = saa711x_reset, | 1505 | .reset = saa711x_reset, |
1515 | .s_gpio = saa711x_s_gpio, | 1506 | .s_gpio = saa711x_s_gpio, |
1516 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1507 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
@@ -1520,7 +1511,6 @@ static const struct v4l2_subdev_core_ops saa711x_core_ops = { | |||
1520 | }; | 1511 | }; |
1521 | 1512 | ||
1522 | static const struct v4l2_subdev_tuner_ops saa711x_tuner_ops = { | 1513 | static const struct v4l2_subdev_tuner_ops saa711x_tuner_ops = { |
1523 | .s_std = saa711x_s_std, | ||
1524 | .s_radio = saa711x_s_radio, | 1514 | .s_radio = saa711x_s_radio, |
1525 | .g_tuner = saa711x_g_tuner, | 1515 | .g_tuner = saa711x_g_tuner, |
1526 | }; | 1516 | }; |
@@ -1676,10 +1666,7 @@ MODULE_DEVICE_TABLE(i2c, saa7115_id); | |||
1676 | 1666 | ||
1677 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 1667 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
1678 | .name = "saa7115", | 1668 | .name = "saa7115", |
1679 | .driverid = I2C_DRIVERID_SAA711X, | ||
1680 | .command = saa711x_command, | ||
1681 | .probe = saa711x_probe, | 1669 | .probe = saa711x_probe, |
1682 | .remove = saa711x_remove, | 1670 | .remove = saa711x_remove, |
1683 | .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL, | ||
1684 | .id_table = saa7115_id, | 1671 | .id_table = saa7115_id, |
1685 | }; | 1672 | }; |
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index 128bb8b8dbbf..2fe7a701b954 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c | |||
@@ -570,15 +570,16 @@ static int saa7127_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
570 | return saa7127_set_std(sd, std); | 570 | return saa7127_set_std(sd, std); |
571 | } | 571 | } |
572 | 572 | ||
573 | static int saa7127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 573 | static int saa7127_s_routing(struct v4l2_subdev *sd, |
574 | u32 input, u32 output, u32 config) | ||
574 | { | 575 | { |
575 | struct saa7127_state *state = to_state(sd); | 576 | struct saa7127_state *state = to_state(sd); |
576 | int rc = 0; | 577 | int rc = 0; |
577 | 578 | ||
578 | if (state->input_type != route->input) | 579 | if (state->input_type != input) |
579 | rc = saa7127_set_input_type(sd, route->input); | 580 | rc = saa7127_set_input_type(sd, input); |
580 | if (rc == 0 && state->output_type != route->output) | 581 | if (rc == 0 && state->output_type != output) |
581 | rc = saa7127_set_output_type(sd, route->output); | 582 | rc = saa7127_set_output_type(sd, output); |
582 | return rc; | 583 | return rc; |
583 | } | 584 | } |
584 | 585 | ||
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index dc2213e2f86e..63c4b8f1f541 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -928,9 +928,6 @@ static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { | |||
928 | .g_ext_ctrls = saa6752hs_g_ext_ctrls, | 928 | .g_ext_ctrls = saa6752hs_g_ext_ctrls, |
929 | .s_ext_ctrls = saa6752hs_s_ext_ctrls, | 929 | .s_ext_ctrls = saa6752hs_s_ext_ctrls, |
930 | .try_ext_ctrls = saa6752hs_try_ext_ctrls, | 930 | .try_ext_ctrls = saa6752hs_try_ext_ctrls, |
931 | }; | ||
932 | |||
933 | static const struct v4l2_subdev_tuner_ops saa6752hs_tuner_ops = { | ||
934 | .s_std = saa6752hs_s_std, | 931 | .s_std = saa6752hs_s_std, |
935 | }; | 932 | }; |
936 | 933 | ||
@@ -941,7 +938,6 @@ static const struct v4l2_subdev_video_ops saa6752hs_video_ops = { | |||
941 | 938 | ||
942 | static const struct v4l2_subdev_ops saa6752hs_ops = { | 939 | static const struct v4l2_subdev_ops saa6752hs_ops = { |
943 | .core = &saa6752hs_core_ops, | 940 | .core = &saa6752hs_core_ops, |
944 | .tuner = &saa6752hs_tuner_ops, | ||
945 | .video = &saa6752hs_video_ops, | 941 | .video = &saa6752hs_video_ops, |
946 | }; | 942 | }; |
947 | 943 | ||
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index a790a7246a63..fdb19449d269 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4508,12 +4508,17 @@ struct saa7134_board saa7134_boards[] = { | |||
4508 | /* Matthias Schwarzott <zzam@gentoo.org> */ | 4508 | /* Matthias Schwarzott <zzam@gentoo.org> */ |
4509 | .name = "Avermedia DVB-S Hybrid+FM A700", | 4509 | .name = "Avermedia DVB-S Hybrid+FM A700", |
4510 | .audio_clock = 0x00187de7, | 4510 | .audio_clock = 0x00187de7, |
4511 | .tuner_type = TUNER_ABSENT, /* TUNER_XC2028 */ | 4511 | .tuner_type = TUNER_XC2028, |
4512 | .radio_type = UNSET, | 4512 | .radio_type = UNSET, |
4513 | .tuner_addr = ADDR_UNSET, | 4513 | .tuner_addr = ADDR_UNSET, |
4514 | .radio_addr = ADDR_UNSET, | 4514 | .radio_addr = ADDR_UNSET, |
4515 | .mpeg = SAA7134_MPEG_DVB, | 4515 | .mpeg = SAA7134_MPEG_DVB, |
4516 | .inputs = { { | 4516 | .inputs = { { |
4517 | .name = name_tv, | ||
4518 | .vmux = 4, | ||
4519 | .amux = TV, | ||
4520 | .tv = 1, | ||
4521 | }, { | ||
4517 | .name = name_comp, | 4522 | .name = name_comp, |
4518 | .vmux = 1, | 4523 | .vmux = 1, |
4519 | .amux = LINE1, | 4524 | .amux = LINE1, |
@@ -4522,6 +4527,10 @@ struct saa7134_board saa7134_boards[] = { | |||
4522 | .vmux = 6, | 4527 | .vmux = 6, |
4523 | .amux = LINE1, | 4528 | .amux = LINE1, |
4524 | } }, | 4529 | } }, |
4530 | .radio = { | ||
4531 | .name = name_radio, | ||
4532 | .amux = TV, | ||
4533 | }, | ||
4525 | }, | 4534 | }, |
4526 | [SAA7134_BOARD_BEHOLD_H6] = { | 4535 | [SAA7134_BOARD_BEHOLD_H6] = { |
4527 | /* Igor Kuznetsov <igk@igk.ru> */ | 4536 | /* Igor Kuznetsov <igk@igk.ru> */ |
@@ -5914,6 +5923,11 @@ static int saa7134_xc2028_callback(struct saa7134_dev *dev, | |||
5914 | msleep(10); | 5923 | msleep(10); |
5915 | saa7134_set_gpio(dev, 21, 1); | 5924 | saa7134_set_gpio(dev, 21, 1); |
5916 | break; | 5925 | break; |
5926 | case SAA7134_BOARD_AVERMEDIA_A700_HYBRID: | ||
5927 | saa7134_set_gpio(dev, 18, 0); | ||
5928 | msleep(10); | ||
5929 | saa7134_set_gpio(dev, 18, 1); | ||
5930 | break; | ||
5917 | } | 5931 | } |
5918 | return 0; | 5932 | return 0; |
5919 | } | 5933 | } |
@@ -6259,10 +6273,6 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
6259 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0c0007cd, 0x0c0007cd); | 6273 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0c0007cd, 0x0c0007cd); |
6260 | break; | 6274 | break; |
6261 | case SAA7134_BOARD_AVERMEDIA_A700_HYBRID: | 6275 | case SAA7134_BOARD_AVERMEDIA_A700_HYBRID: |
6262 | printk("%s: %s: hybrid analog/dvb card\n" | ||
6263 | "%s: Sorry, of the analog inputs, only analog s-video and composite " | ||
6264 | "are supported for now.\n", | ||
6265 | dev->name, card(dev).name, dev->name); | ||
6266 | case SAA7134_BOARD_AVERMEDIA_A700_PRO: | 6276 | case SAA7134_BOARD_AVERMEDIA_A700_PRO: |
6267 | /* write windows gpio values */ | 6277 | /* write windows gpio values */ |
6268 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); | 6278 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); |
@@ -6326,6 +6336,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
6326 | case SAA7134_BOARD_AVERMEDIA_A16D: | 6336 | case SAA7134_BOARD_AVERMEDIA_A16D: |
6327 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | 6337 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
6328 | case SAA7134_BOARD_AVERMEDIA_M103: | 6338 | case SAA7134_BOARD_AVERMEDIA_M103: |
6339 | case SAA7134_BOARD_AVERMEDIA_A700_HYBRID: | ||
6329 | ctl.demod = XC3028_FE_ZARLINK456; | 6340 | ctl.demod = XC3028_FE_ZARLINK456; |
6330 | break; | 6341 | break; |
6331 | default: | 6342 | default: |
@@ -6599,20 +6610,24 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
6599 | /* Note: radio tuner address is always filled in, | 6610 | /* Note: radio tuner address is always filled in, |
6600 | so we do not need to probe for a radio tuner device. */ | 6611 | so we do not need to probe for a radio tuner device. */ |
6601 | if (dev->radio_type != UNSET) | 6612 | if (dev->radio_type != UNSET) |
6602 | v4l2_i2c_new_subdev(&dev->i2c_adap, | 6613 | v4l2_i2c_new_subdev(&dev->v4l2_dev, |
6603 | "tuner", "tuner", dev->radio_addr); | 6614 | &dev->i2c_adap, "tuner", "tuner", |
6615 | dev->radio_addr); | ||
6604 | if (has_demod) | 6616 | if (has_demod) |
6605 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", | 6617 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, |
6606 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 6618 | &dev->i2c_adap, "tuner", "tuner", |
6619 | v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
6607 | if (dev->tuner_addr == ADDR_UNSET) { | 6620 | if (dev->tuner_addr == ADDR_UNSET) { |
6608 | enum v4l2_i2c_tuner_type type = | 6621 | enum v4l2_i2c_tuner_type type = |
6609 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | 6622 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; |
6610 | 6623 | ||
6611 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", | 6624 | v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, |
6612 | "tuner", v4l2_i2c_tuner_addrs(type)); | 6625 | &dev->i2c_adap, "tuner", "tuner", |
6626 | v4l2_i2c_tuner_addrs(type)); | ||
6613 | } else { | 6627 | } else { |
6614 | v4l2_i2c_new_subdev(&dev->i2c_adap, | 6628 | v4l2_i2c_new_subdev(&dev->v4l2_dev, |
6615 | "tuner", "tuner", dev->tuner_addr); | 6629 | &dev->i2c_adap, "tuner", "tuner", |
6630 | dev->tuner_addr); | ||
6616 | } | 6631 | } |
6617 | } | 6632 | } |
6618 | 6633 | ||
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index dafa0d88bed0..0bb09f1723d1 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -982,7 +982,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
982 | /* load i2c helpers */ | 982 | /* load i2c helpers */ |
983 | if (card_is_empress(dev)) { | 983 | if (card_is_empress(dev)) { |
984 | struct v4l2_subdev *sd = | 984 | struct v4l2_subdev *sd = |
985 | v4l2_i2c_new_subdev(&dev->i2c_adap, | 985 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
986 | "saa6752hs", "saa6752hs", | 986 | "saa6752hs", "saa6752hs", |
987 | saa7134_boards[dev->board].empress_addr); | 987 | saa7134_boards[dev->board].empress_addr); |
988 | 988 | ||
@@ -991,12 +991,11 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
991 | } | 991 | } |
992 | 992 | ||
993 | if (saa7134_boards[dev->board].rds_addr) { | 993 | if (saa7134_boards[dev->board].rds_addr) { |
994 | unsigned short addrs[2] = { 0, I2C_CLIENT_END }; | ||
995 | struct v4l2_subdev *sd; | 994 | struct v4l2_subdev *sd; |
996 | 995 | ||
997 | addrs[0] = saa7134_boards[dev->board].rds_addr; | 996 | sd = v4l2_i2c_new_probed_subdev_addr(&dev->v4l2_dev, |
998 | sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa6588", | 997 | &dev->i2c_adap, "saa6588", "saa6588", |
999 | "saa6588", addrs); | 998 | saa7134_boards[dev->board].rds_addr); |
1000 | if (sd) | 999 | if (sd) |
1001 | printk(KERN_INFO "%s: found RDS decoder\n", dev->name); | 1000 | printk(KERN_INFO "%s: found RDS decoder\n", dev->name); |
1002 | } | 1001 | } |
@@ -1015,7 +1014,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1015 | saa7134_irq_video_signalchange(dev); | 1014 | saa7134_irq_video_signalchange(dev); |
1016 | 1015 | ||
1017 | if (TUNER_ABSENT != dev->tuner_type) | 1016 | if (TUNER_ABSENT != dev->tuner_type) |
1018 | saa_call_all(dev, core, s_standby, 0); | 1017 | saa_call_all(dev, tuner, s_standby); |
1019 | 1018 | ||
1020 | /* register v4l devices */ | 1019 | /* register v4l devices */ |
1021 | if (saa7134_no_overlay > 0) | 1020 | if (saa7134_no_overlay > 0) |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 404f70eeb355..493cad941460 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -625,10 +625,10 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) | |||
625 | saa7134_set_decoder(dev); | 625 | saa7134_set_decoder(dev); |
626 | 626 | ||
627 | if (card_in(dev, dev->ctl_input).tv) | 627 | if (card_in(dev, dev->ctl_input).tv) |
628 | saa_call_all(dev, tuner, s_std, dev->tvnorm->id); | 628 | saa_call_all(dev, core, s_std, dev->tvnorm->id); |
629 | /* Set the correct norm for the saa6752hs. This function | 629 | /* Set the correct norm for the saa6752hs. This function |
630 | does nothing if there is no saa6752hs. */ | 630 | does nothing if there is no saa6752hs. */ |
631 | saa_call_empress(dev, tuner, s_std, dev->tvnorm->id); | 631 | saa_call_empress(dev, core, s_std, dev->tvnorm->id); |
632 | } | 632 | } |
633 | 633 | ||
634 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) | 634 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) |
@@ -1496,7 +1496,7 @@ static int video_release(struct file *file) | |||
1496 | saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); | 1496 | saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); |
1497 | saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); | 1497 | saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); |
1498 | 1498 | ||
1499 | saa_call_all(dev, core, s_standby, 0); | 1499 | saa_call_all(dev, tuner, s_standby); |
1500 | if (fh->radio) | 1500 | if (fh->radio) |
1501 | saa_call_all(dev, core, ioctl, RDS_CMD_CLOSE, &cmd); | 1501 | saa_call_all(dev, core, ioctl, RDS_CMD_CLOSE, &cmd); |
1502 | 1502 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index a2dd326de5b9..0cbaf90d4874 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -20,7 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/version.h> | 22 | #include <linux/version.h> |
23 | #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,14) | 23 | #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,15) |
24 | 24 | ||
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c index 25bf2303a6b5..b15c40908e84 100644 --- a/drivers/media/video/saa717x.c +++ b/drivers/media/video/saa717x.c | |||
@@ -1104,22 +1104,22 @@ static struct v4l2_queryctrl saa717x_qctrl[] = { | |||
1104 | }, | 1104 | }, |
1105 | }; | 1105 | }; |
1106 | 1106 | ||
1107 | static int saa717x_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 1107 | static int saa717x_s_video_routing(struct v4l2_subdev *sd, |
1108 | u32 input, u32 output, u32 config) | ||
1108 | { | 1109 | { |
1109 | struct saa717x_state *decoder = to_state(sd); | 1110 | struct saa717x_state *decoder = to_state(sd); |
1110 | int inp = route->input; | 1111 | int is_tuner = input & 0x80; /* tuner input flag */ |
1111 | int is_tuner = inp & 0x80; /* tuner input flag */ | ||
1112 | 1112 | ||
1113 | inp &= 0x7f; | 1113 | input &= 0x7f; |
1114 | 1114 | ||
1115 | v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", inp); | 1115 | v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", input); |
1116 | /* inputs from 0-9 are available*/ | 1116 | /* inputs from 0-9 are available*/ |
1117 | /* saa717x have mode0-mode9 but mode5 is reserved. */ | 1117 | /* saa717x have mode0-mode9 but mode5 is reserved. */ |
1118 | if (inp < 0 || inp > 9 || inp == 5) | 1118 | if (input < 0 || input > 9 || input == 5) |
1119 | return -EINVAL; | 1119 | return -EINVAL; |
1120 | 1120 | ||
1121 | if (decoder->input != inp) { | 1121 | if (decoder->input != input) { |
1122 | int input_line = inp; | 1122 | int input_line = input; |
1123 | 1123 | ||
1124 | decoder->input = input_line; | 1124 | decoder->input = input_line; |
1125 | v4l2_dbg(1, debug, sd, "now setting %s input %d\n", | 1125 | v4l2_dbg(1, debug, sd, "now setting %s input %d\n", |
@@ -1276,12 +1276,13 @@ static int saa717x_s_std(struct v4l2_subdev *sd, v4l2_std_id std) | |||
1276 | return 0; | 1276 | return 0; |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | static int saa717x_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 1279 | static int saa717x_s_audio_routing(struct v4l2_subdev *sd, |
1280 | u32 input, u32 output, u32 config) | ||
1280 | { | 1281 | { |
1281 | struct saa717x_state *decoder = to_state(sd); | 1282 | struct saa717x_state *decoder = to_state(sd); |
1282 | 1283 | ||
1283 | if (route->input < 3) { /* FIXME! --tadachi */ | 1284 | if (input < 3) { /* FIXME! --tadachi */ |
1284 | decoder->audio_input = route->input; | 1285 | decoder->audio_input = input; |
1285 | v4l2_dbg(1, debug, sd, | 1286 | v4l2_dbg(1, debug, sd, |
1286 | "set decoder audio input to %d\n", | 1287 | "set decoder audio input to %d\n", |
1287 | decoder->audio_input); | 1288 | decoder->audio_input); |
@@ -1390,12 +1391,12 @@ static const struct v4l2_subdev_core_ops saa717x_core_ops = { | |||
1390 | .queryctrl = saa717x_queryctrl, | 1391 | .queryctrl = saa717x_queryctrl, |
1391 | .g_ctrl = saa717x_g_ctrl, | 1392 | .g_ctrl = saa717x_g_ctrl, |
1392 | .s_ctrl = saa717x_s_ctrl, | 1393 | .s_ctrl = saa717x_s_ctrl, |
1394 | .s_std = saa717x_s_std, | ||
1393 | }; | 1395 | }; |
1394 | 1396 | ||
1395 | static const struct v4l2_subdev_tuner_ops saa717x_tuner_ops = { | 1397 | static const struct v4l2_subdev_tuner_ops saa717x_tuner_ops = { |
1396 | .g_tuner = saa717x_g_tuner, | 1398 | .g_tuner = saa717x_g_tuner, |
1397 | .s_tuner = saa717x_s_tuner, | 1399 | .s_tuner = saa717x_s_tuner, |
1398 | .s_std = saa717x_s_std, | ||
1399 | .s_radio = saa717x_s_radio, | 1400 | .s_radio = saa717x_s_radio, |
1400 | }; | 1401 | }; |
1401 | 1402 | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 75747b104d07..212baa10829b 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -245,14 +245,15 @@ static int saa7185_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | |||
245 | return 0; | 245 | return 0; |
246 | } | 246 | } |
247 | 247 | ||
248 | static int saa7185_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 248 | static int saa7185_s_routing(struct v4l2_subdev *sd, |
249 | u32 input, u32 output, u32 config) | ||
249 | { | 250 | { |
250 | struct saa7185 *encoder = to_saa7185(sd); | 251 | struct saa7185 *encoder = to_saa7185(sd); |
251 | 252 | ||
252 | /* RJ: route->input = 0: input is from SA7111 | 253 | /* RJ: input = 0: input is from SA7111 |
253 | route->input = 1: input is from ZR36060 */ | 254 | input = 1: input is from ZR36060 */ |
254 | 255 | ||
255 | switch (route->input) { | 256 | switch (input) { |
256 | case 0: | 257 | case 0: |
257 | /* turn off colorbar */ | 258 | /* turn off colorbar */ |
258 | saa7185_write(sd, 0x3a, 0x0f); | 259 | saa7185_write(sd, 0x3a, 0x0f); |
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index 3f523aeec56e..a2513772196b 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c | |||
@@ -160,14 +160,14 @@ static int saa7191_write_block(struct v4l2_subdev *sd, | |||
160 | /* Helper functions */ | 160 | /* Helper functions */ |
161 | 161 | ||
162 | static int saa7191_s_routing(struct v4l2_subdev *sd, | 162 | static int saa7191_s_routing(struct v4l2_subdev *sd, |
163 | const struct v4l2_routing *route) | 163 | u32 input, u32 output, u32 config) |
164 | { | 164 | { |
165 | struct saa7191 *decoder = to_saa7191(sd); | 165 | struct saa7191 *decoder = to_saa7191(sd); |
166 | u8 luma = saa7191_read_reg(sd, SAA7191_REG_LUMA); | 166 | u8 luma = saa7191_read_reg(sd, SAA7191_REG_LUMA); |
167 | u8 iock = saa7191_read_reg(sd, SAA7191_REG_IOCK); | 167 | u8 iock = saa7191_read_reg(sd, SAA7191_REG_IOCK); |
168 | int err; | 168 | int err; |
169 | 169 | ||
170 | switch (route->input) { | 170 | switch (input) { |
171 | case SAA7191_INPUT_COMPOSITE: /* Set Composite input */ | 171 | case SAA7191_INPUT_COMPOSITE: /* Set Composite input */ |
172 | iock &= ~(SAA7191_IOCK_CHRS | SAA7191_IOCK_GPSW1 | 172 | iock &= ~(SAA7191_IOCK_CHRS | SAA7191_IOCK_GPSW1 |
173 | | SAA7191_IOCK_GPSW2); | 173 | | SAA7191_IOCK_GPSW2); |
@@ -190,7 +190,7 @@ static int saa7191_s_routing(struct v4l2_subdev *sd, | |||
190 | if (err) | 190 | if (err) |
191 | return -EIO; | 191 | return -EIO; |
192 | 192 | ||
193 | decoder->input = route->input; | 193 | decoder->input = input; |
194 | 194 | ||
195 | return 0; | 195 | return 0; |
196 | } | 196 | } |
@@ -582,9 +582,6 @@ static const struct v4l2_subdev_core_ops saa7191_core_ops = { | |||
582 | .g_chip_ident = saa7191_g_chip_ident, | 582 | .g_chip_ident = saa7191_g_chip_ident, |
583 | .g_ctrl = saa7191_g_ctrl, | 583 | .g_ctrl = saa7191_g_ctrl, |
584 | .s_ctrl = saa7191_s_ctrl, | 584 | .s_ctrl = saa7191_s_ctrl, |
585 | }; | ||
586 | |||
587 | static const struct v4l2_subdev_tuner_ops saa7191_tuner_ops = { | ||
588 | .s_std = saa7191_s_std, | 585 | .s_std = saa7191_s_std, |
589 | }; | 586 | }; |
590 | 587 | ||
@@ -597,7 +594,6 @@ static const struct v4l2_subdev_video_ops saa7191_video_ops = { | |||
597 | static const struct v4l2_subdev_ops saa7191_ops = { | 594 | static const struct v4l2_subdev_ops saa7191_ops = { |
598 | .core = &saa7191_core_ops, | 595 | .core = &saa7191_core_ops, |
599 | .video = &saa7191_video_ops, | 596 | .video = &saa7191_video_ops, |
600 | .tuner = &saa7191_tuner_ops, | ||
601 | }; | 597 | }; |
602 | 598 | ||
603 | static int saa7191_probe(struct i2c_client *client, | 599 | static int saa7191_probe(struct i2c_client *client, |
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 6d8bfd4d97e2..0e890cc23377 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -764,7 +764,10 @@ static int soc_camera_s_register(struct file *file, void *fh, | |||
764 | 764 | ||
765 | static int device_register_link(struct soc_camera_device *icd) | 765 | static int device_register_link(struct soc_camera_device *icd) |
766 | { | 766 | { |
767 | int ret = device_register(&icd->dev); | 767 | int ret = dev_set_name(&icd->dev, "%u-%u", icd->iface, icd->devnum); |
768 | |||
769 | if (!ret) | ||
770 | ret = device_register(&icd->dev); | ||
768 | 771 | ||
769 | if (ret < 0) { | 772 | if (ret < 0) { |
770 | /* Prevent calling device_unregister() */ | 773 | /* Prevent calling device_unregister() */ |
@@ -1060,7 +1063,6 @@ int soc_camera_device_register(struct soc_camera_device *icd) | |||
1060 | 1063 | ||
1061 | icd->devnum = num; | 1064 | icd->devnum = num; |
1062 | icd->dev.bus = &soc_camera_bus_type; | 1065 | icd->dev.bus = &soc_camera_bus_type; |
1063 | dev_set_name(&icd->dev, "%u-%u", icd->iface, icd->devnum); | ||
1064 | 1066 | ||
1065 | icd->dev.release = dummy_release; | 1067 | icd->dev.release = dummy_release; |
1066 | icd->use_count = 0; | 1068 | icd->use_count = 0; |
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index fe1158094c24..d381fce3db40 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -192,7 +192,6 @@ static int tda9840_remove(struct i2c_client *client) | |||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | |||
196 | static const struct i2c_device_id tda9840_id[] = { | 195 | static const struct i2c_device_id tda9840_id[] = { |
197 | { "tda9840", 0 }, | 196 | { "tda9840", 0 }, |
198 | { } | 197 | { } |
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index d61c56f42bcd..d4a9ed45764b 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -47,12 +47,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
47 | 47 | ||
48 | 48 | ||
49 | /* makes a connection between the input-pin 'i' and the output-pin 'o' */ | 49 | /* makes a connection between the input-pin 'i' and the output-pin 'o' */ |
50 | static int tea6415c_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 50 | static int tea6415c_s_routing(struct v4l2_subdev *sd, |
51 | u32 i, u32 o, u32 config) | ||
51 | { | 52 | { |
52 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 53 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
53 | u8 byte = 0; | 54 | u8 byte = 0; |
54 | u32 i = route->input; | ||
55 | u32 o = route->output; | ||
56 | int ret; | 55 | int ret; |
57 | 56 | ||
58 | v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o); | 57 | v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o); |
@@ -170,7 +169,6 @@ static int tea6415c_remove(struct i2c_client *client) | |||
170 | return 0; | 169 | return 0; |
171 | } | 170 | } |
172 | 171 | ||
173 | |||
174 | static const struct i2c_device_id tea6415c_id[] = { | 172 | static const struct i2c_device_id tea6415c_id[] = { |
175 | { "tea6415c", 0 }, | 173 | { "tea6415c", 0 }, |
176 | { } | 174 | { } |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 34922232402a..ced6eadf347a 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
@@ -48,15 +48,15 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
48 | 48 | ||
49 | /* make a connection between the input 'i' and the output 'o' | 49 | /* make a connection between the input 'i' and the output 'o' |
50 | with gain 'g' (note: i = 6 means 'mute') */ | 50 | with gain 'g' (note: i = 6 means 'mute') */ |
51 | static int tea6420_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 51 | static int tea6420_s_routing(struct v4l2_subdev *sd, |
52 | u32 i, u32 o, u32 config) | ||
52 | { | 53 | { |
53 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 54 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
54 | int i = route->input; | 55 | int g = (o >> 4) & 0xf; |
55 | int o = route->output & 0xf; | ||
56 | int g = (route->output >> 4) & 0xf; | ||
57 | u8 byte; | 56 | u8 byte; |
58 | int ret; | 57 | int ret; |
59 | 58 | ||
59 | o &= 0xf; | ||
60 | v4l2_dbg(1, debug, sd, "i=%d, o=%d, g=%d\n", i, o, g); | 60 | v4l2_dbg(1, debug, sd, "i=%d, o=%d, g=%d\n", i, o, g); |
61 | 61 | ||
62 | /* check if the parameters are valid */ | 62 | /* check if the parameters are valid */ |
@@ -133,13 +133,8 @@ static int tea6420_probe(struct i2c_client *client, | |||
133 | 133 | ||
134 | /* set initial values: set "mute"-input to all outputs at gain 0 */ | 134 | /* set initial values: set "mute"-input to all outputs at gain 0 */ |
135 | err = 0; | 135 | err = 0; |
136 | for (i = 1; i < 5; i++) { | 136 | for (i = 1; i < 5; i++) |
137 | struct v4l2_routing route; | 137 | err += tea6420_s_routing(sd, 6, i, 0); |
138 | |||
139 | route.input = 6; | ||
140 | route.output = i; | ||
141 | err += tea6420_s_routing(sd, &route); | ||
142 | } | ||
143 | if (err) { | 138 | if (err) { |
144 | v4l_dbg(1, debug, client, "could not initialize tea6420\n"); | 139 | v4l_dbg(1, debug, client, "could not initialize tea6420\n"); |
145 | return -ENODEV; | 140 | return -ENODEV; |
@@ -156,7 +151,6 @@ static int tea6420_remove(struct i2c_client *client) | |||
156 | return 0; | 151 | return 0; |
157 | } | 152 | } |
158 | 153 | ||
159 | |||
160 | static const struct i2c_device_id tea6420_id[] = { | 154 | static const struct i2c_device_id tea6420_id[] = { |
161 | { "tea6420", 0 }, | 155 | { "tea6420", 0 }, |
162 | { } | 156 | { } |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 72d41032742d..78c377a399cb 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -15,12 +15,12 @@ | |||
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/videodev.h> | 18 | #include <linux/videodev2.h> |
19 | #include <media/tuner.h> | 19 | #include <media/tuner.h> |
20 | #include <media/tuner-types.h> | 20 | #include <media/tuner-types.h> |
21 | #include <media/v4l2-device.h> | 21 | #include <media/v4l2-device.h> |
22 | #include <media/v4l2-ioctl.h> | 22 | #include <media/v4l2-ioctl.h> |
23 | #include <media/v4l2-i2c-drv-legacy.h> | 23 | #include <media/v4l2-i2c-drv.h> |
24 | #include "mt20xx.h" | 24 | #include "mt20xx.h" |
25 | #include "tda8290.h" | 25 | #include "tda8290.h" |
26 | #include "tea5761.h" | 26 | #include "tea5761.h" |
@@ -101,18 +101,6 @@ static inline struct tuner *to_tuner(struct v4l2_subdev *sd) | |||
101 | return container_of(sd, struct tuner, sd); | 101 | return container_of(sd, struct tuner, sd); |
102 | } | 102 | } |
103 | 103 | ||
104 | /* standard i2c insmod options */ | ||
105 | static unsigned short normal_i2c[] = { | ||
106 | #if defined(CONFIG_MEDIA_TUNER_TEA5761) || (defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE) && defined(MODULE)) | ||
107 | 0x10, | ||
108 | #endif | ||
109 | 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ | ||
110 | 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, | ||
111 | 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, | ||
112 | I2C_CLIENT_END | ||
113 | }; | ||
114 | |||
115 | I2C_CLIENT_INSMOD; | ||
116 | 104 | ||
117 | /* insmod options used at init time => read/only */ | 105 | /* insmod options used at init time => read/only */ |
118 | static unsigned int addr; | 106 | static unsigned int addr; |
@@ -785,7 +773,7 @@ static int tuner_s_radio(struct v4l2_subdev *sd) | |||
785 | return 0; | 773 | return 0; |
786 | } | 774 | } |
787 | 775 | ||
788 | static int tuner_s_standby(struct v4l2_subdev *sd, u32 standby) | 776 | static int tuner_s_standby(struct v4l2_subdev *sd) |
789 | { | 777 | { |
790 | struct tuner *t = to_tuner(sd); | 778 | struct tuner *t = to_tuner(sd); |
791 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; | 779 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
@@ -951,11 +939,6 @@ static int tuner_log_status(struct v4l2_subdev *sd) | |||
951 | return 0; | 939 | return 0; |
952 | } | 940 | } |
953 | 941 | ||
954 | static int tuner_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
955 | { | ||
956 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
957 | } | ||
958 | |||
959 | static int tuner_suspend(struct i2c_client *c, pm_message_t state) | 942 | static int tuner_suspend(struct i2c_client *c, pm_message_t state) |
960 | { | 943 | { |
961 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); | 944 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
@@ -980,15 +963,28 @@ static int tuner_resume(struct i2c_client *c) | |||
980 | return 0; | 963 | return 0; |
981 | } | 964 | } |
982 | 965 | ||
966 | static int tuner_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
967 | { | ||
968 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | ||
969 | |||
970 | /* TUNER_SET_CONFIG is still called by tuner-simple.c, so we have | ||
971 | to handle it here. | ||
972 | There must be a better way of doing this... */ | ||
973 | switch (cmd) { | ||
974 | case TUNER_SET_CONFIG: | ||
975 | return tuner_s_config(sd, arg); | ||
976 | } | ||
977 | return -ENOIOCTLCMD; | ||
978 | } | ||
979 | |||
983 | /* ----------------------------------------------------------------------- */ | 980 | /* ----------------------------------------------------------------------- */ |
984 | 981 | ||
985 | static const struct v4l2_subdev_core_ops tuner_core_ops = { | 982 | static const struct v4l2_subdev_core_ops tuner_core_ops = { |
986 | .log_status = tuner_log_status, | 983 | .log_status = tuner_log_status, |
987 | .s_standby = tuner_s_standby, | 984 | .s_std = tuner_s_std, |
988 | }; | 985 | }; |
989 | 986 | ||
990 | static const struct v4l2_subdev_tuner_ops tuner_tuner_ops = { | 987 | static const struct v4l2_subdev_tuner_ops tuner_tuner_ops = { |
991 | .s_std = tuner_s_std, | ||
992 | .s_radio = tuner_s_radio, | 988 | .s_radio = tuner_s_radio, |
993 | .g_tuner = tuner_g_tuner, | 989 | .g_tuner = tuner_g_tuner, |
994 | .s_tuner = tuner_s_tuner, | 990 | .s_tuner = tuner_s_tuner, |
@@ -996,6 +992,7 @@ static const struct v4l2_subdev_tuner_ops tuner_tuner_ops = { | |||
996 | .g_frequency = tuner_g_frequency, | 992 | .g_frequency = tuner_g_frequency, |
997 | .s_type_addr = tuner_s_type_addr, | 993 | .s_type_addr = tuner_s_type_addr, |
998 | .s_config = tuner_s_config, | 994 | .s_config = tuner_s_config, |
995 | .s_standby = tuner_s_standby, | ||
999 | }; | 996 | }; |
1000 | 997 | ||
1001 | static const struct v4l2_subdev_ops tuner_ops = { | 998 | static const struct v4l2_subdev_ops tuner_ops = { |
@@ -1023,7 +1020,7 @@ static void tuner_lookup(struct i2c_adapter *adap, | |||
1023 | int mode_mask; | 1020 | int mode_mask; |
1024 | 1021 | ||
1025 | if (pos->i2c->adapter != adap || | 1022 | if (pos->i2c->adapter != adap || |
1026 | pos->i2c->driver->id != I2C_DRIVERID_TUNER) | 1023 | strcmp(pos->i2c->driver->driver.name, "tuner")) |
1027 | continue; | 1024 | continue; |
1028 | 1025 | ||
1029 | mode_mask = pos->mode_mask & ~T_STANDBY; | 1026 | mode_mask = pos->mode_mask & ~T_STANDBY; |
@@ -1167,40 +1164,6 @@ register_client: | |||
1167 | return 0; | 1164 | return 0; |
1168 | } | 1165 | } |
1169 | 1166 | ||
1170 | static int tuner_legacy_probe(struct i2c_adapter *adap) | ||
1171 | { | ||
1172 | if (0 != addr) { | ||
1173 | normal_i2c[0] = addr; | ||
1174 | normal_i2c[1] = I2C_CLIENT_END; | ||
1175 | } | ||
1176 | |||
1177 | if ((adap->class & I2C_CLASS_TV_ANALOG) == 0) | ||
1178 | return 0; | ||
1179 | |||
1180 | /* HACK: Ignore 0x6b and 0x6f on cx88 boards. | ||
1181 | * FusionHDTV5 RT Gold has an ir receiver at 0x6b | ||
1182 | * and an RTC at 0x6f which can get corrupted if probed. | ||
1183 | */ | ||
1184 | if ((adap->id == I2C_HW_B_CX2388x) || | ||
1185 | (adap->id == I2C_HW_B_CX23885)) { | ||
1186 | unsigned int i = 0; | ||
1187 | |||
1188 | while (i < I2C_CLIENT_MAX_OPTS && ignore[i] != I2C_CLIENT_END) | ||
1189 | i += 2; | ||
1190 | if (i + 4 < I2C_CLIENT_MAX_OPTS) { | ||
1191 | ignore[i+0] = adap->nr; | ||
1192 | ignore[i+1] = 0x6b; | ||
1193 | ignore[i+2] = adap->nr; | ||
1194 | ignore[i+3] = 0x6f; | ||
1195 | ignore[i+4] = I2C_CLIENT_END; | ||
1196 | } else | ||
1197 | printk(KERN_WARNING "tuner: " | ||
1198 | "too many options specified " | ||
1199 | "in i2c probe ignore list!\n"); | ||
1200 | } | ||
1201 | return 1; | ||
1202 | } | ||
1203 | |||
1204 | static int tuner_remove(struct i2c_client *client) | 1167 | static int tuner_remove(struct i2c_client *client) |
1205 | { | 1168 | { |
1206 | struct tuner *t = to_tuner(i2c_get_clientdata(client)); | 1169 | struct tuner *t = to_tuner(i2c_get_clientdata(client)); |
@@ -1227,13 +1190,11 @@ MODULE_DEVICE_TABLE(i2c, tuner_id); | |||
1227 | 1190 | ||
1228 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 1191 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
1229 | .name = "tuner", | 1192 | .name = "tuner", |
1230 | .driverid = I2C_DRIVERID_TUNER, | ||
1231 | .command = tuner_command, | ||
1232 | .probe = tuner_probe, | 1193 | .probe = tuner_probe, |
1233 | .remove = tuner_remove, | 1194 | .remove = tuner_remove, |
1195 | .command = tuner_command, | ||
1234 | .suspend = tuner_suspend, | 1196 | .suspend = tuner_suspend, |
1235 | .resume = tuner_resume, | 1197 | .resume = tuner_resume, |
1236 | .legacy_probe = tuner_legacy_probe, | ||
1237 | .id_table = tuner_id, | 1198 | .id_table = tuner_id, |
1238 | }; | 1199 | }; |
1239 | 1200 | ||
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 226bf3565ac9..0869bafc2b56 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <media/tvaudio.h> | 35 | #include <media/tvaudio.h> |
36 | #include <media/v4l2-device.h> | 36 | #include <media/v4l2-device.h> |
37 | #include <media/v4l2-chip-ident.h> | 37 | #include <media/v4l2-chip-ident.h> |
38 | #include <media/v4l2-i2c-drv-legacy.h> | 38 | #include <media/v4l2-i2c-drv.h> |
39 | 39 | ||
40 | #include <media/i2c-addr.h> | 40 | #include <media/i2c-addr.h> |
41 | 41 | ||
@@ -136,20 +136,6 @@ static inline struct CHIPSTATE *to_state(struct v4l2_subdev *sd) | |||
136 | return container_of(sd, struct CHIPSTATE, sd); | 136 | return container_of(sd, struct CHIPSTATE, sd); |
137 | } | 137 | } |
138 | 138 | ||
139 | /* ---------------------------------------------------------------------- */ | ||
140 | /* i2c addresses */ | ||
141 | |||
142 | static unsigned short normal_i2c[] = { | ||
143 | I2C_ADDR_TDA8425 >> 1, | ||
144 | I2C_ADDR_TEA6300 >> 1, | ||
145 | I2C_ADDR_TEA6420 >> 1, | ||
146 | I2C_ADDR_TDA9840 >> 1, | ||
147 | I2C_ADDR_TDA985x_L >> 1, | ||
148 | I2C_ADDR_TDA985x_H >> 1, | ||
149 | I2C_ADDR_TDA9874 >> 1, | ||
150 | I2C_ADDR_PIC16C54 >> 1, | ||
151 | I2C_CLIENT_END }; | ||
152 | I2C_CLIENT_INSMOD; | ||
153 | 139 | ||
154 | /* ---------------------------------------------------------------------- */ | 140 | /* ---------------------------------------------------------------------- */ |
155 | /* i2c I/O functions */ | 141 | /* i2c I/O functions */ |
@@ -1795,17 +1781,18 @@ static int tvaudio_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
1795 | return -EINVAL; | 1781 | return -EINVAL; |
1796 | } | 1782 | } |
1797 | 1783 | ||
1798 | static int tvaudio_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt) | 1784 | static int tvaudio_s_routing(struct v4l2_subdev *sd, |
1785 | u32 input, u32 output, u32 config) | ||
1799 | { | 1786 | { |
1800 | struct CHIPSTATE *chip = to_state(sd); | 1787 | struct CHIPSTATE *chip = to_state(sd); |
1801 | struct CHIPDESC *desc = chip->desc; | 1788 | struct CHIPDESC *desc = chip->desc; |
1802 | 1789 | ||
1803 | if (!(desc->flags & CHIP_HAS_INPUTSEL)) | 1790 | if (!(desc->flags & CHIP_HAS_INPUTSEL)) |
1804 | return 0; | 1791 | return 0; |
1805 | if (rt->input >= 4) | 1792 | if (input >= 4) |
1806 | return -EINVAL; | 1793 | return -EINVAL; |
1807 | /* There are four inputs: tuner, radio, extern and intern. */ | 1794 | /* There are four inputs: tuner, radio, extern and intern. */ |
1808 | chip->input = rt->input; | 1795 | chip->input = input; |
1809 | if (chip->muted) | 1796 | if (chip->muted) |
1810 | return 0; | 1797 | return 0; |
1811 | chip_write_masked(chip, desc->inputreg, | 1798 | chip_write_masked(chip, desc->inputreg, |
@@ -1918,11 +1905,6 @@ static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ide | |||
1918 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVAUDIO, 0); | 1905 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVAUDIO, 0); |
1919 | } | 1906 | } |
1920 | 1907 | ||
1921 | static int tvaudio_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
1922 | { | ||
1923 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
1924 | } | ||
1925 | |||
1926 | /* ----------------------------------------------------------------------- */ | 1908 | /* ----------------------------------------------------------------------- */ |
1927 | 1909 | ||
1928 | static const struct v4l2_subdev_core_ops tvaudio_core_ops = { | 1910 | static const struct v4l2_subdev_core_ops tvaudio_core_ops = { |
@@ -1930,12 +1912,12 @@ static const struct v4l2_subdev_core_ops tvaudio_core_ops = { | |||
1930 | .queryctrl = tvaudio_queryctrl, | 1912 | .queryctrl = tvaudio_queryctrl, |
1931 | .g_ctrl = tvaudio_g_ctrl, | 1913 | .g_ctrl = tvaudio_g_ctrl, |
1932 | .s_ctrl = tvaudio_s_ctrl, | 1914 | .s_ctrl = tvaudio_s_ctrl, |
1915 | .s_std = tvaudio_s_std, | ||
1933 | }; | 1916 | }; |
1934 | 1917 | ||
1935 | static const struct v4l2_subdev_tuner_ops tvaudio_tuner_ops = { | 1918 | static const struct v4l2_subdev_tuner_ops tvaudio_tuner_ops = { |
1936 | .s_radio = tvaudio_s_radio, | 1919 | .s_radio = tvaudio_s_radio, |
1937 | .s_frequency = tvaudio_s_frequency, | 1920 | .s_frequency = tvaudio_s_frequency, |
1938 | .s_std = tvaudio_s_std, | ||
1939 | .s_tuner = tvaudio_s_tuner, | 1921 | .s_tuner = tvaudio_s_tuner, |
1940 | .s_tuner = tvaudio_g_tuner, | 1922 | .s_tuner = tvaudio_g_tuner, |
1941 | }; | 1923 | }; |
@@ -2088,17 +2070,6 @@ static int tvaudio_remove(struct i2c_client *client) | |||
2088 | return 0; | 2070 | return 0; |
2089 | } | 2071 | } |
2090 | 2072 | ||
2091 | static int tvaudio_legacy_probe(struct i2c_adapter *adap) | ||
2092 | { | ||
2093 | /* don't attach on saa7146 based cards, | ||
2094 | because dedicated drivers are used */ | ||
2095 | if ((adap->id == I2C_HW_SAA7146)) | ||
2096 | return 0; | ||
2097 | if (adap->class & I2C_CLASS_TV_ANALOG) | ||
2098 | return 1; | ||
2099 | return 0; | ||
2100 | } | ||
2101 | |||
2102 | /* This driver supports many devices and the idea is to let the driver | 2073 | /* This driver supports many devices and the idea is to let the driver |
2103 | detect which device is present. So rather than listing all supported | 2074 | detect which device is present. So rather than listing all supported |
2104 | devices here, we pretend to support a single, fake device type. */ | 2075 | devices here, we pretend to support a single, fake device type. */ |
@@ -2110,10 +2081,7 @@ MODULE_DEVICE_TABLE(i2c, tvaudio_id); | |||
2110 | 2081 | ||
2111 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 2082 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
2112 | .name = "tvaudio", | 2083 | .name = "tvaudio", |
2113 | .driverid = I2C_DRIVERID_TVAUDIO, | ||
2114 | .command = tvaudio_command, | ||
2115 | .probe = tvaudio_probe, | 2084 | .probe = tvaudio_probe, |
2116 | .remove = tvaudio_remove, | 2085 | .remove = tvaudio_remove, |
2117 | .legacy_probe = tvaudio_legacy_probe, | ||
2118 | .id_table = tvaudio_id, | 2086 | .id_table = tvaudio_id, |
2119 | }; | 2087 | }; |
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 3a5a95f134b4..2d38e253f14e 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
11 | #include <media/v4l2-device.h> | 11 | #include <media/v4l2-device.h> |
12 | #include <media/tvp5150.h> | 12 | #include <media/tvp5150.h> |
13 | #include <media/v4l2-i2c-drv-legacy.h> | 13 | #include <media/v4l2-i2c-drv.h> |
14 | #include <media/v4l2-chip-ident.h> | 14 | #include <media/v4l2-chip-ident.h> |
15 | 15 | ||
16 | #include "tvp5150_reg.h" | 16 | #include "tvp5150_reg.h" |
@@ -19,14 +19,6 @@ MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver"); | |||
19 | MODULE_AUTHOR("Mauro Carvalho Chehab"); | 19 | MODULE_AUTHOR("Mauro Carvalho Chehab"); |
20 | MODULE_LICENSE("GPL"); | 20 | MODULE_LICENSE("GPL"); |
21 | 21 | ||
22 | /* standard i2c insmod options */ | ||
23 | static unsigned short normal_i2c[] = { | ||
24 | 0xb8 >> 1, | ||
25 | 0xba >> 1, | ||
26 | I2C_CLIENT_END | ||
27 | }; | ||
28 | |||
29 | I2C_CLIENT_INSMOD; | ||
30 | 22 | ||
31 | static int debug; | 23 | static int debug; |
32 | module_param(debug, int, 0); | 24 | module_param(debug, int, 0); |
@@ -77,7 +69,8 @@ struct tvp5150 { | |||
77 | struct v4l2_subdev sd; | 69 | struct v4l2_subdev sd; |
78 | 70 | ||
79 | v4l2_std_id norm; /* Current set standard */ | 71 | v4l2_std_id norm; /* Current set standard */ |
80 | struct v4l2_routing route; | 72 | u32 input; |
73 | u32 output; | ||
81 | int enable; | 74 | int enable; |
82 | int bright; | 75 | int bright; |
83 | int contrast; | 76 | int contrast; |
@@ -288,10 +281,10 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd) | |||
288 | int input = 0; | 281 | int input = 0; |
289 | unsigned char val; | 282 | unsigned char val; |
290 | 283 | ||
291 | if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable) | 284 | if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable) |
292 | input = 8; | 285 | input = 8; |
293 | 286 | ||
294 | switch (decoder->route.input) { | 287 | switch (decoder->input) { |
295 | case TVP5150_COMPOSITE1: | 288 | case TVP5150_COMPOSITE1: |
296 | input |= 2; | 289 | input |= 2; |
297 | /* fall through */ | 290 | /* fall through */ |
@@ -307,8 +300,8 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd) | |||
307 | 300 | ||
308 | v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i " | 301 | v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i " |
309 | "=> tvp5150 input=%i, opmode=%i\n", | 302 | "=> tvp5150 input=%i, opmode=%i\n", |
310 | decoder->route.input,decoder->route.output, | 303 | decoder->input, decoder->output, |
311 | input, opmode ); | 304 | input, opmode); |
312 | 305 | ||
313 | tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode); | 306 | tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode); |
314 | tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input); | 307 | tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input); |
@@ -317,7 +310,7 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd) | |||
317 | * For Composite and TV, it should be the reverse | 310 | * For Composite and TV, it should be the reverse |
318 | */ | 311 | */ |
319 | val = tvp5150_read(sd, TVP5150_MISC_CTL); | 312 | val = tvp5150_read(sd, TVP5150_MISC_CTL); |
320 | if (decoder->route.input == TVP5150_SVIDEO) | 313 | if (decoder->input == TVP5150_SVIDEO) |
321 | val = (val & ~0x40) | 0x10; | 314 | val = (val & ~0x40) | 0x10; |
322 | else | 315 | else |
323 | val = (val & ~0x10) | 0x40; | 316 | val = (val & ~0x10) | 0x40; |
@@ -886,11 +879,13 @@ static int tvp5150_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
886 | I2C Command | 879 | I2C Command |
887 | ****************************************************************************/ | 880 | ****************************************************************************/ |
888 | 881 | ||
889 | static int tvp5150_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 882 | static int tvp5150_s_routing(struct v4l2_subdev *sd, |
883 | u32 input, u32 output, u32 config) | ||
890 | { | 884 | { |
891 | struct tvp5150 *decoder = to_tvp5150(sd); | 885 | struct tvp5150 *decoder = to_tvp5150(sd); |
892 | 886 | ||
893 | decoder->route = *route; | 887 | decoder->input = input; |
888 | decoder->output = output; | ||
894 | tvp5150_selmux(sd); | 889 | tvp5150_selmux(sd); |
895 | return 0; | 890 | return 0; |
896 | } | 891 | } |
@@ -1026,11 +1021,6 @@ static int tvp5150_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
1026 | return -EINVAL; | 1021 | return -EINVAL; |
1027 | } | 1022 | } |
1028 | 1023 | ||
1029 | static int tvp5150_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
1030 | { | ||
1031 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
1032 | } | ||
1033 | |||
1034 | /* ----------------------------------------------------------------------- */ | 1024 | /* ----------------------------------------------------------------------- */ |
1035 | 1025 | ||
1036 | static const struct v4l2_subdev_core_ops tvp5150_core_ops = { | 1026 | static const struct v4l2_subdev_core_ops tvp5150_core_ops = { |
@@ -1038,6 +1028,7 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = { | |||
1038 | .g_ctrl = tvp5150_g_ctrl, | 1028 | .g_ctrl = tvp5150_g_ctrl, |
1039 | .s_ctrl = tvp5150_s_ctrl, | 1029 | .s_ctrl = tvp5150_s_ctrl, |
1040 | .queryctrl = tvp5150_queryctrl, | 1030 | .queryctrl = tvp5150_queryctrl, |
1031 | .s_std = tvp5150_s_std, | ||
1041 | .reset = tvp5150_reset, | 1032 | .reset = tvp5150_reset, |
1042 | .g_chip_ident = tvp5150_g_chip_ident, | 1033 | .g_chip_ident = tvp5150_g_chip_ident, |
1043 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1034 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
@@ -1047,7 +1038,6 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = { | |||
1047 | }; | 1038 | }; |
1048 | 1039 | ||
1049 | static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = { | 1040 | static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = { |
1050 | .s_std = tvp5150_s_std, | ||
1051 | .g_tuner = tvp5150_g_tuner, | 1041 | .g_tuner = tvp5150_g_tuner, |
1052 | }; | 1042 | }; |
1053 | 1043 | ||
@@ -1090,7 +1080,7 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1090 | c->addr << 1, c->adapter->name); | 1080 | c->addr << 1, c->adapter->name); |
1091 | 1081 | ||
1092 | core->norm = V4L2_STD_ALL; /* Default is autodetect */ | 1082 | core->norm = V4L2_STD_ALL; /* Default is autodetect */ |
1093 | core->route.input = TVP5150_COMPOSITE1; | 1083 | core->input = TVP5150_COMPOSITE1; |
1094 | core->enable = 1; | 1084 | core->enable = 1; |
1095 | core->bright = 128; | 1085 | core->bright = 128; |
1096 | core->contrast = 128; | 1086 | core->contrast = 128; |
@@ -1125,9 +1115,7 @@ MODULE_DEVICE_TABLE(i2c, tvp5150_id); | |||
1125 | 1115 | ||
1126 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 1116 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
1127 | .name = "tvp5150", | 1117 | .name = "tvp5150", |
1128 | .command = tvp5150_command, | ||
1129 | .probe = tvp5150_probe, | 1118 | .probe = tvp5150_probe, |
1130 | .remove = tvp5150_remove, | 1119 | .remove = tvp5150_remove, |
1131 | .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL, | ||
1132 | .id_table = tvp5150_id, | 1120 | .id_table = tvp5150_id, |
1133 | }; | 1121 | }; |
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c index c0ac651bb358..a07a3fbb51eb 100644 --- a/drivers/media/video/upd64031a.c +++ b/drivers/media/video/upd64031a.c | |||
@@ -124,17 +124,18 @@ static int upd64031a_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency * | |||
124 | 124 | ||
125 | /* ------------------------------------------------------------------------ */ | 125 | /* ------------------------------------------------------------------------ */ |
126 | 126 | ||
127 | static int upd64031a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 127 | static int upd64031a_s_routing(struct v4l2_subdev *sd, |
128 | u32 input, u32 output, u32 config) | ||
128 | { | 129 | { |
129 | struct upd64031a_state *state = to_state(sd); | 130 | struct upd64031a_state *state = to_state(sd); |
130 | u8 r00, r05, r08; | 131 | u8 r00, r05, r08; |
131 | 132 | ||
132 | state->gr_mode = (route->input & 3) << 6; | 133 | state->gr_mode = (input & 3) << 6; |
133 | state->direct_3dycs_connect = (route->input & 0xc) << 4; | 134 | state->direct_3dycs_connect = (input & 0xc) << 4; |
134 | state->ext_comp_sync = | 135 | state->ext_comp_sync = |
135 | (route->input & UPD64031A_COMPOSITE_EXTERNAL) << 1; | 136 | (input & UPD64031A_COMPOSITE_EXTERNAL) << 1; |
136 | state->ext_vert_sync = | 137 | state->ext_vert_sync = |
137 | (route->input & UPD64031A_VERTICAL_EXTERNAL) << 2; | 138 | (input & UPD64031A_VERTICAL_EXTERNAL) << 2; |
138 | r00 = (state->regs[R00] & ~GR_MODE_MASK) | state->gr_mode; | 139 | r00 = (state->regs[R00] & ~GR_MODE_MASK) | state->gr_mode; |
139 | r05 = (state->regs[R00] & ~SYNC_CIRCUIT_MASK) | | 140 | r05 = (state->regs[R00] & ~SYNC_CIRCUIT_MASK) | |
140 | state->ext_comp_sync | state->ext_vert_sync; | 141 | state->ext_comp_sync | state->ext_vert_sync; |
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c index 410c915d51fa..6eb0e5b00c32 100644 --- a/drivers/media/video/upd64083.c +++ b/drivers/media/video/upd64083.c | |||
@@ -102,15 +102,16 @@ static u8 upd64083_read(struct v4l2_subdev *sd, u8 reg) | |||
102 | 102 | ||
103 | /* ------------------------------------------------------------------------ */ | 103 | /* ------------------------------------------------------------------------ */ |
104 | 104 | ||
105 | static int upd64083_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 105 | static int upd64083_s_routing(struct v4l2_subdev *sd, |
106 | u32 input, u32 output, u32 config) | ||
106 | { | 107 | { |
107 | struct upd64083_state *state = to_state(sd); | 108 | struct upd64083_state *state = to_state(sd); |
108 | u8 r00, r02; | 109 | u8 r00, r02; |
109 | 110 | ||
110 | if (route->input > 7 || (route->input & 6) == 6) | 111 | if (input > 7 || (input & 6) == 6) |
111 | return -EINVAL; | 112 | return -EINVAL; |
112 | state->mode = (route->input & 3) << 6; | 113 | state->mode = (input & 3) << 6; |
113 | state->ext_y_adc = (route->input & UPD64083_EXT_Y_ADC) << 3; | 114 | state->ext_y_adc = (input & UPD64083_EXT_Y_ADC) << 3; |
114 | r00 = (state->regs[R00] & ~(3 << 6)) | state->mode; | 115 | r00 = (state->regs[R00] & ~(3 << 6)) | state->mode; |
115 | r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc; | 116 | r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc; |
116 | upd64083_write(sd, R00, r00); | 117 | upd64083_write(sd, R00, r00); |
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index a0feb1c97736..8bc03b9e1315 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
@@ -2597,7 +2597,6 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel) | |||
2597 | /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */ | 2597 | /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */ |
2598 | int mode[4]= {SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3}; | 2598 | int mode[4]= {SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3}; |
2599 | int audio[]= {1, 0, 0, 0}; | 2599 | int audio[]= {1, 0, 0, 0}; |
2600 | struct v4l2_routing route; | ||
2601 | //channel 0 is TV with audiochannel 1 (tuner mono) | 2600 | //channel 0 is TV with audiochannel 1 (tuner mono) |
2602 | //channel 1 is Composite with audio channel 0 (line in) | 2601 | //channel 1 is Composite with audio channel 0 (line in) |
2603 | //channel 2 is S-Video with audio channel 0 (line in) | 2602 | //channel 2 is S-Video with audio channel 0 (line in) |
@@ -2630,9 +2629,7 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel) | |||
2630 | mode[2] = SAA7115_SVIDEO1; | 2629 | mode[2] = SAA7115_SVIDEO1; |
2631 | break; | 2630 | break; |
2632 | } | 2631 | } |
2633 | route.input = mode[channel]; | 2632 | call_all(usbvision, video, s_routing, mode[channel], 0, 0); |
2634 | route.output = 0; | ||
2635 | call_all(usbvision, video, s_routing, &route); | ||
2636 | usbvision_set_audio(usbvision, audio[channel]); | 2633 | usbvision_set_audio(usbvision, audio[channel]); |
2637 | return 0; | 2634 | return 0; |
2638 | } | 2635 | } |
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index dd2f8f27c73b..1fe5befbbf85 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/version.h> | ||
32 | #include <linux/utsname.h> | 31 | #include <linux/utsname.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
@@ -247,7 +246,8 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
247 | switch (usbvision_device_data[usbvision->DevModel].Codec) { | 246 | switch (usbvision_device_data[usbvision->DevModel].Codec) { |
248 | case CODEC_SAA7113: | 247 | case CODEC_SAA7113: |
249 | case CODEC_SAA7111: | 248 | case CODEC_SAA7111: |
250 | v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "saa7115", | 249 | v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev, |
250 | &usbvision->i2c_adap, "saa7115", | ||
251 | "saa7115_auto", saa711x_addrs); | 251 | "saa7115_auto", saa711x_addrs); |
252 | break; | 252 | break; |
253 | } | 253 | } |
@@ -256,13 +256,15 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
256 | enum v4l2_i2c_tuner_type type; | 256 | enum v4l2_i2c_tuner_type type; |
257 | struct tuner_setup tun_setup; | 257 | struct tuner_setup tun_setup; |
258 | 258 | ||
259 | sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner", | 259 | sd = v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev, |
260 | &usbvision->i2c_adap, "tuner", | ||
260 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 261 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); |
261 | /* depending on whether we found a demod or not, select | 262 | /* depending on whether we found a demod or not, select |
262 | the tuner type. */ | 263 | the tuner type. */ |
263 | type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | 264 | type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; |
264 | 265 | ||
265 | sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner", | 266 | sd = v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev, |
267 | &usbvision->i2c_adap, "tuner", | ||
266 | "tuner", v4l2_i2c_tuner_addrs(type)); | 268 | "tuner", v4l2_i2c_tuner_addrs(type)); |
267 | 269 | ||
268 | if (usbvision->tuner_type != -1) { | 270 | if (usbvision->tuner_type != -1) { |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index fa62a2fd7b22..d7056a5b7f9b 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * USB USBVISION Video device driver 0.9.9 | 2 | * USB USBVISION Video device driver 0.9.10 |
3 | * | 3 | * |
4 | * | 4 | * |
5 | * | 5 | * |
@@ -79,7 +79,7 @@ | |||
79 | #define DRIVER_LICENSE "GPL" | 79 | #define DRIVER_LICENSE "GPL" |
80 | #define USBVISION_DRIVER_VERSION_MAJOR 0 | 80 | #define USBVISION_DRIVER_VERSION_MAJOR 0 |
81 | #define USBVISION_DRIVER_VERSION_MINOR 9 | 81 | #define USBVISION_DRIVER_VERSION_MINOR 9 |
82 | #define USBVISION_DRIVER_VERSION_PATCHLEVEL 9 | 82 | #define USBVISION_DRIVER_VERSION_PATCHLEVEL 10 |
83 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ | 83 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ |
84 | USBVISION_DRIVER_VERSION_MINOR,\ | 84 | USBVISION_DRIVER_VERSION_MINOR,\ |
85 | USBVISION_DRIVER_VERSION_PATCHLEVEL) | 85 | USBVISION_DRIVER_VERSION_PATCHLEVEL) |
@@ -621,7 +621,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
621 | usbvision->tvnormId=*id; | 621 | usbvision->tvnormId=*id; |
622 | 622 | ||
623 | mutex_lock(&usbvision->lock); | 623 | mutex_lock(&usbvision->lock); |
624 | call_all(usbvision, tuner, s_std, usbvision->tvnormId); | 624 | call_all(usbvision, core, s_std, usbvision->tvnormId); |
625 | mutex_unlock(&usbvision->lock); | 625 | mutex_unlock(&usbvision->lock); |
626 | /* propagate the change to the decoder */ | 626 | /* propagate the change to the decoder */ |
627 | usbvision_muxsel(usbvision, usbvision->ctl_input); | 627 | usbvision_muxsel(usbvision, usbvision->ctl_input); |
@@ -1522,7 +1522,8 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | |||
1522 | * Returns NULL on error, a pointer to usb_usbvision else. | 1522 | * Returns NULL on error, a pointer to usb_usbvision else. |
1523 | * | 1523 | * |
1524 | */ | 1524 | */ |
1525 | static struct usb_usbvision *usbvision_alloc(struct usb_device *dev) | 1525 | static struct usb_usbvision *usbvision_alloc(struct usb_device *dev, |
1526 | struct usb_interface *intf) | ||
1526 | { | 1527 | { |
1527 | struct usb_usbvision *usbvision; | 1528 | struct usb_usbvision *usbvision; |
1528 | 1529 | ||
@@ -1531,7 +1532,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev) | |||
1531 | return NULL; | 1532 | return NULL; |
1532 | 1533 | ||
1533 | usbvision->dev = dev; | 1534 | usbvision->dev = dev; |
1534 | if (v4l2_device_register(&dev->dev, &usbvision->v4l2_dev)) | 1535 | if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev)) |
1535 | goto err_free; | 1536 | goto err_free; |
1536 | 1537 | ||
1537 | mutex_init(&usbvision->lock); /* available */ | 1538 | mutex_init(&usbvision->lock); /* available */ |
@@ -1669,7 +1670,8 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1669 | return -ENODEV; | 1670 | return -ENODEV; |
1670 | } | 1671 | } |
1671 | 1672 | ||
1672 | if ((usbvision = usbvision_alloc(dev)) == NULL) { | 1673 | usbvision = usbvision_alloc(dev, intf); |
1674 | if (usbvision == NULL) { | ||
1673 | dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__); | 1675 | dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__); |
1674 | return -ENOMEM; | 1676 | return -ENOMEM; |
1675 | } | 1677 | } |
diff --git a/drivers/media/video/uvc/Kconfig b/drivers/media/video/uvc/Kconfig index c2d9760de832..2956a7637219 100644 --- a/drivers/media/video/uvc/Kconfig +++ b/drivers/media/video/uvc/Kconfig | |||
@@ -9,7 +9,7 @@ config USB_VIDEO_CLASS | |||
9 | config USB_VIDEO_CLASS_INPUT_EVDEV | 9 | config USB_VIDEO_CLASS_INPUT_EVDEV |
10 | bool "UVC input events device support" | 10 | bool "UVC input events device support" |
11 | default y | 11 | default y |
12 | depends on USB_VIDEO_CLASS && INPUT | 12 | depends on USB_VIDEO_CLASS=INPUT || INPUT=y |
13 | ---help--- | 13 | ---help--- |
14 | This option makes USB Video Class devices register an input device | 14 | This option makes USB Video Class devices register an input device |
15 | to report button events. | 15 | to report button events. |
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index b617bf05e2d7..02f2a6d18b45 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
@@ -575,6 +575,8 @@ static noinline long v4l1_compat_get_input_info( | |||
575 | chan->norm = VIDEO_MODE_NTSC; | 575 | chan->norm = VIDEO_MODE_NTSC; |
576 | if (sid & V4L2_STD_SECAM) | 576 | if (sid & V4L2_STD_SECAM) |
577 | chan->norm = VIDEO_MODE_SECAM; | 577 | chan->norm = VIDEO_MODE_SECAM; |
578 | if (sid == V4L2_STD_ALL) | ||
579 | chan->norm = VIDEO_MODE_AUTO; | ||
578 | } | 580 | } |
579 | done: | 581 | done: |
580 | return err; | 582 | return err; |
@@ -601,6 +603,9 @@ static noinline long v4l1_compat_set_input( | |||
601 | case VIDEO_MODE_SECAM: | 603 | case VIDEO_MODE_SECAM: |
602 | sid = V4L2_STD_SECAM; | 604 | sid = V4L2_STD_SECAM; |
603 | break; | 605 | break; |
606 | case VIDEO_MODE_AUTO: | ||
607 | sid = V4L2_STD_ALL; | ||
608 | break; | ||
604 | } | 609 | } |
605 | if (0 != sid) { | 610 | if (0 != sid) { |
606 | err = drv(file, VIDIOC_S_STD, &sid); | 611 | err = drv(file, VIDIOC_S_STD, &sid); |
@@ -804,9 +809,9 @@ static noinline long v4l1_compat_select_tuner( | |||
804 | 809 | ||
805 | t.index = tun->tuner; | 810 | t.index = tun->tuner; |
806 | 811 | ||
807 | err = drv(file, VIDIOC_S_INPUT, &t); | 812 | err = drv(file, VIDIOC_S_TUNER, &t); |
808 | if (err < 0) | 813 | if (err < 0) |
809 | dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %ld\n", err); | 814 | dprintk("VIDIOCSTUNER / VIDIOC_S_TUNER: %ld\n", err); |
810 | return err; | 815 | return err; |
811 | } | 816 | } |
812 | 817 | ||
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 1da8cb836cb6..f576ef66b807 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -739,33 +739,8 @@ EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); | |||
739 | 739 | ||
740 | /* ----------------------------------------------------------------- */ | 740 | /* ----------------------------------------------------------------- */ |
741 | 741 | ||
742 | /* Helper function for I2C legacy drivers */ | 742 | /* I2C Helper functions */ |
743 | 743 | ||
744 | int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, | ||
745 | const char *name, | ||
746 | int (*probe)(struct i2c_client *, const struct i2c_device_id *)) | ||
747 | { | ||
748 | struct i2c_client *client; | ||
749 | int err; | ||
750 | |||
751 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
752 | if (!client) | ||
753 | return -ENOMEM; | ||
754 | |||
755 | client->addr = address; | ||
756 | client->adapter = adapter; | ||
757 | client->driver = driver; | ||
758 | strlcpy(client->name, name, sizeof(client->name)); | ||
759 | |||
760 | err = probe(client, NULL); | ||
761 | if (err == 0) { | ||
762 | i2c_attach_client(client); | ||
763 | } else { | ||
764 | kfree(client); | ||
765 | } | ||
766 | return err != -ENOMEM ? 0 : err; | ||
767 | } | ||
768 | EXPORT_SYMBOL(v4l2_i2c_attach); | ||
769 | 744 | ||
770 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, | 745 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
771 | const struct v4l2_subdev_ops *ops) | 746 | const struct v4l2_subdev_ops *ops) |
@@ -785,18 +760,16 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init); | |||
785 | 760 | ||
786 | 761 | ||
787 | 762 | ||
788 | /* Load an i2c sub-device. It assumes that i2c_get_adapdata(adapter) | 763 | /* Load an i2c sub-device. */ |
789 | returns the v4l2_device and that i2c_get_clientdata(client) | 764 | struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, |
790 | returns the v4l2_subdev. */ | 765 | struct i2c_adapter *adapter, |
791 | struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, | ||
792 | const char *module_name, const char *client_type, u8 addr) | 766 | const char *module_name, const char *client_type, u8 addr) |
793 | { | 767 | { |
794 | struct v4l2_device *dev = i2c_get_adapdata(adapter); | ||
795 | struct v4l2_subdev *sd = NULL; | 768 | struct v4l2_subdev *sd = NULL; |
796 | struct i2c_client *client; | 769 | struct i2c_client *client; |
797 | struct i2c_board_info info; | 770 | struct i2c_board_info info; |
798 | 771 | ||
799 | BUG_ON(!dev); | 772 | BUG_ON(!v4l2_dev); |
800 | 773 | ||
801 | if (module_name) | 774 | if (module_name) |
802 | request_module(module_name); | 775 | request_module(module_name); |
@@ -823,7 +796,7 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, | |||
823 | 796 | ||
824 | /* Register with the v4l2_device which increases the module's | 797 | /* Register with the v4l2_device which increases the module's |
825 | use count as well. */ | 798 | use count as well. */ |
826 | if (v4l2_device_register_subdev(dev, sd)) | 799 | if (v4l2_device_register_subdev(v4l2_dev, sd)) |
827 | sd = NULL; | 800 | sd = NULL; |
828 | /* Decrease the module use count to match the first try_module_get. */ | 801 | /* Decrease the module use count to match the first try_module_get. */ |
829 | module_put(client->driver->driver.owner); | 802 | module_put(client->driver->driver.owner); |
@@ -837,19 +810,17 @@ error: | |||
837 | } | 810 | } |
838 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); | 811 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); |
839 | 812 | ||
840 | /* Probe and load an i2c sub-device. It assumes that i2c_get_adapdata(adapter) | 813 | /* Probe and load an i2c sub-device. */ |
841 | returns the v4l2_device and that i2c_get_clientdata(client) | 814 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, |
842 | returns the v4l2_subdev. */ | 815 | struct i2c_adapter *adapter, |
843 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter, | ||
844 | const char *module_name, const char *client_type, | 816 | const char *module_name, const char *client_type, |
845 | const unsigned short *addrs) | 817 | const unsigned short *addrs) |
846 | { | 818 | { |
847 | struct v4l2_device *dev = i2c_get_adapdata(adapter); | ||
848 | struct v4l2_subdev *sd = NULL; | 819 | struct v4l2_subdev *sd = NULL; |
849 | struct i2c_client *client = NULL; | 820 | struct i2c_client *client = NULL; |
850 | struct i2c_board_info info; | 821 | struct i2c_board_info info; |
851 | 822 | ||
852 | BUG_ON(!dev); | 823 | BUG_ON(!v4l2_dev); |
853 | 824 | ||
854 | if (module_name) | 825 | if (module_name) |
855 | request_module(module_name); | 826 | request_module(module_name); |
@@ -875,7 +846,7 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter, | |||
875 | 846 | ||
876 | /* Register with the v4l2_device which increases the module's | 847 | /* Register with the v4l2_device which increases the module's |
877 | use count as well. */ | 848 | use count as well. */ |
878 | if (v4l2_device_register_subdev(dev, sd)) | 849 | if (v4l2_device_register_subdev(v4l2_dev, sd)) |
879 | sd = NULL; | 850 | sd = NULL; |
880 | /* Decrease the module use count to match the first try_module_get. */ | 851 | /* Decrease the module use count to match the first try_module_get. */ |
881 | module_put(client->driver->driver.owner); | 852 | module_put(client->driver->driver.owner); |
@@ -889,6 +860,17 @@ error: | |||
889 | } | 860 | } |
890 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev); | 861 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev); |
891 | 862 | ||
863 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev, | ||
864 | struct i2c_adapter *adapter, | ||
865 | const char *module_name, const char *client_type, u8 addr) | ||
866 | { | ||
867 | unsigned short addrs[2] = { addr, I2C_CLIENT_END }; | ||
868 | |||
869 | return v4l2_i2c_new_probed_subdev(v4l2_dev, adapter, | ||
870 | module_name, client_type, addrs); | ||
871 | } | ||
872 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev_addr); | ||
873 | |||
892 | /* Return i2c client address of v4l2_subdev. */ | 874 | /* Return i2c client address of v4l2_subdev. */ |
893 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) | 875 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) |
894 | { | 876 | { |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 91228b3df07d..31eac66411d7 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -229,7 +229,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) | |||
229 | static int v4l2_open(struct inode *inode, struct file *filp) | 229 | static int v4l2_open(struct inode *inode, struct file *filp) |
230 | { | 230 | { |
231 | struct video_device *vdev; | 231 | struct video_device *vdev; |
232 | int ret; | 232 | int ret = 0; |
233 | 233 | ||
234 | /* Check if the video device is available */ | 234 | /* Check if the video device is available */ |
235 | mutex_lock(&videodev_lock); | 235 | mutex_lock(&videodev_lock); |
@@ -243,7 +243,9 @@ static int v4l2_open(struct inode *inode, struct file *filp) | |||
243 | /* and increase the device refcount */ | 243 | /* and increase the device refcount */ |
244 | video_get(vdev); | 244 | video_get(vdev); |
245 | mutex_unlock(&videodev_lock); | 245 | mutex_unlock(&videodev_lock); |
246 | ret = vdev->fops->open(filp); | 246 | if (vdev->fops->open) |
247 | ret = vdev->fops->open(filp); | ||
248 | |||
247 | /* decrease the refcount in case of an error */ | 249 | /* decrease the refcount in case of an error */ |
248 | if (ret) | 250 | if (ret) |
249 | video_put(vdev); | 251 | video_put(vdev); |
@@ -254,7 +256,10 @@ static int v4l2_open(struct inode *inode, struct file *filp) | |||
254 | static int v4l2_release(struct inode *inode, struct file *filp) | 256 | static int v4l2_release(struct inode *inode, struct file *filp) |
255 | { | 257 | { |
256 | struct video_device *vdev = video_devdata(filp); | 258 | struct video_device *vdev = video_devdata(filp); |
257 | int ret = vdev->fops->release(filp); | 259 | int ret = 0; |
260 | |||
261 | if (vdev->fops->release) | ||
262 | vdev->fops->release(filp); | ||
258 | 263 | ||
259 | /* decrease the refcount unconditionally since the release() | 264 | /* decrease the refcount unconditionally since the release() |
260 | return value is ignored. */ | 265 | return value is ignored. */ |
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index f41c6f506f42..88f10d6cbc92 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -275,32 +275,6 @@ static const char *v4l2_ioctls[] = { | |||
275 | }; | 275 | }; |
276 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | 276 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) |
277 | 277 | ||
278 | static const char *v4l2_int_ioctls[] = { | ||
279 | [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", | ||
280 | |||
281 | [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", | ||
282 | [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", | ||
283 | [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG", | ||
284 | |||
285 | [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", | ||
286 | [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", | ||
287 | [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", | ||
288 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", | ||
289 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", | ||
290 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", | ||
291 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", | ||
292 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", | ||
293 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", | ||
294 | [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING", | ||
295 | [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING", | ||
296 | [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING", | ||
297 | [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ", | ||
298 | [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT", | ||
299 | [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT", | ||
300 | [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT", | ||
301 | }; | ||
302 | #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) | ||
303 | |||
304 | /* Common ioctl debug function. This function can be used by | 278 | /* Common ioctl debug function. This function can be used by |
305 | external ioctl messages as well as internal V4L ioctl */ | 279 | external ioctl messages as well as internal V4L ioctl */ |
306 | void v4l_printk_ioctl(unsigned int cmd) | 280 | void v4l_printk_ioctl(unsigned int cmd) |
@@ -309,12 +283,8 @@ void v4l_printk_ioctl(unsigned int cmd) | |||
309 | 283 | ||
310 | switch (_IOC_TYPE(cmd)) { | 284 | switch (_IOC_TYPE(cmd)) { |
311 | case 'd': | 285 | case 'd': |
312 | if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) { | 286 | type = "v4l2_int"; |
313 | type = "v4l2_int"; | 287 | break; |
314 | break; | ||
315 | } | ||
316 | printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]); | ||
317 | return; | ||
318 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 288 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
319 | case 'v': | 289 | case 'v': |
320 | if (_IOC_NR(cmd) >= V4L1_IOCTLS) { | 290 | if (_IOC_NR(cmd) >= V4L1_IOCTLS) { |
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c deleted file mode 100644 index dc881671d536..000000000000 --- a/drivers/media/video/v4l2-subdev.c +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* | ||
2 | V4L2 sub-device support. | ||
3 | |||
4 | Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl> | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | #include <linux/ioctl.h> | ||
23 | #include <linux/i2c.h> | ||
24 | #include <linux/videodev2.h> | ||
25 | #include <media/v4l2-subdev.h> | ||
26 | |||
27 | int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg) | ||
28 | { | ||
29 | switch (cmd) { | ||
30 | case VIDIOC_QUERYCTRL: | ||
31 | return v4l2_subdev_call(sd, core, queryctrl, arg); | ||
32 | case VIDIOC_G_CTRL: | ||
33 | return v4l2_subdev_call(sd, core, g_ctrl, arg); | ||
34 | case VIDIOC_S_CTRL: | ||
35 | return v4l2_subdev_call(sd, core, s_ctrl, arg); | ||
36 | case VIDIOC_G_EXT_CTRLS: | ||
37 | return v4l2_subdev_call(sd, core, g_ext_ctrls, arg); | ||
38 | case VIDIOC_S_EXT_CTRLS: | ||
39 | return v4l2_subdev_call(sd, core, s_ext_ctrls, arg); | ||
40 | case VIDIOC_TRY_EXT_CTRLS: | ||
41 | return v4l2_subdev_call(sd, core, try_ext_ctrls, arg); | ||
42 | case VIDIOC_QUERYMENU: | ||
43 | return v4l2_subdev_call(sd, core, querymenu, arg); | ||
44 | case VIDIOC_LOG_STATUS: | ||
45 | return v4l2_subdev_call(sd, core, log_status); | ||
46 | case VIDIOC_DBG_G_CHIP_IDENT: | ||
47 | return v4l2_subdev_call(sd, core, g_chip_ident, arg); | ||
48 | case VIDIOC_INT_S_STANDBY: | ||
49 | return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0); | ||
50 | case VIDIOC_INT_RESET: | ||
51 | return v4l2_subdev_call(sd, core, reset, arg ? (*(u32 *)arg) : 0); | ||
52 | case VIDIOC_INT_S_GPIO: | ||
53 | return v4l2_subdev_call(sd, core, s_gpio, arg ? (*(u32 *)arg) : 0); | ||
54 | case VIDIOC_INT_INIT: | ||
55 | return v4l2_subdev_call(sd, core, init, arg ? (*(u32 *)arg) : 0); | ||
56 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
57 | case VIDIOC_DBG_G_REGISTER: | ||
58 | return v4l2_subdev_call(sd, core, g_register, arg); | ||
59 | case VIDIOC_DBG_S_REGISTER: | ||
60 | return v4l2_subdev_call(sd, core, s_register, arg); | ||
61 | #endif | ||
62 | |||
63 | case VIDIOC_INT_S_TUNER_MODE: | ||
64 | return v4l2_subdev_call(sd, tuner, s_mode, *(enum v4l2_tuner_type *)arg); | ||
65 | case AUDC_SET_RADIO: | ||
66 | return v4l2_subdev_call(sd, tuner, s_radio); | ||
67 | case VIDIOC_S_TUNER: | ||
68 | return v4l2_subdev_call(sd, tuner, s_tuner, arg); | ||
69 | case VIDIOC_G_TUNER: | ||
70 | return v4l2_subdev_call(sd, tuner, g_tuner, arg); | ||
71 | case VIDIOC_S_STD: | ||
72 | return v4l2_subdev_call(sd, tuner, s_std, *(v4l2_std_id *)arg); | ||
73 | case VIDIOC_S_FREQUENCY: | ||
74 | return v4l2_subdev_call(sd, tuner, s_frequency, arg); | ||
75 | case VIDIOC_G_FREQUENCY: | ||
76 | return v4l2_subdev_call(sd, tuner, g_frequency, arg); | ||
77 | case TUNER_SET_TYPE_ADDR: | ||
78 | return v4l2_subdev_call(sd, tuner, s_type_addr, arg); | ||
79 | case TUNER_SET_CONFIG: | ||
80 | return v4l2_subdev_call(sd, tuner, s_config, arg); | ||
81 | |||
82 | case VIDIOC_INT_AUDIO_CLOCK_FREQ: | ||
83 | return v4l2_subdev_call(sd, audio, s_clock_freq, *(u32 *)arg); | ||
84 | case VIDIOC_INT_S_AUDIO_ROUTING: | ||
85 | return v4l2_subdev_call(sd, audio, s_routing, arg); | ||
86 | case VIDIOC_INT_I2S_CLOCK_FREQ: | ||
87 | return v4l2_subdev_call(sd, audio, s_i2s_clock_freq, *(u32 *)arg); | ||
88 | |||
89 | case VIDIOC_INT_S_VIDEO_ROUTING: | ||
90 | return v4l2_subdev_call(sd, video, s_routing, arg); | ||
91 | case VIDIOC_INT_S_CRYSTAL_FREQ: | ||
92 | return v4l2_subdev_call(sd, video, s_crystal_freq, arg); | ||
93 | case VIDIOC_INT_DECODE_VBI_LINE: | ||
94 | return v4l2_subdev_call(sd, video, decode_vbi_line, arg); | ||
95 | case VIDIOC_INT_S_VBI_DATA: | ||
96 | return v4l2_subdev_call(sd, video, s_vbi_data, arg); | ||
97 | case VIDIOC_INT_G_VBI_DATA: | ||
98 | return v4l2_subdev_call(sd, video, g_vbi_data, arg); | ||
99 | case VIDIOC_G_SLICED_VBI_CAP: | ||
100 | return v4l2_subdev_call(sd, video, g_sliced_vbi_cap, arg); | ||
101 | case VIDIOC_ENUM_FMT: | ||
102 | return v4l2_subdev_call(sd, video, enum_fmt, arg); | ||
103 | case VIDIOC_TRY_FMT: | ||
104 | return v4l2_subdev_call(sd, video, try_fmt, arg); | ||
105 | case VIDIOC_S_FMT: | ||
106 | return v4l2_subdev_call(sd, video, s_fmt, arg); | ||
107 | case VIDIOC_G_FMT: | ||
108 | return v4l2_subdev_call(sd, video, g_fmt, arg); | ||
109 | case VIDIOC_INT_S_STD_OUTPUT: | ||
110 | return v4l2_subdev_call(sd, video, s_std_output, *(v4l2_std_id *)arg); | ||
111 | case VIDIOC_QUERYSTD: | ||
112 | return v4l2_subdev_call(sd, video, querystd, arg); | ||
113 | case VIDIOC_INT_G_INPUT_STATUS: | ||
114 | return v4l2_subdev_call(sd, video, g_input_status, arg); | ||
115 | case VIDIOC_STREAMON: | ||
116 | return v4l2_subdev_call(sd, video, s_stream, 1); | ||
117 | case VIDIOC_STREAMOFF: | ||
118 | return v4l2_subdev_call(sd, video, s_stream, 0); | ||
119 | case VIDIOC_S_PARM: | ||
120 | return v4l2_subdev_call(sd, video, s_parm, arg); | ||
121 | case VIDIOC_G_PARM: | ||
122 | return v4l2_subdev_call(sd, video, g_parm, arg); | ||
123 | |||
124 | default: | ||
125 | return v4l2_subdev_call(sd, core, ioctl, cmd, arg); | ||
126 | } | ||
127 | } | ||
128 | EXPORT_SYMBOL_GPL(v4l2_subdev_command); | ||
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index 8da4dd1e0e94..43e0998adb53 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -60,8 +60,8 @@ | |||
60 | // #define VINO_DEBUG | 60 | // #define VINO_DEBUG |
61 | // #define VINO_DEBUG_INT | 61 | // #define VINO_DEBUG_INT |
62 | 62 | ||
63 | #define VINO_MODULE_VERSION "0.0.5" | 63 | #define VINO_MODULE_VERSION "0.0.6" |
64 | #define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 5) | 64 | #define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 6) |
65 | 65 | ||
66 | MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver"); | 66 | MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver"); |
67 | MODULE_VERSION(VINO_MODULE_VERSION); | 67 | MODULE_VERSION(VINO_MODULE_VERSION); |
@@ -2565,12 +2565,11 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) | |||
2565 | int input; | 2565 | int input; |
2566 | int data_norm; | 2566 | int data_norm; |
2567 | v4l2_std_id norm; | 2567 | v4l2_std_id norm; |
2568 | struct v4l2_routing route = { 0, 0 }; | ||
2569 | 2568 | ||
2570 | input = VINO_INPUT_COMPOSITE; | 2569 | input = VINO_INPUT_COMPOSITE; |
2571 | 2570 | ||
2572 | route.input = vino_get_saa7191_input(input); | 2571 | ret = decoder_call(video, s_routing, |
2573 | ret = decoder_call(video, s_routing, &route); | 2572 | vino_get_saa7191_input(input), 0, 0); |
2574 | if (ret) { | 2573 | if (ret) { |
2575 | ret = -EINVAL; | 2574 | ret = -EINVAL; |
2576 | goto out; | 2575 | goto out; |
@@ -2589,7 +2588,7 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) | |||
2589 | } | 2588 | } |
2590 | if (data_norm == 3) | 2589 | if (data_norm == 3) |
2591 | data_norm = VINO_DATA_NORM_PAL; | 2590 | data_norm = VINO_DATA_NORM_PAL; |
2592 | ret = decoder_call(tuner, s_std, norm); | 2591 | ret = decoder_call(core, s_std, norm); |
2593 | } | 2592 | } |
2594 | 2593 | ||
2595 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | 2594 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
@@ -2656,10 +2655,9 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) | |||
2656 | if (vino_drvdata->decoder_owner == vcs->channel) { | 2655 | if (vino_drvdata->decoder_owner == vcs->channel) { |
2657 | int data_norm; | 2656 | int data_norm; |
2658 | v4l2_std_id norm; | 2657 | v4l2_std_id norm; |
2659 | struct v4l2_routing route = { 0, 0 }; | ||
2660 | 2658 | ||
2661 | route.input = vino_get_saa7191_input(input); | 2659 | ret = decoder_call(video, s_routing, |
2662 | ret = decoder_call(video, s_routing, &route); | 2660 | vino_get_saa7191_input(input), 0, 0); |
2663 | if (ret) { | 2661 | if (ret) { |
2664 | vino_drvdata->decoder_owner = VINO_NO_CHANNEL; | 2662 | vino_drvdata->decoder_owner = VINO_NO_CHANNEL; |
2665 | ret = -EINVAL; | 2663 | ret = -EINVAL; |
@@ -2679,7 +2677,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) | |||
2679 | } | 2677 | } |
2680 | if (data_norm == 3) | 2678 | if (data_norm == 3) |
2681 | data_norm = VINO_DATA_NORM_PAL; | 2679 | data_norm = VINO_DATA_NORM_PAL; |
2682 | ret = decoder_call(tuner, s_std, norm); | 2680 | ret = decoder_call(core, s_std, norm); |
2683 | } | 2681 | } |
2684 | 2682 | ||
2685 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | 2683 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
@@ -2813,7 +2811,7 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs, | |||
2813 | * as it may take a while... */ | 2811 | * as it may take a while... */ |
2814 | 2812 | ||
2815 | norm = vino_data_norms[data_norm].std; | 2813 | norm = vino_data_norms[data_norm].std; |
2816 | err = decoder_call(tuner, s_std, norm); | 2814 | err = decoder_call(core, s_std, norm); |
2817 | 2815 | ||
2818 | spin_lock_irqsave(&vino_drvdata->input_lock, *flags); | 2816 | spin_lock_irqsave(&vino_drvdata->input_lock, *flags); |
2819 | 2817 | ||
@@ -4266,7 +4264,6 @@ static int vino_init_channel_settings(struct vino_channel_settings *vcs, | |||
4266 | 4264 | ||
4267 | static int __init vino_module_init(void) | 4265 | static int __init vino_module_init(void) |
4268 | { | 4266 | { |
4269 | unsigned short addr[] = { 0, I2C_CLIENT_END }; | ||
4270 | int ret; | 4267 | int ret; |
4271 | 4268 | ||
4272 | printk(KERN_INFO "SGI VINO driver version %s\n", | 4269 | printk(KERN_INFO "SGI VINO driver version %s\n", |
@@ -4336,12 +4333,12 @@ static int __init vino_module_init(void) | |||
4336 | } | 4333 | } |
4337 | vino_init_stage++; | 4334 | vino_init_stage++; |
4338 | 4335 | ||
4339 | addr[0] = 0x45; | 4336 | vino_drvdata->decoder = |
4340 | vino_drvdata->decoder = v4l2_i2c_new_probed_subdev(&vino_i2c_adapter, | 4337 | v4l2_i2c_new_probed_subdev_addr(&vino_drvdata->v4l2_dev, |
4341 | "saa7191", "saa7191", addr); | 4338 | &vino_i2c_adapter, "saa7191", "saa7191", 0x45); |
4342 | addr[0] = 0x2b; | 4339 | vino_drvdata->camera = |
4343 | vino_drvdata->camera = v4l2_i2c_new_probed_subdev(&vino_i2c_adapter, | 4340 | v4l2_i2c_new_probed_subdev_addr(&vino_drvdata->v4l2_dev, |
4344 | "indycam", "indycam", addr); | 4341 | &vino_i2c_adapter, "indycam", "indycam", 0x2b); |
4345 | 4342 | ||
4346 | dprintk("init complete!\n"); | 4343 | dprintk("init complete!\n"); |
4347 | 4344 | ||
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c index 42e23a4fa607..38e53b303cc3 100644 --- a/drivers/media/video/vp27smpx.c +++ b/drivers/media/video/vp27smpx.c | |||
@@ -134,11 +134,11 @@ static int vp27smpx_log_status(struct v4l2_subdev *sd) | |||
134 | static const struct v4l2_subdev_core_ops vp27smpx_core_ops = { | 134 | static const struct v4l2_subdev_core_ops vp27smpx_core_ops = { |
135 | .log_status = vp27smpx_log_status, | 135 | .log_status = vp27smpx_log_status, |
136 | .g_chip_ident = vp27smpx_g_chip_ident, | 136 | .g_chip_ident = vp27smpx_g_chip_ident, |
137 | .s_std = vp27smpx_s_std, | ||
137 | }; | 138 | }; |
138 | 139 | ||
139 | static const struct v4l2_subdev_tuner_ops vp27smpx_tuner_ops = { | 140 | static const struct v4l2_subdev_tuner_ops vp27smpx_tuner_ops = { |
140 | .s_radio = vp27smpx_s_radio, | 141 | .s_radio = vp27smpx_s_radio, |
141 | .s_std = vp27smpx_s_std, | ||
142 | .s_tuner = vp27smpx_s_tuner, | 142 | .s_tuner = vp27smpx_s_tuner, |
143 | .g_tuner = vp27smpx_g_tuner, | 143 | .g_tuner = vp27smpx_g_tuner, |
144 | }; | 144 | }; |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 2fa7e8bb5746..97e0ce28ff18 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -376,33 +376,34 @@ static int vpx3220_s_std(struct v4l2_subdev *sd, v4l2_std_id std) | |||
376 | return 0; | 376 | return 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | static int vpx3220_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 379 | static int vpx3220_s_routing(struct v4l2_subdev *sd, |
380 | u32 input, u32 output, u32 config) | ||
380 | { | 381 | { |
381 | int data; | 382 | int data; |
382 | 383 | ||
383 | /* RJ: route->input = 0: ST8 (PCTV) input | 384 | /* RJ: input = 0: ST8 (PCTV) input |
384 | route->input = 1: COMPOSITE input | 385 | input = 1: COMPOSITE input |
385 | route->input = 2: SVHS input */ | 386 | input = 2: SVHS input */ |
386 | 387 | ||
387 | const int input[3][2] = { | 388 | const int input_vals[3][2] = { |
388 | {0x0c, 0}, | 389 | {0x0c, 0}, |
389 | {0x0d, 0}, | 390 | {0x0d, 0}, |
390 | {0x0e, 1} | 391 | {0x0e, 1} |
391 | }; | 392 | }; |
392 | 393 | ||
393 | if (route->input < 0 || route->input > 2) | 394 | if (input < 0 || input > 2) |
394 | return -EINVAL; | 395 | return -EINVAL; |
395 | 396 | ||
396 | v4l2_dbg(1, debug, sd, "input switched to %s\n", inputs[route->input]); | 397 | v4l2_dbg(1, debug, sd, "input switched to %s\n", inputs[input]); |
397 | 398 | ||
398 | vpx3220_write(sd, 0x33, input[route->input][0]); | 399 | vpx3220_write(sd, 0x33, input_vals[input][0]); |
399 | 400 | ||
400 | data = vpx3220_fp_read(sd, 0xf2) & ~(0x0020); | 401 | data = vpx3220_fp_read(sd, 0xf2) & ~(0x0020); |
401 | if (data < 0) | 402 | if (data < 0) |
402 | return data; | 403 | return data; |
403 | /* 0x0010 is required to latch the setting */ | 404 | /* 0x0010 is required to latch the setting */ |
404 | vpx3220_fp_write(sd, 0xf2, | 405 | vpx3220_fp_write(sd, 0xf2, |
405 | data | (input[route->input][1] << 5) | 0x0010); | 406 | data | (input_vals[input][1] << 5) | 0x0010); |
406 | 407 | ||
407 | udelay(10); | 408 | udelay(10); |
408 | return 0; | 409 | return 0; |
@@ -516,9 +517,6 @@ static const struct v4l2_subdev_core_ops vpx3220_core_ops = { | |||
516 | .g_ctrl = vpx3220_g_ctrl, | 517 | .g_ctrl = vpx3220_g_ctrl, |
517 | .s_ctrl = vpx3220_s_ctrl, | 518 | .s_ctrl = vpx3220_s_ctrl, |
518 | .queryctrl = vpx3220_queryctrl, | 519 | .queryctrl = vpx3220_queryctrl, |
519 | }; | ||
520 | |||
521 | static const struct v4l2_subdev_tuner_ops vpx3220_tuner_ops = { | ||
522 | .s_std = vpx3220_s_std, | 520 | .s_std = vpx3220_s_std, |
523 | }; | 521 | }; |
524 | 522 | ||
@@ -531,7 +529,6 @@ static const struct v4l2_subdev_video_ops vpx3220_video_ops = { | |||
531 | 529 | ||
532 | static const struct v4l2_subdev_ops vpx3220_ops = { | 530 | static const struct v4l2_subdev_ops vpx3220_ops = { |
533 | .core = &vpx3220_core_ops, | 531 | .core = &vpx3220_core_ops, |
534 | .tuner = &vpx3220_tuner_ops, | ||
535 | .video = &vpx3220_video_ops, | 532 | .video = &vpx3220_video_ops, |
536 | }; | 533 | }; |
537 | 534 | ||
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 3b08bc4af909..f59b2bd07e89 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
@@ -3440,7 +3440,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3440 | if (!cam) | 3440 | if (!cam) |
3441 | return -ENOMEM; | 3441 | return -ENOMEM; |
3442 | 3442 | ||
3443 | err = v4l2_device_register(&udev->dev, &cam->v4l2_dev); | 3443 | err = v4l2_device_register(&intf->dev, &cam->v4l2_dev); |
3444 | if (err) | 3444 | if (err) |
3445 | goto fail0; | 3445 | goto fail0; |
3446 | 3446 | ||
@@ -3523,7 +3523,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3523 | w9968cf_turn_on_led(cam); | 3523 | w9968cf_turn_on_led(cam); |
3524 | 3524 | ||
3525 | w9968cf_i2c_init(cam); | 3525 | w9968cf_i2c_init(cam); |
3526 | cam->sensor_sd = v4l2_i2c_new_probed_subdev(&cam->i2c_adapter, | 3526 | cam->sensor_sd = v4l2_i2c_new_probed_subdev(&cam->v4l2_dev, |
3527 | &cam->i2c_adapter, | ||
3527 | "ovcamchip", "ovcamchip", addrs); | 3528 | "ovcamchip", "ovcamchip", addrs); |
3528 | 3529 | ||
3529 | usb_set_intfdata(intf, cam); | 3530 | usb_set_intfdata(intf, cam); |
diff --git a/drivers/media/video/w9968cf.h b/drivers/media/video/w9968cf.h index fdfc6a4e1c8f..73ad864b4842 100644 --- a/drivers/media/video/w9968cf.h +++ b/drivers/media/video/w9968cf.h | |||
@@ -134,7 +134,7 @@ static const struct w9968cf_format w9968cf_formatlist[] = { | |||
134 | 134 | ||
135 | #define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \ | 135 | #define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \ |
136 | "Dual Mode Camera Chip" | 136 | "Dual Mode Camera Chip" |
137 | #define W9968CF_MODULE_VERSION "1:1.33-basic" | 137 | #define W9968CF_MODULE_VERSION "1:1.34-basic" |
138 | #define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia" | 138 | #define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia" |
139 | #define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" | 139 | #define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" |
140 | #define W9968CF_MODULE_LICENSE "GPL" | 140 | #define W9968CF_MODULE_LICENSE "GPL" |
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index eddf11abe1d9..f1f261a35245 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c | |||
@@ -79,7 +79,8 @@ static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val) | |||
79 | return -1; | 79 | return -1; |
80 | } | 80 | } |
81 | 81 | ||
82 | static int wm8775_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) | 82 | static int wm8775_s_routing(struct v4l2_subdev *sd, |
83 | u32 input, u32 output, u32 config) | ||
83 | { | 84 | { |
84 | struct wm8775_state *state = to_state(sd); | 85 | struct wm8775_state *state = to_state(sd); |
85 | 86 | ||
@@ -88,11 +89,11 @@ static int wm8775_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
88 | 16 combinations. | 89 | 16 combinations. |
89 | If only one input is active (the normal case) then the | 90 | If only one input is active (the normal case) then the |
90 | input values 1, 2, 4 or 8 should be used. */ | 91 | input values 1, 2, 4 or 8 should be used. */ |
91 | if (route->input > 15) { | 92 | if (input > 15) { |
92 | v4l2_err(sd, "Invalid input %d.\n", route->input); | 93 | v4l2_err(sd, "Invalid input %d.\n", input); |
93 | return -EINVAL; | 94 | return -EINVAL; |
94 | } | 95 | } |
95 | state->input = route->input; | 96 | state->input = input; |
96 | if (state->muted) | 97 | if (state->muted) |
97 | return 0; | 98 | return 0; |
98 | wm8775_write(sd, R21, 0x0c0); | 99 | wm8775_write(sd, R21, 0x0c0); |
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h index afecf32f1a87..d439c76b27e1 100644 --- a/drivers/media/video/zoran/zoran.h +++ b/drivers/media/video/zoran/zoran.h | |||
@@ -143,8 +143,8 @@ Private IOCTL to set up for displaying MJPEG | |||
143 | #ifdef __KERNEL__ | 143 | #ifdef __KERNEL__ |
144 | 144 | ||
145 | #define MAJOR_VERSION 0 /* driver major version */ | 145 | #define MAJOR_VERSION 0 /* driver major version */ |
146 | #define MINOR_VERSION 9 /* driver minor version */ | 146 | #define MINOR_VERSION 10 /* driver minor version */ |
147 | #define RELEASE_VERSION 5 /* release version */ | 147 | #define RELEASE_VERSION 0 /* release version */ |
148 | 148 | ||
149 | #define ZORAN_NAME "ZORAN" /* name of the device */ | 149 | #define ZORAN_NAME "ZORAN" /* name of the device */ |
150 | 150 | ||
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index f91bba435ed5..ea6c577b0eb3 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -1087,10 +1087,8 @@ zr36057_init (struct zoran *zr) | |||
1087 | detect_guest_activity(zr); | 1087 | detect_guest_activity(zr); |
1088 | test_interrupts(zr); | 1088 | test_interrupts(zr); |
1089 | if (!pass_through) { | 1089 | if (!pass_through) { |
1090 | struct v4l2_routing route = { 2, 0 }; | ||
1091 | |||
1092 | decoder_call(zr, video, s_stream, 0); | 1090 | decoder_call(zr, video, s_stream, 0); |
1093 | encoder_call(zr, video, s_routing, &route); | 1091 | encoder_call(zr, video, s_routing, 2, 0, 0); |
1094 | } | 1092 | } |
1095 | 1093 | ||
1096 | zr->zoran_proc = NULL; | 1094 | zr->zoran_proc = NULL; |
@@ -1360,11 +1358,13 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1360 | goto zr_free_irq; | 1358 | goto zr_free_irq; |
1361 | } | 1359 | } |
1362 | 1360 | ||
1363 | zr->decoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, | 1361 | zr->decoder = v4l2_i2c_new_probed_subdev(&zr->v4l2_dev, |
1364 | zr->card.mod_decoder, zr->card.i2c_decoder, zr->card.addrs_decoder); | 1362 | &zr->i2c_adapter, zr->card.mod_decoder, zr->card.i2c_decoder, |
1363 | zr->card.addrs_decoder); | ||
1365 | 1364 | ||
1366 | if (zr->card.mod_encoder) | 1365 | if (zr->card.mod_encoder) |
1367 | zr->encoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, | 1366 | zr->encoder = v4l2_i2c_new_probed_subdev(&zr->v4l2_dev, |
1367 | &zr->i2c_adapter, | ||
1368 | zr->card.mod_encoder, zr->card.i2c_encoder, | 1368 | zr->card.mod_encoder, zr->card.i2c_encoder, |
1369 | zr->card.addrs_encoder); | 1369 | zr->card.addrs_encoder); |
1370 | 1370 | ||
diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c index e0223deed35e..f6c2fb4fc3b4 100644 --- a/drivers/media/video/zoran/zoran_device.c +++ b/drivers/media/video/zoran/zoran_device.c | |||
@@ -971,7 +971,6 @@ zr36057_enable_jpg (struct zoran *zr, | |||
971 | struct vfe_settings cap; | 971 | struct vfe_settings cap; |
972 | int field_size = | 972 | int field_size = |
973 | zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; | 973 | zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; |
974 | struct v4l2_routing route = { 0, 0 }; | ||
975 | 974 | ||
976 | zr->codec_mode = mode; | 975 | zr->codec_mode = mode; |
977 | 976 | ||
@@ -994,8 +993,7 @@ zr36057_enable_jpg (struct zoran *zr, | |||
994 | */ | 993 | */ |
995 | set_videobus_dir(zr, 0); | 994 | set_videobus_dir(zr, 0); |
996 | decoder_call(zr, video, s_stream, 1); | 995 | decoder_call(zr, video, s_stream, 1); |
997 | route.input = 0; | 996 | encoder_call(zr, video, s_routing, 0, 0, 0); |
998 | encoder_call(zr, video, s_routing, &route); | ||
999 | 997 | ||
1000 | /* Take the JPEG codec and the VFE out of sleep */ | 998 | /* Take the JPEG codec and the VFE out of sleep */ |
1001 | jpeg_codec_sleep(zr, 0); | 999 | jpeg_codec_sleep(zr, 0); |
@@ -1043,8 +1041,7 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1043 | */ | 1041 | */ |
1044 | decoder_call(zr, video, s_stream, 0); | 1042 | decoder_call(zr, video, s_stream, 0); |
1045 | set_videobus_dir(zr, 1); | 1043 | set_videobus_dir(zr, 1); |
1046 | route.input = 1; | 1044 | encoder_call(zr, video, s_routing, 1, 0, 0); |
1047 | encoder_call(zr, video, s_routing, &route); | ||
1048 | 1045 | ||
1049 | /* Take the JPEG codec and the VFE out of sleep */ | 1046 | /* Take the JPEG codec and the VFE out of sleep */ |
1050 | jpeg_codec_sleep(zr, 0); | 1047 | jpeg_codec_sleep(zr, 0); |
@@ -1089,8 +1086,7 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1089 | zr36057_adjust_vfe(zr, mode); | 1086 | zr36057_adjust_vfe(zr, mode); |
1090 | 1087 | ||
1091 | decoder_call(zr, video, s_stream, 1); | 1088 | decoder_call(zr, video, s_stream, 1); |
1092 | route.input = 0; | 1089 | encoder_call(zr, video, s_routing, 0, 0, 0); |
1093 | encoder_call(zr, video, s_routing, &route); | ||
1094 | 1090 | ||
1095 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); | 1091 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); |
1096 | break; | 1092 | break; |
@@ -1571,8 +1567,6 @@ zoran_set_pci_master (struct zoran *zr, | |||
1571 | void | 1567 | void |
1572 | zoran_init_hardware (struct zoran *zr) | 1568 | zoran_init_hardware (struct zoran *zr) |
1573 | { | 1569 | { |
1574 | struct v4l2_routing route = { 0, 0 }; | ||
1575 | |||
1576 | /* Enable bus-mastering */ | 1570 | /* Enable bus-mastering */ |
1577 | zoran_set_pci_master(zr, 1); | 1571 | zoran_set_pci_master(zr, 1); |
1578 | 1572 | ||
@@ -1581,16 +1575,14 @@ zoran_init_hardware (struct zoran *zr) | |||
1581 | zr->card.init(zr); | 1575 | zr->card.init(zr); |
1582 | } | 1576 | } |
1583 | 1577 | ||
1584 | route.input = zr->card.input[zr->input].muxsel; | ||
1585 | |||
1586 | decoder_call(zr, core, init, 0); | 1578 | decoder_call(zr, core, init, 0); |
1587 | decoder_call(zr, tuner, s_std, zr->norm); | 1579 | decoder_call(zr, core, s_std, zr->norm); |
1588 | decoder_call(zr, video, s_routing, &route); | 1580 | decoder_call(zr, video, s_routing, |
1581 | zr->card.input[zr->input].muxsel, 0, 0); | ||
1589 | 1582 | ||
1590 | encoder_call(zr, core, init, 0); | 1583 | encoder_call(zr, core, init, 0); |
1591 | encoder_call(zr, video, s_std_output, zr->norm); | 1584 | encoder_call(zr, video, s_std_output, zr->norm); |
1592 | route.input = 0; | 1585 | encoder_call(zr, video, s_routing, 0, 0, 0); |
1593 | encoder_call(zr, video, s_routing, &route); | ||
1594 | 1586 | ||
1595 | /* toggle JPEG codec sleep to sync PLL */ | 1587 | /* toggle JPEG codec sleep to sync PLL */ |
1596 | jpeg_codec_sleep(zr, 1); | 1588 | jpeg_codec_sleep(zr, 1); |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index f16e57cf11e4..092333b1c34f 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -1018,10 +1018,8 @@ zoran_close(struct file *file) | |||
1018 | zoran_set_pci_master(zr, 0); | 1018 | zoran_set_pci_master(zr, 0); |
1019 | 1019 | ||
1020 | if (!pass_through) { /* Switch to color bar */ | 1020 | if (!pass_through) { /* Switch to color bar */ |
1021 | struct v4l2_routing route = { 2, 0 }; | ||
1022 | |||
1023 | decoder_call(zr, video, s_stream, 0); | 1021 | decoder_call(zr, video, s_stream, 0); |
1024 | encoder_call(zr, video, s_routing, &route); | 1022 | encoder_call(zr, video, s_routing, 2, 0, 0); |
1025 | } | 1023 | } |
1026 | } | 1024 | } |
1027 | 1025 | ||
@@ -1449,7 +1447,7 @@ zoran_set_norm (struct zoran *zr, | |||
1449 | v4l2_std_id std = 0; | 1447 | v4l2_std_id std = 0; |
1450 | 1448 | ||
1451 | decoder_call(zr, video, querystd, &std); | 1449 | decoder_call(zr, video, querystd, &std); |
1452 | decoder_call(zr, tuner, s_std, std); | 1450 | decoder_call(zr, core, s_std, std); |
1453 | 1451 | ||
1454 | /* let changes come into effect */ | 1452 | /* let changes come into effect */ |
1455 | ssleep(2); | 1453 | ssleep(2); |
@@ -1461,7 +1459,7 @@ zoran_set_norm (struct zoran *zr, | |||
1461 | "%s: %s - no norm detected\n", | 1459 | "%s: %s - no norm detected\n", |
1462 | ZR_DEVNAME(zr), __func__); | 1460 | ZR_DEVNAME(zr), __func__); |
1463 | /* reset norm */ | 1461 | /* reset norm */ |
1464 | decoder_call(zr, tuner, s_std, zr->norm); | 1462 | decoder_call(zr, core, s_std, zr->norm); |
1465 | return -EIO; | 1463 | return -EIO; |
1466 | } | 1464 | } |
1467 | 1465 | ||
@@ -1480,7 +1478,7 @@ zoran_set_norm (struct zoran *zr, | |||
1480 | if (on) | 1478 | if (on) |
1481 | zr36057_overlay(zr, 0); | 1479 | zr36057_overlay(zr, 0); |
1482 | 1480 | ||
1483 | decoder_call(zr, tuner, s_std, norm); | 1481 | decoder_call(zr, core, s_std, norm); |
1484 | encoder_call(zr, video, s_std_output, norm); | 1482 | encoder_call(zr, video, s_std_output, norm); |
1485 | 1483 | ||
1486 | if (on) | 1484 | if (on) |
@@ -1496,8 +1494,6 @@ static int | |||
1496 | zoran_set_input (struct zoran *zr, | 1494 | zoran_set_input (struct zoran *zr, |
1497 | int input) | 1495 | int input) |
1498 | { | 1496 | { |
1499 | struct v4l2_routing route = { 0, 0 }; | ||
1500 | |||
1501 | if (input == zr->input) { | 1497 | if (input == zr->input) { |
1502 | return 0; | 1498 | return 0; |
1503 | } | 1499 | } |
@@ -1519,10 +1515,10 @@ zoran_set_input (struct zoran *zr, | |||
1519 | return -EINVAL; | 1515 | return -EINVAL; |
1520 | } | 1516 | } |
1521 | 1517 | ||
1522 | route.input = zr->card.input[input].muxsel; | ||
1523 | zr->input = input; | 1518 | zr->input = input; |
1524 | 1519 | ||
1525 | decoder_call(zr, video, s_routing, &route); | 1520 | decoder_call(zr, video, s_routing, |
1521 | zr->card.input[input].muxsel, 0, 0); | ||
1526 | 1522 | ||
1527 | return 0; | 1523 | return 0; |
1528 | } | 1524 | } |
@@ -1748,7 +1744,6 @@ jpgreqbuf_unlock_and_return: | |||
1748 | case BUZIOC_G_STATUS: | 1744 | case BUZIOC_G_STATUS: |
1749 | { | 1745 | { |
1750 | struct zoran_status *bstat = arg; | 1746 | struct zoran_status *bstat = arg; |
1751 | struct v4l2_routing route = { 0, 0 }; | ||
1752 | int status = 0, res = 0; | 1747 | int status = 0, res = 0; |
1753 | v4l2_std_id norm; | 1748 | v4l2_std_id norm; |
1754 | 1749 | ||
@@ -1762,8 +1757,6 @@ jpgreqbuf_unlock_and_return: | |||
1762 | return -EINVAL; | 1757 | return -EINVAL; |
1763 | } | 1758 | } |
1764 | 1759 | ||
1765 | route.input = zr->card.input[bstat->input].muxsel; | ||
1766 | |||
1767 | mutex_lock(&zr->resource_lock); | 1760 | mutex_lock(&zr->resource_lock); |
1768 | 1761 | ||
1769 | if (zr->codec_mode != BUZ_MODE_IDLE) { | 1762 | if (zr->codec_mode != BUZ_MODE_IDLE) { |
@@ -1775,7 +1768,8 @@ jpgreqbuf_unlock_and_return: | |||
1775 | goto gstat_unlock_and_return; | 1768 | goto gstat_unlock_and_return; |
1776 | } | 1769 | } |
1777 | 1770 | ||
1778 | decoder_call(zr, video, s_routing, &route); | 1771 | decoder_call(zr, video, s_routing, |
1772 | zr->card.input[bstat->input].muxsel, 0, 0); | ||
1779 | 1773 | ||
1780 | /* sleep 1 second */ | 1774 | /* sleep 1 second */ |
1781 | ssleep(1); | 1775 | ssleep(1); |
@@ -1785,8 +1779,8 @@ jpgreqbuf_unlock_and_return: | |||
1785 | decoder_call(zr, video, g_input_status, &status); | 1779 | decoder_call(zr, video, g_input_status, &status); |
1786 | 1780 | ||
1787 | /* restore previous input and norm */ | 1781 | /* restore previous input and norm */ |
1788 | route.input = zr->card.input[zr->input].muxsel; | 1782 | decoder_call(zr, video, s_routing, |
1789 | decoder_call(zr, video, s_routing, &route); | 1783 | zr->card.input[zr->input].muxsel, 0, 0); |
1790 | gstat_unlock_and_return: | 1784 | gstat_unlock_and_return: |
1791 | mutex_unlock(&zr->resource_lock); | 1785 | mutex_unlock(&zr->resource_lock); |
1792 | 1786 | ||
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index 221409fe1682..ac169c9eb18d 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include <linux/version.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/usb.h> | 31 | #include <linux/usb.h> |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index ee9fbc172405..c9087de5c6c6 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -51,6 +51,7 @@ | |||
51 | #define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */ | 51 | #define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */ |
52 | #define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ | 52 | #define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ |
53 | #define I2C_HW_B_AU0828 0x010023 /* auvitek au0828 usb bridge */ | 53 | #define I2C_HW_B_AU0828 0x010023 /* auvitek au0828 usb bridge */ |
54 | #define I2C_HW_B_CX231XX 0x010024 /* Conexant CX231XX USB based cards */ | ||
54 | #define I2C_HW_B_HDPVR 0x010025 /* Hauppauge HD PVR */ | 55 | #define I2C_HW_B_HDPVR 0x010025 /* Hauppauge HD PVR */ |
55 | 56 | ||
56 | /* --- SGI adapters */ | 57 | /* --- SGI adapters */ |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 139d234923cd..ebb2ea6b4995 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -737,6 +737,11 @@ struct v4l2_input { | |||
737 | #define V4L2_IN_ST_NO_SIGNAL 0x00000002 | 737 | #define V4L2_IN_ST_NO_SIGNAL 0x00000002 |
738 | #define V4L2_IN_ST_NO_COLOR 0x00000004 | 738 | #define V4L2_IN_ST_NO_COLOR 0x00000004 |
739 | 739 | ||
740 | /* field 'status' - sensor orientation */ | ||
741 | /* If sensor is mounted upside down set both bits */ | ||
742 | #define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */ | ||
743 | #define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */ | ||
744 | |||
740 | /* field 'status' - analog */ | 745 | /* field 'status' - analog */ |
741 | #define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ | 746 | #define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */ |
742 | #define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ | 747 | #define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */ |
diff --git a/include/media/msp3400.h b/include/media/msp3400.h index 6ab854931c05..90cf22ada8b4 100644 --- a/include/media/msp3400.h +++ b/include/media/msp3400.h | |||
@@ -54,13 +54,13 @@ | |||
54 | ======= | 54 | ======= |
55 | 55 | ||
56 | So to specify a complete routing scheme for the msp3400 you will have to | 56 | So to specify a complete routing scheme for the msp3400 you will have to |
57 | specify in the 'input' field of the v4l2_routing struct: | 57 | specify in the 'input' arg of the s_routing function: |
58 | 58 | ||
59 | 1) which tuner input to use | 59 | 1) which tuner input to use |
60 | 2) which SCART input to use | 60 | 2) which SCART input to use |
61 | 3) which DSP input to use for each DSP output | 61 | 3) which DSP input to use for each DSP output |
62 | 62 | ||
63 | And in the 'output' field of the v4l2_routing struct you specify: | 63 | And in the 'output' arg of the s_routing function you specify: |
64 | 64 | ||
65 | 1) which SCART input to use for each SCART output | 65 | 1) which SCART input to use for each SCART output |
66 | 66 | ||
diff --git a/include/media/ov772x.h b/include/media/ov772x.h index 57db48dd85b8..30d9629198ef 100644 --- a/include/media/ov772x.h +++ b/include/media/ov772x.h | |||
@@ -17,10 +17,45 @@ | |||
17 | #define OV772X_FLAG_VFLIP 0x00000001 /* Vertical flip image */ | 17 | #define OV772X_FLAG_VFLIP 0x00000001 /* Vertical flip image */ |
18 | #define OV772X_FLAG_HFLIP 0x00000002 /* Horizontal flip image */ | 18 | #define OV772X_FLAG_HFLIP 0x00000002 /* Horizontal flip image */ |
19 | 19 | ||
20 | /* | ||
21 | * for Edge ctrl | ||
22 | * | ||
23 | * strength also control Auto or Manual Edge Control Mode | ||
24 | * see also OV772X_MANUAL_EDGE_CTRL | ||
25 | */ | ||
26 | struct ov772x_edge_ctrl { | ||
27 | unsigned char strength; | ||
28 | unsigned char threshold; | ||
29 | unsigned char upper; | ||
30 | unsigned char lower; | ||
31 | }; | ||
32 | |||
33 | #define OV772X_MANUAL_EDGE_CTRL 0x80 /* un-used bit of strength */ | ||
34 | #define EDGE_STRENGTH_MASK 0x1F | ||
35 | #define EDGE_THRESHOLD_MASK 0x0F | ||
36 | #define EDGE_UPPER_MASK 0xFF | ||
37 | #define EDGE_LOWER_MASK 0xFF | ||
38 | |||
39 | #define OV772X_AUTO_EDGECTRL(u, l) \ | ||
40 | { \ | ||
41 | .upper = (u & EDGE_UPPER_MASK), \ | ||
42 | .lower = (l & EDGE_LOWER_MASK), \ | ||
43 | } | ||
44 | |||
45 | #define OV772X_MANUAL_EDGECTRL(s, t) \ | ||
46 | { \ | ||
47 | .strength = (s & EDGE_STRENGTH_MASK) | OV772X_MANUAL_EDGE_CTRL,\ | ||
48 | .threshold = (t & EDGE_THRESHOLD_MASK), \ | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * ov772x camera info | ||
53 | */ | ||
20 | struct ov772x_camera_info { | 54 | struct ov772x_camera_info { |
21 | unsigned long buswidth; | 55 | unsigned long buswidth; |
22 | unsigned long flags; | 56 | unsigned long flags; |
23 | struct soc_camera_link link; | 57 | struct soc_camera_link link; |
58 | struct ov772x_edge_ctrl edgectrl; | ||
24 | }; | 59 | }; |
25 | 60 | ||
26 | #endif /* __OV772X_H__ */ | 61 | #endif /* __OV772X_H__ */ |
diff --git a/include/media/saa7146.h b/include/media/saa7146.h index fff4235adae5..7a9f76ecbbbd 100644 --- a/include/media/saa7146.h +++ b/include/media/saa7146.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/vmalloc.h> /* for vmalloc() */ | 18 | #include <linux/vmalloc.h> /* for vmalloc() */ |
19 | #include <linux/mm.h> /* for vmalloc_to_page() */ | 19 | #include <linux/mm.h> /* for vmalloc_to_page() */ |
20 | 20 | ||
21 | #define SAA7146_VERSION_CODE 0x000500 /* 0.5.0 */ | 21 | #define SAA7146_VERSION_CODE 0x000600 /* 0.6.0 */ |
22 | 22 | ||
23 | #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) | 23 | #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) |
24 | #define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) | 24 | #define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) |
diff --git a/include/media/tvaudio.h b/include/media/tvaudio.h index 6915aafc875a..1ac8184693f8 100644 --- a/include/media/tvaudio.h +++ b/include/media/tvaudio.h | |||
@@ -21,10 +21,29 @@ | |||
21 | #ifndef _TVAUDIO_H | 21 | #ifndef _TVAUDIO_H |
22 | #define _TVAUDIO_H | 22 | #define _TVAUDIO_H |
23 | 23 | ||
24 | #include <media/i2c-addr.h> | ||
25 | |||
24 | /* The tvaudio module accepts the following inputs: */ | 26 | /* The tvaudio module accepts the following inputs: */ |
25 | #define TVAUDIO_INPUT_TUNER 0 | 27 | #define TVAUDIO_INPUT_TUNER 0 |
26 | #define TVAUDIO_INPUT_RADIO 1 | 28 | #define TVAUDIO_INPUT_RADIO 1 |
27 | #define TVAUDIO_INPUT_EXTERN 2 | 29 | #define TVAUDIO_INPUT_EXTERN 2 |
28 | #define TVAUDIO_INPUT_INTERN 3 | 30 | #define TVAUDIO_INPUT_INTERN 3 |
29 | 31 | ||
32 | static inline const unsigned short *tvaudio_addrs(void) | ||
33 | { | ||
34 | static const unsigned short addrs[] = { | ||
35 | I2C_ADDR_TDA8425 >> 1, | ||
36 | I2C_ADDR_TEA6300 >> 1, | ||
37 | I2C_ADDR_TEA6420 >> 1, | ||
38 | I2C_ADDR_TDA9840 >> 1, | ||
39 | I2C_ADDR_TDA985x_L >> 1, | ||
40 | I2C_ADDR_TDA985x_H >> 1, | ||
41 | I2C_ADDR_TDA9874 >> 1, | ||
42 | I2C_ADDR_PIC16C54 >> 1, | ||
43 | I2C_CLIENT_END | ||
44 | }; | ||
45 | |||
46 | return addrs; | ||
47 | } | ||
48 | |||
30 | #endif | 49 | #endif |
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 3a6905615d68..c48c24e4d0fa 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h | |||
@@ -125,7 +125,7 @@ int v4l2_chip_match_host(const struct v4l2_dbg_match *match); | |||
125 | 125 | ||
126 | /* ------------------------------------------------------------------------- */ | 126 | /* ------------------------------------------------------------------------- */ |
127 | 127 | ||
128 | /* Helper function for I2C legacy drivers */ | 128 | /* I2C Helper functions */ |
129 | 129 | ||
130 | struct i2c_driver; | 130 | struct i2c_driver; |
131 | struct i2c_adapter; | 131 | struct i2c_adapter; |
@@ -135,21 +135,24 @@ struct v4l2_device; | |||
135 | struct v4l2_subdev; | 135 | struct v4l2_subdev; |
136 | struct v4l2_subdev_ops; | 136 | struct v4l2_subdev_ops; |
137 | 137 | ||
138 | int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, | ||
139 | const char *name, | ||
140 | int (*probe)(struct i2c_client *, const struct i2c_device_id *)); | ||
141 | 138 | ||
142 | /* Load an i2c module and return an initialized v4l2_subdev struct. | 139 | /* Load an i2c module and return an initialized v4l2_subdev struct. |
143 | Only call request_module if module_name != NULL. | 140 | Only call request_module if module_name != NULL. |
144 | The client_type argument is the name of the chip that's on the adapter. */ | 141 | The client_type argument is the name of the chip that's on the adapter. */ |
145 | struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, | 142 | struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, |
143 | struct i2c_adapter *adapter, | ||
146 | const char *module_name, const char *client_type, u8 addr); | 144 | const char *module_name, const char *client_type, u8 addr); |
147 | /* Probe and load an i2c module and return an initialized v4l2_subdev struct. | 145 | /* Probe and load an i2c module and return an initialized v4l2_subdev struct. |
148 | Only call request_module if module_name != NULL. | 146 | Only call request_module if module_name != NULL. |
149 | The client_type argument is the name of the chip that's on the adapter. */ | 147 | The client_type argument is the name of the chip that's on the adapter. */ |
150 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter, | 148 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, |
149 | struct i2c_adapter *adapter, | ||
151 | const char *module_name, const char *client_type, | 150 | const char *module_name, const char *client_type, |
152 | const unsigned short *addrs); | 151 | const unsigned short *addrs); |
152 | /* Like v4l2_i2c_new_probed_subdev, except probe for a single address. */ | ||
153 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev, | ||
154 | struct i2c_adapter *adapter, | ||
155 | const char *module_name, const char *client_type, u8 addr); | ||
153 | /* Initialize an v4l2_subdev with data from an i2c_client struct */ | 156 | /* Initialize an v4l2_subdev with data from an i2c_client struct */ |
154 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, | 157 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
155 | const struct v4l2_subdev_ops *ops); | 158 | const struct v4l2_subdev_ops *ops); |
@@ -171,139 +174,23 @@ const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); | |||
171 | 174 | ||
172 | /* ------------------------------------------------------------------------- */ | 175 | /* ------------------------------------------------------------------------- */ |
173 | 176 | ||
174 | /* Internal ioctls */ | 177 | /* Note: these remaining ioctls/structs should be removed as well, but they are |
175 | 178 | still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and | |
176 | /* VIDIOC_INT_DECODE_VBI_LINE */ | 179 | v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup |
177 | struct v4l2_decode_vbi_line { | 180 | is needed in those modules. */ |
178 | u32 is_second_field; /* Set to 0 for the first (odd) field, | ||
179 | set to 1 for the second (even) field. */ | ||
180 | u8 *p; /* Pointer to the sliced VBI data from the decoder. | ||
181 | On exit points to the start of the payload. */ | ||
182 | u32 line; /* Line number of the sliced VBI data (1-23) */ | ||
183 | u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */ | ||
184 | }; | ||
185 | 181 | ||
182 | /* s_config */ | ||
186 | struct v4l2_priv_tun_config { | 183 | struct v4l2_priv_tun_config { |
187 | int tuner; | 184 | int tuner; |
188 | void *priv; | 185 | void *priv; |
189 | }; | 186 | }; |
190 | |||
191 | /* audio ioctls */ | ||
192 | |||
193 | /* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */ | ||
194 | #define AUDC_SET_RADIO _IO('d',88) | ||
195 | |||
196 | /* tuner ioctls */ | ||
197 | |||
198 | /* Sets tuner type and its I2C addr */ | ||
199 | #define TUNER_SET_TYPE_ADDR _IOW('d', 90, int) | ||
200 | |||
201 | /* Puts tuner on powersaving state, disabling it, except for i2c. To be replaced | ||
202 | by VIDIOC_INT_S_STANDBY. */ | ||
203 | #define TUNER_SET_STANDBY _IOW('d', 91, int) | ||
204 | |||
205 | /* Sets tda9887 specific stuff, like port1, port2 and qss */ | ||
206 | #define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) | 187 | #define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) |
207 | 188 | ||
208 | /* Switch the tuner to a specific tuner mode. Replacement of AUDC_SET_RADIO */ | ||
209 | #define VIDIOC_INT_S_TUNER_MODE _IOW('d', 93, enum v4l2_tuner_type) | ||
210 | |||
211 | /* Generic standby command. Passing -1 (all bits set to 1) will put the whole | ||
212 | chip into standby mode, value 0 will make the chip fully active. Specific | ||
213 | bits can be used by certain chips to enable/disable specific subsystems. | ||
214 | Replacement of TUNER_SET_STANDBY. */ | ||
215 | #define VIDIOC_INT_S_STANDBY _IOW('d', 94, u32) | ||
216 | |||
217 | /* 100, 101 used by VIDIOC_DBG_[SG]_REGISTER */ | ||
218 | |||
219 | /* Generic reset command. The argument selects which subsystems to reset. | ||
220 | Passing 0 will always reset the whole chip. */ | ||
221 | #define VIDIOC_INT_RESET _IOW ('d', 102, u32) | 189 | #define VIDIOC_INT_RESET _IOW ('d', 102, u32) |
222 | 190 | ||
223 | /* Set the frequency (in Hz) of the audio clock output. | ||
224 | Used to slave an audio processor to the video decoder, ensuring that audio | ||
225 | and video remain synchronized. | ||
226 | Usual values for the frequency are 48000, 44100 or 32000 Hz. | ||
227 | If the frequency is not supported, then -EINVAL is returned. */ | ||
228 | #define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOW ('d', 103, u32) | ||
229 | |||
230 | /* Video decoders that support sliced VBI need to implement this ioctl. | ||
231 | Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI | ||
232 | data that was generated by the decoder. The driver then parses the sliced | ||
233 | VBI data and sets the other fields in the struct accordingly. The pointer p | ||
234 | is updated to point to the start of the payload which can be copied | ||
235 | verbatim into the data field of the v4l2_sliced_vbi_data struct. If no | ||
236 | valid VBI data was found, then the type field is set to 0 on return. */ | ||
237 | #define VIDIOC_INT_DECODE_VBI_LINE _IOWR('d', 104, struct v4l2_decode_vbi_line) | ||
238 | |||
239 | /* Used to generate VBI signals on a video signal. v4l2_sliced_vbi_data is | ||
240 | filled with the data packets that should be output. Note that if you set | ||
241 | the line field to 0, then that VBI signal is disabled. If no | ||
242 | valid VBI data was found, then the type field is set to 0 on return. */ | ||
243 | #define VIDIOC_INT_S_VBI_DATA _IOW ('d', 105, struct v4l2_sliced_vbi_data) | ||
244 | |||
245 | /* Used to obtain the sliced VBI packet from a readback register. Not all | ||
246 | video decoders support this. If no data is available because the readback | ||
247 | register contains invalid or erroneous data -EIO is returned. Note that | ||
248 | you must fill in the 'id' member and the 'field' member (to determine | ||
249 | whether CC data from the first or second field should be obtained). */ | ||
250 | #define VIDIOC_INT_G_VBI_DATA _IOWR('d', 106, struct v4l2_sliced_vbi_data) | ||
251 | |||
252 | /* Sets I2S speed in bps. This is used to provide a standard way to select I2S | ||
253 | clock used by driving digital audio streams at some board designs. | ||
254 | Usual values for the frequency are 1024000 and 2048000. | ||
255 | If the frequency is not supported, then -EINVAL is returned. */ | ||
256 | #define VIDIOC_INT_I2S_CLOCK_FREQ _IOW ('d', 108, u32) | ||
257 | |||
258 | /* Routing definition, device dependent. It specifies which inputs (if any) | ||
259 | should be routed to which outputs (if any). */ | ||
260 | struct v4l2_routing { | 191 | struct v4l2_routing { |
261 | u32 input; | 192 | u32 input; |
262 | u32 output; | 193 | u32 output; |
263 | }; | 194 | }; |
264 | 195 | ||
265 | /* These internal commands should be used to define the inputs and outputs | ||
266 | of an audio/video chip. They will replace the v4l2 API commands | ||
267 | VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT, VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT | ||
268 | that are meant to be used by the user. | ||
269 | The internal commands should be used to switch inputs/outputs | ||
270 | because only the driver knows how to map a 'Television' input to the precise | ||
271 | input/output routing of an A/D converter, or a DSP, or a video digitizer. | ||
272 | These four commands should only be sent directly to an i2c device, they | ||
273 | should not be broadcast as the routing is very device specific. */ | ||
274 | #define VIDIOC_INT_S_AUDIO_ROUTING _IOW ('d', 109, struct v4l2_routing) | ||
275 | #define VIDIOC_INT_G_AUDIO_ROUTING _IOR ('d', 110, struct v4l2_routing) | ||
276 | #define VIDIOC_INT_S_VIDEO_ROUTING _IOW ('d', 111, struct v4l2_routing) | ||
277 | #define VIDIOC_INT_G_VIDEO_ROUTING _IOR ('d', 112, struct v4l2_routing) | ||
278 | |||
279 | struct v4l2_crystal_freq { | ||
280 | u32 freq; /* frequency in Hz of the crystal */ | ||
281 | u32 flags; /* device specific flags */ | ||
282 | }; | ||
283 | |||
284 | /* Sets the frequency of the crystal used to generate the clocks. | ||
285 | An extra flags field allows device specific configuration regarding | ||
286 | clock frequency dividers, etc. If not used, then set flags to 0. | ||
287 | If the frequency is not supported, then -EINVAL is returned. */ | ||
288 | #define VIDIOC_INT_S_CRYSTAL_FREQ _IOW('d', 113, struct v4l2_crystal_freq) | ||
289 | |||
290 | /* Initialize the sensor registors to some sort of reasonable | ||
291 | default values. */ | ||
292 | #define VIDIOC_INT_INIT _IOW('d', 114, u32) | ||
293 | |||
294 | /* Set v4l2_std_id for video OUTPUT devices. This is ignored by | ||
295 | video input devices. */ | ||
296 | #define VIDIOC_INT_S_STD_OUTPUT _IOW('d', 115, v4l2_std_id) | ||
297 | |||
298 | /* Get v4l2_std_id for video OUTPUT devices. This is ignored by | ||
299 | video input devices. */ | ||
300 | #define VIDIOC_INT_G_STD_OUTPUT _IOW('d', 116, v4l2_std_id) | ||
301 | |||
302 | /* Set GPIO pins. Very simple right now, might need to be extended with | ||
303 | a v4l2_gpio struct if a direction is also needed. */ | ||
304 | #define VIDIOC_INT_S_GPIO _IOW('d', 117, u32) | ||
305 | |||
306 | /* Get input status. Same as the status field in the v4l2_input struct. */ | ||
307 | #define VIDIOC_INT_G_INPUT_STATUS _IOR('d', 118, u32) | ||
308 | |||
309 | #endif /* V4L2_COMMON_H_ */ | 196 | #endif /* V4L2_COMMON_H_ */ |
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h deleted file mode 100644 index e65dd9d84e8b..000000000000 --- a/include/media/v4l2-i2c-drv-legacy.h +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /* | ||
2 | * v4l2-i2c-drv-legacy.h - contains I2C handling code that's identical | ||
3 | * for all V4L2 I2C drivers. Use this header if the | ||
4 | * I2C driver is used by both legacy drivers and | ||
5 | * drivers converted to the bus-based I2C API. | ||
6 | * | ||
7 | * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | */ | ||
23 | |||
24 | /* NOTE: the full version of this header is in the v4l-dvb repository | ||
25 | * and allows v4l i2c drivers to be compiled on older kernels as well. | ||
26 | * The version of this header as it appears in the kernel is a stripped | ||
27 | * version (without all the backwards compatibility stuff) and so it | ||
28 | * looks a bit odd. | ||
29 | * | ||
30 | * If you look at the full version then you will understand the reason | ||
31 | * for introducing this header since you really don't want to have all | ||
32 | * the tricky backwards compatibility code in each and every i2c driver. | ||
33 | */ | ||
34 | |||
35 | struct v4l2_i2c_driver_data { | ||
36 | const char * const name; | ||
37 | int driverid; | ||
38 | int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); | ||
39 | int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); | ||
40 | int (*remove)(struct i2c_client *client); | ||
41 | int (*suspend)(struct i2c_client *client, pm_message_t state); | ||
42 | int (*resume)(struct i2c_client *client); | ||
43 | int (*legacy_probe)(struct i2c_adapter *adapter); | ||
44 | int legacy_class; | ||
45 | const struct i2c_device_id *id_table; | ||
46 | }; | ||
47 | |||
48 | static struct v4l2_i2c_driver_data v4l2_i2c_data; | ||
49 | static const struct i2c_client_address_data addr_data; | ||
50 | static struct i2c_driver v4l2_i2c_driver_legacy; | ||
51 | static char v4l2_i2c_drv_name_legacy[32]; | ||
52 | |||
53 | static int v4l2_i2c_drv_attach_legacy(struct i2c_adapter *adapter, int address, int kind) | ||
54 | { | ||
55 | return v4l2_i2c_attach(adapter, address, &v4l2_i2c_driver_legacy, | ||
56 | v4l2_i2c_drv_name_legacy, v4l2_i2c_data.probe); | ||
57 | } | ||
58 | |||
59 | static int v4l2_i2c_drv_probe_legacy(struct i2c_adapter *adapter) | ||
60 | { | ||
61 | if (v4l2_i2c_data.legacy_probe) { | ||
62 | if (v4l2_i2c_data.legacy_probe(adapter)) | ||
63 | return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy); | ||
64 | return 0; | ||
65 | } | ||
66 | if (adapter->class & v4l2_i2c_data.legacy_class) | ||
67 | return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy); | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static int v4l2_i2c_drv_detach_legacy(struct i2c_client *client) | ||
72 | { | ||
73 | int err; | ||
74 | |||
75 | if (v4l2_i2c_data.remove) | ||
76 | v4l2_i2c_data.remove(client); | ||
77 | |||
78 | err = i2c_detach_client(client); | ||
79 | if (err) | ||
80 | return err; | ||
81 | kfree(client); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int v4l2_i2c_drv_suspend_helper(struct i2c_client *client, pm_message_t state) | ||
86 | { | ||
87 | return v4l2_i2c_data.suspend ? v4l2_i2c_data.suspend(client, state) : 0; | ||
88 | } | ||
89 | |||
90 | static int v4l2_i2c_drv_resume_helper(struct i2c_client *client) | ||
91 | { | ||
92 | return v4l2_i2c_data.resume ? v4l2_i2c_data.resume(client) : 0; | ||
93 | } | ||
94 | |||
95 | /* ----------------------------------------------------------------------- */ | ||
96 | |||
97 | /* i2c implementation */ | ||
98 | static struct i2c_driver v4l2_i2c_driver_legacy = { | ||
99 | .driver = { | ||
100 | .owner = THIS_MODULE, | ||
101 | }, | ||
102 | .attach_adapter = v4l2_i2c_drv_probe_legacy, | ||
103 | .detach_client = v4l2_i2c_drv_detach_legacy, | ||
104 | .suspend = v4l2_i2c_drv_suspend_helper, | ||
105 | .resume = v4l2_i2c_drv_resume_helper, | ||
106 | }; | ||
107 | |||
108 | /* ----------------------------------------------------------------------- */ | ||
109 | |||
110 | /* i2c implementation */ | ||
111 | static struct i2c_driver v4l2_i2c_driver = { | ||
112 | .suspend = v4l2_i2c_drv_suspend_helper, | ||
113 | .resume = v4l2_i2c_drv_resume_helper, | ||
114 | }; | ||
115 | |||
116 | static int __init v4l2_i2c_drv_init(void) | ||
117 | { | ||
118 | int err; | ||
119 | |||
120 | strlcpy(v4l2_i2c_drv_name_legacy, v4l2_i2c_data.name, sizeof(v4l2_i2c_drv_name_legacy)); | ||
121 | strlcat(v4l2_i2c_drv_name_legacy, "'", sizeof(v4l2_i2c_drv_name_legacy)); | ||
122 | |||
123 | if (v4l2_i2c_data.legacy_class == 0) | ||
124 | v4l2_i2c_data.legacy_class = I2C_CLASS_TV_ANALOG; | ||
125 | |||
126 | v4l2_i2c_driver_legacy.driver.name = v4l2_i2c_drv_name_legacy; | ||
127 | v4l2_i2c_driver_legacy.id = v4l2_i2c_data.driverid; | ||
128 | v4l2_i2c_driver_legacy.command = v4l2_i2c_data.command; | ||
129 | err = i2c_add_driver(&v4l2_i2c_driver_legacy); | ||
130 | |||
131 | if (err) | ||
132 | return err; | ||
133 | v4l2_i2c_driver.driver.name = v4l2_i2c_data.name; | ||
134 | v4l2_i2c_driver.id = v4l2_i2c_data.driverid; | ||
135 | v4l2_i2c_driver.command = v4l2_i2c_data.command; | ||
136 | v4l2_i2c_driver.probe = v4l2_i2c_data.probe; | ||
137 | v4l2_i2c_driver.remove = v4l2_i2c_data.remove; | ||
138 | v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table; | ||
139 | err = i2c_add_driver(&v4l2_i2c_driver); | ||
140 | if (err) | ||
141 | i2c_del_driver(&v4l2_i2c_driver_legacy); | ||
142 | return err; | ||
143 | } | ||
144 | |||
145 | static void __exit v4l2_i2c_drv_cleanup(void) | ||
146 | { | ||
147 | i2c_del_driver(&v4l2_i2c_driver_legacy); | ||
148 | i2c_del_driver(&v4l2_i2c_driver); | ||
149 | } | ||
150 | |||
151 | module_init(v4l2_i2c_drv_init); | ||
152 | module_exit(v4l2_i2c_drv_cleanup); | ||
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h index efdc8bf27f87..10a2882c3cbf 100644 --- a/include/media/v4l2-i2c-drv.h +++ b/include/media/v4l2-i2c-drv.h | |||
@@ -39,14 +39,11 @@ | |||
39 | 39 | ||
40 | struct v4l2_i2c_driver_data { | 40 | struct v4l2_i2c_driver_data { |
41 | const char * const name; | 41 | const char * const name; |
42 | int driverid; | ||
43 | int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); | 42 | int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); |
44 | int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); | 43 | int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); |
45 | int (*remove)(struct i2c_client *client); | 44 | int (*remove)(struct i2c_client *client); |
46 | int (*suspend)(struct i2c_client *client, pm_message_t state); | 45 | int (*suspend)(struct i2c_client *client, pm_message_t state); |
47 | int (*resume)(struct i2c_client *client); | 46 | int (*resume)(struct i2c_client *client); |
48 | int (*legacy_probe)(struct i2c_adapter *adapter); | ||
49 | int legacy_class; | ||
50 | const struct i2c_device_id *id_table; | 47 | const struct i2c_device_id *id_table; |
51 | }; | 48 | }; |
52 | 49 | ||
@@ -54,12 +51,11 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data; | |||
54 | static struct i2c_driver v4l2_i2c_driver; | 51 | static struct i2c_driver v4l2_i2c_driver; |
55 | 52 | ||
56 | 53 | ||
57 | /* Bus-based I2C implementation for kernels >= 2.6.22 */ | 54 | /* Bus-based I2C implementation for kernels >= 2.6.26 */ |
58 | 55 | ||
59 | static int __init v4l2_i2c_drv_init(void) | 56 | static int __init v4l2_i2c_drv_init(void) |
60 | { | 57 | { |
61 | v4l2_i2c_driver.driver.name = v4l2_i2c_data.name; | 58 | v4l2_i2c_driver.driver.name = v4l2_i2c_data.name; |
62 | v4l2_i2c_driver.id = v4l2_i2c_data.driverid; | ||
63 | v4l2_i2c_driver.command = v4l2_i2c_data.command; | 59 | v4l2_i2c_driver.command = v4l2_i2c_data.command; |
64 | v4l2_i2c_driver.probe = v4l2_i2c_data.probe; | 60 | v4l2_i2c_driver.probe = v4l2_i2c_data.probe; |
65 | v4l2_i2c_driver.remove = v4l2_i2c_data.remove; | 61 | v4l2_i2c_driver.remove = v4l2_i2c_data.remove; |
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 1d181b4ccb01..17856081c809 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
@@ -27,6 +27,16 @@ struct v4l2_device; | |||
27 | struct v4l2_subdev; | 27 | struct v4l2_subdev; |
28 | struct tuner_setup; | 28 | struct tuner_setup; |
29 | 29 | ||
30 | /* decode_vbi_line */ | ||
31 | struct v4l2_decode_vbi_line { | ||
32 | u32 is_second_field; /* Set to 0 for the first (odd) field, | ||
33 | set to 1 for the second (even) field. */ | ||
34 | u8 *p; /* Pointer to the sliced VBI data from the decoder. | ||
35 | On exit points to the start of the payload. */ | ||
36 | u32 line; /* Line number of the sliced VBI data (1-23) */ | ||
37 | u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */ | ||
38 | }; | ||
39 | |||
30 | /* Sub-devices are devices that are connected somehow to the main bridge | 40 | /* Sub-devices are devices that are connected somehow to the main bridge |
31 | device. These devices are usually audio/video muxers/encoders/decoders or | 41 | device. These devices are usually audio/video muxers/encoders/decoders or |
32 | sensors and webcam controllers. | 42 | sensors and webcam controllers. |
@@ -68,11 +78,26 @@ struct tuner_setup; | |||
68 | the use-case it might be better to use subdev-specific ops (currently | 78 | the use-case it might be better to use subdev-specific ops (currently |
69 | not yet implemented) since ops provide proper type-checking. | 79 | not yet implemented) since ops provide proper type-checking. |
70 | */ | 80 | */ |
81 | |||
82 | /* init: initialize the sensor registors to some sort of reasonable default | ||
83 | values. Do not use for new drivers and should be removed in existing | ||
84 | drivers. | ||
85 | |||
86 | load_fw: load firmware. | ||
87 | |||
88 | reset: generic reset command. The argument selects which subsystems to | ||
89 | reset. Passing 0 will always reset the whole chip. Do not use for new | ||
90 | drivers without discussing this first on the linux-media mailinglist. | ||
91 | There should be no reason normally to reset a device. | ||
92 | |||
93 | s_gpio: set GPIO pins. Very simple right now, might need to be extended with | ||
94 | a direction argument if needed. | ||
95 | */ | ||
71 | struct v4l2_subdev_core_ops { | 96 | struct v4l2_subdev_core_ops { |
72 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); | 97 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); |
73 | int (*log_status)(struct v4l2_subdev *sd); | 98 | int (*log_status)(struct v4l2_subdev *sd); |
74 | int (*init)(struct v4l2_subdev *sd, u32 val); | 99 | int (*init)(struct v4l2_subdev *sd, u32 val); |
75 | int (*s_standby)(struct v4l2_subdev *sd, u32 standby); | 100 | int (*load_fw)(struct v4l2_subdev *sd); |
76 | int (*reset)(struct v4l2_subdev *sd, u32 val); | 101 | int (*reset)(struct v4l2_subdev *sd, u32 val); |
77 | int (*s_gpio)(struct v4l2_subdev *sd, u32 val); | 102 | int (*s_gpio)(struct v4l2_subdev *sd, u32 val); |
78 | int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc); | 103 | int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc); |
@@ -82,6 +107,7 @@ struct v4l2_subdev_core_ops { | |||
82 | int (*s_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); | 107 | int (*s_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); |
83 | int (*try_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); | 108 | int (*try_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); |
84 | int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); | 109 | int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); |
110 | int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm); | ||
85 | long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); | 111 | long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); |
86 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 112 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
87 | int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); | 113 | int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); |
@@ -89,6 +115,16 @@ struct v4l2_subdev_core_ops { | |||
89 | #endif | 115 | #endif |
90 | }; | 116 | }; |
91 | 117 | ||
118 | /* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. | ||
119 | |||
120 | s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. | ||
121 | |||
122 | s_type_addr: sets tuner type and its I2C addr. | ||
123 | |||
124 | s_config: sets tda9887 specific stuff, like port1, port2 and qss | ||
125 | |||
126 | s_standby: puts tuner on powersaving state, disabling it, except for i2c. | ||
127 | */ | ||
92 | struct v4l2_subdev_tuner_ops { | 128 | struct v4l2_subdev_tuner_ops { |
93 | int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); | 129 | int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); |
94 | int (*s_radio)(struct v4l2_subdev *sd); | 130 | int (*s_radio)(struct v4l2_subdev *sd); |
@@ -96,20 +132,77 @@ struct v4l2_subdev_tuner_ops { | |||
96 | int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); | 132 | int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); |
97 | int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); | 133 | int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); |
98 | int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); | 134 | int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); |
99 | int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm); | ||
100 | int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type); | 135 | int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type); |
101 | int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); | 136 | int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); |
137 | int (*s_standby)(struct v4l2_subdev *sd); | ||
102 | }; | 138 | }; |
103 | 139 | ||
140 | /* s_clock_freq: set the frequency (in Hz) of the audio clock output. | ||
141 | Used to slave an audio processor to the video decoder, ensuring that | ||
142 | audio and video remain synchronized. Usual values for the frequency | ||
143 | are 48000, 44100 or 32000 Hz. If the frequency is not supported, then | ||
144 | -EINVAL is returned. | ||
145 | |||
146 | s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard | ||
147 | way to select I2S clock used by driving digital audio streams at some | ||
148 | board designs. Usual values for the frequency are 1024000 and 2048000. | ||
149 | If the frequency is not supported, then -EINVAL is returned. | ||
150 | |||
151 | s_routing: used to define the input and/or output pins of an audio chip, | ||
152 | and any additional configuration data. | ||
153 | Never attempt to use user-level input IDs (e.g. Composite, S-Video, | ||
154 | Tuner) at this level. An i2c device shouldn't know about whether an | ||
155 | input pin is connected to a Composite connector, become on another | ||
156 | board or platform it might be connected to something else entirely. | ||
157 | The calling driver is responsible for mapping a user-level input to | ||
158 | the right pins on the i2c device. | ||
159 | */ | ||
104 | struct v4l2_subdev_audio_ops { | 160 | struct v4l2_subdev_audio_ops { |
105 | int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq); | 161 | int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq); |
106 | int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq); | 162 | int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq); |
107 | int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); | 163 | int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); |
108 | }; | 164 | }; |
109 | 165 | ||
166 | /* | ||
167 | decode_vbi_line: video decoders that support sliced VBI need to implement | ||
168 | this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the | ||
169 | start of the VBI data that was generated by the decoder. The driver | ||
170 | then parses the sliced VBI data and sets the other fields in the | ||
171 | struct accordingly. The pointer p is updated to point to the start of | ||
172 | the payload which can be copied verbatim into the data field of the | ||
173 | v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the | ||
174 | type field is set to 0 on return. | ||
175 | |||
176 | s_vbi_data: used to generate VBI signals on a video signal. | ||
177 | v4l2_sliced_vbi_data is filled with the data packets that should be | ||
178 | output. Note that if you set the line field to 0, then that VBI signal | ||
179 | is disabled. If no valid VBI data was found, then the type field is | ||
180 | set to 0 on return. | ||
181 | |||
182 | g_vbi_data: used to obtain the sliced VBI packet from a readback register. | ||
183 | Not all video decoders support this. If no data is available because | ||
184 | the readback register contains invalid or erroneous data -EIO is | ||
185 | returned. Note that you must fill in the 'id' member and the 'field' | ||
186 | member (to determine whether CC data from the first or second field | ||
187 | should be obtained). | ||
188 | |||
189 | s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by | ||
190 | video input devices. | ||
191 | |||
192 | s_crystal_freq: sets the frequency of the crystal used to generate the | ||
193 | clocks in Hz. An extra flags field allows device specific configuration | ||
194 | regarding clock frequency dividers, etc. If not used, then set flags | ||
195 | to 0. If the frequency is not supported, then -EINVAL is returned. | ||
196 | |||
197 | g_input_status: get input status. Same as the status field in the v4l2_input | ||
198 | struct. | ||
199 | |||
200 | s_routing: see s_routing in audio_ops, except this version is for video | ||
201 | devices. | ||
202 | */ | ||
110 | struct v4l2_subdev_video_ops { | 203 | struct v4l2_subdev_video_ops { |
111 | int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); | 204 | int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); |
112 | int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq); | 205 | int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags); |
113 | int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line); | 206 | int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line); |
114 | int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data); | 207 | int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data); |
115 | int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data); | 208 | int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data); |
@@ -163,18 +256,6 @@ static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd) | |||
163 | return sd->priv; | 256 | return sd->priv; |
164 | } | 257 | } |
165 | 258 | ||
166 | /* Convert an ioctl-type command to the proper v4l2_subdev_ops function call. | ||
167 | This is used by subdev modules that can be called by both old-style ioctl | ||
168 | commands and through the v4l2_subdev_ops. | ||
169 | |||
170 | The ioctl API of the subdev driver can call this function to call the | ||
171 | right ops based on the ioctl cmd and arg. | ||
172 | |||
173 | Once all subdev drivers have been converted and all drivers no longer | ||
174 | use the ioctl interface, then this function can be removed. | ||
175 | */ | ||
176 | int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg); | ||
177 | |||
178 | static inline void v4l2_subdev_init(struct v4l2_subdev *sd, | 259 | static inline void v4l2_subdev_init(struct v4l2_subdev *sd, |
179 | const struct v4l2_subdev_ops *ops) | 260 | const struct v4l2_subdev_ops *ops) |
180 | { | 261 | { |