Commit dc5a91d4 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 30de0bfc
...@@ -45,7 +45,7 @@ static int drx39xxj_set_powerstate(struct dvb_frontend *fe, int enable) ...@@ -45,7 +45,7 @@ static int drx39xxj_set_powerstate(struct dvb_frontend *fe, int enable)
else else
power_mode = DRX_POWER_DOWN; power_mode = DRX_POWER_DOWN;
result = drx_ctrl(demod, DRX_CTRL_POWER_MODE, &power_mode); result = drxj_ctrl(demod, DRX_CTRL_POWER_MODE, &power_mode);
if (result != 0) { if (result != 0) {
pr_err("Power state change failed\n"); pr_err("Power state change failed\n");
return 0; return 0;
...@@ -64,7 +64,7 @@ static int drx39xxj_read_status(struct dvb_frontend *fe, fe_status_t *status) ...@@ -64,7 +64,7 @@ static int drx39xxj_read_status(struct dvb_frontend *fe, fe_status_t *status)
*status = 0; *status = 0;
result = drx_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_status); result = drxj_ctrl(demod, DRX_CTRL_LOCK_STATUS, &lock_status);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not get lock status!\n"); pr_err("drx39xxj: could not get lock status!\n");
*status = 0; *status = 0;
...@@ -109,7 +109,7 @@ static int drx39xxj_read_ber(struct dvb_frontend *fe, u32 *ber) ...@@ -109,7 +109,7 @@ static int drx39xxj_read_ber(struct dvb_frontend *fe, u32 *ber)
int result; int result;
struct drx_sig_quality sig_quality; struct drx_sig_quality sig_quality;
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not get ber!\n"); pr_err("drx39xxj: could not get ber!\n");
*ber = 0; *ber = 0;
...@@ -128,7 +128,7 @@ static int drx39xxj_read_signal_strength(struct dvb_frontend *fe, ...@@ -128,7 +128,7 @@ static int drx39xxj_read_signal_strength(struct dvb_frontend *fe,
int result; int result;
struct drx_sig_quality sig_quality; struct drx_sig_quality sig_quality;
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not get signal strength!\n"); pr_err("drx39xxj: could not get signal strength!\n");
*strength = 0; *strength = 0;
...@@ -147,7 +147,7 @@ static int drx39xxj_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -147,7 +147,7 @@ static int drx39xxj_read_snr(struct dvb_frontend *fe, u16 *snr)
int result; int result;
struct drx_sig_quality sig_quality; struct drx_sig_quality sig_quality;
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not read snr!\n"); pr_err("drx39xxj: could not read snr!\n");
*snr = 0; *snr = 0;
...@@ -165,7 +165,7 @@ static int drx39xxj_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) ...@@ -165,7 +165,7 @@ static int drx39xxj_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
int result; int result;
struct drx_sig_quality sig_quality; struct drx_sig_quality sig_quality;
result = drx_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality); result = drxj_ctrl(demod, DRX_CTRL_SIG_QUALITY, &sig_quality);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not get uc blocks!\n"); pr_err("drx39xxj: could not get uc blocks!\n");
*ucblocks = 0; *ucblocks = 0;
...@@ -244,7 +244,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe) ...@@ -244,7 +244,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
if (standard != state->current_standard || state->powered_up == 0) { if (standard != state->current_standard || state->powered_up == 0) {
/* Set the standard (will be powered up if necessary */ /* Set the standard (will be powered up if necessary */
result = drx_ctrl(demod, DRX_CTRL_SET_STANDARD, &standard); result = drxj_ctrl(demod, DRX_CTRL_SET_STANDARD, &standard);
if (result != 0) { if (result != 0) {
pr_err("Failed to set standard! result=%02x\n", pr_err("Failed to set standard! result=%02x\n",
result); result);
...@@ -261,7 +261,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe) ...@@ -261,7 +261,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
channel.constellation = constellation; channel.constellation = constellation;
/* program channel */ /* program channel */
result = drx_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel); result = drxj_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel);
if (result != 0) { if (result != 0) {
pr_err("Failed to set channel!\n"); pr_err("Failed to set channel!\n");
return -EINVAL; return -EINVAL;
...@@ -269,7 +269,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe) ...@@ -269,7 +269,7 @@ static int drx39xxj_set_frontend(struct dvb_frontend *fe)
/* Just for giggles, let's shut off the LNA again.... */ /* Just for giggles, let's shut off the LNA again.... */
uio_data.uio = DRX_UIO1; uio_data.uio = DRX_UIO1;
uio_data.value = false; uio_data.value = false;
result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data); result = drxj_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
if (result != 0) { if (result != 0) {
pr_err("Failed to disable LNA!\n"); pr_err("Failed to disable LNA!\n");
return 0; return 0;
...@@ -315,7 +315,7 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -315,7 +315,7 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
return 0; return 0;
} }
result = drx_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &i2c_gate_state); result = drxj_ctrl(demod, DRX_CTRL_I2C_BRIDGE, &i2c_gate_state);
if (result != 0) { if (result != 0) {
pr_err("drx39xxj: could not open i2c gate [%d]\n", pr_err("drx39xxj: could not open i2c gate [%d]\n",
result); result);
...@@ -423,7 +423,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) ...@@ -423,7 +423,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
uio_cfg.uio = DRX_UIO1; uio_cfg.uio = DRX_UIO1;
uio_cfg.mode = DRX_UIO_MODE_READWRITE; uio_cfg.mode = DRX_UIO_MODE_READWRITE;
/* Configure user-I/O #3: enable read/write */ /* Configure user-I/O #3: enable read/write */
result = drx_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg); result = drxj_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg);
if (result) { if (result) {
pr_err("Failed to setup LNA GPIO!\n"); pr_err("Failed to setup LNA GPIO!\n");
goto error; goto error;
...@@ -431,7 +431,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) ...@@ -431,7 +431,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
uio_data.uio = DRX_UIO1; uio_data.uio = DRX_UIO1;
uio_data.value = false; uio_data.value = false;
result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data); result = drxj_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data);
if (result != 0) { if (result != 0) {
pr_err("Failed to disable LNA!\n"); pr_err("Failed to disable LNA!\n");
goto error; goto error;
......
...@@ -2468,9 +2468,6 @@ Exported FUNCTIONS ...@@ -2468,9 +2468,6 @@ Exported FUNCTIONS
int drx_close(struct drx_demod_instance *demod); int drx_close(struct drx_demod_instance *demod);
int drx_ctrl(struct drx_demod_instance *demod,
u32 ctrl, void *ctrl_data);
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
THE END THE END
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
......
...@@ -19797,6 +19797,10 @@ static int ctrl_get_cfg(struct drx_demod_instance *demod, struct drx_cfg *config ...@@ -19797,6 +19797,10 @@ static int ctrl_get_cfg(struct drx_demod_instance *demod, struct drx_cfg *config
/*============================================================================= /*=============================================================================
===== EXPORTED FUNCTIONS ====================================================*/ ===== EXPORTED FUNCTIONS ====================================================*/
static int drx_ctrl_u_code(struct drx_demod_instance *demod,
struct drxu_code_info *mc_info,
enum drxu_code_action action);
/** /**
* \fn drxj_open() * \fn drxj_open()
* \brief Open the demod instance, configure device, configure drxdriver * \brief Open the demod instance, configure device, configure drxdriver
...@@ -19807,6 +19811,7 @@ static int ctrl_get_cfg(struct drx_demod_instance *demod, struct drx_cfg *config ...@@ -19807,6 +19811,7 @@ static int ctrl_get_cfg(struct drx_demod_instance *demod, struct drx_cfg *config
* rely on SCU or AUD ucode to be present. * rely on SCU or AUD ucode to be present.
* *
*/ */
int drxj_open(struct drx_demod_instance *demod) int drxj_open(struct drx_demod_instance *demod)
{ {
struct i2c_device_addr *dev_addr = NULL; struct i2c_device_addr *dev_addr = NULL;
...@@ -19908,15 +19913,21 @@ int drxj_open(struct drx_demod_instance *demod) ...@@ -19908,15 +19913,21 @@ int drxj_open(struct drx_demod_instance *demod)
common_attr->is_opened = true; common_attr->is_opened = true;
ucode_info.mc_file = common_attr->microcode_file; ucode_info.mc_file = common_attr->microcode_file;
rc = drx_ctrl(demod, DRX_CTRL_LOAD_UCODE, &ucode_info); if (DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode)) {
pr_err("Should powerup before loading the firmware.");
return -EINVAL;
}
rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_UPLOAD);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d while uploading the firmware\n", rc);
goto rw_error; goto rw_error;
} }
if (common_attr->verify_microcode == true) { if (common_attr->verify_microcode == true) {
rc = drx_ctrl(demod, DRX_CTRL_VERIFY_UCODE, &ucode_info); rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_VERIFY);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d while verifying the firmware\n",
rc);
goto rw_error; goto rw_error;
} }
} }
...@@ -20454,17 +20465,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod, ...@@ -20454,17 +20465,8 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
rc = drx_check_firmware(demod, (u8 *)mc_data_init, size); rc = drx_check_firmware(demod, (u8 *)mc_data_init, size);
if (rc) if (rc)
goto release; goto release;
/* After scanning, validate the microcode.
It is also valid if no validation control exists.
*/
rc = drx_ctrl(demod, DRX_CTRL_VALIDATE_UCODE, NULL);
if (rc != 0 && rc != -ENOTSUPP) {
pr_err("Validate ucode not supported\n");
return rc;
}
pr_info("Uploading firmware %s\n", mc_file); pr_info("Uploading firmware %s\n", mc_file);
} else if (action == UCODE_VERIFY) { } else {
pr_info("Verifying if firmware upload was ok.\n"); pr_info("Verifying if firmware upload was ok.\n");
} }
...@@ -20579,67 +20581,6 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod, ...@@ -20579,67 +20581,6 @@ static int drx_ctrl_u_code(struct drx_demod_instance *demod,
/*============================================================================*/ /*============================================================================*/
/**
* drx_ctrl_version - Build list of version information.
* @demod: A pointer to a demodulator instance.
* @version_list: Pointer to linked list of versions.
*
* This function returns:
* 0: Version information stored in version_list
* -EINVAL: Invalid arguments.
*/
static int drx_ctrl_version(struct drx_demod_instance *demod,
struct drx_version_list **version_list)
{
static char drx_driver_core_module_name[] = "Core driver";
static char drx_driver_core_version_text[] =
DRX_VERSIONSTRING(0, 0, 0);
static struct drx_version drx_driver_core_version;
static struct drx_version_list drx_driver_core_version_list;
struct drx_version_list *demod_version_list = NULL;
int return_status = -EIO;
/* Check arguments */
if (version_list == NULL)
return -EINVAL;
/* Get version info list from demod */
return_status = (*(demod->my_demod_funct->ctrl_func)) (demod,
DRX_CTRL_VERSION,
(void *)
&demod_version_list);
/* Always fill in the information of the driver SW . */
drx_driver_core_version.module_type = DRX_MODULE_DRIVERCORE;
drx_driver_core_version.module_name = drx_driver_core_module_name;
drx_driver_core_version.v_major = 0;
drx_driver_core_version.v_minor = 0;
drx_driver_core_version.v_patch = 0;
drx_driver_core_version.v_string = drx_driver_core_version_text;
drx_driver_core_version_list.version = &drx_driver_core_version;
drx_driver_core_version_list.next = (struct drx_version_list *) (NULL);
if ((return_status == 0) && (demod_version_list != NULL)) {
/* Append versioninfo from driver to versioninfo from demod */
/* Return version info in "bottom-up" order. This way, multiple
devices can be handled without using malloc. */
struct drx_version_list *current_list_element = demod_version_list;
while (current_list_element->next != NULL)
current_list_element = current_list_element->next;
current_list_element->next = &drx_driver_core_version_list;
*version_list = demod_version_list;
} else {
/* Just return versioninfo from driver */
*version_list = &drx_driver_core_version_list;
}
return 0;
}
/* /*
* Exported functions * Exported functions
*/ */
...@@ -20711,97 +20652,3 @@ int drx_close(struct drx_demod_instance *demod) ...@@ -20711,97 +20652,3 @@ int drx_close(struct drx_demod_instance *demod)
return status; return status;
} }
/**
* drx_ctrl - Control the device.
* @demod: A pointer to a demodulator instance.
* @ctrl: Reference to desired control function.
* @ctrl_data: Pointer to data structure for control function.
*
* Data needed or returned by the control function is stored in ctrl_data.
*
* This function returns:
* 0: Control function completed successfully.
* -EIO: Driver not initialized or error during control demod.
* -EINVAL: Demod instance or ctrl_data has invalid content.
* -ENOTSUPP: Specified control function is not available.
*/
int drx_ctrl(struct drx_demod_instance *demod, u32 ctrl, void *ctrl_data)
{
int status = -EIO;
if ((demod == NULL) ||
(demod->my_demod_funct == NULL) ||
(demod->my_common_attr == NULL) ||
(demod->my_ext_attr == NULL) || (demod->my_i2c_dev_addr == NULL)
) {
return -EINVAL;
}
if (((!demod->my_common_attr->is_opened) &&
(ctrl != DRX_CTRL_PROBE_DEVICE) && (ctrl != DRX_CTRL_VERSION))
) {
return -EINVAL;
}
if ((DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode) &&
(ctrl != DRX_CTRL_POWER_MODE) &&
(ctrl != DRX_CTRL_PROBE_DEVICE) &&
(ctrl != DRX_CTRL_NOP) && (ctrl != DRX_CTRL_VERSION)
)
) {
return -ENOTSUPP;
}
/* Fixed control functions */
switch (ctrl) {
/*======================================================================*/
case DRX_CTRL_NOP:
/* No operation */
return 0;
break;
/*======================================================================*/
case DRX_CTRL_VERSION:
return drx_ctrl_version(demod, (struct drx_version_list **)ctrl_data);
break;
/*======================================================================*/
default:
/* Do nothing */
break;
}
/* Virtual functions */
/* First try calling function from derived class */
status = (*(demod->my_demod_funct->ctrl_func)) (demod, ctrl, ctrl_data);
if (status == -ENOTSUPP) {
/* Now try calling a the base class function */
switch (ctrl) {
/*===================================================================*/
case DRX_CTRL_LOAD_UCODE:
return drx_ctrl_u_code(demod,
(struct drxu_code_info *)ctrl_data,
UCODE_UPLOAD);
break;
/*===================================================================*/
case DRX_CTRL_VERIFY_UCODE:
{
return drx_ctrl_u_code(demod,
(struct drxu_code_info *)ctrl_data,
UCODE_VERIFY);
}
break;
/*===================================================================*/
default:
pr_err("control %d not supported\n", ctrl);
return -ENOTSUPP;
}
} else {
return status;
}
return 0;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment