Lines Matching defs:state
218 struct adv7511_state *state = get_adv7511_state(sd);
226 ret = i2c_smbus_read_i2c_block_data(state->i2c_edid, i,
239 struct adv7511_state *state = get_adv7511_state(sd);
241 return i2c_smbus_read_byte_data(state->i2c_cec, reg);
246 struct adv7511_state *state = get_adv7511_state(sd);
251 ret = i2c_smbus_write_byte_data(state->i2c_cec, reg, val);
267 struct adv7511_state *state = get_adv7511_state(sd);
269 return adv_smbus_read_byte_data(state->i2c_pktmem, reg);
346 struct adv7511_state *state = get_adv7511_state(sd);
349 if (state->fmt_code != MEDIA_BUS_FMT_RGB888_1X24) {
358 if (state->dv_timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) {
382 struct adv7511_state *state = get_adv7511_state(sd);
386 if (state->hdmi_mode_ctrl == ctrl) {
391 if (state->rgb_quantization_range_ctrl == ctrl) {
395 if (state->content_type_ctrl == ctrl) {
398 state->content_type = ctrl->val;
399 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
400 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
418 struct adv7511_state *state = get_adv7511_state(sd);
421 if (state->i2c_cec)
427 struct adv7511_state *state = get_adv7511_state(sd);
435 if (state->i2c_cec) {
450 struct adv7511_state *state = get_adv7511_state(sd);
457 if (state->i2c_cec) {
547 struct adv7511_state *state = get_adv7511_state(sd);
548 struct adv7511_state_edid *edid = &state->edid;
573 v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off");
584 v4l2_info(sd, "state: %s, error: %s, detect count: %u, msk/irq: %02x/%02x\n",
586 errors[adv7511_rd(sd, 0xc8) >> 4], state->edid_detect_counter,
613 if (state->dv_timings.type == V4L2_DV_BT_656_1120)
615 &state->dv_timings, false);
618 v4l2_info(sd, "i2c edid addr: 0x%x\n", state->i2c_edid_addr);
620 if (state->i2c_cec == NULL)
623 v4l2_info(sd, "i2c cec addr: 0x%x\n", state->i2c_cec_addr);
625 v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ?
627 if (state->cec_enabled_adap) {
629 bool is_valid = state->cec_valid_addrs & (1 << i);
633 state->cec_addr[i]);
636 v4l2_info(sd, "i2c pktmem addr: 0x%x\n", state->i2c_pktmem_addr);
643 struct adv7511_state *state = get_adv7511_state(sd);
649 state->power_on = on;
685 adv7511_wr(sd, 0x43, state->i2c_edid_addr);
686 adv7511_wr(sd, 0x45, state->i2c_pktmem_addr);
696 struct adv7511_state *state = cec_get_drvdata(adap);
697 struct v4l2_subdev *sd = &state->sd;
699 if (state->i2c_cec == NULL)
702 if (!state->cec_enabled_adap && enable) {
714 if (state->enabled_irq)
716 } else if (state->cec_enabled_adap && !enable) {
717 if (state->enabled_irq)
723 state->cec_valid_addrs = 0;
725 state->cec_enabled_adap = enable;
731 struct adv7511_state *state = cec_get_drvdata(adap);
732 struct v4l2_subdev *sd = &state->sd;
735 if (!state->cec_enabled_adap)
740 state->cec_valid_addrs = 0;
745 bool is_valid = state->cec_valid_addrs & (1 << i);
749 if (is_valid && state->cec_addr[i] == addr)
757 state->cec_addr[i] = addr;
758 state->cec_valid_addrs |= 1 << i;
786 struct adv7511_state *state = cec_get_drvdata(adap);
787 struct v4l2_subdev *sd = &state->sd;
821 struct adv7511_state *state = get_adv7511_state(sd);
831 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST,
852 cec_transmit_done(state->cec_adap, status,
858 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_OK, 0, 0, 0, 0);
873 struct adv7511_state *state = get_adv7511_state(sd);
880 if (state->enabled_irq == enable)
882 state->enabled_irq = enable;
908 (state->cec_enabled_adap && enable) ? 0x39 : 0x00);
938 struct adv7511_state *state = get_adv7511_state(sd);
957 cec_received_msg(state->cec_adap, &msg);
985 struct adv7511_state *state = get_adv7511_state(sd);
993 state->have_monitor = false;
1001 struct adv7511_state *state = get_adv7511_state(sd);
1016 state->dv_timings = *timings;
1040 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl);
1048 struct adv7511_state *state = get_adv7511_state(sd);
1055 *timings = state->dv_timings;
1168 struct adv7511_state *state = get_adv7511_state(sd);
1176 edid->blocks = state->edid.blocks;
1180 if (state->edid.blocks == 0)
1183 if (edid->start_block >= state->edid.blocks)
1186 if (edid->start_block + edid->blocks > state->edid.blocks)
1187 edid->blocks = state->edid.blocks - edid->start_block;
1189 memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
1218 static void adv7511_fill_format(struct adv7511_state *state,
1221 format->width = state->dv_timings.bt.width;
1222 format->height = state->dv_timings.bt.height;
1230 struct adv7511_state *state = get_adv7511_state(sd);
1236 adv7511_fill_format(state, &format->format);
1248 format->format.code = state->fmt_code;
1249 format->format.colorspace = state->colorspace;
1250 format->format.ycbcr_enc = state->ycbcr_enc;
1251 format->format.quantization = state->quantization;
1252 format->format.xfer_func = state->xfer_func;
1262 struct adv7511_state *state = get_adv7511_state(sd);
1278 u8 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
1279 u8 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
1292 adv7511_fill_format(state, &format->format);
1322 state->fmt_code = format->format.code;
1323 state->colorspace = format->format.colorspace;
1324 state->ycbcr_enc = format->format.ycbcr_enc;
1325 state->quantization = format->format.quantization;
1326 state->xfer_func = format->format.xfer_func;
1396 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl);
1442 struct adv7511_state *state = get_adv7511_state(sd);
1449 cec_s_phys_addr(state->cec_adap, ed.phys_addr, false);
1451 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x0);
1457 struct adv7511_state *state = container_of(dwork, struct adv7511_state, edid_handler);
1458 struct v4l2_subdev *sd = &state->sd;
1471 if (state->edid.read_retries) {
1472 state->edid.read_retries--;
1474 state->have_monitor = false;
1477 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY);
1499 struct adv7511_state *state = get_adv7511_state(sd);
1527 v4l2_ctrl_handler_setup(&state->hdl);
1533 struct adv7511_state *state = get_adv7511_state(sd);
1535 mdt.present = state->have_monitor;
1541 struct adv7511_state *state = get_adv7511_state(sd);
1542 /* read hotplug and rx-sense state */
1552 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0);
1553 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0);
1555 if ((status & MASK_ADV7511_HPD_DETECT) && ((status & MASK_ADV7511_MSEN_DETECT) || state->edid.segments)) {
1557 if (!state->have_monitor) {
1559 state->have_monitor = true;
1567 state->edid.read_retries = EDID_MAX_RETRIES;
1568 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY);
1572 state->edid.read_retries = EDID_MAX_RETRIES;
1573 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY);
1576 if (state->have_monitor) {
1578 state->have_monitor = false;
1582 memset(&state->edid, 0, sizeof(struct adv7511_state_edid));
1599 struct adv7511_state *state = get_adv7511_state(sd);
1600 u32 blocks = state->edid.blocks;
1601 u8 *data = state->edid.data;
1615 struct adv7511_state *state = get_adv7511_state(sd);
1616 u8 *data = state->edid.data;
1625 struct adv7511_state *state = get_adv7511_state(sd);
1629 __func__, EDID_MAX_RETRIES - state->edid.read_retries);
1631 if (state->edid.complete)
1644 err = adv7511_edid_rd(sd, 256, &state->edid.data[segment * 256]);
1646 adv7511_dbg_dump_edid(2, debug, sd, segment, &state->edid.data[segment * 256]);
1648 state->edid.blocks = state->edid.data[0x7e] + 1;
1650 __func__, state->edid.blocks);
1658 state->have_monitor = false;
1664 state->edid.segments = segment + 1;
1665 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x1);
1666 if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) {
1668 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments);
1670 adv7511_wr(sd, 0xc4, state->edid.segments);
1671 state->edid.read_retries = EDID_MAX_RETRIES;
1672 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY);
1676 v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments);
1677 state->edid.complete = true;
1678 ed.phys_addr = cec_get_edid_phys_addr(state->edid.data,
1679 state->edid.segments * 256,
1686 state->edid_detect_counter++;
1687 cec_s_phys_addr(state->cec_adap, ed.phys_addr, false);
1697 struct adv7511_state *state = get_adv7511_state(sd);
1701 err = cec_register_adapter(state->cec_adap, &client->dev);
1703 cec_delete_adapter(state->cec_adap);
1709 struct adv7511_state *state = get_adv7511_state(sd);
1711 cec_unregister_adapter(state->cec_adap);
1723 struct adv7511_state *state = get_adv7511_state(sd);
1724 struct adv7511_state_edid *edid = &state->edid;
1725 u32 cec_clk = state->pdata.cec_clk;
1735 * It might leave the chip in a partly un-initialized state,
1740 state->have_monitor = false;
1745 if (state->i2c_cec == NULL)
1768 struct adv7511_state *state;
1779 state = devm_kzalloc(&client->dev, sizeof(struct adv7511_state), GFP_KERNEL);
1780 if (!state)
1788 memcpy(&state->pdata, pdata, sizeof(state->pdata));
1789 state->fmt_code = MEDIA_BUS_FMT_RGB888_1X24;
1790 state->colorspace = V4L2_COLORSPACE_SRGB;
1792 sd = &state->sd;
1800 hdl = &state->hdl;
1803 state->hdmi_mode_ctrl = v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops,
1806 state->hotplug_ctrl = v4l2_ctrl_new_std(hdl, NULL,
1808 state->rx_sense_ctrl = v4l2_ctrl_new_std(hdl, NULL,
1810 state->have_edid0_ctrl = v4l2_ctrl_new_std(hdl, NULL,
1812 state->rgb_quantization_range_ctrl =
1816 state->content_type_ctrl =
1825 state->pad.flags = MEDIA_PAD_FL_SINK;
1827 err = media_entity_pads_init(&sd->entity, 1, &state->pad);
1832 state->i2c_edid_addr = state->pdata.i2c_edid << 1;
1833 state->i2c_cec_addr = state->pdata.i2c_cec << 1;
1834 state->i2c_pktmem_addr = state->pdata.i2c_pktmem << 1;
1836 state->chip_revision = adv7511_rd(sd, 0x0);
1846 state->i2c_edid = i2c_new_dummy_device(client->adapter,
1847 state->i2c_edid_addr >> 1);
1848 if (IS_ERR(state->i2c_edid)) {
1850 err = PTR_ERR(state->i2c_edid);
1854 adv7511_wr(sd, 0xe1, state->i2c_cec_addr);
1855 if (state->pdata.cec_clk < 3000000 ||
1856 state->pdata.cec_clk > 100000000) {
1858 __func__, state->pdata.cec_clk);
1859 state->pdata.cec_clk = 0;
1862 if (state->pdata.cec_clk) {
1863 state->i2c_cec = i2c_new_dummy_device(client->adapter,
1864 state->i2c_cec_addr >> 1);
1865 if (IS_ERR(state->i2c_cec)) {
1867 err = PTR_ERR(state->i2c_cec);
1875 state->i2c_pktmem = i2c_new_dummy_device(client->adapter, state->i2c_pktmem_addr >> 1);
1876 if (IS_ERR(state->i2c_pktmem)) {
1878 err = PTR_ERR(state->i2c_pktmem);
1882 state->work_queue = create_singlethread_workqueue(sd->name);
1883 if (state->work_queue == NULL) {
1889 INIT_DELAYED_WORK(&state->edid_handler, adv7511_edid_handler);
1894 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
1895 state, dev_name(&client->dev), CEC_CAP_DEFAULTS,
1897 err = PTR_ERR_OR_ZERO(state->cec_adap);
1899 destroy_workqueue(state->work_queue);
1912 i2c_unregister_device(state->i2c_pktmem);
1914 i2c_unregister_device(state->i2c_cec);
1916 i2c_unregister_device(state->i2c_edid);
1920 v4l2_ctrl_handler_free(&state->hdl);
1929 struct adv7511_state *state = get_adv7511_state(sd);
1931 state->chip_revision = -1;
1938 cancel_delayed_work_sync(&state->edid_handler);
1939 i2c_unregister_device(state->i2c_edid);
1940 i2c_unregister_device(state->i2c_cec);
1941 i2c_unregister_device(state->i2c_pktmem);
1942 destroy_workqueue(state->work_queue);