diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c index cf8337dd7bdf747535e53f62f0c9fa88740c72c2..0a2fdcde2f96ac68c35c00b72fb8adebdc850552 100644 --- a/drivers/media/video/saa7164/saa7164-api.c +++ b/drivers/media/video/saa7164/saa7164-api.c @@ -24,6 +24,31 @@ #include "saa7164.h" +int saa7164_api_get_load_info(struct saa7164_dev *dev, tmFwInfoStruct_t *i) +{ + int ret, debug; + + if (!(debug & DBGLVL_CPU)) + return 0; + + dprintk(DBGLVL_API, "%s()\n", __func__); + + i->deviceinst = 0; + i->devicespec = 0; + i->mode = 0; + i->status = 0; + + ret = saa7164_cmd_send(dev, 0, GET_CUR, + GET_FW_STATUS_CONTROL, sizeof(tmFwInfoStruct_t), i); + if (ret != SAA_OK) { + printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); + } + + printk(KERN_INFO "saa7164[%d]-CPU: %d percent", dev->nr, i->CPULoad); + + return ret; +} + int saa7164_api_collect_debug(struct saa7164_dev *dev) { tmComResDebugGetData_t d; diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c index db4b39cb72ac25ef5b27dfb642db0c2a4a8eb7c6..5913ed75cb9056e8bb0623331b8730e16ffac1aa 100644 --- a/drivers/media/video/saa7164/saa7164-core.c +++ b/drivers/media/video/saa7164/saa7164-core.c @@ -1191,6 +1191,8 @@ static int saa7164_proc_create(void) static int saa7164_thread_function(void *data) { struct saa7164_dev *dev = data; + tmFwInfoStruct_t fwinfo; + u64 last_poll_time = 0; dprintk(DBGLVL_THR, "thread started\n"); @@ -1205,8 +1207,16 @@ static int saa7164_thread_function(void *data) dprintk(DBGLVL_THR, "thread running\n"); /* Dump the firmware debug message to console */ + /* Polling this costs us 1-2% of the arm CPU */ + /* convert this into a respnde to interrupt 0x7a */ saa7164_api_collect_debug(dev); + /* Monitor CPU load every 1 second */ + if ((last_poll_time + 1000 /* ms */) < jiffies_to_msecs(jiffies)) { + saa7164_api_get_load_info(dev, &fwinfo); + last_poll_time = jiffies_to_msecs(jiffies); + } + } dprintk(DBGLVL_THR, "thread exiting\n"); diff --git a/drivers/media/video/saa7164/saa7164-reg.h b/drivers/media/video/saa7164/saa7164-reg.h index 153da76e857549d470703c5bc8c328833cbece1e..2bbf81583d33e668d36de6787836926d5398e5e9 100644 --- a/drivers/media/video/saa7164/saa7164-reg.h +++ b/drivers/media/video/saa7164/saa7164-reg.h @@ -60,6 +60,7 @@ #define GET_STRING_CONTROL 0x03 #define GET_LANGUAGE_CONTROL 0x05 #define SET_POWER_CONTROL 0x07 +#define GET_FW_STATUS_CONTROL 0x08 #define GET_FW_VERSION_CONTROL 0x09 #define SET_DEBUG_LEVEL_CONTROL 0x0B #define GET_DEBUG_DATA_CONTROL 0x0C diff --git a/drivers/media/video/saa7164/saa7164-types.h b/drivers/media/video/saa7164/saa7164-types.h index ea245ba563b7de3e6a27b676ffecc5c327e1b99d..e66c29d6ead33a600a3fca6d1ee2ff886c6d3070 100644 --- a/drivers/media/video/saa7164/saa7164-types.h +++ b/drivers/media/video/saa7164/saa7164-types.h @@ -446,3 +446,15 @@ typedef struct u8 ucDebugData[256]; } __attribute__((packed)) tmComResDebugGetData_t; +typedef struct +{ + u32 status; + u32 mode; + u32 devicespec; + u32 deviceinst; + u32 CPULoad; + u32 RemainHeap; + u32 CPUClock; + u32 RAMSpeed; +} __attribute__((packed)) tmFwInfoStruct_t; + diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h index 88b9b91bf4f5185d66f8cec0be83e013e9f468f9..329564452e27e3432cff72cf294a6132582d9937 100644 --- a/drivers/media/video/saa7164/saa7164.h +++ b/drivers/media/video/saa7164/saa7164.h @@ -112,6 +112,7 @@ #define DBGLVL_ENC 1024 #define DBGLVL_VBI 2048 #define DBGLVL_THR 4096 +#define DBGLVL_CPU 8192 #define SAA7164_NORMS ( V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 ) @@ -551,6 +552,7 @@ int saa7164_api_get_videomux(struct saa7164_port *port); int saa7164_api_set_vbi_format(struct saa7164_port *port); int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level); int saa7164_api_collect_debug(struct saa7164_dev *dev); +int saa7164_api_get_load_info(struct saa7164_dev *dev, tmFwInfoStruct_t *i); /* ----------------------------------------------------------- */ /* saa7164-cards.c */