bt878: radio frequency stuck

2013-02-09 Thread Emile Joubert

Hi,

I have the same symptoms as the ones described here:
http://article.gmane.org/gmane.linux.kernel/1214773

I have the same model card (37284) which also stopped working at commit
cbde689823776d187ba1b307a171625dbc02dd4f. Since that commit the radio
produces white noise and changing the frequency has no effect on the
sound. I've tried kernel 3.8.0-rc7 and the problem still exists in that
version.

Please let me know if there is further information I can provide towards
a solution, or if there are any patches I could try.



-Emile




--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 02/10] s5p-fimc: Add device tree support for FIMC devices

2013-02-09 Thread Sylwester Nawrocki

On 02/09/2013 11:29 PM, Sylwester Nawrocki wrote:



After all, what happens in some later SoC where you have two different
types of module that feed into the common module, such that type A
sources have IDs 0..3 in the common module, and type B sources have IDs
4..7 in the common module - you wouldn't want to require alias ISs 4..7
for the type B DT nodes.


I forgot to add, any ID remapping could happen in the common module, if
it requires it. Type A and type B sources could have indexes 0...3 and
the common module could derive its configuration from the source ID *and*
the source type. The idea behind aliases was to identify each instance,
rather than providing an exact configuration data that the common module
could use.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 02/10] s5p-fimc: Add device tree support for FIMC devices

2013-02-09 Thread Sylwester Nawrocki

On 02/09/2013 01:32 AM, Stephen Warren wrote:

On 02/08/2013 05:05 PM, Sylwester Nawrocki wrote:

On 02/09/2013 12:21 AM, Stephen Warren wrote:

On 02/08/2013 04:16 PM, Sylwester Nawrocki wrote:

On 02/07/2013 12:40 AM, Stephen Warren wrote:

diff --git
a/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt
b/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt



+Samsung S5P/EXYNOS SoC Camera Subsystem (FIMC)
+--

...

+For every fimc node a numbered alias should be present in the
aliases node.
+Aliases are of the form fimc, whereis an integer (0...N)
specifying
+the IP's instance index.


Why? Isn't it up to the DT author whether they care if each fimc
node is
assigned a specific identification v.s. whether identification is
assigned automatically?


There are at least three different kinds of IPs that come in multiple
instances in an SoC. To activate data links between them each instance
needs to be clearly identified. There are also differences between
instances of same device. Hence it's important these aliases don't have
random values.

Some more details about the SoC can be found at [1]. The aliases are
also already used in the Exynos5 GScaler bindings [2] in a similar way.


Hmmm. I'd expect explicit DT properties to represent the
instance-specific "configuration", or even different compatible values.
Relying on the alias ID seems rather indirect; what if in e.g.
Exynos6/... the mapping from instance/alias ID to feature set changes.
With explicit DT properties, that'd just be a .dts change, whereas by
requiring alias IDs now, you'd need a driver change to support this.


In the initial version of this patch series I used cell-index property,
but then Grant pointed out in some other mail thread it should be
avoided. Hence I used the node aliases.


To me, using cell-index is semantically equivalent to using the alias ID.


I can't see significant difference either. I just switched to what
seemed to be used for similar purpose.


Different compatible values might not work, when for example there
are 3 IPs out of 4 of one type and the fourth one of another type.
It wouldn't even by really different types, just quirks/little
differences between them, e.g. no data path routed to one of other IPs.


I was thinking of using feature-/quirk-oriented properties. For example,
if there's a port on 3 of the 4 devices to connect to some other IP
block, simply include a boolean property to indicate whether that port
is present. It would be in 3 of the nodes but not the 4th.


Yes, I could add several properties corresponding to all members of this
[3] data structure. But still it is needed to clearly identify the IP
block in a set of the hardware instances.


Then to connect e.g. MIPI-CSIS.0 to FIMC.2 at run time an index of the
MIPI-CSIS needs to be written to the FIMC.2 data input control register.
Even though MIPI-CSIS.N are same in terms of hardware structure they still
need to be distinguished as separate instances.


Oh, so you're using the alias ID as the value to write into the FIMC.2
register for that. I'm not 100% familiar with aliases, but they seem
like a more user-oriented naming thing to me, whereas values for hooking
up intra-SoC routing are an unrelated namespace semantically, even if
the values happen to line up right now. Perhaps rather than a Boolean
property I mentioned above, use a custom property to indicate the ID
that the FIMC.2 object knows the MIPI-CSIS.0 object as? While this seems


That could be 'reg' property in the MIPI-CSIS.0 'port' subnode that
links it to the image sensor node ([4], line 165). Because MIPI-CSIS IP
blocks are immutably connected to the SoC camera physical MIPI CSI-2
interfaces, and the physical camera ports have fixed assignment to the
MIPI-CSIS devices..  This way we could drop alias ID for the MIPI-CSIS
nodes. And their instance index that is required for the top level
driver which exposes topology and the routing capabilities to user space
could be restored from the reg property value by subtracting a fixed
offset.

Similarly an instance index of FIMC-LITE could be derived from the value
of reg property in a port node that links it to FIMC-IS ISP. I have been
omitting these port/endpoint nodes because it seemed unnecessary to model
explicitly those data paths. However it feels a bit overkill to add them
just for the sake of identifying the IP block instance

Still I can't really see a possibility to drop indexes for the FIMC nodes.


similar to using cell-index, my *guess* is that Grant's objection to
using cell-index was more based on re-using cell-index for something
other than its intended purpose than pushing you to use an alias ID
rather than a property.


The comments to a patch for some other driver I was referring to can be
found at [1]. My first patch series appeared significantly later [2].
I confused things a bit, sorry about that.

I can see aliases used in bindings of multiple device

cron job: media_tree daily build: ERRORS

2013-02-09 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Sat Feb  9 19:00:26 CET 2013
git branch: for_v3.9
git hash:   4880f56438ef56457edd5548b257382761591998
gcc version:i686-linux-gcc (GCC) 4.7.2
host hardware:  x86_64
host os:3.8.03-marune

linux-git-arm-davinci: WARNINGS
linux-git-arm-exynos: ERRORS
linux-git-arm-omap: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-rc4-i686: OK
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-rc4-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: Add 0x3009 USB PID to ttusb2 driver (fixed diff)

2013-02-09 Thread Christoph Nuscheler
Sorry about the mess in my last message; this time diff output should be 
formatted correctly.


The "Technisat SkyStar USB plus" is a TT-connect S-2400 clone, which the 
V4L-DVB drivers already support. However, some of these devices (like 
mine) come with a different USB PID 0x3009 instead of 0x3006.


There have already been patches simply overwriting the USB PID in 
dvb-usb-ids.h. Of course these patches were rejected because they would 
have disabled the 0x3006 PID.


This new patch adds the 0x3009 PID to dvb-usb-ids.h, and adds references 
to it within the ttusb2.c driver. PID 0x3006 devices will continue to work.


The only difference between the two hardware models seems to be the 
EEPROM chip. In fact, Windows BDA driver names the 0x3009 device with a 
"(8 kB EEPROM)" suffix. In spite of that, the 0x3009 device works 
absolutely flawlessly using the existing ttusb2 driver.


Signed-off-by: Christoph Nuscheler 

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h

index 7e1597d..399e104 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -242,6 +242,7 @@
 #define USB_PID_AVERMEDIA_A867 0xa867
 #define USB_PID_AVERMEDIA_TWINSTAR 0x0825
 #define USB_PID_TECHNOTREND_CONNECT_S2400   0x3006
+#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c 
b/drivers/media/usb/dvb-usb/ttusb2.c

index bcdac22..07d4994 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -619,6 +619,8 @@ static struct usb_device_id ttusb2_table [] = {
{ USB_DEVICE(USB_VID_TECHNOTREND,
USB_PID_TECHNOTREND_CONNECT_S2400) },
{ USB_DEVICE(USB_VID_TECHNOTREND,
+   USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) },
+   { USB_DEVICE(USB_VID_TECHNOTREND,
USB_PID_TECHNOTREND_CONNECT_CT3650) },
{}  /* Terminating entry */
 };
@@ -721,12 +723,16 @@ static struct dvb_usb_device_properties 
ttusb2_properties_s2400 = {


.generic_bulk_ctrl_endpoint = 0x01,

-   .num_device_descs = 1,
+   .num_device_descs = 2,
.devices = {
{   "Technotrend TT-connect S-2400",
{ &ttusb2_table[2], NULL },
{ NULL },
},
+   {   "Technotrend TT-connect S-2400 (8kB EEPROM)",
+   {&ttusb2_table[3], NULL },
+   { NULL },
+   },
}
 };

