V4L/DVB (8474): pvrusb2: Enable IR chip on HVR-1900 class devices
authorMike Isely <isely@pobox.com>
Fri, 25 Jul 2008 22:35:31 +0000 (19:35 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sat, 26 Jul 2008 15:54:35 +0000 (12:54 -0300)
The Zilog IR chip on HVR-1900 devices is held in reset when the device
initializes.  We have to bring this chip out of reset before LIRC has
any chance of operating the chip.  So do it.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/pvrusb2/pvrusb2-devattr.c
drivers/media/video/pvrusb2/pvrusb2-devattr.h
drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c

index 5d036e7e3f07707eeecd20b089021ef51d4051e2..e3b0511970873237a08abd26f1d6eaf6f89728b7 100644 (file)
@@ -97,13 +97,13 @@ static const struct pvr2_device_desc pvr2_device_24xxx = {
                .flag_has_cx25840 = !0,
                .flag_has_wm8775 = !0,
                .flag_has_hauppauge_rom = !0,
-               .flag_has_hauppauge_custom_ir = !0,
                .flag_has_analogtuner = !0,
                .flag_has_fmradio = !0,
                .flag_has_composite = !0,
                .flag_has_svideo = !0,
                .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
                .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
+               .ir_scheme = PVR2_IR_SCHEME_24XXX,
 };
 
 
@@ -344,6 +344,7 @@ static const struct pvr2_device_desc pvr2_device_73xxx = {
                .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
                .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
                .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
+               .ir_scheme = PVR2_IR_SCHEME_ZILOG,
 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
                .dvb_props = &pvr2_73xxx_dvb_props,
 #endif
@@ -453,6 +454,7 @@ static const struct pvr2_device_desc pvr2_device_750xx = {
                .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
                .default_std_mask = V4L2_STD_NTSC_M,
                .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
+               .ir_scheme = PVR2_IR_SCHEME_ZILOG,
 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
                .dvb_props = &pvr2_750xx_dvb_props,
 #endif
@@ -474,6 +476,7 @@ static const struct pvr2_device_desc pvr2_device_751xx = {
                .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
                .default_std_mask = V4L2_STD_NTSC_M,
                .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
+               .ir_scheme = PVR2_IR_SCHEME_ZILOG,
 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
                .dvb_props = &pvr2_751xx_dvb_props,
 #endif
index e23ce1d2edd772e9996652e18df182ce70c3744c..cb3a33eb027660a12c3dc355271dbad6c35c69ac 100644 (file)
@@ -48,6 +48,10 @@ struct pvr2_string_table {
 #define PVR2_LED_SCHEME_NONE 0
 #define PVR2_LED_SCHEME_HAUPPAUGE 1
 
+#define PVR2_IR_SCHEME_NONE 0
+#define PVR2_IR_SCHEME_24XXX 1
+#define PVR2_IR_SCHEME_ZILOG 2
+
 /* This describes a particular hardware type (except for the USB device ID
    which must live in a separate structure due to environmental
    constraints).  See the top of pvrusb2-hdw.c for where this is
@@ -126,15 +130,19 @@ struct pvr2_device_desc {
           ensure that it is found. */
        unsigned int flag_has_wm8775:1;
 
-       /* Device has IR hardware that can be faked into looking like a
-          normal Hauppauge i2c IR receiver.  This is currently very
-          specific to the 24xxx device, where Hauppauge had replaced their
-          'standard' I2C IR receiver with a bunch of FPGA logic controlled
-          directly via the FX2.  Turning this on tells the pvrusb2 driver
-          to virtualize the presence of the non-existant IR receiver chip and
-          implement the virtual receiver in terms of appropriate FX2
-          commands. */
-       unsigned int flag_has_hauppauge_custom_ir:1;
+       /* Indicate any specialized IR scheme that might need to be
+          supported by this driver.  If not set, then it is assumed that
+          IR can work without help from the driver (which is frequently
+          the case).  This is otherwise set to one of
+          PVR2_IR_SCHEME_xxxx.  For "xxxx", the value "24XXX" indicates a
+          Hauppauge 24xxx class device which has an FPGA-hosted IR
+          receiver that can only be reached via FX2 command codes.  In
+          that case the pvrusb2 driver will emulate the behavior of the
+          older 29xxx device's IR receiver (a "virtual" I2C chip) in terms
+          of those command codes.  For the value "ZILOG", we're dealing
+          with an IR chip that must be taken out of reset via another FX2
+          command code (which is the case for HVR-1950 devices). */
+       unsigned int ir_scheme:2;
 
        /* These bits define which kinds of sources the device can handle.
           Note: Digital tuner presence is inferred by the
index b58369e7f30bcc800d8207784463ff6bc3e7c4c4..614755ea2ea3a92e9a7713748f6f20cf2c336510 100644 (file)
@@ -24,6 +24,8 @@
 #define FX2CMD_MEM_WRITE_DWORD  0x01u
 #define FX2CMD_MEM_READ_DWORD   0x02u
 
+#define FX2CMD_HCW_ZILOG_RESET  0x10u /* 1=reset 0=release */
+
 #define FX2CMD_MEM_READ_64BYTES 0x28u
 
 #define FX2CMD_REG_WRITE        0x04u
index a5217a2cf4c0fa5b96451237d136ee0d6b7907eb..f051c6aa7f1f223cd36744df1b6cc2af4b26d82a 100644 (file)
@@ -250,6 +250,7 @@ struct pvr2_fx2cmd_descdef {
 static const struct pvr2_fx2cmd_descdef pvr2_fx2cmd_desc[] = {
        {FX2CMD_MEM_WRITE_DWORD, "write encoder dword"},
        {FX2CMD_MEM_READ_DWORD, "read encoder dword"},
+       {FX2CMD_HCW_ZILOG_RESET, "zilog IR reset control"},
        {FX2CMD_MEM_READ_64BYTES, "read encoder 64bytes"},
        {FX2CMD_REG_WRITE, "write encoder register"},
        {FX2CMD_REG_READ, "read encoder register"},
@@ -1711,6 +1712,14 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
                if (!pvr2_hdw_dev_ok(hdw)) return;
        }
 
+       /* Take the IR chip out of reset, if appropriate */
+       if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_ZILOG) {
+               pvr2_issue_simple_cmd(hdw,
+                                     FX2CMD_HCW_ZILOG_RESET |
+                                     (1 << 8) |
+                                     ((0) << 16));
+       }
+
        // This step MUST happen after the earlier powerup step.
        pvr2_i2c_core_init(hdw);
        if (!pvr2_hdw_dev_ok(hdw)) return;
index 9d3c18b24744f6cb1e3d3db8c29c6050a4b65c21..e600576a6c4b5b7092293052230e54ff3a857cec 100644 (file)
@@ -979,7 +979,9 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
                printk(KERN_INFO "%s: IR disabled\n",hdw->name);
                hdw->i2c_func[0x18] = i2c_black_hole;
        } else if (ir_mode[hdw->unit_number] == 1) {
-               if (hdw->hdw_desc->flag_has_hauppauge_custom_ir) {
+               if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_24XXX) {
+                       /* This comment is present PURELY to get
+                          checkpatch.pl to STFU.  Lovely, eh? */
                        hdw->i2c_func[0x18] = i2c_24xxx_ir;
                }
        }