[media] cx88: properly maintain decoder config when using MPEG encoder
authorDevin Heitmueller <dheitmueller@kernellabs.com>
Thu, 14 Jul 2011 15:44:46 +0000 (12:44 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 27 Jul 2011 20:56:00 +0000 (17:56 -0300)
The cx88 driver would force core->input to always be zero when doing the
the request_acquire().  While it wasn't actually changing the input register
in the hardware, the driver makes decision based on the current input.  In
particular, it decides whether to do things like enabling the comb filter
when on a composite input but disabling it on s-video.  So for example, on
the HVR-1300, using the s-video input with the MPEG encoder would end up with
the video decoder core configured as though the input type were composite.

In short, the driver state did not match the hardware state.

This patch does two things:

1.  It forces the input to zero only if actually switching to DVB mode.  This
prevents the input from changing when the blackbird driver opens the device.

2.  Keep track of what the input was set to when switching to DVB, and reset
it back when done.  This eliminates a condition where for example the user
had the analog side of the board set to capture on the s-video input, then
he used DVB for a bit, then the analog input would unexpectedly be set to
the tuner input.

This work was sponsored by Anevia S.A.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Florent Audebert <florent.audebert@anevia.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88.h

index ccd8797..cd5386e 100644 (file)
@@ -614,13 +614,17 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
            core->active_type_id != drv->type_id)
                return -EBUSY;
 
-       core->input = 0;
-       for (i = 0;
-            i < (sizeof(core->board.input) / sizeof(struct cx88_input));
-            i++) {
-               if (core->board.input[i].type == CX88_VMUX_DVB) {
-                       core->input = i;
-                       break;
+       if (drv->type_id == CX88_MPEG_DVB) {
+               /* When switching to DVB, always set the input to the tuner */
+               core->last_analog_input = core->input;
+               core->input = 0;
+               for (i = 0;
+                    i < (sizeof(core->board.input) / sizeof(struct cx88_input));
+                    i++) {
+                       if (core->board.input[i].type == CX88_VMUX_DVB) {
+                               core->input = i;
+                               break;
+                       }
                }
        }
 
@@ -645,6 +649,12 @@ static int cx8802_request_release(struct cx8802_driver *drv)
 
        if (drv->advise_release && --core->active_ref == 0)
        {
+               if (drv->type_id == CX88_MPEG_DVB) {
+                       /* If the DVB driver is releasing, reset the input
+                          state to the last configured analog input */
+                       core->input = core->last_analog_input;
+               }
+
                drv->advise_release(drv);
                core->active_type_id = CX88_BOARD_NONE;
                mpeg_dbg(1,"%s() Post release GPIO=%x\n", __func__, cx_read(MO_GP0_IO));
index 425c9fb..fa8d307 100644 (file)
@@ -377,6 +377,7 @@ struct cx88_core {
        u32                        audiomode_manual;
        u32                        audiomode_current;
        u32                        input;
+       u32                        last_analog_input;
        u32                        astat;
        u32                        use_nicam;
        unsigned long              last_change;