@@ -800,7 +806,7 @@ static struct dvb_usb_device_properties 
ttusb2_properties_ct3650 = {

.num_device_descs = 1,
.devices = {
{   "Technotrend TT-connect CT-3650",
-   .warm_ids = { &ttusb2_table[3], NULL },
+   .warm_ids = { &ttusb2_table[4], NULL },
},
}
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: Add 0x3009 USB PID to ttusb2 driver

2013-02-09 Thread Christoph Nuscheler
The "Technisat SkyStar USB plus" is a TT-connect S-2400 clone, which the 
V4L-DVB drivers already support. However, some of these devices (like 
mine) come with a different USB PID 0x3009 instead of 0x3006.


There have already been patches simply overwriting the USB PID in 
dvb-usb-ids.h. Of course these patches were rejected because they would 
have disabled the 0x3006 PID.


This new patch adds the 0x3009 PID to dvb-usb-ids.h, and adds references 
to it within the ttusb2.c driver. PID 0x3006 devices will continue to work.


The only difference between the two hardware models seems to be the 
EEPROM chip. In fact, Windows BDA driver names the 0x3009 device with a 
"(8 kB EEPROM)" suffix. In spite of that, the 0x3009 device works 
absolutely flawlessly using the existing ttusb2 driver.


Signed-off-by: Christoph Nuscheler 

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h

index 7e1597d..399e104 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -242,6 +242,7 @@
 #define USB_PID_AVERMEDIA_A867 0xa867
 #define USB_PID_AVERMEDIA_TWINSTAR 0x0825
 #define USB_PID_TECHNOTREND_CONNECT_S2400   0x3006
+#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c 
b/drivers/media/usb/dvb-usb/ttusb2.c

index bcdac22..07d4994 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -619,6 +619,8 @@ static struct usb_device_id ttusb2_table [] = {
{ USB_DEVICE(USB_VID_TECHNOTREND,
USB_PID_TECHNOTREND_CONNECT_S2400) },
{ USB_DEVICE(USB_VID_TECHNOTREND,
+   USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) },
+   { USB_DEVICE(USB_VID_TECHNOTREND,
USB_PID_TECHNOTREND_CONNECT_CT3650) },
{}  /* Terminating entry */
 };
@@ -721,12 +723,16 @@ static struct dvb_usb_device_properties 
ttusb2_properties_s2400 = {

.generic_bulk_ctrl_endpoint = 0x01,
 -  .num_device_descs = 1,
+   .num_device_descs = 2,
.devices = {
{   "Technotrend TT-connect S-2400",
{ &ttusb2_table[2], NULL },
{ NULL },
},
+   {   "Technotrend TT-connect S-2400 (8kB EEPROM)",
+   {&ttusb2_table[3], NULL },
+   { NULL },
+   },
}
 };
 @@ -800,7 +806,7 @@ static struct dvb_usb_device_properties 
ttusb2_properties_ct3650 = {

.num_device_descs = 1,
.devices = {
{   "Technotrend TT-connect CT-3650",
-   .warm_ids = { &ttusb2_table[3], NULL },
+   .warm_ids = { &ttusb2_table[4], NULL },
},
}
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [oselas] Audio support on Mini6410 board

2013-02-09 Thread Tomasz Figa
Hi,

On Saturday 09 of February 2013 19:21:32 Sylwester Nawrocki wrote:
> Hi,
> 
> On 01/20/2013 09:46 PM, Alexander Nestorov wrote:
> > I have been playing for a week with the board. Both audio and video
> > work correctly, but I haven't
> > been able to set the mic settings in alsamixer (so I can't test the
> > mic). The touchscreen isn't working, so I'll try to make it working
> > and send you some patches.
> > 
> > Anyways, now there's another question/problem that I have. Video
> > playback is really slow because
> > I'm not using the device's cpu-decoder but rather doing everything in
> > software mode.
> > 
> > Is there support for hardware acceleration in the kernel for this
> > device? Also, after talking with
> 
> No, there is still no video codec (MFC) driver for s3c6410 upstream.
> Now, when there is support for the hardware video codec available in
> newer SoC (Exynos4/5) and some V4L2 infrastructure added together with
> the s5p-mfc driver, it should be much easier to write a driver for the
> s3c64xx MFC. Still it is relatively huge task and I didn't see any
> volunteers willing to add support upstream for the s3c64xx MFC, except
> Andrey who replied in this thread. I could provide some help, but
> I will likely won't find time to do any development work or testing.
> 
> Also please note there is no support for the mem-to-mem features (color
> space conversion, scaling, rotation/flip) in the s3c-camif driver.
> It should be relatively simple to add it though. I'm not really sure
> if it is needed to run the codec on s3c64xx, but the plugin [1] uses
> FIMC (CAMIF) as a video post-processor. This plugin sets up processing
> pipeline like:
> 
> memory (compressed data) -> MFC -> (YCbCr tiled) memory -> FIMC ->
> memory (display)

AFAIK the MFC (like rest of the media processing peripherals) on S3C6410 
does not support tiled buffers. It uses the standard planar Y + Cb + Cr 
format.

In addition, the MFC of S3C6410 supports built-in rotation and mirroring 
of decoded video.

For scaling, there is a video post-processor block. There is no upstreamed 
driver for it, but the hardware is reasonably simple, so it wouldn't be 
too hard to write a driver for it. (I might be able to do it, although 
don't count on me, as I have also much other work to do, part of which is 
also related to S3C64xx).

Best regards,
Tomasz

> > some people from #gstreamer they pointed me to a component[1] in
> > gstreamer, but I'm not really
> > sure how to I use it. Any ideas/experience with that?
> 
> This component uses multi-planar V4L2 API [2], which also use the
> s5p-mfc and s5p-fimc driver. The s3c-camif driver uses the
> single-planar API at the camera capture video node. So if this existing
> plugin was to be used with the s3c64xx hardware, the drivers for it
> would have to support the multi-planar API, which I believe is not
> needed on s3c64xx hardware.
> The best is probably to make the drivers only single-plane API aware
> and adapt the plugin. The required changes at the plugin wouldn't be
> significant.
> 
> Anyway, a real problem here is lack of the s3c64xx MFC driver. So
> first we need the codec driver, which could be tested with modified
> test application [3], or directly with modified plugin [1].
> 
> > Regards!
> > 
> > [1] http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/mfc
> 
> [2] http://linuxtv.org/downloads/v4l-dvb-apis/planar-apis.html
> [3]
> http://git.infradead.org/users/kmpark/public-apps/tree/9c057b001e8873861
> a70f7025214003837a0860b
> 
> --
> 
> Regards,
> Sylwester
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-samsung-soc" in the body of a message to
> majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [oselas] Audio support on Mini6410 board

2013-02-09 Thread Sylwester Nawrocki

Cc: LMML

On 02/09/2013 07:21 PM, Sylwester Nawrocki wrote:

Hi,

On 01/20/2013 09:46 PM, Alexander Nestorov wrote:

I have been playing for a week with the board. Both audio and video
work correctly, but I haven't
been able to set the mic settings in alsamixer (so I can't test the mic).
The touchscreen isn't working, so I'll try to make it working and send
you some patches.

Anyways, now there's another question/problem that I have. Video
playback is really slow because
I'm not using the device's cpu-decoder but rather doing everything in
software mode.

Is there support for hardware acceleration in the kernel for this
device? Also, after talking with


No, there is still no video codec (MFC) driver for s3c6410 upstream.
Now, when there is support for the hardware video codec available in
newer SoC (Exynos4/5) and some V4L2 infrastructure added together with
the s5p-mfc driver, it should be much easier to write a driver for the
s3c64xx MFC. Still it is relatively huge task and I didn't see any
volunteers willing to add support upstream for the s3c64xx MFC, except
Andrey who replied in this thread. I could provide some help, but
I will likely won't find time to do any development work or testing.

Also please note there is no support for the mem-to-mem features (color
space conversion, scaling, rotation/flip) in the s3c-camif driver.
It should be relatively simple to add it though. I'm not really sure
if it is needed to run the codec on s3c64xx, but the plugin [1] uses
FIMC (CAMIF) as a video post-processor. This plugin sets up processing
pipeline like:

memory (compressed data) -> MFC -> (YCbCr tiled) memory -> FIMC ->
memory (display)


some people from #gstreamer they pointed me to a component[1] in
gstreamer, but I'm not really
sure how to I use it. Any ideas/experience with that?


This component uses multi-planar V4L2 API [2], which also use the s5p-mfc
and s5p-fimc driver. The s3c-camif driver uses the single-planar API
at the camera capture video node. So if this existing plugin was to be
used with the s3c64xx hardware, the drivers for it would have to
support the multi-planar API, which I believe is not needed on s3c64xx
hardware.
The best is probably to make the drivers only single-plane API aware
and adapt the plugin. The required changes at the plugin wouldn't be
significant.

Anyway, a real problem here is lack of the s3c64xx MFC driver. So
first we need the codec driver, which could be tested with modified
test application [3], or directly with modified plugin [1].


Regards!

[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/mfc


[2] http://linuxtv.org/downloads/v4l-dvb-apis/planar-apis.html
[3]
http://git.infradead.org/users/kmpark/public-apps/tree/9c057b001e8873861a70f7025214003837a0860b


--

Regards,
Sylwester

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] media: rc: gpio-ir-recv: add support for device tree parsing

2013-02-09 Thread Sylwester Nawrocki

On 02/09/2013 01:45 AM, Sebastian Hesselbarth wrote:

new file mode 100644
index 000..8589f30
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
@@ -0,0 +1,16 @@
+Device-Tree bindings for GPIO IR receiver
+
+Required properties:
+ - compatible = "gpio-ir-receiver";
+ - gpios: OF device-tree gpio specification.
+
+Optional properties:
+ - linux,rc-map-name: Linux specific remote control map name.
+
+Example node:
+
+ ir: ir-receiver {
+ compatible = "gpio-ir-receiver";
+ gpios =<&gpio0 19 1>;
+ linux,rc-map-name = "rc-rc6-mce";


Please change this to:
linux,rc-map-name = RC_MAP_RC6_MCE;

(as defined at include/media/rc-map.h).


Mauro,

this is not possible in device tree bindings. Device tree properties
can only carry numeric or string types (and some other stuff) but no
OS specific enumerations. So using strings is the only option here.


The idea of having those strings defined at the same header file is to:


Unfortunately, device tree blobs don't know about linux header files.


I suppose this will change when it will be possible to run C pre-processor
on *.dts files. This is still under discussion though [1] and for the
device tree there will likely be separate copies of the header files
needed. Thus I guess explicit string names for now need to be used.

[1] http://www.spinics.net/lists/kernel/msg1458360.html

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media_build: add PTR_RET to compat.h

2013-02-09 Thread Hans Verkuil
On Sat February 9 2013 15:04:40 Gianluca Gennari wrote:
> PTR_RET is used by the solo6x10 staging driver,
> and was introduced in kernel 2.6.39.
> Add it to compat.h for compatibility with older kernels.

Applied, thanks!

Regards,

Hans

> 
> Signed-off-by: Gianluca Gennari 
> ---
>  v4l/compat.h  | 10 ++
>  v4l/scripts/make_config_compat.pl |  1 +
>  2 files changed, 11 insertions(+)
> 
> diff --git a/v4l/compat.h b/v4l/compat.h
> index 1a82bb7..b27b178 100644
> --- a/v4l/compat.h
> +++ b/v4l/compat.h
> @@ -1137,4 +1137,14 @@ static inline int usb_translate_errors(int error_code)
>  }
>  #endif
>  
> +#ifdef NEED_PTR_RET
> +static inline int __must_check PTR_RET(const void *ptr)
> +{
> + if (IS_ERR(ptr))
> + return PTR_ERR(ptr);
> + else
> + return 0;
> +}
> +#endif
> +
>  #endif /*  _COMPAT_H */
> diff --git a/v4l/scripts/make_config_compat.pl 
> b/v4l/scripts/make_config_compat.pl
> index 583ef9d..51a1f5d 100644
> --- a/v4l/scripts/make_config_compat.pl
> +++ b/v4l/scripts/make_config_compat.pl
> @@ -588,6 +588,7 @@ sub check_other_dependencies()
>   check_files_for_func("config_enabled", "NEED_IS_ENABLED", 
> "include/linux/kconfig.h");
>   check_files_for_func("DEFINE_PCI_DEVICE_TABLE", 
> "NEED_DEFINE_PCI_DEVICE_TABLE", "include/linux/pci.h");
>   check_files_for_func("usb_translate_errors", 
> "NEED_USB_TRANSLATE_ERRORS", "include/linux/usb.h");
> + check_files_for_func("PTR_RET", "NEED_PTR_RET", "include/linux/err.h");
>  
>   # For tests for uapi-dependent logic
>   check_files_for_func_uapi("usb_endpoint_maxp", 
> "NEED_USB_ENDPOINT_MAXP", "usb/ch9.h");
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: af9035 test needed!

2013-02-09 Thread Gianluca Gennari
Il 31/01/2013 19:52, Antti Palosaari ha scritto:
> Jose, Gianluca,
> 
> On 01/31/2013 08:40 PM, Andre Heider wrote:
>> Hey,
>>
>> On Thu, Jan 31, 2013 at 2:59 PM, Antti Palosaari  wrote:
 On Fri, Jan 11, 2013 at 7:38 PM, Antti Palosaari  wrote:
>
> Could you test that (tda18218 & mxl5007t):
>>
>> only now I see you mentioned mxl5007t too, and with the same tree as I
>> used for my 'TerraTec Cinergy T Stick Dual RC (rev. 2)', a 'AVerMedia
>> HD Volar (A867)' with a mxl5007t (and an unkown rev) works too:
>>
>> usb 3-3.1.4: new high-speed USB device number 7 using xhci_hcd
>> usb 3-3.1.4: New USB device found, idVendor=07ca, idProduct=1867
>> usb 3-3.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>> usb 3-3.1.4: Product: A867
>> usb 3-3.1.4: Manufacturer: AVerMedia TECHNOLOGIES, Inc
>> usb 3-3.1.4: SerialNumber: 0305770200261
>> usb 3-3.1.4: af9035_identify_state: prechip_version=00 chip_version=03
>> chip_type=3802
> 
> Who one as able to test with non-working AF9035 + MxL5007T combination.
> Does it report different chip versions? Same firmware used?

Hi Antti,
I finally found a friend with the Avermedia A867 (AF9035 + MxL5007T) non
working revision (A867-DP7):
http://forum.ubuntu-it.org/viewtopic.php?f=9&t=516182&start=60#p4301226

Apparently, there is no difference in the log file about the chip version:

[   90.047319] usb 1-1.3: New USB device found, idVendor=07ca,
idProduct=a867
[   90.047325] usb 1-1.3: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[   90.047330] usb 1-1.3: Product: A867
[   90.047334] usb 1-1.3: Manufacturer: AVerMedia TECHNOLOGIES, Inc
[   90.047337] usb 1-1.3: SerialNumber: 5037944035440
[   90.142796] usbcore: registered new interface driver dvb_usb_af9035
[   90.143779] usb 1-1.3: af9035_identify_state: prechip_version=00
chip_version=03 chip_type=3802
[   90.144178] usb 1-1.3: dvb_usb_v2: found a 'AVerMedia HD Volar
(A867)' in cold state
[   90.170437] usb 1-1.3: dvb_usb_v2: downloading firmware from file
'dvb-usb-af9035-02.fw'
[   90.495461] usb 1-1.3: dvb_usb_af9035: firmware version=12.13.15.0
[   90.495483] usb 1-1.3: dvb_usb_v2: found a 'AVerMedia HD Volar
(A867)' in warm state
[   90.498004] usb 1-1.3: dvb_usb_v2: will pass the complete MPEG2
transport stream to the software demuxer
[   90.498046] DVB: registering new adapter (AVerMedia HD Volar (A867))
[   90.498401] DVB: register adapter0/demux0 @ minor: 0 (0x00)
[   90.498476] DVB: register adapter0/dvr0 @ minor: 1 (0x01)
[   90.498543] DVB: register adapter0/net0 @ minor: 2 (0x02)
[   90.549788] i2c i2c-8: af9033: firmware version: LINK=12.13.15.0
OFDM=6.20.15.0
[   90.549798] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Afatech
AF9033 (DVB-T))...
[   90.549903] DVB: register adapter0/frontend0 @ minor: 3 (0x03)
[   90.913945] mxl5007t 8-0060: creating new instance
[   90.929824] Registered IR keymap rc-empty
[   90.929937] input: AVerMedia HD Volar (A867) as
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0/input13
[   90.930019] rc0: AVerMedia HD Volar (A867) as
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0
[   90.930027] usb 1-1.3: dvb_usb_v2: schedule remote query interval to
500 msecs
[   90.930032] usb 1-1.3: dvb_usb_v2: 'AVerMedia HD Volar (A867)'
successfully initialized and connected


Also, the stick works fine with Jose's patch, independently from the
firmware file used.

Regards,
Gianluca

> 
> 
>> usb 3-3.1.4: dvb_usb_v2: found a 'AVerMedia HD Volar (A867)' in cold
>> state
>> usb 3-3.1.4: dvb_usb_v2: downloading firmware from file
>> 'dvb-usb-af9035-02.fw'
>> usb 3-3.1.4: dvb_usb_af9035: firmware version=11.5.9.0
>> usb 3-3.1.4: dvb_usb_v2: found a 'AVerMedia HD Volar (A867)' in warm
>> state
>> usb 3-3.1.4: dvb_usb_v2: will pass the complete MPEG2 transport stream
>> to the software demuxer
>> DVB: registering new adapter (AVerMedia HD Volar (A867))
>> i2c i2c-19: af9033: firmware version: LINK=11.5.9.0 OFDM=5.17.9.1
>> usb 3-3.1.4: DVB: registering adapter 1 frontend 0 (Afatech AF9033
>> (DVB-T))...
>> mxl5007t 19-0060: creating new instance
>> mxl5007t_get_chip_id: unknown rev (3f)
>> mxl5007t_get_chip_id: MxL5007T detected @ 19-0060
>> Registered IR keymap rc-empty
>> input: AVerMedia HD Volar (A867) as
>> /devices/pci:00/:00:14.0/usb3/3-3/3-3.1/3-3.1.4/rc/rc5/input29
>> rc5: AVerMedia HD Volar (A867) as
>> /devices/pci:00/:00:14.0/usb3/3-3/3-3.1/3-3.1.4/rc/rc5
>> usb 3-3.1.4: dvb_usb_v2: schedule remote query interval to 500 msecs
>> usb 3-3.1.4: dvb_usb_v2: 'AVerMedia HD Volar (A867)' successfully
>> initialized and connected
> 
> regards
> Antti
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media_build: add PTR_RET to compat.h

2013-02-09 Thread Gianluca Gennari
PTR_RET is used by the solo6x10 staging driver,
and was introduced in kernel 2.6.39.
Add it to compat.h for compatibility with older kernels.

Signed-off-by: Gianluca Gennari 
---
 v4l/compat.h  | 10 ++
 v4l/scripts/make_config_compat.pl |  1 +
 2 files changed, 11 insertions(+)

diff --git a/v4l/compat.h b/v4l/compat.h
index 1a82bb7..b27b178 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -1137,4 +1137,14 @@ static inline int usb_translate_errors(int error_code)
 }
 #endif
 
+#ifdef NEED_PTR_RET
+static inline int __must_check PTR_RET(const void *ptr)
+{
+   if (IS_ERR(ptr))
+   return PTR_ERR(ptr);
+   else
+   return 0;
+}
+#endif
+
 #endif /*  _COMPAT_H */
diff --git a/v4l/scripts/make_config_compat.pl 
b/v4l/scripts/make_config_compat.pl
index 583ef9d..51a1f5d 100644
--- a/v4l/scripts/make_config_compat.pl
+++ b/v4l/scripts/make_config_compat.pl
@@ -588,6 +588,7 @@ sub check_other_dependencies()
check_files_for_func("config_enabled", "NEED_IS_ENABLED", 
"include/linux/kconfig.h");
check_files_for_func("DEFINE_PCI_DEVICE_TABLE", 
"NEED_DEFINE_PCI_DEVICE_TABLE", "include/linux/pci.h");
check_files_for_func("usb_translate_errors", 
"NEED_USB_TRANSLATE_ERRORS", "include/linux/usb.h");
+   check_files_for_func("PTR_RET", "NEED_PTR_RET", "include/linux/err.h");
 
# For tests for uapi-dependent logic
check_files_for_func_uapi("usb_endpoint_maxp", 
"NEED_USB_ENDPOINT_MAXP", "usb/ch9.h");
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] media: rc: gpio-ir-recv: add support for device tree parsing

