aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-24 09:14:17 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-04 12:35:18 -0500
commitdc5a91d49d147f47b2305ad76d67982462c5ac5f (patch)
tree8ea6751fdc560586a285376434596638787ba3e2 /drivers/media/dvb-frontends
parent30de0bfc764fe1661928eaad9faa20548c9921e2 (diff)
[media] drx-j: get rid of drx_ctrl
This function is used only as an abstraction layer to call the two firmware functions. Remove it. As a bonus, the drx_ctrl_function is now unused and can be removed. Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx39xxj.c24
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx_driver.h3
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.c185
3 files changed, 28 insertions, 184 deletions
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c
index 7a7a4a87fe25..7e316618bfa9 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c
@@ -45,7 +45,7 @@ static int drx39xxj_set_powerstate(struct dvb_frontend *fe, int enable)
45 else 45 else
46 power_mode = DRX_POWER_DOWN; 46 power_mode = DRX_POWER_DOWN;
47 47
48 result = drx_ctrl(demod, DRX_CTRL_POWER_MODE, &power_mode); 48 result = drxj_ctrl(demod, DRX_CTRL_POWER_MODE, &power_mode);
49 if (result != 0) { 49 if (result != 0) {
50 pr_err("Power state change failed\n"); 50 pr_err("Power state change failed\n");
51 return 0; 51 return 0;
@@ -64,7 +64,7 @@ static int drx39xxj_read_status(struct dvb_frontend *fe, fe_status_t *status)
64 64
65 *status = 0; 65 *status = 0;
66 66
67 result = drx_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_status); 67 result = drxj_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_status);
68 if (result != 0) { 68 if (result != 0) {
69 pr_err("drx39xxj: could not get lock status!\n"); 69 pr_err("drx39xxj: could not get lock status!\n");
70 *status = 0; 70 *status = 0;
@@ -109,7 +109,7 @@ static int drx39xxj_read_ber(struct dvb_frontend *fe, u32 *ber)
109 int result; 109 int result;
110 struct drx_sig_quality sig_quality; 110 struct drx_sig_quality sig_quality;
111 111
112 result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); 112 result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
113 if (result != 0) { 113 if (result != 0) {
114 pr_err("drx39xxj: could not get ber!\n"); 114 pr_err("drx39xxj: could not get ber!\n");
115 *ber = 0; 115 *ber = 0;
@@ -128,7 +128,7 @@ static int drx39xxj_read_signal_strength(struct dvb_frontend *fe,
128 int result; 128 int result;
129 struct drx_sig_quality sig_quality; 129 struct drx_sig_quality sig_quality;
130 130
131 result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); 131 result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
132 if (result != 0) { 132 if (result != 0) {
133 pr_err("drx39xxj: could not get signal strength!\n"); 133 pr_err("drx39xxj: could not get signal strength!\n");
134 *strength = 0; 134 *strength = 0;
@@ -147,7 +147,7 @@ static int drx39xxj_read_snr(struct dvb_frontend *fe, u16 *snr)
147 int result; 147 int result;
148 struct drx_sig_quality sig_quality; 148 struct drx_sig_quality sig_quality;
149 149
150 result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); 150 result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
151 if (result != 0) { 151 if (result != 0) {
152 pr_err("drx39xxj: could not read snr!\n"); 152 pr_err("drx39xxj: could not read snr!\n");
153 *snr = 0; 153 *snr = 0;
@@ -165,7 +165,7 @@ static int drx39xxj_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
165 int result; 165 int result;
166 struct drx_sig_quality sig_quality; 166 struct drx_sig_quality sig_quality;
167 167
168 result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); 168 result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
169 if (result != 0) { 169 if (result != 0) {
170 pr_err("drx39xxj: could not get uc blocks!\n"); 170 pr_err("drx39xxj: could not get uc blocks!\n");
171 *ucblocks = 0; 171 *ucblocks = 0;
@@ -244,7 +244,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
244 244
245 if (standard != state->current_standard || state->powered_up == 0) { 245 if (standard != state->current_standard || state->powered_up == 0) {
246 /* Set the standard (will be powered up if necessary */ 246 /* Set the standard (will be powered up if necessary */
247 result = drx_ctrl(demod, DRX_CTRL_SET_STANDARD, &standard); 247 result = drxj_ctrl(demod, DRX_CTRL_SET_STANDARD, &standard);
248 if (result != 0) { 248 if (result != 0) {
249 pr_err("Failed to set standard! result=%02x\n", 249 pr_err("Failed to set standard! result=%02x\n",
250 result); 250 result);
@@ -261,7 +261,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
261 channel.constellation = constellation; 261 channel.constellation = constellation;
262 262
263 /* program channel */ 263 /* program channel */
264 result = drx_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel); 264 result = drxj_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel);
265 if (result != 0) { 265 if (result != 0) {
266 pr_err("Failed to set channel!\n"); 266 pr_err("Failed to set channel!\n");
267 return -EINVAL; 267 return -EINVAL;
@@ -269,7 +269,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
269 /* Just for giggles, let's shut off the LNA again.... */ 269 /* Just for giggles, let's shut off the LNA again.... */
270 uio_data.uio = DRX_UIO1; 270 uio_data.uio = DRX_UIO1;
271 uio_data.value = false; 271 uio_data.value = false;
272 result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data); 272 result = drxj_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
273 if (result != 0) { 273 if (result != 0) {
274 pr_err("Failed to disable LNA!\n"); 274 pr_err("Failed to disable LNA!\n");
275 return 0; 275 return 0;
@@ -315,7 +315,7 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
315 return 0; 315 return 0;
316 } 316 }
317 317
318 result = drx_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &i2c_gate_state); 318 result = drxj_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &i2c_gate_state);
319 if (result != 0) { 319 if (result != 0) {
320 pr_err("drx39xxj: could not open i2c gate [%d]\n", 320 pr_err("drx39xxj: could not open i2c gate [%d]\n",
321 result); 321 result);
@@ -423,7 +423,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
423 uio_cfg.uio = DRX_UIO1; 423 uio_cfg.uio = DRX_UIO1;
424 uio_cfg.mode = DRX_UIO_MODE_READWRITE; 424 uio_cfg.mode = DRX_UIO_MODE_READWRITE;
425 /* Configure user-I/O #3: enable read/write */ 425 /* Configure user-I/O #3: enable read/write */
426 result = drx_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg); 426 result = drxj_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg);
427 if (result) { 427 if (result) {
428 pr_err("Failed to setup LNA GPIO!\n"); 428 pr_err("Failed to setup LNA GPIO!\n");
429 goto error; 429 goto error;
@@ -431,7 +431,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
431 431
432 uio_data.uio = DRX_UIO1; 432 uio_data.uio = DRX_UIO1;
433 uio_data.value = false; 433 uio_data.value = false;
434 result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data); 434 result = drxj_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
435 if (result != 0) { 435 if (result != 0) {
436 pr_err("Failed to disable LNA!\n"); 436 pr_err("Failed to disable LNA!\n");
437 goto error; 437 goto error;
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx_driver.h b/drivers/media/dvb-frontends/drx39xyj/drx_driver.h
index 343ae519b5dc..9ecf01029e90 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drx_driver.h
+++ b/drivers/media/dvb-frontends/drx39xyj/drx_driver.h
@@ -2468,9 +2468,6 @@ Exported FUNCTIONS
2468 2468
2469 int drx_close(struct drx_demod_instance *demod); 2469 int drx_close(struct drx_demod_instance *demod);
2470 2470
2471 int drx_ctrl(struct drx_demod_instance *demod,
2472 u32 ctrl, void *ctrl_data);
2473
2474/*------------------------------------------------------------------------- 2471/*-------------------------------------------------------------------------
2475THE END 2472THE END
2476-------------------------------------------------------------------------*/ 2473-------------------------------------------------------------------------*/
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index cea5b6d66ab7..083673525243 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -19797,6 +19797,10 @@ rw_error:
19797/*============================================================================= 19797/*=============================================================================
19798===== EXPORTED FUNCTIONS ====================================================*/ 19798===== EXPORTED FUNCTIONS ====================================================*/
19799 19799
19800static int drx_ctrl_u_code(struct drx_demod_instance *demod,
19801 struct drxu_code_info *mc_info,
19802 enum drxu_code_action action);
19803
19800/** 19804/**
19801* \fn drxj_open() 19805* \fn drxj_open()
19802* \brief Open the demod instance, configure device, configure drxdriver 19806* \brief Open the demod instance, configure device, configure drxdriver
@@ -19807,6 +19811,7 @@ rw_error:
19807* rely on SCU or AUD ucode to be present. 19811* rely on SCU or AUD ucode to be present.
19808* 19812*
19809*/ 19813*/
19814
19810int drxj_open(struct drx_demod_instance *demod) 19815int drxj_open(struct drx_demod_instance *demod)
19811{ 19816{
19812 struct i2c_device_addr *dev_addr = NULL; 19817 struct i2c_device_addr *dev_addr = NULL;
@@ -19908,15 +19913,21 @@ int drxj_open(struct drx_demod_instance *demod)
19908 common_attr->is_opened = true; 19913 common_attr->is_opened = true;
19909 ucode_info.mc_file = common_attr->microcode_file; 19914 ucode_info.mc_file = common_attr->microcode_file;
19910 19915
19911 rc = drx_ctrl(demod, DRX_CTRL_LOAD_UCODE, &ucode_info); 19916 if (DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode)) {
19917 pr_err("Should powerup before loading the firmware.");
19918 return -EINVAL;
19919 }
19920
19921 rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_UPLOAD);
19912 if (rc != 0) { 19922 if (rc != 0) {
19913 pr_err("error %d\n", rc); 19923 pr_err("error %d while uploading the firmware\n", rc);
19914 goto rw_error; 19924 goto rw_error;
19915 } 19925 }
19916 if (common_attr->verify_microcode == true) { 19926 if (common_attr->verify_microcode == true) {
19917 rc = drx_ctrl(demod, DRX_CTRL_VERIFY_UCODE, &ucode_info); 19927 rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_VERIFY);
19918 if (rc != 0) { 19928 if (rc != 0) {
19919 pr_err("error %d\n", rc); 19929 pr_err("error %d while verifying the firmware\n",
19930 rc);
19920 goto rw_error; 19931 goto rw_error;
19921 } 19932 }
19922 } 19933 }
@@ -20454,17 +20465,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
20454 rc = drx_check_firmware(demod, (u8 *)mc_data_init, size); 20465 rc = drx_check_firmware(demod, (u8 *)mc_data_init, size);
20455 if (rc) 20466 if (rc)
20456 goto release; 20467 goto release;
20457
20458 /* After scanning, validate the microcode.
20459 It is also valid if no validation control exists.
20460 */
20461 rc = drx_ctrl(demod, DRX_CTRL_VALIDATE_UCODE, NULL);
20462 if (rc != 0 && rc != -ENOTSUPP) {
20463 pr_err("Validate ucode not supported\n");
20464 return rc;
20465 }
20466 pr_info("Uploading firmware %s\n", mc_file); 20468 pr_info("Uploading firmware %s\n", mc_file);
20467 } else if (action == UCODE_VERIFY) { 20469 } else {
20468 pr_info("Verifying if firmware upload was ok.\n"); 20470 pr_info("Verifying if firmware upload was ok.\n");
20469 } 20471 }
20470 20472
@@ -20579,67 +20581,6 @@ release:
20579 20581
20580/*============================================================================*/ 20582/*============================================================================*/
20581 20583
20582/**
20583 * drx_ctrl_version - Build list of version information.
20584 * @demod: A pointer to a demodulator instance.
20585 * @version_list: Pointer to linked list of versions.
20586 *
20587 * This function returns:
20588 * 0: Version information stored in version_list
20589 * -EINVAL: Invalid arguments.
20590 */
20591static int drx_ctrl_version(struct drx_demod_instance *demod,
20592 struct drx_version_list **version_list)
20593{
20594 static char drx_driver_core_module_name[] = "Core driver";
20595 static char drx_driver_core_version_text[] =
20596 DRX_VERSIONSTRING(0, 0, 0);
20597
20598 static struct drx_version drx_driver_core_version;
20599 static struct drx_version_list drx_driver_core_version_list;
20600
20601 struct drx_version_list *demod_version_list = NULL;
20602 int return_status = -EIO;
20603
20604 /* Check arguments */
20605 if (version_list == NULL)
20606 return -EINVAL;
20607
20608 /* Get version info list from demod */
20609 return_status = (*(demod->my_demod_funct->ctrl_func)) (demod,
20610 DRX_CTRL_VERSION,
20611 (void *)
20612 &demod_version_list);
20613
20614 /* Always fill in the information of the driver SW . */
20615 drx_driver_core_version.module_type = DRX_MODULE_DRIVERCORE;
20616 drx_driver_core_version.module_name = drx_driver_core_module_name;
20617 drx_driver_core_version.v_major = 0;
20618 drx_driver_core_version.v_minor = 0;
20619 drx_driver_core_version.v_patch = 0;
20620 drx_driver_core_version.v_string = drx_driver_core_version_text;
20621
20622 drx_driver_core_version_list.version = &drx_driver_core_version;
20623 drx_driver_core_version_list.next = (struct drx_version_list *) (NULL);
20624
20625 if ((return_status == 0) && (demod_version_list != NULL)) {
20626 /* Append versioninfo from driver to versioninfo from demod */
20627 /* Return version info in "bottom-up" order. This way, multiple
20628 devices can be handled without using malloc. */
20629 struct drx_version_list *current_list_element = demod_version_list;
20630 while (current_list_element->next != NULL)
20631 current_list_element = current_list_element->next;
20632 current_list_element->next = &drx_driver_core_version_list;
20633
20634 *version_list = demod_version_list;
20635 } else {
20636 /* Just return versioninfo from driver */
20637 *version_list = &drx_driver_core_version_list;
20638 }
20639
20640 return 0;
20641}
20642
20643/* 20584/*
20644 * Exported functions 20585 * Exported functions
20645 */ 20586 */
@@ -20711,97 +20652,3 @@ int drx_close(struct drx_demod_instance *demod)
20711 20652
20712 return status; 20653 return status;
20713} 20654}
20714/**
20715 * drx_ctrl - Control the device.
20716 * @demod: A pointer to a demodulator instance.
20717 * @ctrl: Reference to desired control function.
20718 * @ctrl_data: Pointer to data structure for control function.
20719 *
20720 * Data needed or returned by the control function is stored in ctrl_data.
20721 *
20722 * This function returns:
20723 * 0: Control function completed successfully.
20724 * -EIO: Driver not initialized or error during control demod.
20725 * -EINVAL: Demod instance or ctrl_data has invalid content.
20726 * -ENOTSUPP: Specified control function is not available.
20727 */
20728
20729int drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
20730{
20731 int status = -EIO;
20732
20733 if ((demod == NULL) ||
20734 (demod->my_demod_funct == NULL) ||
20735 (demod->my_common_attr == NULL) ||
20736 (demod->my_ext_attr == NULL) || (demod->my_i2c_dev_addr == NULL)
20737 ) {
20738 return -EINVAL;
20739 }
20740
20741 if (((!demod->my_common_attr->is_opened) &&
20742 (ctrl != DRX_CTRL_PROBE_DEVICE) && (ctrl != DRX_CTRL_VERSION))
20743 ) {
20744 return -EINVAL;
20745 }
20746
20747 if ((DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode) &&
20748 (ctrl != DRX_CTRL_POWER_MODE) &&
20749 (ctrl != DRX_CTRL_PROBE_DEVICE) &&
20750 (ctrl != DRX_CTRL_NOP) && (ctrl != DRX_CTRL_VERSION)
20751 )
20752 ) {
20753 return -ENOTSUPP;
20754 }
20755
20756 /* Fixed control functions */
20757 switch (ctrl) {
20758 /*======================================================================*/
20759 case DRX_CTRL_NOP:
20760 /* No operation */
20761 return 0;
20762 break;
20763
20764 /*======================================================================*/
20765 case DRX_CTRL_VERSION:
20766 return drx_ctrl_version(demod, (struct drx_version_list **)ctrl_data);
20767 break;
20768
20769 /*======================================================================*/
20770 default:
20771 /* Do nothing */
20772 break;
20773 }
20774
20775 /* Virtual functions */
20776 /* First try calling function from derived class */
20777 status = (*(demod->my_demod_funct->ctrl_func)) (demod, ctrl, ctrl_data);
20778 if (status == -ENOTSUPP) {
20779 /* Now try calling a the base class function */
20780 switch (ctrl) {
20781 /*===================================================================*/
20782 case DRX_CTRL_LOAD_UCODE:
20783 return drx_ctrl_u_code(demod,
20784 (struct drxu_code_info *)ctrl_data,
20785 UCODE_UPLOAD);
20786 break;
20787
20788 /*===================================================================*/
20789 case DRX_CTRL_VERIFY_UCODE:
20790 {
20791 return drx_ctrl_u_code(demod,
20792 (struct drxu_code_info *)ctrl_data,
20793 UCODE_VERIFY);
20794 }
20795 break;
20796
20797 /*===================================================================*/
20798 default:
20799 pr_err("control %d not supported\n", ctrl);
20800 return -ENOTSUPP;
20801 }
20802 } else {
20803 return status;
20804 }
20805
20806 return 0;
20807} \ No newline at end of file