struct drx_demod_instance;
- typedef int(*drx_open_func_t) (struct drx_demod_instance *demod);
- typedef int(*drx_close_func_t) (struct drx_demod_instance *demod);
- typedef int(*drx_ctrl_func_t) (struct drx_demod_instance *demod,
- u32 ctrl,
- void *ctrl_data);
-
-/**
-* \struct struct drx_demod_func * \brief A stucture containing all functions of a demodulator.
-*/
- struct drx_demod_func {
- u32 type_id; /**< Device type identifier. */
- drx_open_func_t open_func; /**< Pointer to Open() function. */
- drx_close_func_t close_func;/**< Pointer to Close() function. */
- drx_ctrl_func_t ctrl_func; /**< Pointer to Ctrl() function. */};
-
/**
* \struct struct drx_demod_instance * \brief Top structure of demodulator instance.
*/
struct drx_demod_instance {
/* type specific demodulator data */
- struct drx_demod_func *my_demod_funct;
- /**< demodulator functions */
struct drx_access_func *my_access_funct;
/**< data access protocol functions */
struct tuner_instance *my_tuner;
*/
#define DRX_ISDVBTSTD(std) ((std) == DRX_STANDARD_DVBT)
-/*-------------------------------------------------------------------------
-Exported FUNCTIONS
--------------------------------------------------------------------------*/
-
- int drx_open(struct drx_demod_instance *demod);
-
- int drx_close(struct drx_demod_instance *demod);
-
/*-------------------------------------------------------------------------
THE END
-------------------------------------------------------------------------*/
drxj_dap_read_modify_write_reg32, /* Not supported */
};
-/**
-* /var DRXJ_Func_g
-* /brief The driver functions of the drxj
-*/
-struct drx_demod_func drxj_functions_g = {
- DRXJ_TYPE_ID,
- drxj_open,
- drxj_close,
- drxj_ctrl
-};
-
struct drxj_data drxj_data_g = {
false, /* has_lna : true if LNA (aka PGA) present */
false, /* has_oob : true if OOB supported */
* \brief Default drxj demodulator instance.
*/
struct drx_demod_instance drxj_default_demod_g = {
- &drxj_functions_g, /* demod functions */
&DRXJ_DAP, /* data access protocol functions */
NULL, /* tuner instance */
&drxj_default_addr_g, /* i2c address & device id */
struct drx_cfg_mpeg_output cfg_mpeg_output;
int rc;
+
+ if ((demod == NULL) ||
+ (demod->my_common_attr == NULL) ||
+ (demod->my_ext_attr == NULL) ||
+ (demod->my_i2c_dev_addr == NULL) ||
+ (demod->my_common_attr->is_opened)) {
+ return -EINVAL;
+ }
+
/* Check arguments */
if (demod->my_ext_attr == NULL)
return -EINVAL;
/* refresh the audio data structure with default */
ext_attr->aud_data = drxj_default_aud_data_g;
+ demod->my_common_attr->is_opened = true;
return 0;
rw_error:
common_attr->is_opened = false;
int rc;
enum drx_power_mode power_mode = DRX_POWER_UP;
+ if ((demod == NULL) ||
+ (demod->my_common_attr == NULL) ||
+ (demod->my_ext_attr == NULL) ||
+ (demod->my_i2c_dev_addr == NULL) ||
+ (!demod->my_common_attr->is_opened)) {
+ return -EINVAL;
+ }
+
/* power up */
rc = ctrl_power_mode(demod, &power_mode);
if (rc != 0) {
goto rw_error;
}
+ DRX_ATTR_ISOPENED(demod) = false;
+
return 0;
rw_error:
+ DRX_ATTR_ISOPENED(demod) = false;
+
return -EIO;
}
return rc;
}
-
-/*============================================================================*/
-
-/*
- * Exported functions
- */
-
-/**
- * drx_open - Open a demodulator instance.
- * @demod: A pointer to a demodulator instance.
- *
- * This function returns:
- * 0: Opened demod instance with succes.
- * -EIO: Driver not initialized or unable to initialize
- * demod.
- * -EINVAL: Demod instance has invalid content.
- *
- */
-
-int drx_open(struct drx_demod_instance *demod)
-{
- int status = 0;
-
- if ((demod == NULL) ||
- (demod->my_demod_funct == NULL) ||
- (demod->my_common_attr == NULL) ||
- (demod->my_ext_attr == NULL) ||
- (demod->my_i2c_dev_addr == NULL) ||
- (demod->my_common_attr->is_opened)) {
- return -EINVAL;
- }
-
- status = (*(demod->my_demod_funct->open_func)) (demod);
-
- if (status == 0)
- demod->my_common_attr->is_opened = true;
-
- return status;
-}
-
-/*============================================================================*/
-
-/**
- * drx_close - Close device
- * @demod: A pointer to a demodulator instance.
- *
- * Free resources occupied by device instance.
- * Put device into sleep mode.
- *
- * This function returns:
- * 0: Closed demod instance with succes.
- * -EIO: Driver not initialized or error during close
- * demod.
- * -EINVAL: Demod instance has invalid content.
- */
-int drx_close(struct drx_demod_instance *demod)
-{
- int status = 0;
-
- if ((demod == NULL) ||
- (demod->my_demod_funct == NULL) ||
- (demod->my_common_attr == NULL) ||
- (demod->my_ext_attr == NULL) ||
- (demod->my_i2c_dev_addr == NULL) ||
- (!demod->my_common_attr->is_opened)) {
- return -EINVAL;
- }
-
- status = (*(demod->my_demod_funct->close_func)) (demod);
-
- DRX_ATTR_ISOPENED(demod) = false;
-
- return status;
-}