Lines Matching refs:adv7511

136 static void adv7511_set_colormap(struct adv7511 *adv7511, bool enable,  in adv7511_set_colormap()  argument
142 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1), in adv7511_set_colormap()
147 regmap_update_bits(adv7511->regmap, in adv7511_set_colormap()
150 regmap_write(adv7511->regmap, in adv7511_set_colormap()
157 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0), in adv7511_set_colormap()
160 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0), in adv7511_set_colormap()
163 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1), in adv7511_set_colormap()
167 static int adv7511_packet_enable(struct adv7511 *adv7511, unsigned int packet) in adv7511_packet_enable() argument
170 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0, in adv7511_packet_enable()
175 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1, in adv7511_packet_enable()
182 static int adv7511_packet_disable(struct adv7511 *adv7511, unsigned int packet) in adv7511_packet_disable() argument
185 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0, in adv7511_packet_disable()
190 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1, in adv7511_packet_disable()
204 static void adv7511_set_config_csc(struct adv7511 *adv7511, in adv7511_set_config_csc() argument
261 adv7511_packet_disable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME); in adv7511_set_config_csc()
263 adv7511_set_colormap(adv7511, config.csc_enable, in adv7511_set_config_csc()
267 regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x81, in adv7511_set_config_csc()
270 regmap_update_bits(adv7511->regmap, ADV7511_REG_HDCP_HDMI_CFG, in adv7511_set_config_csc()
277 regmap_bulk_write(adv7511->regmap, ADV7511_REG_AVI_INFOFRAME_VERSION, in adv7511_set_config_csc()
280 adv7511_packet_enable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME); in adv7511_set_config_csc()
283 static void adv7511_set_link_config(struct adv7511 *adv7511, in adv7511_set_link_config() argument
311 regmap_update_bits(adv7511->regmap, ADV7511_REG_I2C_FREQ_ID_CFG, 0xf, in adv7511_set_link_config()
313 regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x7e, in adv7511_set_link_config()
316 regmap_write(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG2, in adv7511_set_link_config()
318 regmap_write(adv7511->regmap, ADV7511_REG_TIMING_GEN_SEQ, in adv7511_set_link_config()
321 regmap_write(adv7511->regmap, 0xba, clock_delay << 5); in adv7511_set_link_config()
323 adv7511->embedded_sync = config->embedded_sync; in adv7511_set_link_config()
324 adv7511->hsync_polarity = config->hsync_polarity; in adv7511_set_link_config()
325 adv7511->vsync_polarity = config->vsync_polarity; in adv7511_set_link_config()
326 adv7511->rgb = config->input_colorspace == HDMI_COLORSPACE_RGB; in adv7511_set_link_config()
329 static void __adv7511_power_on(struct adv7511 *adv7511) in __adv7511_power_on() argument
331 adv7511->current_edid_segment = -1; in __adv7511_power_on()
333 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, in __adv7511_power_on()
335 if (adv7511->i2c_main->irq) { in __adv7511_power_on()
341 regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0), in __adv7511_power_on()
343 regmap_update_bits(adv7511->regmap, in __adv7511_power_on()
358 if (adv7511->info->hpd_override_enable) in __adv7511_power_on()
359 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in __adv7511_power_on()
363 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in __adv7511_power_on()
368 static void adv7511_power_on(struct adv7511 *adv7511) in adv7511_power_on() argument
370 __adv7511_power_on(adv7511); in adv7511_power_on()
375 regcache_sync(adv7511->regmap); in adv7511_power_on()
377 if (adv7511->info->has_dsi) in adv7511_power_on()
378 adv7533_dsi_power_on(adv7511); in adv7511_power_on()
379 adv7511->powered = true; in adv7511_power_on()
382 static void __adv7511_power_off(struct adv7511 *adv7511) in __adv7511_power_off() argument
385 if (adv7511->info->hpd_override_enable) in __adv7511_power_off()
386 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in __adv7511_power_off()
389 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, in __adv7511_power_off()
392 regmap_update_bits(adv7511->regmap, in __adv7511_power_off()
395 regcache_mark_dirty(adv7511->regmap); in __adv7511_power_off()
398 static void adv7511_power_off(struct adv7511 *adv7511) in adv7511_power_off() argument
400 __adv7511_power_off(adv7511); in adv7511_power_off()
401 if (adv7511->info->has_dsi) in adv7511_power_off()
402 adv7533_dsi_power_off(adv7511); in adv7511_power_off()
403 adv7511->powered = false; in adv7511_power_off()
410 static bool adv7511_hpd(struct adv7511 *adv7511) in adv7511_hpd() argument
415 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); in adv7511_hpd()
420 regmap_write(adv7511->regmap, ADV7511_REG_INT(0), in adv7511_hpd()
430 struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work); in adv7511_hpd_work() local
435 ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); in adv7511_hpd_work()
449 adv7511->connector.status == connector_status_disconnected && in adv7511_hpd_work()
450 adv7511->powered) { in adv7511_hpd_work()
451 regcache_mark_dirty(adv7511->regmap); in adv7511_hpd_work()
452 adv7511_power_on(adv7511); in adv7511_hpd_work()
455 if (adv7511->connector.status != status) { in adv7511_hpd_work()
456 adv7511->connector.status = status; in adv7511_hpd_work()
458 if (adv7511->connector.dev) { in adv7511_hpd_work()
460 cec_phys_addr_invalidate(adv7511->cec_adap); in adv7511_hpd_work()
461 drm_kms_helper_hotplug_event(adv7511->connector.dev); in adv7511_hpd_work()
463 drm_bridge_hpd_notify(&adv7511->bridge, status); in adv7511_hpd_work()
468 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) in adv7511_irq_process() argument
475 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); in adv7511_irq_process()
479 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1); in adv7511_irq_process()
483 regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); in adv7511_irq_process()
484 regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); in adv7511_irq_process()
486 if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) { in adv7511_irq_process()
487 schedule_work(&adv7511->hpd_work); in adv7511_irq_process()
492 adv7511->edid_read = true; in adv7511_irq_process()
494 if (adv7511->i2c_main->irq) in adv7511_irq_process()
495 wake_up_all(&adv7511->wq); in adv7511_irq_process()
500 cec_status = adv7511_cec_irq_process(adv7511, irq1); in adv7511_irq_process()
512 struct adv7511 *adv7511 = devid; in adv7511_irq_handler() local
515 ret = adv7511_irq_process(adv7511, true); in adv7511_irq_handler()
523 static int adv7511_wait_for_edid(struct adv7511 *adv7511, int timeout) in adv7511_wait_for_edid() argument
527 if (adv7511->i2c_main->irq) { in adv7511_wait_for_edid()
528 ret = wait_event_interruptible_timeout(adv7511->wq, in adv7511_wait_for_edid()
529 adv7511->edid_read, msecs_to_jiffies(timeout)); in adv7511_wait_for_edid()
532 ret = adv7511_irq_process(adv7511, false); in adv7511_wait_for_edid()
536 if (adv7511->edid_read) in adv7511_wait_for_edid()
543 return adv7511->edid_read ? 0 : -EIO; in adv7511_wait_for_edid()
549 struct adv7511 *adv7511 = data; in adv7511_get_edid_block() local
558 if (adv7511->current_edid_segment != block / 2) { in adv7511_get_edid_block()
561 ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS, in adv7511_get_edid_block()
567 adv7511->edid_read = false; in adv7511_get_edid_block()
568 regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, in adv7511_get_edid_block()
570 ret = adv7511_wait_for_edid(adv7511, 200); in adv7511_get_edid_block()
579 xfer[0].addr = adv7511->i2c_edid->addr; in adv7511_get_edid_block()
583 xfer[1].addr = adv7511->i2c_edid->addr; in adv7511_get_edid_block()
586 xfer[1].buf = adv7511->edid_buf; in adv7511_get_edid_block()
591 ret = i2c_transfer(adv7511->i2c_edid->adapter, xfer, in adv7511_get_edid_block()
602 adv7511->current_edid_segment = block / 2; in adv7511_get_edid_block()
606 memcpy(buf, adv7511->edid_buf, len); in adv7511_get_edid_block()
608 memcpy(buf, adv7511->edid_buf + 128, len); in adv7511_get_edid_block()
617 static const struct drm_edid *adv7511_edid_read(struct adv7511 *adv7511, in adv7511_edid_read() argument
623 if (!adv7511->powered) { in adv7511_edid_read()
625 (adv7511->i2c_edid->addr << 1); in adv7511_edid_read()
627 __adv7511_power_on(adv7511); in adv7511_edid_read()
630 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, in adv7511_edid_read()
634 drm_edid = drm_edid_read_custom(connector, adv7511_get_edid_block, adv7511); in adv7511_edid_read()
636 if (!adv7511->powered) in adv7511_edid_read()
637 __adv7511_power_off(adv7511); in adv7511_edid_read()
649 adv7511_set_config_csc(adv7511, connector, adv7511->rgb, in adv7511_edid_read()
652 cec_s_phys_addr_from_edid(adv7511->cec_adap, edid); in adv7511_edid_read()
654 cec_s_phys_addr_from_edid(adv7511->cec_adap, NULL); in adv7511_edid_read()
660 static int adv7511_get_modes(struct adv7511 *adv7511, in adv7511_get_modes() argument
666 drm_edid = adv7511_edid_read(adv7511, connector); in adv7511_get_modes()
677 adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector) in adv7511_detect() argument
684 ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); in adv7511_detect()
693 hpd = adv7511_hpd(adv7511); in adv7511_detect()
699 if (status == connector_status_connected && hpd && adv7511->powered) { in adv7511_detect()
700 regcache_mark_dirty(adv7511->regmap); in adv7511_detect()
701 adv7511_power_on(adv7511); in adv7511_detect()
703 adv7511_get_modes(adv7511, connector); in adv7511_detect()
704 if (adv7511->status == connector_status_connected) in adv7511_detect()
708 if (adv7511->info->hpd_override_enable) in adv7511_detect()
709 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in adv7511_detect()
713 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in adv7511_detect()
718 adv7511->status = status; in adv7511_detect()
722 static enum drm_mode_status adv7511_mode_valid(struct adv7511 *adv7511, in adv7511_mode_valid() argument
731 static void adv7511_mode_set(struct adv7511 *adv7511, in adv7511_mode_set() argument
739 if (adv7511->embedded_sync) { in adv7511_mode_set()
755 regmap_write(adv7511->regmap, ADV7511_REG_HSYNC_PLACEMENT_MSB, in adv7511_mode_set()
757 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(0), in adv7511_mode_set()
759 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(1), in adv7511_mode_set()
762 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(2), in adv7511_mode_set()
765 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(3), in adv7511_mode_set()
768 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(4), in adv7511_mode_set()
792 if (adv7511->hsync_polarity != mode_hsync_polarity && in adv7511_mode_set()
793 adv7511->hsync_polarity != in adv7511_mode_set()
797 if (adv7511->vsync_polarity != mode_vsync_polarity && in adv7511_mode_set()
798 adv7511->vsync_polarity != in adv7511_mode_set()
812 if (adv7511->info->type == ADV7511) in adv7511_mode_set()
813 regmap_update_bits(adv7511->regmap, 0xfb, in adv7511_mode_set()
816 regmap_update_bits(adv7511->regmap, 0x4a, in adv7511_mode_set()
819 regmap_update_bits(adv7511->regmap, 0x17, in adv7511_mode_set()
822 drm_mode_copy(&adv7511->curr_mode, adj_mode); in adv7511_mode_set()
829 adv7511->f_tmds = mode->clock; in adv7511_mode_set()
836 static struct adv7511 *connector_to_adv7511(struct drm_connector *connector) in connector_to_adv7511()
838 return container_of(connector, struct adv7511, connector); in connector_to_adv7511()
843 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_get_modes()
852 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_mode_valid()
865 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_detect()
879 static int adv7511_connector_init(struct adv7511 *adv) in adv7511_connector_init()
908 static struct adv7511 *bridge_to_adv7511(struct drm_bridge *bridge) in bridge_to_adv7511()
910 return container_of(bridge, struct adv7511, bridge); in bridge_to_adv7511()
915 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_enable()
922 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_disable()
931 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_mode_set()
940 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_mode_valid()
951 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_attach()
976 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_detect()
984 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_edid_read()
992 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_hpd_notify()
1030 static int adv7511_init_regulators(struct adv7511 *adv) in adv7511_init_regulators()
1053 static void adv7511_uninit_regulators(struct adv7511 *adv) in adv7511_uninit_regulators()
1061 struct adv7511 *adv7511 = i2c_get_clientdata(i2c); in adv7511_cec_register_volatile() local
1063 reg -= adv7511->info->reg_cec_offset; in adv7511_cec_register_volatile()
1093 static int adv7511_init_cec_regmap(struct adv7511 *adv) in adv7511_init_cec_regmap()
1212 struct adv7511 *adv7511; in adv7511_probe() local
1220 adv7511 = devm_kzalloc(dev, sizeof(*adv7511), GFP_KERNEL); in adv7511_probe()
1221 if (!adv7511) in adv7511_probe()
1224 adv7511->i2c_main = i2c; in adv7511_probe()
1225 adv7511->powered = false; in adv7511_probe()
1226 adv7511->status = connector_status_disconnected; in adv7511_probe()
1227 adv7511->info = i2c_get_match_data(i2c); in adv7511_probe()
1232 &adv7511->next_bridge); in adv7511_probe()
1236 if (adv7511->info->link_config) in adv7511_probe()
1239 ret = adv7533_parse_dt(dev->of_node, adv7511); in adv7511_probe()
1243 ret = adv7511_init_regulators(adv7511); in adv7511_probe()
1251 adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", GPIOD_OUT_HIGH); in adv7511_probe()
1252 if (IS_ERR(adv7511->gpio_pd)) { in adv7511_probe()
1253 ret = PTR_ERR(adv7511->gpio_pd); in adv7511_probe()
1257 if (adv7511->gpio_pd) { in adv7511_probe()
1259 gpiod_set_value_cansleep(adv7511->gpio_pd, 0); in adv7511_probe()
1262 adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config); in adv7511_probe()
1263 if (IS_ERR(adv7511->regmap)) { in adv7511_probe()
1264 ret = PTR_ERR(adv7511->regmap); in adv7511_probe()
1268 ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val); in adv7511_probe()
1273 if (adv7511->info->type == ADV7511) in adv7511_probe()
1274 ret = regmap_register_patch(adv7511->regmap, in adv7511_probe()
1278 ret = adv7533_patch_registers(adv7511); in adv7511_probe()
1282 adv7511_packet_disable(adv7511, 0xffff); in adv7511_probe()
1284 adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid", in adv7511_probe()
1286 if (IS_ERR(adv7511->i2c_edid)) { in adv7511_probe()
1287 ret = PTR_ERR(adv7511->i2c_edid); in adv7511_probe()
1291 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, in adv7511_probe()
1292 adv7511->i2c_edid->addr << 1); in adv7511_probe()
1294 adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet", in adv7511_probe()
1296 if (IS_ERR(adv7511->i2c_packet)) { in adv7511_probe()
1297 ret = PTR_ERR(adv7511->i2c_packet); in adv7511_probe()
1301 regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR, in adv7511_probe()
1302 adv7511->i2c_packet->addr << 1); in adv7511_probe()
1304 ret = adv7511_init_cec_regmap(adv7511); in adv7511_probe()
1308 INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work); in adv7511_probe()
1310 adv7511_power_off(adv7511); in adv7511_probe()
1312 i2c_set_clientdata(i2c, adv7511); in adv7511_probe()
1314 if (adv7511->info->link_config) in adv7511_probe()
1315 adv7511_set_link_config(adv7511, &link_config); in adv7511_probe()
1317 ret = adv7511_cec_init(dev, adv7511); in adv7511_probe()
1321 adv7511->bridge.funcs = &adv7511_bridge_funcs; in adv7511_probe()
1322 adv7511->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; in adv7511_probe()
1323 if (adv7511->i2c_main->irq) in adv7511_probe()
1324 adv7511->bridge.ops |= DRM_BRIDGE_OP_HPD; in adv7511_probe()
1326 adv7511->bridge.of_node = dev->of_node; in adv7511_probe()
1327 adv7511->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in adv7511_probe()
1329 drm_bridge_add(&adv7511->bridge); in adv7511_probe()
1331 adv7511_audio_init(dev, adv7511); in adv7511_probe()
1334 init_waitqueue_head(&adv7511->wq); in adv7511_probe()
1340 adv7511); in adv7511_probe()
1345 if (adv7511->info->has_dsi) { in adv7511_probe()
1346 ret = adv7533_attach_dsi(adv7511); in adv7511_probe()
1354 adv7511_audio_exit(adv7511); in adv7511_probe()
1355 drm_bridge_remove(&adv7511->bridge); in adv7511_probe()
1357 cec_unregister_adapter(adv7511->cec_adap); in adv7511_probe()
1358 i2c_unregister_device(adv7511->i2c_cec); in adv7511_probe()
1359 clk_disable_unprepare(adv7511->cec_clk); in adv7511_probe()
1361 i2c_unregister_device(adv7511->i2c_packet); in adv7511_probe()
1363 i2c_unregister_device(adv7511->i2c_edid); in adv7511_probe()
1365 adv7511_uninit_regulators(adv7511); in adv7511_probe()
1372 struct adv7511 *adv7511 = i2c_get_clientdata(i2c); in adv7511_remove() local
1374 adv7511_uninit_regulators(adv7511); in adv7511_remove()
1376 drm_bridge_remove(&adv7511->bridge); in adv7511_remove()
1378 adv7511_audio_exit(adv7511); in adv7511_remove()
1380 cec_unregister_adapter(adv7511->cec_adap); in adv7511_remove()
1381 i2c_unregister_device(adv7511->i2c_cec); in adv7511_remove()
1382 clk_disable_unprepare(adv7511->cec_clk); in adv7511_remove()
1384 i2c_unregister_device(adv7511->i2c_packet); in adv7511_remove()
1385 i2c_unregister_device(adv7511->i2c_edid); in adv7511_remove()