2013-02-09 Thread Mauro Carvalho Chehab
Em Sat, 09 Feb 2013 01:45:42 +0100
Sebastian Hesselbarth  escreveu:

> On 02/09/2013 01:03 AM, Mauro Carvalho Chehab wrote:
> > Em Fri,  8 Feb 2013 21:38:07 +0100
> > Sebastian Hesselbarth  escreveu:
> >
> >> This patch adds device tree parsing for gpio_ir_recv platform_data and
> >> the mandatory binding documentation. It basically follows what we already
> >> have for e.g. gpio_keys. All required device tree properties are OS
> >> independent but an optional property allow linux specific support for rc
> >> maps.
> >>
> >> There was a similar patch sent by Matus Ujhelyi but that discussion
> >> died after the first reviews.
> >>
> >> Signed-off-by: Sebastian Hesselbarth
> >> ---
> >> Changelog
> >>
> >> v1->v2:
> >> - get rid of ptr returned by _get_devtree_pdata()
> >> - check for of_node instead for NULL pdata
> >> - remove unneccessary double check for gpios property
> >> - remove unneccessary #ifdef CONFIG_OF around match table
> >>
> >> Cc: Grant Likely
> >> Cc: Rob Herring
> >> Cc: Rob Landley
> >> Cc: Mauro Carvalho Chehab
> >> Cc: Sebastian Hesselbarth
> >> Cc: Benoit Thebaudeau
> >> Cc: David Hardeman
> >> Cc: Trilok Soni
> >> Cc: Sylwester Nawrocki
> >> Cc: Matus Ujhelyi
> >> Cc: devicetree-disc...@lists.ozlabs.org
> >> Cc: linux-...@vger.kernel.org
> >> Cc: linux-ker...@vger.kernel.org
> >> Cc: linux-media@vger.kernel.org
> >> ---
> >>   .../devicetree/bindings/media/gpio-ir-receiver.txt |   16 ++
> >>   drivers/media/rc/gpio-ir-recv.c|   57 
> >> 
> >>   2 files changed, 73 insertions(+)
> >>   create mode 100644 
> >> Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt 
> >> b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
> >> new file mode 100644
> >> index 000..8589f30
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/media/gpio-ir-receiver.txt
> >> @@ -0,0 +1,16 @@
> >> +Device-Tree bindings for GPIO IR receiver
> >> +
> >> +Required properties:
> >> +  - compatible = "gpio-ir-receiver";
> >> +  - gpios: OF device-tree gpio specification.
> >> +
> >> +Optional properties:
> >> +  - linux,rc-map-name: Linux specific remote control map name.
> >> +
> >> +Example node:
> >> +
> >> +  ir: ir-receiver {
> >> +  compatible = "gpio-ir-receiver";
> >> +  gpios =<&gpio0 19 1>;
> >> +  linux,rc-map-name = "rc-rc6-mce";
> >
> > Please change this to:
> > linux,rc-map-name = RC_MAP_RC6_MCE;
> >
> > (as defined at include/media/rc-map.h).
> 
> Mauro,
> 
> this is not possible in device tree bindings. Device tree properties
> can only carry numeric or string types (and some other stuff) but no
> OS specific enumerations. So using strings is the only option here.
> 
> > The idea of having those strings defined at the same header file is to:
> 
> Unfortunately, device tree blobs don't know about linux header files.
> 
> That leaves two options:
> - allow the user to supply a string of the map in his device tree description
>and risk that there may be a broken map name
> - remove linux,rc-map-name from DT binding and let the user configure in
>from user space (which is propably best choice anyway)
> 
> I tried both, DT supplied map name and ir-keytable from userspace
> both work fine.

IMO, the first option is better, e. g. letting the device tree have the
string there.

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 1/8] stk-webcam: various fixes.

2013-02-09 Thread Arvydas Sidorenko
On Fri, Feb 8, 2013 at 10:20 AM, Hans Verkuil  wrote:
>
> Thanks for the testing! I've pushed some more improvements to my git branch.
> Hopefully the compliance tests are now running OK. Please check the dmesg
> output as well.
>
> In addition I've added an 'upside down' message to the kernel log that tells
> me whether the driver is aware that your sensor is upside down or not.
>
> Which laptop do you have? Asus G1?
>
> Regards,
>
> Hans

Now it looks better, but clearly there is an issue with the upside down thing.
I have ASUS F3Jc laptop.

Although a commit '6f89814d3d' introduced a problem.
> if (rb->count == 0)
> dev->owner = NULL;
Now 'v4l_stk_release' doesn't release the resources because 'dev->owner != fp'.

$ dmesg | grep upside
[4.933507] upside down: 0

$ v4l2-compliance -d /dev/video0
Driver Info:
Driver name   : stk
Card type : stk
Bus info  : usb-:00:1d.7-8
Driver version: 3.1.0
Capabilities  : 0x8501
Video Capture
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x0501
Video Capture
Read/Write
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G_CHIP_IDENT: OK (Not Supported)
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 4 Private Controls: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_PRESETS: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
warn: v4l2-test-formats.cpp(565): TRY_FMT cannot handle an 
invalid
pixelformat. This may or may not be a problem.
See http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
for more information.
test VIDIOC_TRY_FMT: OK
warn: v4l2-test-formats.cpp(723): S_FMT cannot handle an invalid
pixelformat. This may or may not be a problem.
See http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
for more information.
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
warn: v4l2-test-buffers.cpp(175): VIDIOC_CREATE_BUFS not 
supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK

Total: 38, Succeeded: 38, Failed: 0, Warnings: 3


Arvydas
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 09/26] cx231xx: convert to the control framework.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

This is needed to resolve the v4l2-compliance complaints about the control
ioctls.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-audio.c |4 -
 drivers/media/usb/cx231xx/cx231xx-cards.c |2 -
 drivers/media/usb/cx231xx/cx231xx-video.c |  244 +++--
 drivers/media/usb/cx231xx/cx231xx.h   |   13 +-
 4 files changed, 27 insertions(+), 236 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c 
b/drivers/media/usb/cx231xx/cx231xx-audio.c
index b4c99c7..b40360b 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -449,9 +449,6 @@ static int snd_cx231xx_capture_open(struct 
snd_pcm_substream *substream)
return -ENODEV;
}
 
-   /* Sets volume, mute, etc */
-   dev->mute = 0;
-
/* set alternate setting for audio interface */
/* 1 - 48000 samples per sec */
mutex_lock(&dev->lock);
@@ -503,7 +500,6 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream 
*substream)
return ret;
}
 
-   dev->mute = 1;
dev->adev.users--;
mutex_unlock(&dev->lock);
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 8d52956..d6acb1e 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -846,8 +846,6 @@ void cx231xx_card_setup(struct cx231xx *dev)
 int cx231xx_config(struct cx231xx *dev)
 {
/* TBD need to add cx231xx specific code */
-   dev->mute = 1;  /* maybe not the right place... */
-   dev->volume = 0x1f;
 
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index f96fbd6..e2a4330 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -100,125 +100,6 @@ static struct cx231xx_fmt format[] = {
 },
 };
 
-/* supported controls */
-/* Common to all boards */
-
-/* --- */
-
-static const struct v4l2_queryctrl no_ctl = {
-   .name = "42",
-   .flags = V4L2_CTRL_FLAG_DISABLED,
-};
-
-static struct cx231xx_ctrl cx231xx_ctls[] = {
-   /* --- video --- */
-   {
-   .v = {
-   .id = V4L2_CID_BRIGHTNESS,
-   .name = "Brightness",
-   .minimum = 0x00,
-   .maximum = 0xff,
-   .step = 1,
-   .default_value = 0x7f,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   },
-   .off = 128,
-   .reg = LUMA_CTRL,
-   .mask = 0x00ff,
-   .shift = 0,
-   }, {
-   .v = {
-   .id = V4L2_CID_CONTRAST,
-   .name = "Contrast",
-   .minimum = 0,
-   .maximum = 0xff,
-   .step = 1,
-   .default_value = 0x3f,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   },
-   .off = 0,
-   .reg = LUMA_CTRL,
-   .mask = 0xff00,
-   .shift = 8,
-   }, {
-   .v = {
-   .id = V4L2_CID_HUE,
-   .name = "Hue",
-   .minimum = 0,
-   .maximum = 0xff,
-   .step = 1,
-   .default_value = 0x7f,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   },
-   .off = 128,
-   .reg = CHROMA_CTRL,
-   .mask = 0xff,
-   .shift = 16,
-   }, {
-   /* strictly, this only describes only U saturation.
-   * V saturation is handled specially through code.
-   */
-   .v = {
-   .id = V4L2_CID_SATURATION,
-   .name = "Saturation",
-   .minimum = 0,
-   .maximum = 0xff,
-   .step = 1,
-   .default_value = 0x7f,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   },
-   .off = 0,
-   .reg = CHROMA_CTRL,
-   .mask = 0x00ff,
-   .shift = 0,
-   }, {
-   /* --- audio --- */
-   .v = {
-   .id = V4L2_CID_AUDIO_MUTE,
-   .name = "Mute",
-   .minimum = 0,
-   .maximum = 1,
-   .default_value = 1,
-   .type = V4L2_CTRL_TYPE_BOOLEAN,
-   },
-   .reg = PATH1_CTL1,
-   .mask = (0x1f << 24),
-   .shift = 24,
-   }, {
-   .v = {
-   .id = V4L2_CID_AUDIO_VOLUME,
-   .name = "Volu

[RFCv2 PATCH 21/26] cx231xx: remove bogus driver prefix in log messages.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The prefix is generated automatically, so no need to provide it again.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-vbi.c |   25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c 
b/drivers/media/usb/cx231xx/cx231xx-vbi.c
index 46e3892..1340ff2 100644
--- a/drivers/media/usb/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c
@@ -70,10 +70,10 @@ static inline void print_err_status(struct cx231xx *dev, 
int packet, int status)
break;
}
if (packet < 0) {
-   cx231xx_err(DRIVER_NAME "URB status %d [%s].\n", status,
+   cx231xx_err("URB status %d [%s].\n", status,
errmsg);
} else {
-   cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n",
+   cx231xx_err("URB packet %d, status %d [%s].\n",
packet, status, errmsg);
}
 }
@@ -317,7 +317,7 @@ static void cx231xx_irq_vbi_callback(struct urb *urb)
case -ESHUTDOWN:
return;
default:/* error */
-   cx231xx_err(DRIVER_NAME "urb completition error %d.\n",
+   cx231xx_err("urb completition error %d.\n",
urb->status);
break;
}
@@ -332,7 +332,7 @@ static void cx231xx_irq_vbi_callback(struct urb *urb)
 
urb->status = usb_submit_urb(urb, GFP_ATOMIC);
if (urb->status) {
-   cx231xx_err(DRIVER_NAME "urb resubmit failed (error=%i)\n",
+   cx231xx_err("urb resubmit failed (error=%i)\n",
urb->status);
}
 }
@@ -345,7 +345,7 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)
struct urb *urb;
int i;
 
-   cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n");
+   cx231xx_info("called cx231xx_uninit_vbi_isoc\n");
 
dev->vbi_mode.bulk_ctl.nfields = -1;
for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
@@ -394,7 +394,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int 
max_packets,
struct urb *urb;
int rc;
 
-   cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_prepare_isoc\n");
+   cx231xx_info("called cx231xx_vbi_isoc\n");
 
/* De-allocates all pending stuff */
cx231xx_uninit_vbi_isoc(dev);
@@ -442,8 +442,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int 
max_packets,
 
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
-   cx231xx_err(DRIVER_NAME
-   ": cannot alloc bulk_ctl.urb %i\n", i);
+   cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i);
cx231xx_uninit_vbi_isoc(dev);
return -ENOMEM;
}
@@ -453,8 +452,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int 
max_packets,
dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
kzalloc(sb_size, GFP_KERNEL);
if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) {
-   cx231xx_err(DRIVER_NAME
-   ": unable to allocate %i bytes for transfer"
+   cx231xx_err("unable to allocate %i bytes for transfer"
" buffer %i%s\n", sb_size, i,
in_interrupt() ? " while in int" : "");
cx231xx_uninit_vbi_isoc(dev);
@@ -473,8 +471,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int 
max_packets,
for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC);
if (rc) {
-   cx231xx_err(DRIVER_NAME
-   ": submit of urb %i failed (error=%i)\n", i,
+   cx231xx_err("submit of urb %i failed (error=%i)\n", i,
rc);
cx231xx_uninit_vbi_isoc(dev);
return rc;
@@ -526,7 +523,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev,
 struct cx231xx_buffer *buf)
 {
/* Advice that buffer was filled */
-   /* cx231xx_info(DRIVER_NAME "[%p/%d] wakeup\n", buf, buf->vb.i); */
+   /* cx231xx_info("[%p/%d] wakeup\n", buf, buf->vb.i); */
 
buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++;
@@ -618,7 +615,7 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue 
*dma_q,
char *outp;
 
if (list_empty(&dma_q->active)) {
-   cx231xx_err(DRIVER_NAME ": No active queue to serve\n");
+   cx231xx_err("No active queue to serve\n");
dev->vbi_mode.bulk_ctl.buf = NULL;
*buf = NULL;
return;
-- 
1.7.10.4

--
To u

[RFCv2 PATCH 15/26] cx231xx-417: remove empty functions.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c |   68 +--
 1 file changed, 1 insertion(+), 67 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 15dd334..ac15a55 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1551,33 +1551,6 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *id)
dprintk(3, "exit vidioc_s_std() i=0x%x\n", i);
return 0;
 }
-static int vidioc_g_audio(struct file *file, void *fh,
-   struct v4l2_audio *a)
-{
-   struct v4l2_audio *vin = a;
-
-   int ret = -EINVAL;
-   if (vin->index > 0)
-   return ret;
-   strncpy(vin->name, "VideoGrabber Audio", 14);
-   vin->capability = V4L2_AUDCAP_STEREO;
-return 0;
-}
-static int vidioc_enumaudio(struct file *file, void *fh,
-   struct v4l2_audio *a)
-{
-   struct v4l2_audio *vin = a;
-
-   int ret = -EINVAL;
-
-   if (vin->index > 0)
-   return ret;
-   strncpy(vin->name, "VideoGrabber Audio", 14);
-   vin->capability = V4L2_AUDCAP_STEREO;
-
-
-return 0;
-}
 static const char *iname[] = {
[CX231XX_VMUX_COMPOSITE1] = "Composite1",
[CX231XX_VMUX_SVIDEO] = "S-Video",
@@ -1642,32 +1615,6 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int i)
return 0;
 }
 
-static int vidioc_g_tuner(struct file *file, void *priv,
-   struct v4l2_tuner *t)
-{
-   return 0;
-}
-
-static int vidioc_s_tuner(struct file *file, void *priv,
-   struct v4l2_tuner *t)
-{
-   return 0;
-}
-
-static int vidioc_g_frequency(struct file *file, void *priv,
-   struct v4l2_frequency *f)
-{
-   return 0;
-}
-
-static int vidioc_s_frequency(struct file *file, void *priv,
-   struct v4l2_frequency *f)
-{
-
-
-   return 0;
-}
-
 static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
 {
@@ -1748,13 +1695,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, 
void *priv,
return 0;
 }
 
-static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
-   struct v4l2_format *f)
-{
-
-   return 0;
-}
-
 static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *p)
 {
@@ -2073,20 +2013,14 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
.vidioc_s_std= vidioc_s_std,
.vidioc_g_std= vidioc_g_std,
.vidioc_enum_input   = vidioc_enum_input,
-   .vidioc_enumaudio= vidioc_enumaudio,
-   .vidioc_g_audio  = vidioc_g_audio,
.vidioc_g_input  = vidioc_g_input,
.vidioc_s_input  = vidioc_s_input,
-   .vidioc_g_tuner  = vidioc_g_tuner,
-   .vidioc_s_tuner  = vidioc_s_tuner,
-   .vidioc_g_frequency  = vidioc_g_frequency,
-   .vidioc_s_frequency  = vidioc_s_frequency,
.vidioc_s_ctrl   = vidioc_s_ctrl,
.vidioc_querycap = vidioc_querycap,
.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
.vidioc_g_fmt_vid_cap= vidioc_g_fmt_vid_cap,
.vidioc_try_fmt_vid_cap  = vidioc_try_fmt_vid_cap,
-   .vidioc_s_fmt_vid_cap= vidioc_s_fmt_vid_cap,
+   .vidioc_s_fmt_vid_cap= vidioc_try_fmt_vid_cap,
.vidioc_reqbufs  = vidioc_reqbufs,
.vidioc_querybuf = vidioc_querybuf,
.vidioc_qbuf = vidioc_qbuf,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 19/26] cx231xx-417: share ioctls with cx231xx-video.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Share tuner, frequency, debug and input ioctls with cx231xx-video.
These are all shared resources, so no need to implement them again.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c   |  113 +++--
 drivers/media/usb/cx231xx/cx231xx-video.c |   52 ++---
 drivers/media/usb/cx231xx/cx231xx.h   |   15 
 3 files changed, 67 insertions(+), 113 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 2c05c8f..567d7ab 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "cx231xx.h"
