Lines Matching refs:sdev

183 	struct si4713_device *sdev = dev;  in si4713_handler()  local
185 v4l2_dbg(2, debug, &sdev->sd, in si4713_handler()
187 complete(&sdev->work); in si4713_handler()
202 static int si4713_send_command(struct si4713_device *sdev, const u8 command, in si4713_send_command() argument
206 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd); in si4713_send_command()
217 DBG_BUFFER(&sdev->sd, "Parameters", data1, argn + 1); in si4713_send_command()
221 v4l2_err(&sdev->sd, "Error while sending command 0x%02x\n", in si4713_send_command()
230 if (!wait_for_completion_timeout(&sdev->work, in si4713_send_command()
232 v4l2_warn(&sdev->sd, in si4713_send_command()
240 v4l2_err(&sdev->sd, in si4713_send_command()
246 DBG_BUFFER(&sdev->sd, "Response", response, respn); in si4713_send_command()
267 static int si4713_read_property(struct si4713_device *sdev, u16 prop, u32 *pv) in si4713_read_property() argument
282 err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY, in si4713_read_property()
291 v4l2_dbg(1, debug, &sdev->sd, in si4713_read_property()
304 static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val) in si4713_write_property() argument
323 rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY, in si4713_write_property()
331 v4l2_dbg(1, debug, &sdev->sd, in si4713_write_property()
349 static int si4713_powerup(struct si4713_device *sdev) in si4713_powerup() argument
351 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd); in si4713_powerup()
363 if (sdev->power_state) in si4713_powerup()
366 if (sdev->vdd) { in si4713_powerup()
367 err = regulator_enable(sdev->vdd); in si4713_powerup()
369 v4l2_err(&sdev->sd, "Failed to enable vdd: %d\n", err); in si4713_powerup()
374 if (sdev->vio) { in si4713_powerup()
375 err = regulator_enable(sdev->vio); in si4713_powerup()
377 v4l2_err(&sdev->sd, "Failed to enable vio: %d\n", err); in si4713_powerup()
382 if (sdev->gpio_reset) { in si4713_powerup()
384 gpiod_set_value(sdev->gpio_reset, 1); in si4713_powerup()
390 err = si4713_send_command(sdev, SI4713_CMD_POWER_UP, in si4713_powerup()
396 v4l2_dbg(1, debug, &sdev->sd, "Powerup response: 0x%02x\n", in si4713_powerup()
398 v4l2_dbg(1, debug, &sdev->sd, "Device in power up mode\n"); in si4713_powerup()
399 sdev->power_state = POWER_ON; in si4713_powerup()
402 err = si4713_write_property(sdev, SI4713_GPO_IEN, in si4713_powerup()
406 gpiod_set_value(sdev->gpio_reset, 0); in si4713_powerup()
409 if (sdev->vdd) { in si4713_powerup()
410 err = regulator_disable(sdev->vdd); in si4713_powerup()
412 v4l2_err(&sdev->sd, "Failed to disable vdd: %d\n", err); in si4713_powerup()
415 if (sdev->vio) { in si4713_powerup()
416 err = regulator_disable(sdev->vio); in si4713_powerup()
418 v4l2_err(&sdev->sd, "Failed to disable vio: %d\n", err); in si4713_powerup()
428 static int si4713_powerdown(struct si4713_device *sdev) in si4713_powerdown() argument
433 if (!sdev->power_state) in si4713_powerdown()
436 err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN, in si4713_powerdown()
442 v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", in si4713_powerdown()
444 v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); in si4713_powerdown()
445 if (sdev->gpio_reset) in si4713_powerdown()
446 gpiod_set_value(sdev->gpio_reset, 0); in si4713_powerdown()
448 if (sdev->vdd) { in si4713_powerdown()
449 err = regulator_disable(sdev->vdd); in si4713_powerdown()
451 v4l2_err(&sdev->sd, in si4713_powerdown()
456 if (sdev->vio) { in si4713_powerdown()
457 err = regulator_disable(sdev->vio); in si4713_powerdown()
459 v4l2_err(&sdev->sd, in si4713_powerdown()
463 sdev->power_state = POWER_OFF; in si4713_powerdown()
473 static int si4713_checkrev(struct si4713_device *sdev) in si4713_checkrev() argument
475 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd); in si4713_checkrev()
479 rval = si4713_send_command(sdev, SI4713_CMD_GET_REV, in si4713_checkrev()
488 v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n", in si4713_checkrev()
491 v4l2_err(&sdev->sd, "Invalid product number 0x%X\n", resp[1]); in si4713_checkrev()
503 static int si4713_wait_stc(struct si4713_device *sdev, const int usecs) in si4713_wait_stc() argument
505 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd); in si4713_wait_stc()
511 !wait_for_completion_timeout(&sdev->work, usecs_to_jiffies(usecs) + 1)) in si4713_wait_stc()
512 v4l2_warn(&sdev->sd, in si4713_wait_stc()
517 err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS, in si4713_wait_stc()
524 v4l2_dbg(1, debug, &sdev->sd, in si4713_wait_stc()
547 static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency) in si4713_tx_tune_freq() argument
562 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ, in si4713_tx_tune_freq()
569 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_tune_freq()
573 err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE); in si4713_tx_tune_freq()
591 static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power, in si4713_tx_tune_power() argument
613 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER, in si4713_tx_tune_power()
620 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_tune_power()
624 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER); in si4713_tx_tune_power()
639 static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency, in si4713_tx_tune_measure() argument
657 sdev->tune_rnl = DEFAULT_TUNE_RNL; in si4713_tx_tune_measure()
662 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE, in si4713_tx_tune_measure()
669 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_tune_measure()
673 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE); in si4713_tx_tune_measure()
690 static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack, in si4713_tx_tune_status() argument
703 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS, in si4713_tx_tune_status()
708 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_tune_status()
711 sdev->frequency = *frequency; in si4713_tx_tune_status()
715 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_tune_status()
733 static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb, in si4713_tx_rds_buff() argument
749 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF, in si4713_tx_rds_buff()
754 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_rds_buff()
757 v4l2_dbg(1, debug, &sdev->sd, in si4713_tx_rds_buff()
771 static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid, in si4713_tx_rds_ps() argument
785 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS, in si4713_tx_rds_ps()
792 v4l2_dbg(1, debug, &sdev->sd, "%s: status=0x%02x\n", __func__, val[0]); in si4713_tx_rds_ps()
797 static int si4713_set_power_state(struct si4713_device *sdev, u8 value) in si4713_set_power_state() argument
800 return si4713_powerup(sdev); in si4713_set_power_state()
801 return si4713_powerdown(sdev); in si4713_set_power_state()
804 static int si4713_set_mute(struct si4713_device *sdev, u16 mute) in si4713_set_mute() argument
810 if (sdev->power_state) in si4713_set_mute()
811 rval = si4713_write_property(sdev, in si4713_set_mute()
817 static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name) in si4713_set_rds_ps_name() argument
826 if (sdev->power_state) { in si4713_set_rds_ps_name()
829 rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)), in si4713_set_rds_ps_name()
841 rval = si4713_write_property(sdev, in si4713_set_rds_ps_name()
847 rval = si4713_write_property(sdev, in si4713_set_rds_ps_name()
857 static int si4713_set_rds_radio_text(struct si4713_device *sdev, const char *rt) in si4713_set_rds_radio_text() argument
865 if (!sdev->power_state) in si4713_set_rds_radio_text()
868 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0, &left); in si4713_set_rds_radio_text()
890 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD, in si4713_set_rds_radio_text()
912 static int si4713_update_tune_status(struct si4713_device *sdev) in si4713_update_tune_status() argument
918 rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n); in si4713_update_tune_status()
928 sdev->tune_rnl = n; in si4713_update_tune_status()
934 static int si4713_choose_econtrol_action(struct si4713_device *sdev, u32 id, in si4713_choose_econtrol_action() argument
1061 static int si4713_setup(struct si4713_device *sdev) in si4713_setup() argument
1069 f.frequency = sdev->frequency ? sdev->frequency : DEFAULT_FREQUENCY; in si4713_setup()
1071 rval = si4713_s_frequency(&sdev->sd, &f); in si4713_setup()
1074 if (sdev->stereo) in si4713_setup()
1078 if (sdev->rds_enabled) in si4713_setup()
1080 si4713_s_modulator(&sdev->sd, &vm); in si4713_setup()
1089 static int si4713_initialize(struct si4713_device *sdev) in si4713_initialize() argument
1093 rval = si4713_set_power_state(sdev, POWER_ON); in si4713_initialize()
1097 rval = si4713_checkrev(sdev); in si4713_initialize()
1101 rval = si4713_set_power_state(sdev, POWER_OFF); in si4713_initialize()
1105 sdev->frequency = DEFAULT_FREQUENCY; in si4713_initialize()
1106 sdev->stereo = 1; in si4713_initialize()
1107 sdev->tune_rnl = DEFAULT_TUNE_RNL; in si4713_initialize()
1114 struct si4713_device *sdev = in si4713_s_ctrl() local
1130 ret = si4713_set_mute(sdev, ctrl->val); in si4713_s_ctrl()
1132 ret = si4713_set_power_state(sdev, POWER_DOWN); in si4713_s_ctrl()
1135 ret = si4713_set_power_state(sdev, POWER_UP); in si4713_s_ctrl()
1137 ret = si4713_set_mute(sdev, ctrl->val); in si4713_s_ctrl()
1139 ret = si4713_setup(sdev); in si4713_s_ctrl()
1145 if (!sdev->power_state) in si4713_s_ctrl()
1156 ret = si4713_set_rds_ps_name(sdev, ctrl->p_new.p_char); in si4713_s_ctrl()
1160 ret = si4713_set_rds_radio_text(sdev, ctrl->p_new.p_char); in si4713_s_ctrl()
1171 ret = si4713_tx_tune_power(sdev, in si4713_s_ctrl()
1172 sdev->tune_pwr_level->val, sdev->tune_ant_cap->val); in si4713_s_ctrl()
1175 sdev->tune_ant_cap->is_new = false; in si4713_s_ctrl()
1176 sdev->tune_pwr_level->is_new = false; in si4713_s_ctrl()
1182 if (sdev->rds_alt_freqs_enable->val) { in si4713_s_ctrl()
1183 val = sdev->rds_alt_freqs->p_new.p_u32[0]; in si4713_s_ctrl()
1188 ret = si4713_write_property(sdev, SI4713_TX_RDS_PS_AF, val); in si4713_s_ctrl()
1192 ret = si4713_choose_econtrol_action(sdev, ctrl->id, &bit, in si4713_s_ctrl()
1209 ret = si4713_read_property(sdev, property, &val); in si4713_s_ctrl()
1215 ret = si4713_write_property(sdev, property, val); in si4713_s_ctrl()
1230 struct si4713_device *sdev = to_si4713_device(sd); in si4713_ioctl() local
1242 if (sdev->power_state) { in si4713_ioctl()
1244 rval = si4713_tx_tune_measure(sdev, frequency, 0); in si4713_ioctl()
1248 rval = si4713_update_tune_status(sdev); in si4713_ioctl()
1252 rnl->rnl = sdev->tune_rnl; in si4713_ioctl()
1266 struct si4713_device *sdev = to_si4713_device(sd); in si4713_g_modulator() local
1269 if (!sdev) in si4713_g_modulator()
1283 if (sdev->power_state) { in si4713_g_modulator()
1286 rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE, in si4713_g_modulator()
1291 sdev->stereo = get_status_bit(comp_en, 1, 1 << 1); in si4713_g_modulator()
1295 if (sdev->stereo) in si4713_g_modulator()
1301 if (sdev->rds_enabled) in si4713_g_modulator()
1312 struct si4713_device *sdev = to_si4713_device(sd); in si4713_s_modulator() local
1317 if (!sdev) in si4713_s_modulator()
1333 if (sdev->power_state) { in si4713_s_modulator()
1334 rval = si4713_read_property(sdev, in si4713_s_modulator()
1342 rval = si4713_write_property(sdev, in si4713_s_modulator()
1348 sdev->stereo = stereo; in si4713_s_modulator()
1349 sdev->rds_enabled = rds; in si4713_s_modulator()
1357 struct si4713_device *sdev = to_si4713_device(sd); in si4713_g_frequency() local
1363 if (sdev->power_state) { in si4713_g_frequency()
1367 rval = si4713_tx_tune_status(sdev, 0x00, &freq, &p, &a, &n); in si4713_g_frequency()
1371 sdev->frequency = freq; in si4713_g_frequency()
1374 f->frequency = si4713_to_v4l2(sdev->frequency); in si4713_g_frequency()
1382 struct si4713_device *sdev = to_si4713_device(sd); in si4713_s_frequency() local
1392 if (sdev->power_state) { in si4713_s_frequency()
1393 rval = si4713_tx_tune_freq(sdev, frequency); in si4713_s_frequency()
1399 sdev->frequency = frequency; in si4713_s_frequency()
1442 struct si4713_device *sdev; in si4713_probe() local
1450 sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL); in si4713_probe()
1451 if (!sdev) { in si4713_probe()
1457 sdev->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", in si4713_probe()
1459 if (IS_ERR(sdev->gpio_reset)) { in si4713_probe()
1460 rval = PTR_ERR(sdev->gpio_reset); in si4713_probe()
1465 sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd"); in si4713_probe()
1466 if (IS_ERR(sdev->vdd)) { in si4713_probe()
1467 rval = PTR_ERR(sdev->vdd); in si4713_probe()
1472 sdev->vdd = NULL; in si4713_probe()
1475 sdev->vio = devm_regulator_get_optional(&client->dev, "vio"); in si4713_probe()
1476 if (IS_ERR(sdev->vio)) { in si4713_probe()
1477 rval = PTR_ERR(sdev->vio); in si4713_probe()
1482 sdev->vio = NULL; in si4713_probe()
1485 v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops); in si4713_probe()
1487 init_completion(&sdev->work); in si4713_probe()
1489 hdl = &sdev->ctrl_handler; in si4713_probe()
1491 sdev->mute = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1494 sdev->rds_pi = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1496 sdev->rds_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1498 sdev->rds_compressed = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1500 sdev->rds_art_head = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1502 sdev->rds_stereo = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1504 sdev->rds_tp = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1506 sdev->rds_ta = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1508 sdev->rds_ms = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1510 sdev->rds_dyn_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1512 sdev->rds_alt_freqs_enable = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1514 sdev->rds_alt_freqs = v4l2_ctrl_new_custom(hdl, &si4713_alt_freqs_ctrl, NULL); in si4713_probe()
1515 sdev->rds_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1523 sdev->rds_ps_name = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1530 sdev->rds_radio_text = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1533 sdev->limiter_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1535 sdev->limiter_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1538 sdev->limiter_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1542 sdev->compression_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1544 sdev->compression_gain = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1547 sdev->compression_threshold = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1551 sdev->compression_attack_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1554 sdev->compression_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1558 sdev->pilot_tone_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1560 sdev->pilot_tone_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1563 sdev->pilot_tone_freq = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1567 sdev->tune_preemphasis = v4l2_ctrl_new_std_menu(hdl, &si4713_ctrl_ops, in si4713_probe()
1570 sdev->tune_pwr_level = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1573 sdev->tune_ant_cap = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, in si4713_probe()
1581 v4l2_ctrl_cluster(29, &sdev->mute); in si4713_probe()
1582 sdev->sd.ctrl_handler = hdl; in si4713_probe()
1587 client->name, sdev); in si4713_probe()
1589 v4l2_err(&sdev->sd, "Could not request IRQ\n"); in si4713_probe()
1592 v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n"); in si4713_probe()
1594 v4l2_warn(&sdev->sd, "IRQ not configured. Using timeouts.\n"); in si4713_probe()
1597 rval = si4713_initialize(sdev); in si4713_probe()
1599 v4l2_err(&sdev->sd, "Failed to probe device information.\n"); in si4713_probe()
1622 sdev->pd = si4713_pdev; in si4713_probe()
1628 v4l2_device_unregister_subdev(&sdev->sd); in si4713_probe()
1639 struct si4713_device *sdev = to_si4713_device(sd); in si4713_remove() local
1641 platform_device_unregister(sdev->pd); in si4713_remove()
1643 if (sdev->power_state) in si4713_remove()
1644 si4713_set_power_state(sdev, POWER_DOWN); in si4713_remove()