else
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) {
pr_err("Power state change failed\n");
return 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) {
pr_err("drx39xxj: could not get lock status!\n");
*status = 0;
int result;
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) {
pr_err("drx39xxj: could not get ber!\n");
*ber = 0;
int result;
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) {
pr_err("drx39xxj: could not get signal strength!\n");
*strength = 0;
int result;
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) {
pr_err("drx39xxj: could not read snr!\n");
*snr = 0;
int result;
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) {
pr_err("drx39xxj: could not get uc blocks!\n");
*ucblocks = 0;
if (standard != state->current_standard || state->powered_up == 0) {
/* 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) {
pr_err("Failed to set standard! result=%02x\n",
result);
channel.constellation = constellation;
/* program channel */
- result = drx_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel);
+ result = drxj_ctrl(demod, DRX_CTRL_SET_CHANNEL, &channel);
if (result != 0) {
pr_err("Failed to set channel!\n");
return -EINVAL;
/* Just for giggles, let's shut off the LNA again.... */
uio_data.uio = DRX_UIO1;
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) {
pr_err("Failed to disable LNA!\n");
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) {
pr_err("drx39xxj: could not open i2c gate [%d]\n",
result);
uio_cfg.uio = DRX_UIO1;
uio_cfg.mode = DRX_UIO_MODE_READWRITE;
/* 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) {
pr_err("Failed to setup LNA GPIO!\n");
goto error;
uio_data.uio = DRX_UIO1;
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) {
pr_err("Failed to disable LNA!\n");
goto error;
/*=============================================================================
===== 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()
* \brief Open the demod instance, configure device, configure drxdriver
* rely on SCU or AUD ucode to be present.
*
*/
+
int drxj_open(struct drx_demod_instance *demod)
{
struct i2c_device_addr *dev_addr = NULL;
common_attr->is_opened = true;
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) {
- pr_err("error %d\n", rc);
+ pr_err("error %d while uploading the firmware\n", rc);
goto rw_error;
}
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) {
- pr_err("error %d\n", rc);
+ pr_err("error %d while verifying the firmware\n",
+ rc);
goto rw_error;
}
}
rc = drx_check_firmware(demod, (u8 *)mc_data_init, size);
if (rc)
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);
- } else if (action == UCODE_VERIFY) {
+ } else {
pr_info("Verifying if firmware upload was ok.\n");
}
/*============================================================================*/
-/**
- * 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
*/
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