@@ -1551,68 +1552,6 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *id)
return 0;
 }
 
-static const char * const iname[] = {
-   [CX231XX_VMUX_COMPOSITE1] = "Composite1",
-   [CX231XX_VMUX_SVIDEO] = "S-Video",
-   [CX231XX_VMUX_TELEVISION] = "Television",
-   [CX231XX_VMUX_CABLE]  = "Cable TV",
-   [CX231XX_VMUX_DVB]= "DVB",
-   [CX231XX_VMUX_DEBUG]  = "for debug only",
-};
-
-static int vidioc_enum_input(struct file *file, void *priv,
-   struct v4l2_input *i)
-{
-   struct cx231xx_fh  *fh  = file->private_data;
-   struct cx231xx *dev = fh->dev;
-   struct cx231xx_input *input;
-   int n;
-   dprintk(3, "enter vidioc_enum_input()i->index=%d\n", i->index);
-
-   if (i->index >= 4)
-   return -EINVAL;
-
-   input = &cx231xx_boards[dev->model].input[i->index];
-
-   if (input->type == 0)
-   return -EINVAL;
-
-   /* FIXME
-* strcpy(i->name, input->name); */
-
-   n = i->index;
-   strcpy(i->name, iname[INPUT(n)->type]);
-
-   if (input->type == CX231XX_VMUX_TELEVISION ||
-   input->type == CX231XX_VMUX_CABLE)
-   i->type = V4L2_INPUT_TYPE_TUNER;
-   else
-   i->type  = V4L2_INPUT_TYPE_CAMERA;
-   return 0;
-}
-
-static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
-{
-   *i = 0;
-   return  0;
-}
-
-static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
-{
-   struct cx231xx_fh  *fh  = file->private_data;
-   struct cx231xx *dev = fh->dev;
-
-   dprintk(3, "enter vidioc_s_input() i=%d\n", i);
-
-   video_mux(dev, i);
-
-   if (i >= 4)
-   return -EINVAL;
-   dev->input = i;
-   dprintk(3, "exit vidioc_s_input()\n");
-   return 0;
-}
-
 static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
 {
@@ -1831,22 +1770,12 @@ static int vidioc_queryctrl(struct file *file, void 
*priv,
 
 static int mpeg_open(struct file *file)
 {
-   int minor = video_devdata(file)->minor;
-   struct cx231xx *h, *dev = NULL;
-   /*struct list_head *list;*/
+   struct video_device *vdev = video_devdata(file);
+   struct cx231xx *dev = video_drvdata(file);
struct cx231xx_fh *fh;
-   /*u32 value = 0;*/
 
dprintk(2, "%s()\n", __func__);
 
-   list_for_each_entry(h, &cx231xx_devlist, devlist) {
-   if (h->v4l_device->minor == minor)
-   dev = h;
-   }
-
-   if (dev == NULL)
-   return -ENODEV;
-
if (mutex_lock_interruptible(&dev->lock))
return -ERESTARTSYS;
 
@@ -1858,7 +1787,8 @@ static int mpeg_open(struct file *file)
}
 
file->private_data = fh;
-   fh->dev  = dev;
+   v4l2_fh_init(&fh->fh, vdev);
+   fh->dev = dev;
 
 
videobuf_queue_vmalloc_init(&fh->vidq, &cx231xx_qops,
@@ -1880,6 +1810,7 @@ static int mpeg_open(struct file *file)
cx231xx_initialize_codec(dev);
 
mutex_unlock(&dev->lock);
+   v4l2_fh_add(&fh->fh);
cx231xx_start_TS1(dev);
 
return 0;
@@ -1892,11 +1823,6 @@ static int mpeg_release(struct file *file)
 
dprintk(3, "mpeg_release()! dev=0x%p\n", dev);
 
-   if (!dev) {
-   dprintk(3, "abort!!!\n");
-   return 0;
-   }
-
mutex_lock(&dev->lock);
 
cx231xx_stop_TS1(dev);
@@ -1930,7 +1856,8 @@ static int mpeg_release(struct file *file)
videobuf_read_stop(&fh->vidq);
 
videobuf_mmap_free(&fh->vidq);
-   file->private_data = NULL;
+   v4l2_fh_del(&fh->fh);
+   v4l2_fh_exit(&fh->fh);
kfree(fh);
mutex_unlock(&dev->lock);
return 0;
@@ -1986,9 +1913,13 @@ static struct v4l2_file_operations mpeg_fops = {
 static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
.vidioc_s_std= vidioc_s_std,
.vidioc_g_std= vidioc_g_std,
-   .vidioc_enum_input   = vidioc_enum_input,
-   .vidioc_g_input  = vidioc_g_input,
-   .vidioc_s_input  = vidioc_s_input,
+   

[RFCv2 PATCH 12/26] cx231xx: replace ioctl by unlocked_ioctl.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

There was already a core lock, so why wasn't ioctl already replaced by
unlock_ioctl?

This patch switches to unlocked_ioctl.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c   |   15 ++-
 drivers/media/usb/cx231xx/cx231xx-video.c |2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index a4091dd..15dd334 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1633,12 +1633,8 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int i)
 
dprintk(3, "enter vidioc_s_input() i=%d\n", i);
 
-   mutex_lock(&dev->lock);
-
video_mux(dev, i);
 
-   mutex_unlock(&dev->lock);
-
if (i >= 4)
return -EINVAL;
dev->input = i;
@@ -1932,7 +1928,8 @@ static int mpeg_open(struct file *file)
if (dev == NULL)
return -ENODEV;
 
-   mutex_lock(&dev->lock);
+   if (mutex_lock_interruptible(&dev->lock))
+   return -ERESTARTSYS;
 
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
@@ -1948,14 +1945,14 @@ static int mpeg_open(struct file *file)
videobuf_queue_vmalloc_init(&fh->vidq, &cx231xx_qops,
NULL, &dev->video_mode.slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_INTERLACED,
-   sizeof(struct cx231xx_buffer), fh, NULL);
+   sizeof(struct cx231xx_buffer), fh, &dev->lock);
 /*
videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops,
&dev->udev->dev, &dev->ts1.slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx231xx_buffer),
-   fh, NULL);
+   fh, &dev->lock);
 */
 
 
@@ -2069,7 +2066,7 @@ static struct v4l2_file_operations mpeg_fops = {
.read  = mpeg_read,
.poll  = mpeg_poll,
.mmap  = mpeg_mmap,
-   .ioctl = video_ioctl2,
+   .unlocked_ioctl = video_ioctl2,
 };
 
 static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
@@ -2144,11 +2141,11 @@ static struct video_device *cx231xx_video_dev_alloc(
if (NULL == vfd)
return NULL;
*vfd = *template;
-   vfd->minor = -1;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name,
type, cx231xx_boards[dev->model].name);
 
vfd->v4l2_dev = &dev->v4l2_dev;
+   vfd->lock = &dev->lock;
vfd->release = video_device_release;
 
return vfd;
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 617dc32..e3c69f7 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -2236,7 +2236,7 @@ static const struct v4l2_file_operations radio_fops = {
.open   = cx231xx_v4l2_open,
.release = cx231xx_v4l2_close,
.poll = v4l2_ctrl_poll,
-   .ioctl   = video_ioctl2,
+   .unlocked_ioctl = video_ioctl2,
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 20/26] cx231xx-417: convert to the control framework.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c |  213 ---
 drivers/media/usb/cx231xx/cx231xx.h |2 +-
 2 files changed, 86 insertions(+), 129 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 567d7ab..49c842a 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -744,7 +745,7 @@ static int cx231xx_mbox_func(void *priv, u32 command, int 
in, int out,
if (value != 0x12345678) {
dprintk(3, "Firmware and/or mailbox pointer not initialized or 
corrupted, signature = 0x%x, cmd = %s\n",
value, cmd_to_str(command));
-   return -1;
+   return -EIO;
}
 
/* This read looks at 32 bits, but flag is only 8 bits.
@@ -754,7 +755,7 @@ static int cx231xx_mbox_func(void *priv, u32 command, int 
in, int out,
if (flag) {
dprintk(3, "ERROR: Mailbox appears to be in use (%x), cmd = 
%s\n",
flag, cmd_to_str(command));
-   return -1;
+   return -EBUSY;
}
 
flag |= 1; /* tell 'em we're working on it */
@@ -783,7 +784,7 @@ static int cx231xx_mbox_func(void *priv, u32 command, int 
in, int out,
break;
if (time_after(jiffies, timeout)) {
dprintk(3, "ERROR: API Mailbox timeout\n");
-   return -1;
+   return -EIO;
}
udelay(10);
}
@@ -800,7 +801,7 @@ static int cx231xx_mbox_func(void *priv, u32 command, int 
in, int out,
flag = 0;
mc417_memory_write(dev, dev->cx23417_mailbox, flag);
 
-   return retval;
+   return 0;
 }
 
 /* We don't need to call the API often, so using just one
@@ -829,6 +830,7 @@ static int cx231xx_api_cmd(struct cx231xx *dev, u32 command,
return err;
 }
 
+
 static int cx231xx_find_mailbox(struct cx231xx *dev)
 {
u32 signature[4] = {
@@ -1092,10 +1094,10 @@ static void cx231xx_codec_settings(struct cx231xx *dev)
cx231xx_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
dev->ts1.height, dev->ts1.width);
 
-   dev->mpeg_params.width = dev->ts1.width;
-   dev->mpeg_params.height = dev->ts1.height;
+   dev->mpeg_ctrl_handler.width = dev->ts1.width;
+   dev->mpeg_ctrl_handler.height = dev->ts1.height;
 
-   cx2341x_update(dev, cx231xx_mbox_func, NULL, &dev->mpeg_params);
+   cx2341x_handler_setup(&dev->mpeg_ctrl_handler);
 
cx231xx_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 3, 1);
cx231xx_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 4, 1);
@@ -1481,36 +1483,6 @@ static struct videobuf_queue_ops cx231xx_qops = {
 
 /* -- */
 
-static const u32 *ctrl_classes[] = {
-   cx2341x_mpeg_ctrls,
-   NULL
-};
-
-static int cx231xx_queryctrl(struct cx231xx *dev,
-   struct v4l2_queryctrl *qctrl)
-{
-   qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
-   if (qctrl->id == 0)
-   return -EINVAL;
-
-   /* MPEG V4L2 controls */
-   if (cx2341x_ctrl_query(&dev->mpeg_params, qctrl))
-   qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
-
-   return 0;
-}
-
-static int cx231xx_querymenu(struct cx231xx *dev,
-   struct v4l2_querymenu *qmenu)
-{
-   struct v4l2_queryctrl qctrl;
-
-   qctrl.id = qmenu->id;
-   cx231xx_queryctrl(dev, &qctrl);
-   return v4l2_ctrl_query_menu(qmenu, &qctrl,
-   cx2341x_ctrl_get_menu(&dev->mpeg_params, qmenu->id));
-}
-
 static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm)
 {
struct cx231xx_fh  *fh  = file->private_data;
@@ -1537,12 +1509,12 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *id)
dprintk(3, "encodernorm set to NTSC\n");
dev->norm = V4L2_STD_NTSC;
dev->ts1.height = 480;
-   dev->mpeg_params.is_50hz = 0;
+   cx2341x_handler_set_50hz(&dev->mpeg_ctrl_handler, false);
} else {
dprintk(3, "encodernorm set to PAL\n");
dev->norm = V4L2_STD_PAL_B;
dev->ts1.height = 576;
-   dev->mpeg_params.is_50hz = 1;
+   cx2341x_handler_set_50hz(&dev->mpeg_ctrl_handler, true);
}
call_all(dev, core, s_std, dev->norm);
/* do mode control overrides */
@@ -1680,92 +1652,13 @@ static int vidioc_streamoff(struct file *file, void 
*priv, enum v4l2_buf_type i)
return videobuf_streamoff(&fh->vidq);
 }
 
