Lines Matching refs:adv7511
135 static void adv7511_set_colormap(struct adv7511 *adv7511, bool enable, in adv7511_set_colormap() argument
141 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1), in adv7511_set_colormap()
146 regmap_update_bits(adv7511->regmap, in adv7511_set_colormap()
149 regmap_write(adv7511->regmap, in adv7511_set_colormap()
156 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0), in adv7511_set_colormap()
159 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0), in adv7511_set_colormap()
162 regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1), in adv7511_set_colormap()
166 static int adv7511_packet_enable(struct adv7511 *adv7511, unsigned int packet) in adv7511_packet_enable() argument
169 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0, in adv7511_packet_enable()
174 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1, in adv7511_packet_enable()
181 static int adv7511_packet_disable(struct adv7511 *adv7511, unsigned int packet) in adv7511_packet_disable() argument
184 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0, in adv7511_packet_disable()
189 regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1, in adv7511_packet_disable()
203 static void adv7511_set_config_csc(struct adv7511 *adv7511, in adv7511_set_config_csc() argument
260 adv7511_packet_disable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME); in adv7511_set_config_csc()
262 adv7511_set_colormap(adv7511, config.csc_enable, in adv7511_set_config_csc()
266 regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x81, in adv7511_set_config_csc()
269 regmap_update_bits(adv7511->regmap, ADV7511_REG_HDCP_HDMI_CFG, in adv7511_set_config_csc()
276 regmap_bulk_write(adv7511->regmap, ADV7511_REG_AVI_INFOFRAME_VERSION, in adv7511_set_config_csc()
279 adv7511_packet_enable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME); in adv7511_set_config_csc()
282 static void adv7511_set_link_config(struct adv7511 *adv7511, in adv7511_set_link_config() argument
310 regmap_update_bits(adv7511->regmap, ADV7511_REG_I2C_FREQ_ID_CFG, 0xf, in adv7511_set_link_config()
312 regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x7e, in adv7511_set_link_config()
315 regmap_write(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG2, in adv7511_set_link_config()
317 regmap_write(adv7511->regmap, ADV7511_REG_TIMING_GEN_SEQ, in adv7511_set_link_config()
320 regmap_write(adv7511->regmap, 0xba, clock_delay << 5); in adv7511_set_link_config()
322 adv7511->embedded_sync = config->embedded_sync; in adv7511_set_link_config()
323 adv7511->hsync_polarity = config->hsync_polarity; in adv7511_set_link_config()
324 adv7511->vsync_polarity = config->vsync_polarity; in adv7511_set_link_config()
325 adv7511->rgb = config->input_colorspace == HDMI_COLORSPACE_RGB; in adv7511_set_link_config()
328 static void __adv7511_power_on(struct adv7511 *adv7511) in __adv7511_power_on() argument
330 adv7511->current_edid_segment = -1; in __adv7511_power_on()
332 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, in __adv7511_power_on()
334 if (adv7511->i2c_main->irq) { in __adv7511_power_on()
340 regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0), in __adv7511_power_on()
342 regmap_update_bits(adv7511->regmap, in __adv7511_power_on()
356 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in __adv7511_power_on()
361 static void adv7511_power_on(struct adv7511 *adv7511) in adv7511_power_on() argument
363 __adv7511_power_on(adv7511); in adv7511_power_on()
368 regcache_sync(adv7511->regmap); in adv7511_power_on()
370 if (adv7511->type == ADV7533 || adv7511->type == ADV7535) in adv7511_power_on()
371 adv7533_dsi_power_on(adv7511); in adv7511_power_on()
372 adv7511->powered = true; in adv7511_power_on()
375 static void __adv7511_power_off(struct adv7511 *adv7511) in __adv7511_power_off() argument
378 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER, in __adv7511_power_off()
381 regmap_update_bits(adv7511->regmap, in __adv7511_power_off()
384 regcache_mark_dirty(adv7511->regmap); in __adv7511_power_off()
387 static void adv7511_power_off(struct adv7511 *adv7511) in adv7511_power_off() argument
389 __adv7511_power_off(adv7511); in adv7511_power_off()
390 if (adv7511->type == ADV7533 || adv7511->type == ADV7535) in adv7511_power_off()
391 adv7533_dsi_power_off(adv7511); in adv7511_power_off()
392 adv7511->powered = false; in adv7511_power_off()
399 static bool adv7511_hpd(struct adv7511 *adv7511) in adv7511_hpd() argument
404 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); in adv7511_hpd()
409 regmap_write(adv7511->regmap, ADV7511_REG_INT(0), in adv7511_hpd()
419 struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work); in adv7511_hpd_work() local
424 ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); in adv7511_hpd_work()
438 adv7511->connector.status == connector_status_disconnected && in adv7511_hpd_work()
439 adv7511->powered) { in adv7511_hpd_work()
440 regcache_mark_dirty(adv7511->regmap); in adv7511_hpd_work()
441 adv7511_power_on(adv7511); in adv7511_hpd_work()
444 if (adv7511->connector.status != status) { in adv7511_hpd_work()
445 adv7511->connector.status = status; in adv7511_hpd_work()
447 if (adv7511->connector.dev) { in adv7511_hpd_work()
449 cec_phys_addr_invalidate(adv7511->cec_adap); in adv7511_hpd_work()
450 drm_kms_helper_hotplug_event(adv7511->connector.dev); in adv7511_hpd_work()
452 drm_bridge_hpd_notify(&adv7511->bridge, status); in adv7511_hpd_work()
457 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) in adv7511_irq_process() argument
462 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); in adv7511_irq_process()
466 ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1); in adv7511_irq_process()
470 regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); in adv7511_irq_process()
471 regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); in adv7511_irq_process()
473 if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) in adv7511_irq_process()
474 schedule_work(&adv7511->hpd_work); in adv7511_irq_process()
477 adv7511->edid_read = true; in adv7511_irq_process()
479 if (adv7511->i2c_main->irq) in adv7511_irq_process()
480 wake_up_all(&adv7511->wq); in adv7511_irq_process()
484 adv7511_cec_irq_process(adv7511, irq1); in adv7511_irq_process()
492 struct adv7511 *adv7511 = devid; in adv7511_irq_handler() local
495 ret = adv7511_irq_process(adv7511, true); in adv7511_irq_handler()
503 static int adv7511_wait_for_edid(struct adv7511 *adv7511, int timeout) in adv7511_wait_for_edid() argument
507 if (adv7511->i2c_main->irq) { in adv7511_wait_for_edid()
508 ret = wait_event_interruptible_timeout(adv7511->wq, in adv7511_wait_for_edid()
509 adv7511->edid_read, msecs_to_jiffies(timeout)); in adv7511_wait_for_edid()
512 ret = adv7511_irq_process(adv7511, false); in adv7511_wait_for_edid()
516 if (adv7511->edid_read) in adv7511_wait_for_edid()
523 return adv7511->edid_read ? 0 : -EIO; in adv7511_wait_for_edid()
529 struct adv7511 *adv7511 = data; in adv7511_get_edid_block() local
538 if (adv7511->current_edid_segment != block / 2) { in adv7511_get_edid_block()
541 ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS, in adv7511_get_edid_block()
547 adv7511->edid_read = false; in adv7511_get_edid_block()
548 regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, in adv7511_get_edid_block()
550 ret = adv7511_wait_for_edid(adv7511, 200); in adv7511_get_edid_block()
559 xfer[0].addr = adv7511->i2c_edid->addr; in adv7511_get_edid_block()
563 xfer[1].addr = adv7511->i2c_edid->addr; in adv7511_get_edid_block()
566 xfer[1].buf = adv7511->edid_buf; in adv7511_get_edid_block()
571 ret = i2c_transfer(adv7511->i2c_edid->adapter, xfer, in adv7511_get_edid_block()
582 adv7511->current_edid_segment = block / 2; in adv7511_get_edid_block()
586 memcpy(buf, adv7511->edid_buf, len); in adv7511_get_edid_block()
588 memcpy(buf, adv7511->edid_buf + 128, len); in adv7511_get_edid_block()
597 static struct edid *adv7511_get_edid(struct adv7511 *adv7511, in adv7511_get_edid() argument
603 if (!adv7511->powered) { in adv7511_get_edid()
605 (adv7511->i2c_edid->addr << 1); in adv7511_get_edid()
607 __adv7511_power_on(adv7511); in adv7511_get_edid()
610 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, in adv7511_get_edid()
614 edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); in adv7511_get_edid()
616 if (!adv7511->powered) in adv7511_get_edid()
617 __adv7511_power_off(adv7511); in adv7511_get_edid()
619 adv7511_set_config_csc(adv7511, connector, adv7511->rgb, in adv7511_get_edid()
622 cec_s_phys_addr_from_edid(adv7511->cec_adap, edid); in adv7511_get_edid()
627 static int adv7511_get_modes(struct adv7511 *adv7511, in adv7511_get_modes() argument
633 edid = adv7511_get_edid(adv7511, connector); in adv7511_get_modes()
644 adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector) in adv7511_detect() argument
651 ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); in adv7511_detect()
660 hpd = adv7511_hpd(adv7511); in adv7511_detect()
666 if (status == connector_status_connected && hpd && adv7511->powered) { in adv7511_detect()
667 regcache_mark_dirty(adv7511->regmap); in adv7511_detect()
668 adv7511_power_on(adv7511); in adv7511_detect()
670 adv7511_get_modes(adv7511, connector); in adv7511_detect()
671 if (adv7511->status == connector_status_connected) in adv7511_detect()
675 regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2, in adv7511_detect()
680 adv7511->status = status; in adv7511_detect()
684 static enum drm_mode_status adv7511_mode_valid(struct adv7511 *adv7511, in adv7511_mode_valid() argument
693 static void adv7511_mode_set(struct adv7511 *adv7511, in adv7511_mode_set() argument
701 if (adv7511->embedded_sync) { in adv7511_mode_set()
717 regmap_write(adv7511->regmap, ADV7511_REG_HSYNC_PLACEMENT_MSB, in adv7511_mode_set()
719 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(0), in adv7511_mode_set()
721 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(1), in adv7511_mode_set()
724 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(2), in adv7511_mode_set()
727 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(3), in adv7511_mode_set()
730 regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(4), in adv7511_mode_set()
754 if (adv7511->hsync_polarity != mode_hsync_polarity && in adv7511_mode_set()
755 adv7511->hsync_polarity != in adv7511_mode_set()
759 if (adv7511->vsync_polarity != mode_vsync_polarity && in adv7511_mode_set()
760 adv7511->vsync_polarity != in adv7511_mode_set()
774 regmap_update_bits(adv7511->regmap, 0xfb, in adv7511_mode_set()
776 regmap_update_bits(adv7511->regmap, 0x17, in adv7511_mode_set()
779 if (adv7511->type == ADV7533 || adv7511->type == ADV7535) in adv7511_mode_set()
780 adv7533_mode_set(adv7511, adj_mode); in adv7511_mode_set()
782 drm_mode_copy(&adv7511->curr_mode, adj_mode); in adv7511_mode_set()
789 adv7511->f_tmds = mode->clock; in adv7511_mode_set()
796 static struct adv7511 *connector_to_adv7511(struct drm_connector *connector) in connector_to_adv7511()
798 return container_of(connector, struct adv7511, connector); in connector_to_adv7511()
803 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_get_modes()
812 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_mode_valid()
825 struct adv7511 *adv = connector_to_adv7511(connector); in adv7511_connector_detect()
839 static int adv7511_connector_init(struct adv7511 *adv) in adv7511_connector_init()
873 static struct adv7511 *bridge_to_adv7511(struct drm_bridge *bridge) in bridge_to_adv7511()
875 return container_of(bridge, struct adv7511, bridge); in bridge_to_adv7511()
880 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_enable()
887 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_disable()
896 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_mode_set()
904 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_attach()
925 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_detect()
933 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_get_edid()
941 struct adv7511 *adv = bridge_to_adv7511(bridge); in adv7511_bridge_hpd_notify()
978 static int adv7511_init_regulators(struct adv7511 *adv) in adv7511_init_regulators()
1008 static void adv7511_uninit_regulators(struct adv7511 *adv) in adv7511_uninit_regulators()
1016 struct adv7511 *adv7511 = i2c_get_clientdata(i2c); in adv7511_cec_register_volatile() local
1018 if (adv7511->type == ADV7533 || adv7511->type == ADV7535) in adv7511_cec_register_volatile()
1043 static int adv7511_init_cec_regmap(struct adv7511 *adv) in adv7511_init_cec_regmap()
1158 struct adv7511 *adv7511; in adv7511_probe() local
1166 adv7511 = devm_kzalloc(dev, sizeof(*adv7511), GFP_KERNEL); in adv7511_probe()
1167 if (!adv7511) in adv7511_probe()
1170 adv7511->i2c_main = i2c; in adv7511_probe()
1171 adv7511->powered = false; in adv7511_probe()
1172 adv7511->status = connector_status_disconnected; in adv7511_probe()
1175 adv7511->type = (enum adv7511_type)of_device_get_match_data(dev); in adv7511_probe()
1177 adv7511->type = id->driver_data; in adv7511_probe()
1181 if (adv7511->type == ADV7511) in adv7511_probe()
1184 ret = adv7533_parse_dt(dev->of_node, adv7511); in adv7511_probe()
1188 ret = adv7511_init_regulators(adv7511); in adv7511_probe()
1198 adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", GPIOD_OUT_HIGH); in adv7511_probe()
1199 if (IS_ERR(adv7511->gpio_pd)) { in adv7511_probe()
1200 ret = PTR_ERR(adv7511->gpio_pd); in adv7511_probe()
1204 if (adv7511->gpio_pd) { in adv7511_probe()
1206 gpiod_set_value_cansleep(adv7511->gpio_pd, 0); in adv7511_probe()
1209 adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config); in adv7511_probe()
1210 if (IS_ERR(adv7511->regmap)) { in adv7511_probe()
1211 ret = PTR_ERR(adv7511->regmap); in adv7511_probe()
1215 ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val); in adv7511_probe()
1220 if (adv7511->type == ADV7511) in adv7511_probe()
1221 ret = regmap_register_patch(adv7511->regmap, in adv7511_probe()
1225 ret = adv7533_patch_registers(adv7511); in adv7511_probe()
1229 adv7511_packet_disable(adv7511, 0xffff); in adv7511_probe()
1231 adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid", in adv7511_probe()
1233 if (IS_ERR(adv7511->i2c_edid)) { in adv7511_probe()
1234 ret = PTR_ERR(adv7511->i2c_edid); in adv7511_probe()
1238 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, in adv7511_probe()
1239 adv7511->i2c_edid->addr << 1); in adv7511_probe()
1241 adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet", in adv7511_probe()
1243 if (IS_ERR(adv7511->i2c_packet)) { in adv7511_probe()
1244 ret = PTR_ERR(adv7511->i2c_packet); in adv7511_probe()
1248 regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR, in adv7511_probe()
1249 adv7511->i2c_packet->addr << 1); in adv7511_probe()
1251 ret = adv7511_init_cec_regmap(adv7511); in adv7511_probe()
1255 regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, in adv7511_probe()
1256 adv7511->i2c_cec->addr << 1); in adv7511_probe()
1258 INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work); in adv7511_probe()
1261 init_waitqueue_head(&adv7511->wq); in adv7511_probe()
1266 adv7511); in adv7511_probe()
1271 adv7511_power_off(adv7511); in adv7511_probe()
1273 i2c_set_clientdata(i2c, adv7511); in adv7511_probe()
1275 if (adv7511->type == ADV7511) in adv7511_probe()
1276 adv7511_set_link_config(adv7511, &link_config); in adv7511_probe()
1278 ret = adv7511_cec_init(dev, adv7511); in adv7511_probe()
1282 adv7511->bridge.funcs = &adv7511_bridge_funcs; in adv7511_probe()
1283 adv7511->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID in adv7511_probe()
1285 adv7511->bridge.of_node = dev->of_node; in adv7511_probe()
1286 adv7511->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in adv7511_probe()
1288 drm_bridge_add(&adv7511->bridge); in adv7511_probe()
1290 adv7511_audio_init(dev, adv7511); in adv7511_probe()
1294 i2c_unregister_device(adv7511->i2c_cec); in adv7511_probe()
1295 if (adv7511->cec_clk) in adv7511_probe()
1296 clk_disable_unprepare(adv7511->cec_clk); in adv7511_probe()
1298 i2c_unregister_device(adv7511->i2c_packet); in adv7511_probe()
1300 i2c_unregister_device(adv7511->i2c_edid); in adv7511_probe()
1302 adv7511_uninit_regulators(adv7511); in adv7511_probe()
1309 struct adv7511 *adv7511 = i2c_get_clientdata(i2c); in adv7511_remove() local
1311 if (adv7511->type == ADV7533 || adv7511->type == ADV7535) in adv7511_remove()
1312 adv7533_detach_dsi(adv7511); in adv7511_remove()
1313 i2c_unregister_device(adv7511->i2c_cec); in adv7511_remove()
1314 if (adv7511->cec_clk) in adv7511_remove()
1315 clk_disable_unprepare(adv7511->cec_clk); in adv7511_remove()
1317 adv7511_uninit_regulators(adv7511); in adv7511_remove()
1319 drm_bridge_remove(&adv7511->bridge); in adv7511_remove()
1321 adv7511_audio_exit(adv7511); in adv7511_remove()
1323 cec_unregister_adapter(adv7511->cec_adap); in adv7511_remove()
1325 i2c_unregister_device(adv7511->i2c_packet); in adv7511_remove()
1326 i2c_unregister_device(adv7511->i2c_edid); in adv7511_remove()