Lines Matching refs:sdev

186 	struct si4713_device *sdev = dev;
188 v4l2_dbg(2, debug, &sdev->sd,
190 complete(&sdev->work);
197 * @sdev: si4713_device structure for the device we are communicating
205 static int si4713_send_command(struct si4713_device *sdev, const u8 command,
209 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
220 DBG_BUFFER(&sdev->sd, "Parameters", data1, argn + 1);
224 v4l2_err(&sdev->sd, "Error while sending command 0x%02x\n",
233 if (!wait_for_completion_timeout(&sdev->work,
235 v4l2_warn(&sdev->sd,
243 v4l2_err(&sdev->sd,
249 DBG_BUFFER(&sdev->sd, "Response", response, respn);
266 * @sdev: si4713_device structure for the device we are communicating
270 static int si4713_read_property(struct si4713_device *sdev, u16 prop, u32 *pv)
285 err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
294 v4l2_dbg(1, debug, &sdev->sd,
303 * @sdev: si4713_device structure for the device we are communicating
307 static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
326 rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
334 v4l2_dbg(1, debug, &sdev->sd,
350 * @sdev: si4713_device structure for the device we are communicating
352 static int si4713_powerup(struct si4713_device *sdev)
354 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
366 if (sdev->power_state)
369 if (sdev->supplies) {
370 err = regulator_bulk_enable(sdev->supplies, sdev->supply_data);
372 v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err);
376 if (gpio_is_valid(sdev->gpio_reset)) {
378 gpio_set_value(sdev->gpio_reset, 1);
384 err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
390 v4l2_dbg(1, debug, &sdev->sd, "Powerup response: 0x%02x\n",
392 v4l2_dbg(1, debug, &sdev->sd, "Device in power up mode\n");
393 sdev->power_state = POWER_ON;
396 err = si4713_write_property(sdev, SI4713_GPO_IEN,
400 if (gpio_is_valid(sdev->gpio_reset))
401 gpio_set_value(sdev->gpio_reset, 0);
402 if (sdev->supplies) {
403 err = regulator_bulk_disable(sdev->supplies, sdev->supply_data);
405 v4l2_err(&sdev->sd,
414 * @sdev: si4713_device structure for the device we are communicating
416 static int si4713_powerdown(struct si4713_device *sdev)
421 if (!sdev->power_state)
424 err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
430 v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n",
432 v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
433 if (gpio_is_valid(sdev->gpio_reset))
434 gpio_set_value(sdev->gpio_reset, 0);
435 if (sdev->supplies) {
436 err = regulator_bulk_disable(sdev->supplies,
437 sdev->supply_data);
439 v4l2_err(&sdev->sd,
442 sdev->power_state = POWER_OFF;
450 * @sdev: si4713_device structure for the device we are communicating
452 static int si4713_checkrev(struct si4713_device *sdev)
454 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
458 rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
467 v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n",
470 v4l2_err(&sdev->sd, "Invalid product number 0x%X\n", resp[1]);
479 * @sdev: si4713_device structure for the device we are communicating
482 static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
484 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
490 !wait_for_completion_timeout(&sdev->work, usecs_to_jiffies(usecs) + 1))
491 v4l2_warn(&sdev->sd,
496 err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
503 v4l2_dbg(1, debug, &sdev->sd,
523 * @sdev: si4713_device structure for the device we are communicating
526 static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
541 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
548 v4l2_dbg(1, debug, &sdev->sd,
552 err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
566 * @sdev: si4713_device structure for the device we are communicating
570 static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
592 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
599 v4l2_dbg(1, debug, &sdev->sd,
603 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
614 * @sdev: si4713_device structure for the device we are communicating
618 static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
636 sdev->tune_rnl = DEFAULT_TUNE_RNL;
641 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
648 v4l2_dbg(1, debug, &sdev->sd,
652 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
662 * @sdev: si4713_device structure for the device we are communicating
669 static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
682 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
687 v4l2_dbg(1, debug, &sdev->sd,
690 sdev->frequency = *frequency;
694 v4l2_dbg(1, debug, &sdev->sd, "%s: response: %d x 10 kHz "
704 * @sdev: si4713_device structure for the device we are communicating
712 static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
728 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
733 v4l2_dbg(1, debug, &sdev->sd,
736 v4l2_dbg(1, debug, &sdev->sd, "%s: response: interrupts"
747 * @sdev: si4713_device structure for the device we are communicating
751 static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
765 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
772 v4l2_dbg(1, debug, &sdev->sd, "%s: status=0x%02x\n", __func__, val[0]);
777 static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
780 return si4713_powerup(sdev);
781 return si4713_powerdown(sdev);
784 static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
790 if (sdev->power_state)
791 rval = si4713_write_property(sdev,
797 static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
806 if (sdev->power_state) {
809 rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
821 rval = si4713_write_property(sdev,
827 rval = si4713_write_property(sdev,
837 static int si4713_set_rds_radio_text(struct si4713_device *sdev, const char *rt)
845 if (!sdev->power_state)
848 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0, &left);
870 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
889 * command. Must be called with sdev->mutex held.
890 * @sdev: si4713_device structure for the device we are communicating
892 static int si4713_update_tune_status(struct si4713_device *sdev)
898 rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
906 sdev->power_level = p;
907 sdev->antenna_capacitor = a;*/
908 sdev->tune_rnl = n;
914 static int si4713_choose_econtrol_action(struct si4713_device *sdev, u32 id,
1039 * @sdev: si4713_device structure for the device we are communicating
1041 static int si4713_setup(struct si4713_device *sdev)
1049 f.frequency = sdev->frequency ? sdev->frequency : DEFAULT_FREQUENCY;
1051 rval = si4713_s_frequency(&sdev->sd, &f);
1054 if (sdev->stereo)
1058 if (sdev->rds_enabled)
1060 si4713_s_modulator(&sdev->sd, &vm);
1067 * @sdev: si4713_device structure for the device we are communicating
1069 static int si4713_initialize(struct si4713_device *sdev)
1073 rval = si4713_set_power_state(sdev, POWER_ON);
1077 rval = si4713_checkrev(sdev);
1081 rval = si4713_set_power_state(sdev, POWER_OFF);
1085 sdev->frequency = DEFAULT_FREQUENCY;
1086 sdev->stereo = 1;
1087 sdev->tune_rnl = DEFAULT_TUNE_RNL;
1094 struct si4713_device *sdev =
1110 ret = si4713_set_mute(sdev, ctrl->val);
1112 ret = si4713_set_power_state(sdev, POWER_DOWN);
1115 ret = si4713_set_power_state(sdev, POWER_UP);
1117 ret = si4713_set_mute(sdev, ctrl->val);
1119 ret = si4713_setup(sdev);
1125 if (!sdev->power_state)
1136 ret = si4713_set_rds_ps_name(sdev, ctrl->p_new.p_char);
1140 ret = si4713_set_rds_radio_text(sdev, ctrl->p_new.p_char);
1151 ret = si4713_tx_tune_power(sdev,
1152 sdev->tune_pwr_level->val, sdev->tune_ant_cap->val);
1155 sdev->tune_ant_cap->is_new = false;
1156 sdev->tune_pwr_level->is_new = false;
1162 if (sdev->rds_alt_freqs_enable->val) {
1163 val = sdev->rds_alt_freqs->p_new.p_u32[0];
1168 ret = si4713_write_property(sdev, SI4713_TX_RDS_PS_AF, val);
1172 ret = si4713_choose_econtrol_action(sdev, ctrl->id, &bit,
1189 ret = si4713_read_property(sdev, property, &val);
1195 ret = si4713_write_property(sdev, property, val);
1210 struct si4713_device *sdev = to_si4713_device(sd);
1222 if (sdev->power_state) {
1224 rval = si4713_tx_tune_measure(sdev, frequency, 0);
1228 rval = si4713_update_tune_status(sdev);
1232 rnl->rnl = sdev->tune_rnl;
1246 struct si4713_device *sdev = to_si4713_device(sd);
1249 if (!sdev)
1263 if (sdev->power_state) {
1266 rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE,
1271 sdev->stereo = get_status_bit(comp_en, 1, 1 << 1);
1275 if (sdev->stereo)
1281 if (sdev->rds_enabled)
1292 struct si4713_device *sdev = to_si4713_device(sd);
1297 if (!sdev)
1313 if (sdev->power_state) {
1314 rval = si4713_read_property(sdev,
1322 rval = si4713_write_property(sdev,
1328 sdev->stereo = stereo;
1329 sdev->rds_enabled = rds;
1337 struct si4713_device *sdev = to_si4713_device(sd);
1343 if (sdev->power_state) {
1347 rval = si4713_tx_tune_status(sdev, 0x00, &freq, &p, &a, &n);
1351 sdev->frequency = freq;
1354 f->frequency = si4713_to_v4l2(sdev->frequency);
1362 struct si4713_device *sdev = to_si4713_device(sd);
1372 if (sdev->power_state) {
1373 rval = si4713_tx_tune_freq(sdev, frequency);
1379 sdev->frequency = frequency;
1422 struct si4713_device *sdev;
1427 sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
1428 if (!sdev) {
1434 sdev->gpio_reset = -1;
1442 sdev->gpio_reset = pdata->gpio_reset;
1443 gpio_direction_output(sdev->gpio_reset, 0);
1444 sdev->supplies = pdata->supplies;
1447 for (i = 0; i < sdev->supplies; i++)
1448 sdev->supply_data[i].supply = pdata->supply_names[i];
1450 rval = regulator_bulk_get(&client->dev, sdev->supplies,
1451 sdev->supply_data);
1457 v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops);
1459 init_completion(&sdev->work);
1461 hdl = &sdev->ctrl_handler;
1463 sdev->mute = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1466 sdev->rds_pi = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1468 sdev->rds_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1470 sdev->rds_compressed = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1472 sdev->rds_art_head = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1474 sdev->rds_stereo = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1476 sdev->rds_tp = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1478 sdev->rds_ta = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1480 sdev->rds_ms = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1482 sdev->rds_dyn_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1484 sdev->rds_alt_freqs_enable = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1486 sdev->rds_alt_freqs = v4l2_ctrl_new_custom(hdl, &si4713_alt_freqs_ctrl, NULL);
1487 sdev->rds_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1495 sdev->rds_ps_name = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1502 sdev->rds_radio_text = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1505 sdev->limiter_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1507 sdev->limiter_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1510 sdev->limiter_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1514 sdev->compression_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1516 sdev->compression_gain = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1519 sdev->compression_threshold = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1523 sdev->compression_attack_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1526 sdev->compression_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1530 sdev->pilot_tone_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1532 sdev->pilot_tone_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1535 sdev->pilot_tone_freq = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1539 sdev->tune_preemphasis = v4l2_ctrl_new_std_menu(hdl, &si4713_ctrl_ops,
1542 sdev->tune_pwr_level = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1545 sdev->tune_ant_cap = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops,
1553 v4l2_ctrl_cluster(29, &sdev->mute);
1554 sdev->sd.ctrl_handler = hdl;
1559 client->name, sdev);
1561 v4l2_err(&sdev->sd, "Could not request IRQ\n");
1564 v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n");
1566 v4l2_warn(&sdev->sd, "IRQ not configured. Using timeouts.\n");
1569 rval = si4713_initialize(sdev);
1571 v4l2_err(&sdev->sd, "Failed to probe device information.\n");
1579 free_irq(client->irq, sdev);
1583 regulator_bulk_free(sdev->supplies, sdev->supply_data);
1585 if (gpio_is_valid(sdev->gpio_reset))
1586 gpio_free(sdev->gpio_reset);
1588 kfree(sdev);
1597 struct si4713_device *sdev = to_si4713_device(sd);
1599 if (sdev->power_state)
1600 si4713_set_power_state(sdev, POWER_DOWN);
1603 free_irq(client->irq, sdev);
1607 regulator_bulk_free(sdev->supplies, sdev->supply_data);
1608 if (gpio_is_valid(sdev->gpio_reset))
1609 gpio_free(sdev->gpio_reset);
1610 kfree(sdev);