-static int vidioc_g_ext_ctrls(struct file *file, void *priv,
-   struct v4l2_ext_controls *f)
-{
-   struct cx231x

[RFCv2 PATCH 13/26] cx231xx: get rid of a bunch of unused cx231xx_fh fields.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |6 +-
 drivers/media/usb/cx231xx/cx231xx.h   |   18 +-
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index e3c69f7..311d106 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1620,9 +1620,6 @@ static int vidioc_streamoff(struct file *file, void *priv,
if (rc < 0)
return rc;
 
-   if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
-   (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))
-   return -EINVAL;
if (type != fh->type)
return -EINVAL;
 
@@ -1868,7 +1865,6 @@ static int cx231xx_v4l2_open(struct file *filp)
return -ERESTARTSYS;
}
fh->dev = dev;
-   fh->radio = radio;
fh->type = fh_type;
filp->private_data = fh;
v4l2_fh_init(&fh->fh, vdev);
@@ -1899,7 +1895,7 @@ static int cx231xx_v4l2_open(struct file *filp)
dev->video_input = dev->video_input > 2 ? 2 : dev->video_input;
 
}
-   if (fh->radio) {
+   if (radio) {
cx231xx_videodbg("video_open: setting radio device\n");
 
/* cx231xx_start_radio(dev); */
diff --git a/drivers/media/usb/cx231xx/cx231xx.h 
b/drivers/media/usb/cx231xx/cx231xx.h
index 4c83ff5..c17889d 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -433,25 +433,9 @@ struct cx231xx_fh {
struct v4l2_fh fh;
struct cx231xx *dev;
unsigned int stream_on:1;   /* Locks streams */
-   int radio;
-
-   struct videobuf_queue vb_vidq;
-
enum v4l2_buf_type type;
 
-
-
-/*following is copyed from cx23885.h*/
-   u32resources;
-
-   /* video overlay */
-   struct v4l2_window win;
-   struct v4l2_clip   *clips;
-   unsigned int   nclips;
-
-   /* video capture */
-   struct cx23417_fmt *fmt;
-   unsigned int   width, height;
+   struct videobuf_queue vb_vidq;
 
/* vbi capture */
struct videobuf_queue  vidq;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 22/26] cx231xx: disable 417 support from the Conexant video grabber

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The 417 support doesn't work. Until someone can dig into this driver to
figure out why it isn't working the 417 support is disabled.

Sometimes you can actually stream a bit, but very soon the whole machine
crashes, so something is seriously wrong.

For the record, this was not introduced by my recent changes to this driver,
it was broken before that.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-cards.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index d6acb1e..7094451 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -263,7 +263,10 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_PAL,
.no_alt_vanc = 1,
.external_av = 1,
-   .has_417 = 1,
+   /* Actually, it has a 417, but it isn't working correctly.
+* So set to 0 for now until someone can manage to get this
+* to work reliably. */
+   .has_417 = 0,
 
.input = {{
.type = CX231XX_VMUX_COMPOSITE1,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 16/26] cx231xx-417: use one querycap for all device nodes.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c   |   20 +---
 drivers/media/usb/cx231xx/cx231xx-video.c |6 +++---
 drivers/media/usb/cx231xx/cx231xx.h   |2 ++
 3 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index ac15a55..be8f7481 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1626,24 +1626,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
dprintk(3, "exit vidioc_s_ctrl()\n");
return 0;
 }
-static struct v4l2_capability pvr_capability = {
-   .driver = "cx231xx",
-   .card   = "VideoGrabber",
-   .bus_info   = "usb",
-   .version= 1,
-   .capabilities   = (V4L2_CAP_VIDEO_CAPTURE |
-  V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_RADIO |
-V4L2_CAP_STREAMING | V4L2_CAP_READWRITE),
-};
-static int vidioc_querycap(struct file *file, void  *priv,
-   struct v4l2_capability *cap)
-{
-
-
-
-   memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability));
-   return 0;
-}
 
 static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
struct v4l2_fmtdesc *f)
@@ -2016,7 +1998,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
.vidioc_g_input  = vidioc_g_input,
.vidioc_s_input  = vidioc_s_input,
.vidioc_s_ctrl   = vidioc_s_ctrl,
-   .vidioc_querycap = vidioc_querycap,
+   .vidioc_querycap = cx231xx_querycap,
.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
.vidioc_g_fmt_vid_cap= vidioc_g_fmt_vid_cap,
.vidioc_try_fmt_vid_cap  = vidioc_try_fmt_vid_cap,
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 208926f..60a7b3ee 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1631,7 +1631,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
return 0;
 }
 
-static int vidioc_querycap(struct file *file, void *priv,
+int cx231xx_querycap(struct file *file, void *priv,
   struct v4l2_capability *cap)
 {
struct video_device *vdev = video_devdata(file);
@@ -2185,7 +2185,7 @@ static const struct v4l2_file_operations cx231xx_v4l_fops 
= {
 };
 
 static const struct v4l2_ioctl_ops video_ioctl_ops = {
-   .vidioc_querycap   = vidioc_querycap,
+   .vidioc_querycap   = cx231xx_querycap,
.vidioc_enum_fmt_vid_cap   = vidioc_enum_fmt_vid_cap,
.vidioc_g_fmt_vid_cap  = vidioc_g_fmt_vid_cap,
.vidioc_try_fmt_vid_cap= vidioc_try_fmt_vid_cap,
@@ -2236,7 +2236,7 @@ static const struct v4l2_file_operations radio_fops = {
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
-   .vidioc_querycap= vidioc_querycap,
+   .vidioc_querycap= cx231xx_querycap,
.vidioc_g_tuner = radio_g_tuner,
.vidioc_s_tuner = radio_s_tuner,
.vidioc_g_frequency = vidioc_g_frequency,
diff --git a/drivers/media/usb/cx231xx/cx231xx.h 
b/drivers/media/usb/cx231xx/cx231xx.h
index c17889d..efc0d1c 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -934,6 +934,8 @@ int cx231xx_register_extension(struct cx231xx_ops *dev);
 void cx231xx_unregister_extension(struct cx231xx_ops *dev);
 void cx231xx_init_extension(struct cx231xx *dev);
 void cx231xx_close_extension(struct cx231xx *dev);
+int cx231xx_querycap(struct file *file, void *priv,
+  struct v4l2_capability *cap);
 
 /* Provided by cx231xx-cards.c */
 extern void cx231xx_pre_card_setup(struct cx231xx *dev);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 26/26] cx231xx: fix gpio big-endian problems

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Tested on my big-endian ppc-based test machine.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-avcore.c |   73 +++-
 drivers/media/usb/cx231xx/cx231xx.h|2 -
 2 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c 
b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index 3f26f64..2e51fb9 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -2638,20 +2638,23 @@ EXPORT_SYMBOL_GPL(cx231xx_capture_start);
 /*
 *   G P I O   B I T control functions*
 **/
-int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val)
+static int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u32 
gpio_val)
 {
int status = 0;
 
-   status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 0);
+   gpio_val = cpu_to_le32(gpio_val);
+   status = cx231xx_send_gpio_cmd(dev, gpio_bit, (u8 *)&gpio_val, 4, 0, 0);
 
return status;
 }
 
-int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val)
+static int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u32 
*gpio_val)
 {
+   u32 tmp;
int status = 0;
 
-   status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 1);
+   status = cx231xx_send_gpio_cmd(dev, gpio_bit, (u8 *)&tmp, 4, 0, 1);
+   *gpio_val = le32_to_cpu(tmp);
 
return status;
 }
@@ -2683,7 +2686,7 @@ int cx231xx_set_gpio_direction(struct cx231xx *dev,
else
value = dev->gpio_dir | (1 << pin_number);
 
-   status = cx231xx_set_gpio_bit(dev, value, (u8 *) &dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, value, dev->gpio_val);
 
/* cache the value for future */
dev->gpio_dir = value;
@@ -2717,7 +2720,7 @@ int cx231xx_set_gpio_value(struct cx231xx *dev, int 
pin_number, int pin_value)
value = dev->gpio_dir | (1 << pin_number);
dev->gpio_dir = value;
status = cx231xx_set_gpio_bit(dev, dev->gpio_dir,
- (u8 *) &dev->gpio_val);
+ dev->gpio_val);
value = 0;
}
 
@@ -2730,7 +2733,7 @@ int cx231xx_set_gpio_value(struct cx231xx *dev, int 
pin_number, int pin_value)
dev->gpio_val = value;
 
/* toggle bit0 of GP_IO */
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
 
return status;
 }
@@ -2748,7 +2751,7 @@ int cx231xx_gpio_i2c_start(struct cx231xx *dev)
dev->gpio_val |= 1 << dev->board.tuner_scl_gpio;
dev->gpio_val |= 1 << dev->board.tuner_sda_gpio;
 
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
if (status < 0)
return -EINVAL;
 
@@ -2756,7 +2759,7 @@ int cx231xx_gpio_i2c_start(struct cx231xx *dev)
dev->gpio_val |= 1 << dev->board.tuner_scl_gpio;
dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio);
 
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
if (status < 0)
return -EINVAL;
 
@@ -2764,7 +2767,7 @@ int cx231xx_gpio_i2c_start(struct cx231xx *dev)
dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio);
dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio);
 
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
if (status < 0)
return -EINVAL;
 
@@ -2782,7 +2785,7 @@ int cx231xx_gpio_i2c_end(struct cx231xx *dev)
dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio);
dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio);
 
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
if (status < 0)
return -EINVAL;
 
@@ -2790,7 +2793,7 @@ int cx231xx_gpio_i2c_end(struct cx231xx *dev)
dev->gpio_val |= 1 << dev->board.tuner_scl_gpio;
dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio);
 
-   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val);
+   status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, dev->gpio_val);
if (status < 0)
return -EINVAL;
 
@@ -2800,7 +2803,7 @@ int cx231xx_gpio_i2c_end(struct cx231xx *dev)
dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio);
 
status =
-   cx231xx_set_gpio_b

[RFCv2 PATCH 18/26] cx231xx-417: checkpatch cleanups.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c |  732 +++
 1 file changed, 360 insertions(+), 372 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index cbdc141..2c05c8f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -38,7 +38,6 @@
 #include 
 
 #include "cx231xx.h"
-/*#include "cx23885-ioctl.h"*/
 
 #define CX231xx_FIRM_IMAGE_SIZE 376836
 #define CX231xx_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw"
@@ -75,9 +74,11 @@
 static unsigned int mpegbufs = 8;
 module_param(mpegbufs, int, 0644);
 MODULE_PARM_DESC(mpegbufs, "number of mpeg buffers, range 2-32");
+
 static unsigned int mpeglines = 128;
 module_param(mpeglines, int, 0644);
 MODULE_PARM_DESC(mpeglines, "number of lines in an MPEG buffer, range 2-32");
