Lines Matching defs:sdev

174 	struct si4713_device *sdev = dev;
176 v4l2_dbg(2, debug, &sdev->sd,
178 complete(&sdev->work);
185 * @sdev: si4713_device structure for the device we are communicating
193 static int si4713_send_command(struct si4713_device *sdev, const u8 command,
197 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
208 DBG_BUFFER(&sdev->sd, "Parameters", data1, argn + 1);
212 v4l2_err(&sdev->sd, "Error while sending command 0x%02x\n",
221 if (!wait_for_completion_timeout(&sdev->work,
223 v4l2_warn(&sdev->sd,
231 v4l2_err(&sdev->sd,
237 DBG_BUFFER(&sdev->sd, "Response", response, respn);
254 * @sdev: si4713_device structure for the device we are communicating
258 static int si4713_read_property(struct si4713_device *sdev, u16 prop, u32 *pv)
273 err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
282 v4l2_dbg(1, debug, &sdev->sd,
291 * @sdev: si4713_device structure for the device we are communicating
295 static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
314 rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
322 v4l2_dbg(1, debug, &sdev->sd,
338 * @sdev: si4713_device structure for the device we are communicating
340 static int si4713_powerup(struct si4713_device *sdev)
342 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
354 if (sdev->power_state)
357 if (sdev->vdd) {
358 err = regulator_enable(sdev->vdd);
360 v4l2_err(&sdev->sd, "Failed to enable vdd: %d\n", err);
365 if (sdev->vio) {
366 err = regulator_enable(sdev->vio);
368 v4l2_err(&sdev->sd, "Failed to enable vio: %d\n", err);
373 if (sdev->gpio_reset) {
375 gpiod_set_value(sdev->gpio_reset, 1);
381 err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
387 v4l2_dbg(1, debug, &sdev->sd, "Powerup response: 0x%02x\n",
389 v4l2_dbg(1, debug, &sdev->sd, "Device in power up mode\n");
390 sdev->power_state = POWER_ON;
393 err = si4713_write_property(sdev, SI4713_GPO_IEN,
397 gpiod_set_value(sdev->gpio_reset, 0);
400 if (sdev->vdd) {
401 err = regulator_disable(sdev->vdd);
403 v4l2_err(&sdev->sd, "Failed to disable vdd: %d\n", err);
406 if (sdev->vio) {
407 err = regulator_disable(sdev->vio);
409 v4l2_err(&sdev->sd, "Failed to disable vio: %d\n", err);
417 * @sdev: si4713_device structure for the device we are communicating
419 static int si4713_powerdown(struct si4713_device *sdev)
424 if (!sdev->power_state)
427 err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
433 v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n",
435 v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
436 if (sdev->gpio_reset)
437 gpiod_set_value(sdev->gpio_reset, 0);
439 if (sdev->vdd) {
440 err = regulator_disable(sdev->vdd);
442 v4l2_err(&sdev->sd,
447 if (sdev->vio) {
448 err = regulator_disable(sdev->vio);
450 v4l2_err(&sdev->sd,
454 sdev->power_state = POWER_OFF;
462 * @sdev: si4713_device structure for the device we are communicating
464 static int si4713_checkrev(struct si4713_device *sdev)
466 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
470 rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
479 v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n",
482 v4l2_err(&sdev->sd, "Invalid product number 0x%X\n", resp[1]);
491 * @sdev: si4713_device structure for the device we are communicating
494 static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
496 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
502 !wait_for_completion_timeout(&sdev->work, usecs_to_jiffies(usecs) + 1))
503 v4l2_warn(&sdev->sd,
508 err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
515 v4l2_dbg(1, debug, &sdev->sd,
535 * @sdev: si4713_device structure for the device we are communicating
538 static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
553 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
560 v4l2_dbg(1, debug, &sdev->sd,
564 err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
578 * @sdev: si4713_device structure for the device we are communicating
582 static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
604 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
611 v4l2_dbg(1, debug, &sdev->sd,
615 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
626 * @sdev: si4713_device structure for the device we are communicating
630 static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
648 sdev->tune_rnl = DEFAULT_TUNE_RNL;
653 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
660 v4l2_dbg(1, debug, &sdev->sd,
664 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
674 * @sdev: si4713_device structure for the device we are communicating
681 static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
694 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
699 v4l2_dbg(1, debug, &sdev->sd,
702 sdev->frequency = *frequency;
706 v4l2_dbg(1, debug, &sdev->sd,
716 * @sdev: si4713_device structure for the device we are communicating
724 static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
740 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
745 v4l2_dbg(1, debug, &sdev->sd,
748 v4l2_dbg(1, debug, &sdev->sd,
758 * @sdev: si4713_device structure for the device we are communicating
762 static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
776 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
783 v4l2_dbg(1, debug, &sdev->sd, "%s: status=0x%02x\n", __func__, val[0]);
788 static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
791 return si4713_powerup(sdev);
792 return si4713_powerdown(sdev);
795 static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
801 if (sdev->power_state)
802 rval = si4713_write_property(sdev,
808 static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
817 if (sdev->power_state) {
820 rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
832 rval = si4713_write_property(sdev,
838 rval = si4713_write_property(sdev,
848 static int si4713_set_rds_radio_text(struct si4713_device *sdev, const char *rt)
856 if (!sdev->power_state)
859 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0, &left);
881 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
900 * command. Must be called with sdev->mutex held.
901 * @sdev: si4713_device structure for the device we are communicating
903 static int si4713_update_tune_status(struct si4713_device *sdev)
909 rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
917 sdev->power_level = p;
918 sdev->antenna_capacitor = a;*/
919 sdev->tune_rnl = n;
925 static int si4713_choose_econtrol_action(struct si4713_device *sdev, u32 id,
1050 * @sdev: si4713_device structure for the device we are communicating
1052 static int si4713_setup(struct si4713_device *sdev)
1060 f.frequency = sdev->frequency ? sdev->frequency : DEFAULT_FREQUENCY;
1062 rval = si4713_s_frequency(&sdev->sd, &f);
1065 if (sdev->stereo)
1069 if (sdev->rds_enabled)
1071 si4713_s_modulator(&sdev->sd, &vm);
1078 * @sdev: si4713_device structure for the device we are communicating
1080 static int si4713_initialize(struct si4713_device *sdev)
1084 rval = si4713_set_power_state(sdev, POWER_ON);
1088 rval = si4713_checkrev(sdev);
1092 rval = si4713_set_power_state(sdev, POWER_OFF);
1096 sdev->frequency = DEFAULT_FREQUENCY;
1097 sdev->stereo = 1;
1098 sdev->tune_rnl = DEFAULT_TUNE_RNL;
1105 struct si4713_device *sdev =
1121 ret = si4713_set_mute(sdev, ctrl->val);
1123 ret = si4713_set_power_state(sdev, POWER_DOWN);
1126 ret = si4713_set_power_state(sdev, POWER_UP);
1128 ret = si4713_set_mute(sdev, ctrl->val);
1130 ret = si4713_setup(sdev);
1136 if (!sdev->power_state)
1147 ret = si4713_set_rds_ps_name(sdev, ctrl->p_new.p_char);
1151 ret = si4713_set_rds_radio_text(sdev, ctrl->p_new.p_char);
1162 ret = si4713_tx_tune_power(sdev,
1163 sdev->tune_pwr_level->val, sdev->tune_ant_cap->val);
1166 sdev->tune_ant_cap->is_new = false;
1167 sdev->tune_pwr_level->is_new = false;
1173 if (sdev->rds_alt_freqs_enable->val) {
1174 val = sdev->rds_alt_freqs->p_new.p_u32[0];
1179 ret = si4713_write_property(sdev, SI4713_TX_RDS_PS_AF, val);
1183 ret = si4713_choose_econtrol_action(sdev, ctrl->id, &bit,
1200 ret = si4713_read_property(sdev, property, &val);
1206 ret = si4713_write_property(sdev, property, val);
1221 struct si4713_device *sdev = to_si4713_device(sd);
1233 if (sdev->power_state) {
1235 rval = si4713_tx_tune_measure(sdev, frequency, 0);
1239 rval = si4713_update_tune_status(sdev);
1243 rnl->rnl = sdev->tune_rnl;
1257 struct si4713_device *sdev = to_si4713_device(sd);
1260 if (!sdev)
1274 if (sdev->power_state) {
1277 rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE,
1282 sdev->stereo = get_status_bit(comp_en, 1, 1 << 1);
1286 if (sdev->stereo)
1292 if (sdev->rds_enabled)
1303 struct si4713_device *sdev = to_si4713_device(sd);
1308 if (!sdev)
1324 if (sdev->power_state) {
1325 rval = si4713_read_property(sdev,
1333 rval = si4713_write_property(sdev,
1339 sdev->stereo = stereo;
1340 sdev->rds_enabled = rds;
1348 struct si4713_device *sdev = to_si4713_device(sd);
1354 if (sdev->power_state) {
1358 rval = si4713_tx_tune_status(sdev, 0x00, &freq, &p, &a, &n);
1362 sdev->frequency = freq;
1365 f->frequency = si4713_to_v4l2(sdev->frequency);
1373 struct si4713_device *sdev = to_si4713_device(sd);
1383 if (sdev->power_state) {
1384 rval = si4713_tx_tune_freq(sdev, frequency);
1390 sdev->frequency = frequency;
1432 struct si4713_device *sdev;
1440 sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL);
1441 if (!sdev) {
1447 sdev->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
1449 if (IS_ERR(sdev->gpio_reset)) {
1450 rval = PTR_ERR(sdev->gpio_reset);
1455 sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd");
1456 if (IS_ERR(sdev->vdd)) {
1457 rval = PTR_ERR(sdev->vdd);
1462 sdev->vdd = NULL;
1465 sdev->vio = devm_regulator_get_optional(&client->dev, "vio");
1466 if (IS_ERR(sdev->vio)) {
1467 rval = PTR_ERR(sdev->vio);
1472 sdev->vio = NULL;
1475 v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops);
1477 init_completion(&sdev->work);
1479 hdl = &sdev->ctrl_handler;
1481 sdev->mute = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1484 sdev->rds_pi = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1486 sdev->rds_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1488 sdev->rds_compressed = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1490 sdev->rds_art_head = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1492 sdev->rds_stereo = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1494 sdev->rds_tp = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1496 sdev->rds_ta = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1498 sdev->rds_ms = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1500 sdev->rds_dyn_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1502 sdev->rds_alt_freqs_enable = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1504 sdev->rds_alt_freqs = v4l2_ctrl_new_custom(hdl, &si4713_alt_freqs_ctrl, NULL);
1505 sdev->rds_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1513 sdev->rds_ps_name = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1520 sdev->rds_radio_text = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1523 sdev->limiter_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1525 sdev->limiter_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1528 sdev->limiter_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1532 sdev->compression_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1534 sdev->compression_gain = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1537 sdev->compression_threshold = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1541 sdev->compression_attack_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1544 sdev->compression_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1548 sdev->pilot_tone_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1550 sdev->pilot_tone_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1553 sdev->pilot_tone_freq = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1557 sdev->tune_preemphasis = v4l2_ctrl_new_std_menu(hdl, &si4713_ctrl_ops,
1560 sdev->tune_pwr_level = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1563 sdev->tune_ant_cap = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1571 v4l2_ctrl_cluster(29, &sdev->mute);
1572 sdev->sd.ctrl_handler = hdl;
1577 client->name, sdev);
1579 v4l2_err(&sdev->sd, "Could not request IRQ\n");
1582 v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n");
1584 v4l2_warn(&sdev->sd, "IRQ not configured. Using timeouts.\n");
1587 rval = si4713_initialize(sdev);
1589 v4l2_err(&sdev->sd, "Failed to probe device information.\n");
1612 sdev->pd = si4713_pdev;
1618 v4l2_device_unregister_subdev(&sdev->sd);
1629 struct si4713_device *sdev = to_si4713_device(sd);
1631 platform_device_unregister(sdev->pd);
1633 if (sdev->power_state)
1634 si4713_set_power_state(sdev, POWER_DOWN);