Lines Matching refs:sdev

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