+
 static unsigned int mpeglinesize = 512;
 module_param(mpeglinesize, int, 0644);
 MODULE_PARM_DESC(mpeglinesize,
@@ -86,10 +87,10 @@ MODULE_PARM_DESC(mpeglinesize,
 static unsigned int v4l_debug = 1;
 module_param(v4l_debug, int, 0644);
 MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages");
-struct cx231xx_dmaqueue *dma_qq;
+
 #define dprintk(level, fmt, arg...)\
do { if (v4l_debug >= level) \
-   printk(KERN_INFO "%s: " fmt, \
+   pr_info("%s: " fmt, \
(dev) ? dev->name : "cx231xx[?]", ## arg); \
} while (0)
 
@@ -131,11 +132,13 @@ static struct cx231xx_tvnorm cx231xx_tvnorms[] = {
 };
 
 /* -- */
+
 enum cx231xx_capture_type {
CX231xx_MPEG_CAPTURE,
CX231xx_RAW_CAPTURE,
CX231xx_RAW_PASSTHRU_CAPTURE
 };
+
 enum cx231xx_capture_bits {
CX231xx_RAW_BITS_NONE = 0x00,
CX231xx_RAW_BITS_YUV_CAPTURE  = 0x01,
@@ -144,33 +147,40 @@ enum cx231xx_capture_bits {
CX231xx_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
CX231xx_RAW_BITS_TO_HOST_CAPTURE  = 0x10
 };
+
 enum cx231xx_capture_end {
CX231xx_END_AT_GOP, /* stop at the end of gop, generate irq */
CX231xx_END_NOW, /* stop immediately, no irq */
 };
+
 enum cx231xx_framerate {
CX231xx_FRAMERATE_NTSC_30, /* NTSC: 30fps */
CX231xx_FRAMERATE_PAL_25   /* PAL: 25fps */
 };
+
 enum cx231xx_stream_port {
CX231xx_OUTPUT_PORT_MEMORY,
CX231xx_OUTPUT_PORT_STREAMING,
CX231xx_OUTPUT_PORT_SERIAL
 };
+
 enum cx231xx_data_xfer_status {
CX231xx_MORE_BUFFERS_FOLLOW,
CX231xx_LAST_BUFFER,
 };
+
 enum cx231xx_picture_mask {
CX231xx_PICTURE_MASK_NONE,
CX231xx_PICTURE_MASK_I_FRAMES,
CX231xx_PICTURE_MASK_I_P_FRAMES = 0x3,
CX231xx_PICTURE_MASK_ALL_FRAMES = 0x7,
 };
+
 enum cx231xx_vbi_mode_bits {
CX231xx_VBI_BITS_SLICED,
CX231xx_VBI_BITS_RAW,
 };
+
 enum cx231xx_vbi_insertion_bits {
CX231xx_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,
CX231xx_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,
@@ -178,56 +188,69 @@ enum cx231xx_vbi_insertion_bits {
CX231xx_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,
CX231xx_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,
 };
+
 enum cx231xx_dma_unit {
CX231xx_DMA_BYTES,
CX231xx_DMA_FRAMES,
 };
+
 enum cx231xx_dma_transfer_status_bits {
CX231xx_DMA_TRANSFER_BITS_DONE = 0x01,
CX231xx_DMA_TRANSFER_BITS_ERROR = 0x04,
CX231xx_DMA_TRANSFER_BITS_LL_ERROR = 0x10,
 };
+
 enum cx231xx_pause {
CX231xx_PAUSE_ENCODING,
CX231xx_RESUME_ENCODING,
 };
+
 enum cx231xx_copyright {
CX231xx_COPYRIGHT_OFF,
CX231xx_COPYRIGHT_ON,
 };
+
 enum cx231xx_notification_type {
CX231xx_NOTIFICATION_REFRESH,
 };
+
 enum cx231xx_notification_status {
CX231xx_NOTIFICATION_OFF,
CX231xx_NOTIFICATION_ON,
 };
+
 enum cx231xx_notification_mailbox {
CX231xx_NOTIFICATION_NO_MAILBOX = -1,
 };
+
 enum cx231xx_field1_lines {
CX231xx_FIELD1_SAA7114 = 0x00EF, /* 239 */
CX231xx_FIELD1_SAA7115 = 0x00F0, /* 240 */
CX231xx_FIELD1_MICRONAS = 0x0105, /* 261 */
 };
+
 enum cx231xx_field2_lines {
CX231xx_FIELD2_SAA7114 = 0x00EF, /* 239 */
CX231xx_FIELD2_SAA7115 = 0x00F0, /* 240 */
CX231xx_FIELD2_MICRONAS = 0x0106, /* 262 */
 };
+
 enum cx231xx_custom_data_type {
CX231xx_CUSTOM_EXTENSION_USR_DATA,
CX231xx_CUSTOM_PRIVATE_PACKET,
 };
+
 enum cx231xx_mute {
CX231xx_UNMUTE,
CX231xx_MUTE,
 };
+
 enum cx231xx_mute_video_mask {
CX231xx_MUTE_VIDEO_V_MASK = 0xFF00,
CX231xx_MUTE_VIDEO_U_MASK = 0x00FF,
CX231xx_MUTE_VIDEO_Y_MASK = 0xFF00,
 };
+
 enum cx231xx_mute_video_shift {
CX231xx_MUTE_VIDEO_V_SHIFT = 8,
CX231xx_MUTE_VIDEO_U_SHIFT = 16,
@@ -296,41 +319,43 @@ enum cx231xx_mute_video_shift {
 
 
 #define CX23417_GPIO_MASK 0xFC0003FF
-static int setITVCReg(struct cx231xx *dev, u32 gpio_direc

[RFCv2 PATCH 25/26] cx231xx: fix big-endian problems.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Tested on my big-endian ppc-based test machine.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-audio.c   |4 ++--
 drivers/media/usb/cx231xx/cx231xx-avcore.c  |8 
 drivers/media/usb/cx231xx/cx231xx-cards.c   |   16 
 drivers/media/usb/cx231xx/cx231xx-core.c|2 +-
 drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c |2 +-
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c 
b/drivers/media/usb/cx231xx/cx231xx-audio.c
index b40360b..81a1d97 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -704,8 +704,8 @@ static int cx231xx_audio_init(struct cx231xx *dev)
audio_index + 1];
 
adev->end_point_addr =
-   le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
-   bEndpointAddress);
+   uif->altsetting[0].endpoint[isoc_pipe].desc.
+   bEndpointAddress;
 
adev->num_alt = uif->num_altsetting;
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c 
b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index 4706ed3..3f26f64 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -2221,7 +2221,7 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum 
AV_MODE mode)
if (status < 0)
return status;
 
-   tmp = *((u32 *) value);
+   tmp = le32_to_cpu(*((u32 *) value));
 
switch (mode) {
case POLARIS_AVMODE_ENXTERNAL_AV:
@@ -2442,7 +2442,7 @@ int cx231xx_power_suspend(struct cx231xx *dev)
if (status > 0)
return status;
 
-   tmp = *((u32 *) value);
+   tmp = le32_to_cpu(*((u32 *) value));
tmp &= (~PWR_MODE_MASK);
 
value[0] = (u8) tmp;
@@ -2470,7 +2470,7 @@ int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask)
if (status < 0)
return status;
 
-   tmp = *((u32 *) value);
+   tmp = le32_to_cpu(*((u32 *) value));
tmp |= ep_mask;
value[0] = (u8) tmp;
value[1] = (u8) (tmp >> 8);
@@ -2495,7 +2495,7 @@ int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask)
if (status < 0)
return status;
 
-   tmp = *((u32 *) value);
+   tmp = le32_to_cpu(*((u32 *) value));
tmp &= (~ep_mask);
value[0] = (u8) tmp;
value[1] = (u8) (tmp >> 8);
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 62d104b..b7b1acd 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1189,8 +1189,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
uif = udev->actconfig->interface[dev->current_pcb_config.
   hs_config_info[0].interface_info.video_index + 1];
 
-   dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0].
-   endpoint[isoc_pipe].desc.bEndpointAddress);
+   dev->video_mode.end_point_addr = uif->altsetting[0].
+   endpoint[isoc_pipe].desc.bEndpointAddress;
 
dev->video_mode.num_alt = uif->num_altsetting;
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
@@ -1223,8 +1223,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
   vanc_index + 1];
 
dev->vbi_mode.end_point_addr =
-   le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
-   bEndpointAddress);
+   uif->altsetting[0].endpoint[isoc_pipe].desc.
+   bEndpointAddress;
 
dev->vbi_mode.num_alt = uif->num_altsetting;
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
@@ -1258,8 +1258,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
   hanc_index + 1];
 
dev->sliced_cc_mode.end_point_addr =
-   le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
-   bEndpointAddress);
+   uif->altsetting[0].endpoint[isoc_pipe].desc.
+   bEndpointAddress;
 
dev->sliced_cc_mode.num_alt = uif->num_altsetting;
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
@@ -1294,8 +1294,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
   ts1_index + 1];
 
dev->ts1_mode.end_point_addr =
-   le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].
-   desc.bEndpointAddress);
+   uif->altsetting[0].endpoint[isoc_pipe].
+   desc.bEndpointAddress;
 
dev->ts1_mode.num_alt = uif->num_altsetting;
cx231xx_info("E

[RFCv2 PATCH 24/26] cx231xx: don't use port 3 on the Conexant video grabber.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

It's not working reliably if port 3 is enabled.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-cards.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 7094451..62d104b 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -263,6 +263,7 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_PAL,
.no_alt_vanc = 1,
.external_av = 1,
+   .dont_use_port_3 = 1,
/* Actually, it has a 417, but it isn't working correctly.
 * So set to 0 for now until someone can manage to get this
 * to work reliably. */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 11/26] cx231xx: remove current_norm usage.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The use of this field is deprecated since it will not work when multiple
device nodes reference the same video input (the video and vbi nodes in
this case). The norm field should be a device-global value.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c   |1 -
 drivers/media/usb/cx231xx/cx231xx-video.c |3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 28688db..a4091dd 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -2115,7 +2115,6 @@ static struct video_device cx231xx_mpeg_template = {
.ioctl_ops = &mpeg_ioctl_ops,
.minor = -1,
.tvnorms   = CX231xx_NORMS,
-   .current_norm  = V4L2_STD_NTSC_M,
 };
 
 void cx231xx_417_unregister(struct cx231xx *dev)
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 48a0269..617dc32 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -2229,7 +2229,6 @@ static const struct video_device cx231xx_video_template = 
{
.release  = video_device_release,
.ioctl_ops= &video_ioctl_ops,
.tvnorms  = V4L2_STD_ALL,
-   .current_norm = V4L2_STD_PAL,
 };
 
 static const struct v4l2_file_operations radio_fops = {
@@ -2300,7 +2299,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
 dev->name, CX231XX_VERSION);
 
/* set default norm */
-   /*dev->norm = cx231xx_video_template.current_norm; */
+   dev->norm = V4L2_STD_PAL;
dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev);
dev->interlaced = 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 23/26] cx231xx: don't reset width/height on first open.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The last set width/height must be preserved as per the spec.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index dc799de..0254bd6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1870,9 +1870,6 @@ static int cx231xx_v4l2_open(struct file *filp)
v4l2_fh_init(&fh->fh, vdev);
 
if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
-   dev->width = norm_maxw(dev);
-   dev->height = norm_maxh(dev);
-
/* Power up in Analog TV mode */
if (dev->board.external_av)
cx231xx_set_power_mode(dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 02/26] cx231xx: add required VIDIOC_DBG_G_CHIP_IDENT support.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

This fixes a v4l2_compliance failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index ffeedcd..794b83c 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1456,6 +1456,18 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
return rc;
 }
 
+static int vidioc_g_chip_ident(struct file *file, void *fh, struct 
v4l2_dbg_chip_ident *chip)
+{
+   chip->ident = V4L2_IDENT_NONE;
+   chip->revision = 0;
+   if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
+   if (v4l2_chip_match_host(&chip->match))
+   chip->ident = V4L2_IDENT_CX23100;
+   return 0;
+   }
+   return -EINVAL;
+}
+
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 
 /*
@@ -2514,6 +2526,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_tuner= vidioc_s_tuner,
.vidioc_g_frequency= vidioc_g_frequency,
.vidioc_s_frequency= vidioc_s_frequency,
+   .vidioc_g_chip_ident   = vidioc_g_chip_ident,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 17/26] cx231xx-417: fix g/try_fmt compliance problems

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Colorspace, field and priv were not set, and sizeimage was calculated
using the wrong values (dev->ts1.ts_packet_size and dev->ts1.ts_packet_count
can be 0 at module load).

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c |   34 +--
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index be8f7481..cbdc141 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1223,6 +1223,7 @@ static int bb_buf_setup(struct videobuf_queue *q,
 
return 0;
 }
+
 static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
 {
struct cx231xx_fh *fh = vq->priv_data;
@@ -1645,17 +1646,18 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
 {
struct cx231xx_fh  *fh  = file->private_data;
struct cx231xx *dev = fh->dev;
+
dprintk(3, "enter vidioc_g_fmt_vid_cap()\n");
-   f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+   f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.bytesperline = 0;
-   f->fmt.pix.sizeimage=
-   dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
-   f->fmt.pix.colorspace   = 0;
-   f->fmt.pix.width= dev->ts1.width;
-   f->fmt.pix.height   = dev->ts1.height;
-   f->fmt.pix.field= fh->vidq.field;
-   dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
-   dev->ts1.width, dev->ts1.height, fh->vidq.field);
+   f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
+   f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
+   f->fmt.pix.width = dev->ts1.width;
+   f->fmt.pix.height = dev->ts1.height;
+   f->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   f->fmt.pix.priv = 0;
+   dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n",
+   dev->ts1.width, dev->ts1.height);
dprintk(3, "exit vidioc_g_fmt_vid_cap()\n");
return 0;
 }
@@ -1665,14 +1667,16 @@ static int vidioc_try_fmt_vid_cap(struct file *file, 
void *priv,
 {
struct cx231xx_fh  *fh  = file->private_data;
struct cx231xx *dev = fh->dev;
+
dprintk(3, "enter vidioc_try_fmt_vid_cap()\n");
-   f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+   f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.bytesperline = 0;
-   f->fmt.pix.sizeimage=
-   dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
-   f->fmt.pix.colorspace   = 0;
-   dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
-   dev->ts1.width, dev->ts1.height, fh->vidq.field);
+   f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
+   f->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
+   f->fmt.pix.priv = 0;
+   dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n",
+   dev->ts1.width, dev->ts1.height);
dprintk(3, "exit vidioc_try_fmt_vid_cap()\n");
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 14/26] cx231xx: improve std handling.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Set the initial standard of subdevices instead of leaving it undefined.
Also update the width and height when a new standard is chosen and
return -EBUSY when attempting to change the standard while videobuf is
busy.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 311d106..208926f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -992,34 +992,34 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
struct v4l2_mbus_framefmt mbus_fmt;
-   struct v4l2_format f;
int rc;
 
rc = check_dev(dev);
if (rc < 0)
return rc;
 
-   cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm);
+   if (dev->norm == *norm)
+   return 0;
+
+   if (videobuf_queue_is_busy(&fh->vb_vidq))
+   return -EBUSY;
 
dev->norm = *norm;
 
/* Adjusts width/height, if needed */
-   f.fmt.pix.width = dev->width;
-   f.fmt.pix.height = dev->height;
-   vidioc_try_fmt_vid_cap(file, priv, &f);
+   dev->width = 720;
+   dev->height = (dev->norm & V4L2_STD_625_50) ? 576 : 480;
 
call_all(dev, core, s_std, dev->norm);
 
/* We need to reset basic properties in the decoder related to
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
-   v4l2_fill_mbus_format(&mbus_fmt, &f.fmt.pix, V4L2_MBUS_FMT_FIXED);
+   memset(&mbus_fmt, 0, sizeof(mbus_fmt));
+   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.width = dev->width;
+   mbus_fmt.height = dev->height;
call_all(dev, video, s_mbus_fmt, &mbus_fmt);
-   v4l2_fill_pix_format(&f.fmt.pix, &mbus_fmt);
-
-   /* set new image size */
-   dev->width = f.fmt.pix.width;
-   dev->height = f.fmt.pix.height;
 
/* do mode control overrides */
cx231xx_do_mode_ctrl_overrides(dev);
@@ -2306,6 +2306,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
/* Set the initial input */
video_mux(dev, dev->video_input);
 
