Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic-arcpgu-fixes' of https://github.com/foss-for-synopsys-dwc-arc-processors/linux into drm-fixes

* 'topic-arcpgu-fixes' of https://github.com/foss-for-synopsys-dwc-arc-processors/linux:
drm/arcpgu: Accommodate adv7511 switch to DRM bridge

+17 -142
+17 -142
drivers/gpu/drm/arc/arcpgu_hdmi.c
··· 14 14 * 15 15 */ 16 16 17 - #include <drm/drm_crtc_helper.h> 17 + #include <drm/drm_crtc.h> 18 18 #include <drm/drm_encoder_slave.h> 19 - #include <drm/drm_atomic_helper.h> 20 19 21 20 #include "arcpgu.h" 22 - 23 - struct arcpgu_drm_connector { 24 - struct drm_connector connector; 25 - struct drm_encoder_slave *encoder_slave; 26 - }; 27 - 28 - static int arcpgu_drm_connector_get_modes(struct drm_connector *connector) 29 - { 30 - const struct drm_encoder_slave_funcs *sfuncs; 31 - struct drm_encoder_slave *slave; 32 - struct arcpgu_drm_connector *con = 33 - container_of(connector, struct arcpgu_drm_connector, connector); 34 - 35 - slave = con->encoder_slave; 36 - if (slave == NULL) { 37 - dev_err(connector->dev->dev, 38 - "connector_get_modes: cannot find slave encoder for connector\n"); 39 - return 0; 40 - } 41 - 42 - sfuncs = slave->slave_funcs; 43 - if (sfuncs->get_modes == NULL) 44 - return 0; 45 - 46 - return sfuncs->get_modes(&slave->base, connector); 47 - } 48 - 49 - static enum drm_connector_status 50 - arcpgu_drm_connector_detect(struct drm_connector *connector, bool force) 51 - { 52 - enum drm_connector_status status = connector_status_unknown; 53 - const struct drm_encoder_slave_funcs *sfuncs; 54 - struct drm_encoder_slave *slave; 55 - 56 - struct arcpgu_drm_connector *con = 57 - container_of(connector, struct arcpgu_drm_connector, connector); 58 - 59 - slave = con->encoder_slave; 60 - if (slave == NULL) { 61 - dev_err(connector->dev->dev, 62 - "connector_detect: cannot find slave encoder for connector\n"); 63 - return status; 64 - } 65 - 66 - sfuncs = slave->slave_funcs; 67 - if (sfuncs && sfuncs->detect) 68 - return sfuncs->detect(&slave->base, connector); 69 - 70 - dev_err(connector->dev->dev, "connector_detect: could not detect slave funcs\n"); 71 - return status; 72 - } 73 - 74 - static void arcpgu_drm_connector_destroy(struct drm_connector *connector) 75 - { 76 - drm_connector_unregister(connector); 77 - drm_connector_cleanup(connector); 78 - } 79 - 80 - static const struct drm_connector_helper_funcs 81 - arcpgu_drm_connector_helper_funcs = { 82 - .get_modes = arcpgu_drm_connector_get_modes, 83 - }; 84 - 85 - static const struct drm_connector_funcs arcpgu_drm_connector_funcs = { 86 - .dpms = drm_helper_connector_dpms, 87 - .reset = drm_atomic_helper_connector_reset, 88 - .detect = arcpgu_drm_connector_detect, 89 - .fill_modes = drm_helper_probe_single_connector_modes, 90 - .destroy = arcpgu_drm_connector_destroy, 91 - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 92 - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 93 - }; 94 - 95 - static struct drm_encoder_helper_funcs arcpgu_drm_encoder_helper_funcs = { 96 - .dpms = drm_i2c_encoder_dpms, 97 - .mode_fixup = drm_i2c_encoder_mode_fixup, 98 - .mode_set = drm_i2c_encoder_mode_set, 99 - .prepare = drm_i2c_encoder_prepare, 100 - .commit = drm_i2c_encoder_commit, 101 - .detect = drm_i2c_encoder_detect, 102 - }; 103 21 104 22 static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { 105 23 .destroy = drm_encoder_cleanup, ··· 25 107 26 108 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np) 27 109 { 28 - struct arcpgu_drm_connector *arcpgu_connector; 29 - struct drm_i2c_encoder_driver *driver; 30 - struct drm_encoder_slave *encoder; 31 - struct drm_connector *connector; 32 - struct i2c_client *i2c_slave; 33 - int ret; 110 + struct drm_encoder *encoder; 111 + struct drm_bridge *bridge; 112 + 113 + int ret = 0; 34 114 35 115 encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); 36 116 if (encoder == NULL) 37 117 return -ENOMEM; 38 118 39 - i2c_slave = of_find_i2c_device_by_node(np); 40 - if (!i2c_slave || !i2c_get_clientdata(i2c_slave)) { 41 - dev_err(drm->dev, "failed to find i2c slave encoder\n"); 119 + /* Locate drm bridge from the hdmi encoder DT node */ 120 + bridge = of_drm_find_bridge(np); 121 + if (!bridge) 42 122 return -EPROBE_DEFER; 43 - } 44 123 45 - if (i2c_slave->dev.driver == NULL) { 46 - dev_err(drm->dev, "failed to find i2c slave driver\n"); 47 - return -EPROBE_DEFER; 48 - } 49 - 50 - driver = 51 - to_drm_i2c_encoder_driver(to_i2c_driver(i2c_slave->dev.driver)); 52 - ret = driver->encoder_init(i2c_slave, drm, encoder); 53 - if (ret) { 54 - dev_err(drm->dev, "failed to initialize i2c encoder slave\n"); 55 - return ret; 56 - } 57 - 58 - encoder->base.possible_crtcs = 1; 59 - encoder->base.possible_clones = 0; 60 - ret = drm_encoder_init(drm, &encoder->base, &arcpgu_drm_encoder_funcs, 124 + encoder->possible_crtcs = 1; 125 + encoder->possible_clones = 0; 126 + ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs, 61 127 DRM_MODE_ENCODER_TMDS, NULL); 62 128 if (ret) 63 129 return ret; 64 130 65 - drm_encoder_helper_add(&encoder->base, 66 - &arcpgu_drm_encoder_helper_funcs); 131 + /* Link drm_bridge to encoder */ 132 + bridge->encoder = encoder; 133 + encoder->bridge = bridge; 67 134 68 - arcpgu_connector = devm_kzalloc(drm->dev, sizeof(*arcpgu_connector), 69 - GFP_KERNEL); 70 - if (!arcpgu_connector) { 71 - ret = -ENOMEM; 72 - goto error_encoder_cleanup; 73 - } 135 + ret = drm_bridge_attach(drm, bridge); 136 + if (ret) 137 + drm_encoder_cleanup(encoder); 74 138 75 - connector = &arcpgu_connector->connector; 76 - drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs); 77 - ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, 78 - DRM_MODE_CONNECTOR_HDMIA); 79 - if (ret < 0) { 80 - dev_err(drm->dev, "failed to initialize drm connector\n"); 81 - goto error_encoder_cleanup; 82 - } 83 - 84 - ret = drm_mode_connector_attach_encoder(connector, &encoder->base); 85 - if (ret < 0) { 86 - dev_err(drm->dev, "could not attach connector to encoder\n"); 87 - drm_connector_unregister(connector); 88 - goto error_connector_cleanup; 89 - } 90 - 91 - arcpgu_connector->encoder_slave = encoder; 92 - 93 - return 0; 94 - 95 - error_connector_cleanup: 96 - drm_connector_cleanup(connector); 97 - 98 - error_encoder_cleanup: 99 - drm_encoder_cleanup(&encoder->base); 100 139 return ret; 101 140 }