The patch number 8097 was added via Michael Krufky <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Steven Toth  <[EMAIL PROTECTED]>
xc5000: check device hardware state to determine if firmware download is needed


This patch ensures that the xc5000 will have firmware loaded as needed if the
part is powered down or reset via gpio from the host. An example of this, in
some cases, could be after the system resumes from standby or hibernate modes.

Signed-off-by: Michael Krufky <[EMAIL PROTECTED]>


---

 linux/drivers/media/common/tuners/xc5000.c      |   30 ++++++++++++----
 linux/drivers/media/common/tuners/xc5000_priv.h |    1 
 2 files changed, 23 insertions(+), 8 deletions(-)

diff -r eeeaefde1a01 -r b0a0840dff93 linux/drivers/media/common/tuners/xc5000.c
--- a/linux/drivers/media/common/tuners/xc5000.c        Sat Jun 21 15:32:41 
2008 -0400
+++ b/linux/drivers/media/common/tuners/xc5000.c        Sat Jun 21 17:06:02 
2008 -0400
@@ -177,6 +177,7 @@ static XC_TV_STANDARD XC5000_Standard[MA
        {"FM Radio-INPUT1",   0x0208, 0x9002}
 };
 
+static int  xc5000_is_firmware_loaded(struct dvb_frontend *fe);
 static int  xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len);
 static int  xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len);
 static void xc5000_TunerReset(struct dvb_frontend *fe);
@@ -352,7 +353,7 @@ static int xc_SetTVStandard(struct xc500
 
 static int xc_shutdown(struct xc5000_priv *priv)
 {
-       return 0;
+       return XC_RESULT_SUCCESS;
        /* Fixme: cannot bring tuner back alive once shutdown
         *        without reloading the driver modules.
         *    return xc_write_reg(priv, XREG_POWER_DOWN, 0);
@@ -704,6 +705,25 @@ static int xc5000_set_params(struct dvb_
        return 0;
 }
 
+static int xc5000_is_firmware_loaded(struct dvb_frontend *fe)
+{
+       struct xc5000_priv *priv = fe->tuner_priv;
+       int ret;
+       u16 id;
+
+       ret = xc5000_readreg(priv, XREG_PRODUCT_ID, &id);
+       if (ret == XC_RESULT_SUCCESS) {
+               if (id == XC_PRODUCT_ID_FW_NOT_LOADED)
+                       ret = XC_RESULT_RESET_FAILURE;
+               else
+                       ret = XC_RESULT_SUCCESS;
+       }
+
+       dprintk(1, "%s() returns %s id = 0x%x\n", __func__,
+               ret == XC_RESULT_SUCCESS ? "True" : "False", id);
+       return ret;
+}
+
 static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe);
 
 static int xc5000_set_analog_params(struct dvb_frontend *fe,
@@ -712,7 +732,7 @@ static int xc5000_set_analog_params(stru
        struct xc5000_priv *priv = fe->tuner_priv;
        int ret;
 
-       if(priv->fwloaded == 0)
+       if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS)
                xc_load_fw_and_init_tuner(fe);
 
        dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n",
@@ -827,11 +847,10 @@ static int xc_load_fw_and_init_tuner(str
        struct xc5000_priv *priv = fe->tuner_priv;
        int ret = 0;
 
-       if (priv->fwloaded == 0) {
+       if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) {
                ret = xc5000_fwupload(fe);
                if (ret != XC_RESULT_SUCCESS)
                        return ret;
-               priv->fwloaded = 1;
        }
 
        /* Start the tuner self-calibration process */
@@ -871,7 +890,6 @@ static int xc5000_sleep(struct dvb_front
                return -EREMOTEIO;
        }
        else {
-               /* priv->fwloaded = 0; */
                return XC_RESULT_SUCCESS;
        }
 }
@@ -952,7 +970,6 @@ struct dvb_frontend *xc5000_attach(struc
                        cfg->i2c_address);
                printk(KERN_INFO
                        "xc5000: Firmware has been loaded previously\n");
-               priv->fwloaded = 1;
                break;
        case XC_PRODUCT_ID_FW_NOT_LOADED:
                printk(KERN_INFO
@@ -960,7 +977,6 @@ struct dvb_frontend *xc5000_attach(struc
                        cfg->i2c_address);
                printk(KERN_INFO
                        "xc5000: Firmware has not been loaded previously\n");
-               priv->fwloaded = 0;
                break;
        default:
                printk(KERN_ERR
diff -r eeeaefde1a01 -r b0a0840dff93 
linux/drivers/media/common/tuners/xc5000_priv.h
--- a/linux/drivers/media/common/tuners/xc5000_priv.h   Sat Jun 21 15:32:41 
2008 -0400
+++ b/linux/drivers/media/common/tuners/xc5000_priv.h   Sat Jun 21 17:06:02 
2008 -0400
@@ -30,7 +30,6 @@ struct xc5000_priv {
        u32 bandwidth;
        u8  video_standard;
        u8  rf_mode;
-       u8  fwloaded;
 
        void *devptr;
 };


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/b0a0840dff93c0977beb71ed5ed7a5b5c27e3c60

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to