+   call_all(dev, core, s_std, dev->norm);
+
v4l2_ctrl_handler_init(&dev->ctrl_handler, 10);
v4l2_ctrl_handler_init(&dev->radio_ctrl_handler, 5);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 08/26] cx231xx: fix vbi compliance issues.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Various v4l2-compliance fixes: remove unused sliced VBI functions, zero the
reserved fields of struct v4l2_vbi_format and implement the missing 
s_fmt_vbi_cap.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   67 -
 1 file changed, 17 insertions(+), 50 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 36ec4bc..f96fbd6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1867,47 +1867,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, 
void *priv,
return 0;
 }
 
-/* Sliced VBI ioctls */
-static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
-  struct v4l2_format *f)
-{
-   struct cx231xx_fh *fh = priv;
-   struct cx231xx *dev = fh->dev;
-   int rc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
-
-   f->fmt.sliced.service_set = 0;
-
-   call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced);
-
-   if (f->fmt.sliced.service_set == 0)
-   rc = -EINVAL;
-
-   return rc;
-}
-
-static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
-struct v4l2_format *f)
-{
-   struct cx231xx_fh *fh = priv;
-   struct cx231xx *dev = fh->dev;
-   int rc;
-
-   rc = check_dev(dev);
-   if (rc < 0)
-   return rc;
-
-   call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced);
-
-   if (f->fmt.sliced.service_set == 0)
-   return -EINVAL;
-
-   return 0;
-}
-
 /* RAW VBI ioctls */
 
 static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
@@ -1915,6 +1874,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void 
*priv,
 {
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
+
f->fmt.vbi.sampling_rate = 675 * 4;
f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
@@ -1926,6 +1886,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void 
*priv,
f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ?
PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263;
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
+   memset(f->fmt.vbi.reserved, 0, sizeof(f->fmt.vbi.reserved));
 
return 0;
 
@@ -1937,12 +1898,6 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, 
void *priv,
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
 
-   if (dev->vbi_stream_on && !fh->stream_on) {
-   cx231xx_errdev("%s device in use by another fh\n", __func__);
-   return -EBUSY;
-   }
-
-   f->type = V4L2_BUF_TYPE_VBI_CAPTURE;
f->fmt.vbi.sampling_rate = 675 * 4;
f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
@@ -1955,11 +1910,25 @@ static int vidioc_try_fmt_vbi_cap(struct file *file, 
void *priv,
f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ?
PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263;
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
+   memset(f->fmt.vbi.reserved, 0, sizeof(f->fmt.vbi.reserved));
 
return 0;
 
 }
 
+static int vidioc_s_fmt_vbi_cap(struct file *file, void *priv,
+ struct v4l2_format *f)
+{
+   struct cx231xx_fh *fh = priv;
+   struct cx231xx *dev = fh->dev;
+
+   if (dev->vbi_stream_on && !fh->stream_on) {
+   cx231xx_errdev("%s device in use by another fh\n", __func__);
+   return -EBUSY;
+   }
+   return vidioc_try_fmt_vbi_cap(file, priv, f);
+}
+
 static int vidioc_reqbufs(struct file *file, void *priv,
  struct v4l2_requestbuffers *rb)
 {
@@ -2421,10 +2390,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_s_fmt_vid_cap  = vidioc_s_fmt_vid_cap,
.vidioc_g_fmt_vbi_cap  = vidioc_g_fmt_vbi_cap,
.vidioc_try_fmt_vbi_cap= vidioc_try_fmt_vbi_cap,
-   .vidioc_s_fmt_vbi_cap  = vidioc_try_fmt_vbi_cap,
+   .vidioc_s_fmt_vbi_cap  = vidioc_s_fmt_vbi_cap,
.vidioc_cropcap= vidioc_cropcap,
-   .vidioc_g_fmt_sliced_vbi_cap   = vidioc_g_fmt_sliced_vbi_cap,
-   .vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap,
.vidioc_reqbufs= vidioc_reqbufs,
.vidioc_querybuf   = vidioc_querybuf,
.vidioc_qbuf   = vidioc_qbuf,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 07/26] cx231xx: fix frequency clamping.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Let the tuner clamp the frequency and store that clamped value.
This fixes a v4l2_compliance failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 90f4510..36ec4bc 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1356,11 +1356,8 @@ static int vidioc_g_frequency(struct file *file, void 
*priv,
if (f->tuner)
return -EINVAL;
 
-   f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->ctl_freq;
 
-   call_all(dev, tuner, g_frequency, f);
-
return 0;
 }
 
@@ -1383,16 +1380,12 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
if (0 != f->tuner)
return -EINVAL;
 
-   if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV))
-   return -EINVAL;
-   if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
-   return -EINVAL;
-
/* set pre channel change settings in DIF first */
rc = cx231xx_tuner_pre_channel_change(dev);
 
-   dev->ctl_freq = f->frequency;
call_all(dev, tuner, s_frequency, f);
+   call_all(dev, tuner, g_frequency, f);
+   dev->ctl_freq = f->frequency;
 
/* set post channel change settings in DIF first */
rc = cx231xx_tuner_post_channel_change(dev);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 06/26] cx231xx: zero priv field and use right width in try_fmt

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The priv field of v4l2_pix_format must be zeroed. Also fix a bug in try_fmt
where the current width was used instead of the width passed to try_fmt.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 8e0703c..90f4510 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1005,6 +1005,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
 
f->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   f->fmt.pix.priv = 0;
 
return 0;
 }
@@ -1045,10 +1046,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, 
void *priv,
f->fmt.pix.width = width;
f->fmt.pix.height = height;
f->fmt.pix.pixelformat = fmt->fourcc;
-   f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3;
+   f->fmt.pix.bytesperline = (width * fmt->depth + 7) >> 3;
f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
f->fmt.pix.field = V4L2_FIELD_INTERLACED;
+   f->fmt.pix.priv = 0;
 
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 10/26] cx231xx: add struct v4l2_fh to get prio and event support.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Required to resolve v4l2-compliance failures.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   31 -
 drivers/media/usb/cx231xx/cx231xx.h   |2 ++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index e2a4330..48a0269 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -35,6 +35,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1870,6 +1871,7 @@ static int cx231xx_v4l2_open(struct file *filp)
fh->radio = radio;
fh->type = fh_type;
filp->private_data = fh;
+   v4l2_fh_init(&fh->fh, vdev);
 
if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
dev->width = norm_maxw(dev);
@@ -1925,6 +1927,7 @@ static int cx231xx_v4l2_open(struct file *filp)
fh, &dev->lock);
}
mutex_unlock(&dev->lock);
+   v4l2_fh_add(&fh->fh);
 
return errCode;
 }
@@ -2019,12 +2022,15 @@ static int cx231xx_close(struct file *filp)
else
cx231xx_set_alt_setting(dev, INDEX_HANC, 0);
 
+   v4l2_fh_del(&fh->fh);
+   v4l2_fh_exit(&fh->fh);
kfree(fh);
dev->users--;
wake_up_interruptible_nr(&dev->open, 1);
return 0;
}
 
+   v4l2_fh_del(&fh->fh);
dev->users--;
if (!dev->users) {
videobuf_stop(&fh->vb_vidq);
@@ -2051,6 +2057,7 @@ static int cx231xx_close(struct file *filp)
/* set alternate 0 */
cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0);
}
+   v4l2_fh_exit(&fh->fh);
kfree(fh);
wake_up_interruptible_nr(&dev->open, 1);
return 0;
@@ -2107,29 +2114,37 @@ cx231xx_v4l2_read(struct file *filp, char __user *buf, 
size_t count,
  */
 static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table *wait)
 {
+   unsigned long req_events = poll_requested_events(wait);
struct cx231xx_fh *fh = filp->private_data;
struct cx231xx *dev = fh->dev;
+   unsigned res = 0;
int rc;
 
rc = check_dev(dev);
if (rc < 0)
-   return rc;
+   return POLLERR;
 
rc = res_get(fh);
 
if (unlikely(rc < 0))
return POLLERR;
 
+   if (v4l2_event_pending(&fh->fh))
+   res |= POLLPRI;
+   else
+   poll_wait(filp, &fh->fh.wait, wait);
+
+   if (!(req_events & (POLLIN | POLLRDNORM)))
+   return res;
+
if ((V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) ||
(V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)) {
-   unsigned int res;
-
mutex_lock(&dev->lock);
-   res = videobuf_poll_stream(filp, &fh->vb_vidq, wait);
+   res |= videobuf_poll_stream(filp, &fh->vb_vidq, wait);
mutex_unlock(&dev->lock);
return res;
}
-   return POLLERR;
+   return res | POLLERR;
 }
 
 /*
@@ -2203,6 +2218,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
 #endif
+   .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
 
 static struct video_device cx231xx_vbi_template;
@@ -2219,6 +2236,7 @@ static const struct v4l2_file_operations radio_fops = {
.owner   = THIS_MODULE,
.open   = cx231xx_v4l2_open,
.release = cx231xx_v4l2_close,
+   .poll = v4l2_ctrl_poll,
.ioctl   = video_ioctl2,
 };
 
@@ -2233,6 +2251,8 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_g_register  = vidioc_g_register,
.vidioc_s_register  = vidioc_s_register,
 #endif
+   .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
 
 static struct video_device cx231xx_radio_template = {
@@ -2258,6 +2278,7 @@ static struct video_device *cx231xx_vdev_init(struct 
cx231xx *dev,
vfd->release = video_device_release;
vfd->debug = video_debug;
vfd->lock = &dev->lock;
+   set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
 
snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
 
diff --git a/drivers/media/usb/cx231xx/cx231xx.h 
b/drivers/media/usb/cx231xx/cx231xx.h
index 53408ce..4c83ff5 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -429,6 +430,7 @@ struct cx231xx_audio {
 struct cx231xx;
 
 s

[RFCv2 PATCH 05/26] cx231xx: fix tuner compliance issues.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The g_tuner call wasn't passed on to the subdevices, g_frequency didn't
check for invalid tuners and a low-level function that was expected to
return 0 or a negative error returned a positive number instead, causing
s_frequency to return bogus errors.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-avcore.c |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c  |4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c 
b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index 7222079..4706ed3 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -2133,7 +2133,7 @@ int cx231xx_tuner_post_channel_change(struct cx231xx *dev)
 
status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval);
 
-   return status;
+   return status == sizeof(dwval) ? 0 : -EIO;
 }
 
 /**
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index f4243c6..8e0703c 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1322,6 +1322,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, 
struct v4l2_tuner *t)
t->capability = V4L2_TUNER_CAP_NORM;
t->rangehigh = 0xUL;
t->signal = 0x; /* LOCKED */
+   call_all(dev, tuner, g_tuner, t);
 
return 0;
 }
@@ -1350,6 +1351,9 @@ static int vidioc_g_frequency(struct file *file, void 
*priv,
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
 
+   if (f->tuner)
+   return -EINVAL;
+
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->ctl_freq;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 03/26] cx231xx: clean up radio support.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

Radio should not use video or audio inputs.
In addition, fix a bug in radio_g_tuner where s_tuner was called in the tuner
subdev instead of g_tuner.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   79 +++--
 1 file changed, 18 insertions(+), 61 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 794b83c..0436b12 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1874,20 +1874,24 @@ static int vidioc_querycap(struct file *file, void 
*priv,
strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
 
-   cap->device_caps =
-   V4L2_CAP_AUDIO  |
-   V4L2_CAP_READWRITE  |
-   V4L2_CAP_STREAMING;
-
-   if (vdev->vfl_type == VFL_TYPE_VBI)
-   cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
-   else
-   cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+   if (vdev->vfl_type == VFL_TYPE_RADIO)
+   cap->device_caps = V4L2_CAP_RADIO;
+   else {
+   cap->device_caps = V4L2_CAP_AUDIO | V4L2_CAP_READWRITE |
+   V4L2_CAP_STREAMING;
+   if (vdev->vfl_type == VFL_TYPE_VBI)
+   cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
+   else
+   cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+   }
if (dev->tuner_type != TUNER_ABSENT)
cap->device_caps |= V4L2_CAP_TUNER;
cap->capabilities = cap->device_caps |
V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_DEVICE_CAPS;
+   V4L2_CAP_AUDIO | V4L2_CAP_READWRITE |
+   V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
+   if (dev->radio_dev)
+   cap->capabilities |= V4L2_CAP_RADIO;
 
return 0;
 }
@@ -2054,53 +2058,19 @@ static int vidioc_dqbuf(struct file *file, void *priv, 
struct v4l2_buffer *b)
 /* RADIO ESPECIFIC IOCTLS  */
 /* --- */
 
-static int radio_querycap(struct file *file, void *priv,
- struct v4l2_capability *cap)
-{
-   struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
-
-   strlcpy(cap->driver, "cx231xx", sizeof(cap->driver));
-   strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
-   usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
-
-   cap->capabilities = V4L2_CAP_TUNER;
-   return 0;
-}
-
 static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
 {
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
 
-   if (unlikely(t->index > 0))
+   if (t->index)
return -EINVAL;
 
strcpy(t->name, "Radio");
-   t->type = V4L2_TUNER_RADIO;
-
-   call_all(dev, tuner, s_tuner, t);
-
-   return 0;
-}
 
-static int radio_enum_input(struct file *file, void *priv, struct v4l2_input 
*i)
-{
-   if (i->index != 0)
-   return -EINVAL;
-   strcpy(i->name, "Radio");
-   i->type = V4L2_INPUT_TYPE_TUNER;
-
-   return 0;
-}
-
-static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
-{
-   if (unlikely(a->index))
-   return -EINVAL;
+   call_all(dev, tuner, g_tuner, t);
 
-   strcpy(a->name, "Radio");
return 0;
 }
-
 static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
 {
struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev;
@@ -2113,16 +2083,6 @@ static int radio_s_tuner(struct file *file, void *priv, 
struct v4l2_tuner *t)
return 0;
 }
 
