Lines Matching full:sii902x

174 struct sii902x {  struct
235 static inline struct sii902x *bridge_to_sii902x(struct drm_bridge *bridge) in bridge_to_sii902x()
237 return container_of(bridge, struct sii902x, bridge); in bridge_to_sii902x()
240 static inline struct sii902x *connector_to_sii902x(struct drm_connector *con) in connector_to_sii902x()
242 return container_of(con, struct sii902x, connector); in connector_to_sii902x()
245 static void sii902x_reset(struct sii902x *sii902x) in sii902x_reset() argument
247 if (!sii902x->reset_gpio) in sii902x_reset()
250 gpiod_set_value_cansleep(sii902x->reset_gpio, 1); in sii902x_reset()
255 gpiod_set_value_cansleep(sii902x->reset_gpio, 0); in sii902x_reset()
258 static enum drm_connector_status sii902x_detect(struct sii902x *sii902x) in sii902x_detect() argument
262 mutex_lock(&sii902x->mutex); in sii902x_detect()
264 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_detect()
266 mutex_unlock(&sii902x->mutex); in sii902x_detect()
275 struct sii902x *sii902x = connector_to_sii902x(connector); in sii902x_connector_detect() local
277 return sii902x_detect(sii902x); in sii902x_connector_detect()
289 static const struct drm_edid *sii902x_edid_read(struct sii902x *sii902x, in sii902x_edid_read() argument
294 mutex_lock(&sii902x->mutex); in sii902x_edid_read()
296 drm_edid = drm_edid_read_ddc(connector, sii902x->i2cmux->adapter[0]); in sii902x_edid_read()
298 mutex_unlock(&sii902x->mutex); in sii902x_edid_read()
305 struct sii902x *sii902x = connector_to_sii902x(connector); in sii902x_get_modes() local
309 drm_edid = sii902x_edid_read(sii902x, connector); in sii902x_get_modes()
316 sii902x->sink_is_hdmi = connector->display_info.is_hdmi; in sii902x_get_modes()
328 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_atomic_disable() local
330 mutex_lock(&sii902x->mutex); in sii902x_bridge_atomic_disable()
332 regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_atomic_disable()
336 mutex_unlock(&sii902x->mutex); in sii902x_bridge_atomic_disable()
342 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_atomic_enable() local
344 mutex_lock(&sii902x->mutex); in sii902x_bridge_atomic_enable()
346 regmap_update_bits(sii902x->regmap, SII902X_PWR_STATE_CTRL, in sii902x_bridge_atomic_enable()
349 regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_atomic_enable()
352 mutex_unlock(&sii902x->mutex); in sii902x_bridge_atomic_enable()
359 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_mode_set() local
361 struct regmap *regmap = sii902x->regmap; in sii902x_bridge_mode_set()
367 if (sii902x->sink_is_hdmi) in sii902x_bridge_mode_set()
383 mutex_lock(&sii902x->mutex); in sii902x_bridge_mode_set()
385 ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_mode_set()
395 &sii902x->connector, adj); in sii902x_bridge_mode_set()
413 mutex_unlock(&sii902x->mutex); in sii902x_bridge_mode_set()
419 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_attach() local
425 return drm_bridge_attach(bridge->encoder, sii902x->next_bridge, in sii902x_bridge_attach()
428 drm_connector_helper_add(&sii902x->connector, in sii902x_bridge_attach()
432 dev_err(&sii902x->i2c->dev, in sii902x_bridge_attach()
433 "sii902x driver is only compatible with DRM devices supporting atomic updates\n"); in sii902x_bridge_attach()
437 ret = drm_connector_init(drm, &sii902x->connector, in sii902x_bridge_attach()
443 if (sii902x->i2c->irq > 0) in sii902x_bridge_attach()
444 sii902x->connector.polled = DRM_CONNECTOR_POLL_HPD; in sii902x_bridge_attach()
446 sii902x->connector.polled = DRM_CONNECTOR_POLL_CONNECT; in sii902x_bridge_attach()
448 ret = drm_display_info_set_bus_formats(&sii902x->connector.display_info, in sii902x_bridge_attach()
453 drm_connector_attach_encoder(&sii902x->connector, bridge->encoder); in sii902x_bridge_attach()
460 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_detect() local
462 return sii902x_detect(sii902x); in sii902x_bridge_detect()
468 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_edid_read() local
470 return sii902x_edid_read(sii902x, connector); in sii902x_bridge_edid_read()
541 static int sii902x_mute(struct sii902x *sii902x, bool mute) in sii902x_mute() argument
543 struct device *dev = &sii902x->i2c->dev; in sii902x_mute()
549 return regmap_update_bits(sii902x->regmap, in sii902x_mute()
598 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_hw_params() local
670 ret = clk_prepare_enable(sii902x->audio.mclk); in sii902x_audio_hw_params()
676 if (sii902x->audio.mclk) { in sii902x_audio_hw_params()
677 mclk_rate = clk_get_rate(sii902x->audio.mclk); in sii902x_audio_hw_params()
685 mutex_lock(&sii902x->mutex); in sii902x_audio_hw_params()
687 ret = regmap_write(sii902x->regmap, in sii902x_audio_hw_params()
693 ret = regmap_write(sii902x->regmap, SII902X_TPI_I2S_INPUT_CONFIG_REG, in sii902x_audio_hw_params()
698 for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence) && in sii902x_audio_hw_params()
699 sii902x->audio.i2s_fifo_sequence[i]; i++) in sii902x_audio_hw_params()
700 regmap_write(sii902x->regmap, in sii902x_audio_hw_params()
702 sii902x->audio.i2s_fifo_sequence[i]); in sii902x_audio_hw_params()
704 ret = regmap_write(sii902x->regmap, SII902X_TPI_AUDIO_CONFIG_BYTE3_REG, in sii902x_audio_hw_params()
709 ret = regmap_bulk_write(sii902x->regmap, SII902X_TPI_I2S_STRM_HDR_BASE, in sii902x_audio_hw_params()
724 ret = regmap_bulk_write(sii902x->regmap, in sii902x_audio_hw_params()
732 ret = regmap_write(sii902x->regmap, SII902X_IND_SET_PAGE, 0x02); in sii902x_audio_hw_params()
736 ret = regmap_write(sii902x->regmap, SII902X_IND_OFFSET, 0x24); in sii902x_audio_hw_params()
740 ret = regmap_write(sii902x->regmap, SII902X_IND_VALUE, 0x02); in sii902x_audio_hw_params()
746 mutex_unlock(&sii902x->mutex); in sii902x_audio_hw_params()
749 clk_disable_unprepare(sii902x->audio.mclk); in sii902x_audio_hw_params()
759 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_shutdown() local
761 mutex_lock(&sii902x->mutex); in sii902x_audio_shutdown()
763 regmap_write(sii902x->regmap, SII902X_TPI_AUDIO_CONFIG_BYTE2_REG, in sii902x_audio_shutdown()
766 mutex_unlock(&sii902x->mutex); in sii902x_audio_shutdown()
768 clk_disable_unprepare(sii902x->audio.mclk); in sii902x_audio_shutdown()
774 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_mute() local
776 mutex_lock(&sii902x->mutex); in sii902x_audio_mute()
778 sii902x_mute(sii902x, enable); in sii902x_audio_mute()
780 mutex_unlock(&sii902x->mutex); in sii902x_audio_mute()
788 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_get_eld() local
790 mutex_lock(&sii902x->mutex); in sii902x_audio_get_eld()
792 memcpy(buf, sii902x->connector.eld, in sii902x_audio_get_eld()
793 min(sizeof(sii902x->connector.eld), len)); in sii902x_audio_get_eld()
795 mutex_unlock(&sii902x->mutex); in sii902x_audio_get_eld()
829 static int sii902x_audio_codec_init(struct sii902x *sii902x, in sii902x_audio_codec_init() argument
879 sii902x->audio.i2s_fifo_sequence[i] |= audio_fifo_id[i] | in sii902x_audio_codec_init()
882 sii902x->audio.mclk = devm_clk_get_optional(dev, "mclk"); in sii902x_audio_codec_init()
883 if (IS_ERR(sii902x->audio.mclk)) { in sii902x_audio_codec_init()
885 __func__, PTR_ERR(sii902x->audio.mclk)); in sii902x_audio_codec_init()
886 return PTR_ERR(sii902x->audio.mclk); in sii902x_audio_codec_init()
889 sii902x->audio.pdev = platform_device_register_data( in sii902x_audio_codec_init()
893 return PTR_ERR_OR_ZERO(sii902x->audio.pdev); in sii902x_audio_codec_init()
908 .disable_locking = true, /* struct sii902x mutex should be enough */
916 struct sii902x *sii902x = data; in sii902x_interrupt() local
919 mutex_lock(&sii902x->mutex); in sii902x_interrupt()
921 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_interrupt()
922 regmap_write(sii902x->regmap, SII902X_INT_STATUS, status); in sii902x_interrupt()
924 mutex_unlock(&sii902x->mutex); in sii902x_interrupt()
926 if ((status & SII902X_HOTPLUG_EVENT) && sii902x->bridge.dev) { in sii902x_interrupt()
927 drm_helper_hpd_irq_event(sii902x->bridge.dev); in sii902x_interrupt()
928 drm_bridge_hpd_notify(&sii902x->bridge, (status & SII902X_PLUGGED_STATUS) in sii902x_interrupt()
950 struct sii902x *sii902x = i2c_mux_priv(mux); in sii902x_i2c_bypass_select() local
951 struct device *dev = &sii902x->i2c->dev; in sii902x_i2c_bypass_select()
956 ret = sii902x_update_bits_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
965 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
977 return sii902x_write_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
995 struct sii902x *sii902x = i2c_mux_priv(mux); in sii902x_i2c_bypass_deselect() local
996 struct device *dev = &sii902x->i2c->dev; in sii902x_i2c_bypass_deselect()
1016 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1025 ret = sii902x_update_bits_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1034 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1057 static int sii902x_init(struct sii902x *sii902x) in sii902x_init() argument
1059 struct device *dev = &sii902x->i2c->dev; in sii902x_init()
1064 sii902x_reset(sii902x); in sii902x_init()
1066 ret = regmap_write(sii902x->regmap, SII902X_REG_TPI_RQB, 0x0); in sii902x_init()
1070 ret = regmap_bulk_read(sii902x->regmap, SII902X_REG_CHIPID(0), in sii902x_init()
1084 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_init()
1085 regmap_write(sii902x->regmap, SII902X_INT_STATUS, status); in sii902x_init()
1087 if (sii902x->i2c->irq > 0) { in sii902x_init()
1088 regmap_write(sii902x->regmap, SII902X_INT_ENABLE, in sii902x_init()
1091 ret = devm_request_threaded_irq(dev, sii902x->i2c->irq, NULL, in sii902x_init()
1094 sii902x); in sii902x_init()
1099 ret = sii902x_audio_codec_init(sii902x, dev); in sii902x_init()
1103 i2c_set_clientdata(sii902x->i2c, sii902x); in sii902x_init()
1105 sii902x->i2cmux = i2c_mux_alloc(sii902x->i2c->adapter, dev, in sii902x_init()
1109 if (!sii902x->i2cmux) { in sii902x_init()
1114 sii902x->i2cmux->priv = sii902x; in sii902x_init()
1115 ret = i2c_mux_add_adapter(sii902x->i2cmux, 0, 0); in sii902x_init()
1119 sii902x->bridge.funcs = &sii902x_bridge_funcs; in sii902x_init()
1120 sii902x->bridge.of_node = dev->of_node; in sii902x_init()
1121 sii902x->bridge.timings = &default_sii902x_timings; in sii902x_init()
1122 sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; in sii902x_init()
1124 if (sii902x->i2c->irq > 0) in sii902x_init()
1125 sii902x->bridge.ops |= DRM_BRIDGE_OP_HPD; in sii902x_init()
1127 drm_bridge_add(&sii902x->bridge); in sii902x_init()
1132 if (!PTR_ERR_OR_ZERO(sii902x->audio.pdev)) in sii902x_init()
1133 platform_device_unregister(sii902x->audio.pdev); in sii902x_init()
1142 struct sii902x *sii902x; in sii902x_probe() local
1153 sii902x = devm_kzalloc(dev, sizeof(*sii902x), GFP_KERNEL); in sii902x_probe()
1154 if (!sii902x) in sii902x_probe()
1157 sii902x->i2c = client; in sii902x_probe()
1158 sii902x->regmap = devm_regmap_init_i2c(client, &sii902x_regmap_config); in sii902x_probe()
1159 if (IS_ERR(sii902x->regmap)) in sii902x_probe()
1160 return PTR_ERR(sii902x->regmap); in sii902x_probe()
1162 sii902x->reset_gpio = devm_gpiod_get_optional(dev, "reset", in sii902x_probe()
1164 if (IS_ERR(sii902x->reset_gpio)) { in sii902x_probe()
1166 PTR_ERR(sii902x->reset_gpio)); in sii902x_probe()
1167 return PTR_ERR(sii902x->reset_gpio); in sii902x_probe()
1186 sii902x->next_bridge = of_drm_find_bridge(remote); in sii902x_probe()
1188 if (!sii902x->next_bridge) in sii902x_probe()
1193 mutex_init(&sii902x->mutex); in sii902x_probe()
1199 return sii902x_init(sii902x); in sii902x_probe()
1204 struct sii902x *sii902x = i2c_get_clientdata(client); in sii902x_remove() local
1206 drm_bridge_remove(&sii902x->bridge); in sii902x_remove()
1207 i2c_mux_del_adapters(sii902x->i2cmux); in sii902x_remove()
1209 if (!PTR_ERR_OR_ZERO(sii902x->audio.pdev)) in sii902x_remove()
1210 platform_device_unregister(sii902x->audio.pdev); in sii902x_remove()
1229 .name = "sii902x",
1237 MODULE_DESCRIPTION("SII902x RGB -> HDMI bridges");