-static int radio_s_audio(struct file *file, void *fh, const struct v4l2_audio 
*a)
-{
-   return 0;
-}
-
-static int radio_s_input(struct file *file, void *fh, unsigned int i)
-{
-   return 0;
-}
-
 static int radio_queryctrl(struct file *file, void *priv,
   struct v4l2_queryctrl *c)
 {
@@ -2551,18 +2511,15 @@ static const struct v4l2_file_operations radio_fops = {
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
-   .vidioc_querycap= radio_querycap,
+   .vidioc_querycap= vidioc_querycap,
.vidioc_g_tuner = radio_g_tuner,
-   .vidioc_enum_input  = radio_enum_input,
-   .vidioc_g_audio = radio_g_audio,
.vidioc_s_tuner = radio_s_tuner,
-   .vidioc_s_audio = radio_s_audio,
-   .vidioc_s_input = radio_s_input,
.vidioc_queryctrl   = radio_queryctrl,
.vidioc_g_ctrl  = vidioc_g_ctrl,
.vidioc_s_ctrl  = vidioc_s_ctrl,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
+   .vidioc_g_chip_ident = vidioc_g_chip_ident,
 #

[RFCv2 PATCH 04/26] cx231xx: remove broken audio input support from the driver.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

The audio selection code is broken. Audio and video indices were
mixed up and s_audio would reject changing the audio input to
something else anyway, so what's the point?

All the audio input code has been removed.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   52 +
 1 file changed, 8 insertions(+), 44 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 0436b12..f4243c6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1231,44 +1231,6 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int i)
return 0;
 }
 
-static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
-{
-   struct cx231xx_fh *fh = priv;
-   struct cx231xx *dev = fh->dev;
-
-   switch (a->index) {
-   case CX231XX_AMUX_VIDEO:
-   strcpy(a->name, "Television");
-   break;
-   case CX231XX_AMUX_LINE_IN:
-   strcpy(a->name, "Line In");
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   a->index = dev->ctl_ainput;
-   a->capability = V4L2_AUDCAP_STEREO;
-
-   return 0;
-}
-
-static int vidioc_s_audio(struct file *file, void *priv, const struct 
v4l2_audio *a)
-{
-   struct cx231xx_fh *fh = priv;
-   struct cx231xx *dev = fh->dev;
-   int status = 0;
-
-   /* Doesn't allow manual routing */
-   if (a->index != dev->ctl_ainput)
-   return -EINVAL;
-
-   dev->ctl_ainput = INPUT(a->index)->amux;
-   status = cx231xx_set_audio_input(dev, dev->ctl_ainput);
-
-   return status;
-}
-
 static int vidioc_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *qc)
 {
@@ -1877,8 +1839,7 @@ static int vidioc_querycap(struct file *file, void *priv,
if (vdev->vfl_type == VFL_TYPE_RADIO)
cap->device_caps = V4L2_CAP_RADIO;
else {
-   cap->device_caps = V4L2_CAP_AUDIO | V4L2_CAP_READWRITE |
-   V4L2_CAP_STREAMING;
+   cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
if (vdev->vfl_type == VFL_TYPE_VBI)
cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
else
@@ -1886,9 +1847,8 @@ static int vidioc_querycap(struct file *file, void *priv,
}
if (dev->tuner_type != TUNER_ABSENT)
cap->device_caps |= V4L2_CAP_TUNER;
-   cap->capabilities = cap->device_caps |
+   cap->capabilities = cap->device_caps | V4L2_CAP_READWRITE |
V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_AUDIO | V4L2_CAP_READWRITE |
V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
if (dev->radio_dev)
cap->capabilities |= V4L2_CAP_RADIO;
@@ -2463,8 +2423,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_g_fmt_vbi_cap  = vidioc_g_fmt_vbi_cap,
.vidioc_try_fmt_vbi_cap= vidioc_try_fmt_vbi_cap,
.vidioc_s_fmt_vbi_cap  = vidioc_try_fmt_vbi_cap,
-   .vidioc_g_audio=  vidioc_g_audio,
-   .vidioc_s_audio= vidioc_s_audio,
.vidioc_cropcap= vidioc_cropcap,
.vidioc_g_fmt_sliced_vbi_cap   = vidioc_g_fmt_sliced_vbi_cap,
.vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap,
@@ -2553,6 +2511,12 @@ static struct video_device *cx231xx_vdev_init(struct 
cx231xx *dev,
snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
 
video_set_drvdata(vfd, dev);
+   if (dev->tuner_type == TUNER_ABSENT) {
+   v4l2_disable_ioctl(vfd, VIDIOC_G_FREQUENCY);
+   v4l2_disable_ioctl(vfd, VIDIOC_S_FREQUENCY);
+   v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER);
+   v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER);
+   }
return vfd;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 00/26] cx231xx: v4l2-compliance fixes, big-endian fixes

2013-02-09 Thread Hans Verkuil
Hi all,

This patch series cleans up the cx231xx driver based on v4l2-compliance
reports.

I have tested this on various cx231xx devices. However, I have no hardware
that supports the radio tuner, so that's untested.

Also note that the MPEG encoder support does not seem to work. It didn't work
before these patches are applied, and it doesn't work afterwards. At best it
will stream for a bit and then hang the machine. While I did convert the 417
code to have it pass the compliance tests, I did disable 417 support in the
single card that supports it (gracefully provided by Conexant for which I
want to thank them!) until someone can find the time to dig into it and
figure out what is wrong. Note that that board is an evaluation board and not
a consumer product.

In addition the vbi support is flaky as well. It was flaky before this patch
series, and it is equally flaky afterwards. I have managed to get something
to work only on rare occasions and only for NTSC, never for PAL.

Finally I have tested this on a big-endian machine so there are a bunch of
patches fixing a lot of endianness problems.

A general note regarding this driver: I've found this to be a particularly
fragile driver. Things like changing formats/standards, unplugging at
unexpected times and vbi support all seem very prone to errors. I have
serious doubts about the disconnect handling: this code really should use the
core support for handling such events (in particular the v4l2_device release
callback).

New since v1:

- I reverted a bunch of bytesperline calculation changes: those aren't needed
  for this driver (patch 06/26)
- Some vbi fmt patches ended up in patch 07 instead of 08, moved them to the
  right patch. No actual code was changed.
- Patches 21-26 are new.

All other patches are unchanged.

If there are no comments, then I'll post a pull request for this series in a
week.

Regards,

Hans

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 01/26] cx231xx: add device_caps support to QUERYCAP.

2013-02-09 Thread Hans Verkuil
From: Hans Verkuil 

This fixes a v4l2_compliance failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-video.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 06376d9..ffeedcd 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1854,6 +1854,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
 static int vidioc_querycap(struct file *file, void *priv,
   struct v4l2_capability *cap)
 {
+   struct video_device *vdev = video_devdata(file);
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
 
@@ -1861,17 +1862,20 @@ static int vidioc_querycap(struct file *file, void 
*priv,
strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
 
-   cap->capabilities = V4L2_CAP_VBI_CAPTURE |
-#if 0
-   V4L2_CAP_SLICED_VBI_CAPTURE |
-#endif
-   V4L2_CAP_VIDEO_CAPTURE  |
+   cap->device_caps =
V4L2_CAP_AUDIO  |
V4L2_CAP_READWRITE  |
V4L2_CAP_STREAMING;
 
+   if (vdev->vfl_type == VFL_TYPE_VBI)
+   cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
+   else
+   cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
if (dev->tuner_type != TUNER_ABSENT)
-   cap->capabilities |= V4L2_CAP_TUNER;
+   cap->device_caps |= V4L2_CAP_TUNER;
+   cap->capabilities = cap->device_caps |
+   V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
+   V4L2_CAP_DEVICE_CAPS;
 
return 0;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL FOR v3.8] Regression fix: cx18/ivtv: remove __init from a non-init function.

2013-02-09 Thread Hans Verkuil
Mauro,

Please fast-track this for 3.8. Two days ago I discovered that commits made
earlier for 3.8 kill ivtv and cx18 (as in: unable to boot, instant crash) since
a function was made __init that was actually called after initialization.

We are already at rc7 and this should make it for 3.8 if at all possible.
Without this patch anyone with a cx18/ivtv will crash immediately as soon
as they upgrade to 3.8.

This second version of the pull request also corrects two headers where __init
was present for the snd_cx18/ivtv_pcm_create function. The function in the C
source didn't have that annotation, so the first version of my fix worked fine,
it just generated false warnings which are now fixed as well.

Regards,

  Hans

The following changes since commit 4880f56438ef56457edd5548b257382761591998:

  [media] stv0900: remove unnecessary null pointer check (2013-02-08 18:05:48 
-0200)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git ivtv2

for you to fetch changes up to 6a2f1a23e007690d498f7a904bc9fc408f0afc5f:

  cx18/ivtv: fix regression: remove __init from a non-init function. 
(2013-02-09 09:40:10 +0100)


Hans Verkuil (1):
  cx18/ivtv: fix regression: remove __init from a non-init function.

 drivers/media/pci/cx18/cx18-alsa-main.c |2 +-
 drivers/media/pci/cx18/cx18-alsa-pcm.h  |2 +-
 drivers/media/pci/ivtv/ivtv-alsa-main.c |2 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.h  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL FOR v3.8] Regression fix: cx18/ivtv: remove __init from a non-init function.

2013-02-09 Thread Hans Verkuil
On Sat February 9 2013 01:33:44 Mauro Carvalho Chehab wrote:
> Em Fri, 8 Feb 2013 09:40:27 +0100
> Hans Verkuil  escreveu:
> 
> > Mauro,
> > 
> > Please fast-track this for 3.8. Yesterday I discovered that commits made 
> > earlier
> > for 3.8 kill ivtv and cx18 (as in: unable to boot, instant crash) since a
> > function was made __init that was actually called *after* initialization.
> > 
> > We are already at rc6 and this *must* make it for 3.8. Without this patch
> > anyone with a cx18/ivtv will crash immediately as soon as they upgrade to 
> > 3.8.
> > 
> > Regards,
> > 
> > Hans
> > 
> > The following changes since commit 248ac368ce4b3cd36515122d888403909d7a2500:
> > 
> >   [media] s5p-fimc: Fix fimc-lite entities deregistration (2013-02-06 
> > 09:42:19 -0200)
> > 
> > are available in the git repository at:
> > 
> >   git://linuxtv.org/hverkuil/media_tree.git ivtv
> > 
> > for you to fetch changes up to ddf276062e68607323fca363b99bdf426dddad9b:
> > 
> >   cx18/ivtv: fix regression: remove __init from a non-init function. 
> > (2013-02-08 09:30:11 +0100)
> > 
> > 
> > Hans Verkuil (1):
> >   cx18/ivtv: fix regression: remove __init from a non-init function.
> 
> Hmm... the patch seems to be broken/incomplete:

It turned out that the cx18/ivtv-alsa-pcm.h header had an __init annotation,
although the corresponding function in the c source didn't. And
CONFIG_DEBUG_SECTION_MISMATCH was turned off, so I didn't see the full warning
message (now corrected). The fact that __init wasn't present in the C source
is the reason why the fix worked.

I'll post a new pull request fixing the headers as well.

Regards,

Hans



> 
> 
> WARNING: drivers/media/pci/cx18/cx18-alsa.o(.text+0x449): Section mismatch in 
> reference from the function cx18_alsa_load() to the function 
> .init.text:snd_cx18_pcm_create()
> The function cx18_alsa_load() references
> the function __init snd_cx18_pcm_create().
> This is often because cx18_alsa_load lacks a __init 
> annotation or the annotation of snd_cx18_pcm_create is wrong.
> 
> WARNING: drivers/media/pci/cx18/built-in.o(.text+0x1be69): Section mismatch 
> in reference from the function cx18_alsa_load() to the function 
> .init.text:snd_cx18_pcm_create()
> The function cx18_alsa_load() references
> the function __init snd_cx18_pcm_create().
> This is often because cx18_alsa_load lacks a __init 
> annotation or the annotation of snd_cx18_pcm_create is wrong.
> 
> WARNING: drivers/media/pci/ivtv/ivtv-alsa.o(.text+0x454): Section mismatch in 
> reference from the function ivtv_alsa_load() to the function 
> .init.text:snd_ivtv_pcm_create()
> The function ivtv_alsa_load() references
> the function __init snd_ivtv_pcm_create().
> This is often because ivtv_alsa_load lacks a __init 
> annotation or the annotation of snd_ivtv_pcm_create is wrong.
> 
> WARNING: drivers/media/pci/ivtv/built-in.o(.text+0x20790): Section mismatch 
> in reference from the function ivtv_alsa_load() to the function 
> .init.text:snd_ivtv_pcm_create()
> The function ivtv_alsa_load() references
> the function __init snd_ivtv_pcm_create().
> This is often because ivtv_alsa_load lacks a __init 
> annotation or the annotation of snd_ivtv_pcm_create is wrong.
> 
> WARNING: drivers/media/pci/built-in.o(.text+0x6b958): Section mismatch in 
> reference from the function ivtv_alsa_load() to the function 
> .init.text:snd_ivtv_pcm_create()
> The function ivtv_alsa_load() references
> the function __init snd_ivtv_pcm_create().
> This is often because ivtv_alsa_load lacks a __init 
> annotation or the annotation of snd_ivtv_pcm_create is wrong.
> 
> WARNING: drivers/media/pci/built-in.o(.text+0x9fc21): Section mismatch in 
> reference from the function cx18_alsa_load() to the function 
> .init.text:snd_cx18_pcm_create()
> The function cx18_alsa_load() references
> the function __init snd_cx18_pcm_create().
> This is often because cx18_alsa_load lacks a __init 
> annotation or the annotation of snd_cx18_pcm_create is wrong.
> 
> WARNING: drivers/media/built-in.o(.text+0x289f48): Section mismatch in 
> reference from the function ivtv_alsa_load() to the function 
> .init.text:snd_ivtv_pcm_create()
> The function ivtv_alsa_load() references
> the function __init snd_ivtv_pcm_create().
> This is often because ivtv_alsa_load lacks a __init 
> annotation or the annotation of snd_ivtv_pcm_create is wrong.
> 
> WARNING: drivers/media/built-in.o(.text+0x2be211): Section mismatch in 
> reference from the function cx18_alsa_load() to the function 
> .init.text:snd_cx18_pcm_create()
> The function cx18_alsa_load() references
> the function __init snd_cx18_pcm_create().
> This is often because cx18_alsa_load lacks a __init 
> annotation or the annotation of snd_cx18_pcm_create is wrong.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kerne