diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-08-14 06:28:53 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-09-29 14:26:09 -0400 |
commit | 9525c4dd923f8ffe38818f86cee523a5f7b19617 (patch) | |
tree | 736d75ccec3efa346c049b3f6383ad0f8e624708 | |
parent | a3584f60f4898c9479931cdca1dc19f758af45fb (diff) |
drm/i2c: tda998x: clean up after struct tda998x_priv2 removal
We can now kill a number of glue functions which were sitting between
the common tda998x code and the drm encoder/connector methods. This
results in slightly cleaner code.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | drivers/gpu/drm/i2c/tda998x_drv.c | 80 |
1 files changed, 22 insertions, 58 deletions
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index 8bca9155ee18..896b6aaf8c4d 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c | |||
@@ -54,6 +54,12 @@ struct tda998x_priv { | |||
54 | struct drm_connector connector; | 54 | struct drm_connector connector; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | #define conn_to_tda998x_priv(x) \ | ||
58 | container_of(x, struct tda998x_priv, connector) | ||
59 | |||
60 | #define enc_to_tda998x_priv(x) \ | ||
61 | container_of(x, struct tda998x_priv, encoder) | ||
62 | |||
57 | /* The TDA9988 series of devices use a paged register scheme.. to simplify | 63 | /* The TDA9988 series of devices use a paged register scheme.. to simplify |
58 | * things we encode the page # in upper bits of the register #. To read/ | 64 | * things we encode the page # in upper bits of the register #. To read/ |
59 | * write a given register, we need to make sure CURPAGE register is set | 65 | * write a given register, we need to make sure CURPAGE register is set |
@@ -562,7 +568,7 @@ tda998x_reset(struct tda998x_priv *priv) | |||
562 | * trying to read EDID data. | 568 | * trying to read EDID data. |
563 | * | 569 | * |
564 | * However, tda998x_encoder_get_modes() may be called at any moment | 570 | * However, tda998x_encoder_get_modes() may be called at any moment |
565 | * after tda998x_encoder_detect() indicates that we are connected, so | 571 | * after tda998x_connector_detect() indicates that we are connected, so |
566 | * we need to delay probing modes in tda998x_encoder_get_modes() after | 572 | * we need to delay probing modes in tda998x_encoder_get_modes() after |
567 | * we have seen a HPD inactive->active transition. This code implements | 573 | * we have seen a HPD inactive->active transition. This code implements |
568 | * that delay. | 574 | * that delay. |
@@ -816,8 +822,10 @@ static void tda998x_encoder_set_config(struct tda998x_priv *priv, | |||
816 | priv->params = *p; | 822 | priv->params = *p; |
817 | } | 823 | } |
818 | 824 | ||
819 | static void tda998x_encoder_dpms(struct tda998x_priv *priv, int mode) | 825 | static void tda998x_encoder_dpms(struct drm_encoder *encoder, int mode) |
820 | { | 826 | { |
827 | struct tda998x_priv *priv = enc_to_tda998x_priv(encoder); | ||
828 | |||
821 | /* we only care about on or off: */ | 829 | /* we only care about on or off: */ |
822 | if (mode != DRM_MODE_DPMS_ON) | 830 | if (mode != DRM_MODE_DPMS_ON) |
823 | mode = DRM_MODE_DPMS_OFF; | 831 | mode = DRM_MODE_DPMS_OFF; |
@@ -867,8 +875,8 @@ tda998x_encoder_mode_fixup(struct drm_encoder *encoder, | |||
867 | return true; | 875 | return true; |
868 | } | 876 | } |
869 | 877 | ||
870 | static int tda998x_encoder_mode_valid(struct tda998x_priv *priv, | 878 | static int tda998x_connector_mode_valid(struct drm_connector *connector, |
871 | struct drm_display_mode *mode) | 879 | struct drm_display_mode *mode) |
872 | { | 880 | { |
873 | if (mode->clock > 150000) | 881 | if (mode->clock > 150000) |
874 | return MODE_CLOCK_HIGH; | 882 | return MODE_CLOCK_HIGH; |
@@ -880,10 +888,11 @@ static int tda998x_encoder_mode_valid(struct tda998x_priv *priv, | |||
880 | } | 888 | } |
881 | 889 | ||
882 | static void | 890 | static void |
883 | tda998x_encoder_mode_set(struct tda998x_priv *priv, | 891 | tda998x_encoder_mode_set(struct drm_encoder *encoder, |
884 | struct drm_display_mode *mode, | 892 | struct drm_display_mode *mode, |
885 | struct drm_display_mode *adjusted_mode) | 893 | struct drm_display_mode *adjusted_mode) |
886 | { | 894 | { |
895 | struct tda998x_priv *priv = enc_to_tda998x_priv(encoder); | ||
887 | u16 ref_pix, ref_line, n_pix, n_line; | 896 | u16 ref_pix, ref_line, n_pix, n_line; |
888 | u16 hs_pix_s, hs_pix_e; | 897 | u16 hs_pix_s, hs_pix_e; |
889 | u16 vs1_pix_s, vs1_pix_e, vs1_line_s, vs1_line_e; | 898 | u16 vs1_pix_s, vs1_pix_e, vs1_line_s, vs1_line_e; |
@@ -1071,8 +1080,9 @@ tda998x_encoder_mode_set(struct tda998x_priv *priv, | |||
1071 | } | 1080 | } |
1072 | 1081 | ||
1073 | static enum drm_connector_status | 1082 | static enum drm_connector_status |
1074 | tda998x_encoder_detect(struct tda998x_priv *priv) | 1083 | tda998x_connector_detect(struct drm_connector *connector, bool force) |
1075 | { | 1084 | { |
1085 | struct tda998x_priv *priv = conn_to_tda998x_priv(connector); | ||
1076 | u8 val = cec_read(priv, REG_CEC_RXSHPDLEV); | 1086 | u8 val = cec_read(priv, REG_CEC_RXSHPDLEV); |
1077 | 1087 | ||
1078 | return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected : | 1088 | return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected : |
@@ -1135,10 +1145,9 @@ static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t length) | |||
1135 | return 0; | 1145 | return 0; |
1136 | } | 1146 | } |
1137 | 1147 | ||
1138 | static int | 1148 | static int tda998x_connector_get_modes(struct drm_connector *connector) |
1139 | tda998x_encoder_get_modes(struct tda998x_priv *priv, | ||
1140 | struct drm_connector *connector) | ||
1141 | { | 1149 | { |
1150 | struct tda998x_priv *priv = conn_to_tda998x_priv(connector); | ||
1142 | struct edid *edid; | 1151 | struct edid *edid; |
1143 | int n; | 1152 | int n; |
1144 | 1153 | ||
@@ -1330,46 +1339,24 @@ fail: | |||
1330 | return -ENXIO; | 1339 | return -ENXIO; |
1331 | } | 1340 | } |
1332 | 1341 | ||
1333 | #define conn_to_tda998x_priv(x) \ | ||
1334 | container_of(x, struct tda998x_priv, connector); | ||
1335 | |||
1336 | #define enc_to_tda998x_priv(x) \ | ||
1337 | container_of(x, struct tda998x_priv, encoder); | ||
1338 | |||
1339 | static void tda998x_encoder2_dpms(struct drm_encoder *encoder, int mode) | ||
1340 | { | ||
1341 | struct tda998x_priv *priv = enc_to_tda998x_priv(encoder); | ||
1342 | |||
1343 | tda998x_encoder_dpms(priv, mode); | ||
1344 | } | ||
1345 | |||
1346 | static void tda998x_encoder_prepare(struct drm_encoder *encoder) | 1342 | static void tda998x_encoder_prepare(struct drm_encoder *encoder) |
1347 | { | 1343 | { |
1348 | tda998x_encoder2_dpms(encoder, DRM_MODE_DPMS_OFF); | 1344 | tda998x_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); |
1349 | } | 1345 | } |
1350 | 1346 | ||
1351 | static void tda998x_encoder_commit(struct drm_encoder *encoder) | 1347 | static void tda998x_encoder_commit(struct drm_encoder *encoder) |
1352 | { | 1348 | { |
1353 | tda998x_encoder2_dpms(encoder, DRM_MODE_DPMS_ON); | 1349 | tda998x_encoder_dpms(encoder, DRM_MODE_DPMS_ON); |
1354 | } | ||
1355 | |||
1356 | static void tda998x_encoder2_mode_set(struct drm_encoder *encoder, | ||
1357 | struct drm_display_mode *mode, | ||
1358 | struct drm_display_mode *adjusted_mode) | ||
1359 | { | ||
1360 | struct tda998x_priv *priv = enc_to_tda998x_priv(encoder); | ||
1361 | |||
1362 | tda998x_encoder_mode_set(priv, mode, adjusted_mode); | ||
1363 | } | 1350 | } |
1364 | 1351 | ||
1365 | static const struct drm_encoder_helper_funcs tda998x_encoder_helper_funcs = { | 1352 | static const struct drm_encoder_helper_funcs tda998x_encoder_helper_funcs = { |
1366 | .dpms = tda998x_encoder2_dpms, | 1353 | .dpms = tda998x_encoder_dpms, |
1367 | .save = tda998x_encoder_save, | 1354 | .save = tda998x_encoder_save, |
1368 | .restore = tda998x_encoder_restore, | 1355 | .restore = tda998x_encoder_restore, |
1369 | .mode_fixup = tda998x_encoder_mode_fixup, | 1356 | .mode_fixup = tda998x_encoder_mode_fixup, |
1370 | .prepare = tda998x_encoder_prepare, | 1357 | .prepare = tda998x_encoder_prepare, |
1371 | .commit = tda998x_encoder_commit, | 1358 | .commit = tda998x_encoder_commit, |
1372 | .mode_set = tda998x_encoder2_mode_set, | 1359 | .mode_set = tda998x_encoder_mode_set, |
1373 | }; | 1360 | }; |
1374 | 1361 | ||
1375 | static void tda998x_encoder_destroy(struct drm_encoder *encoder) | 1362 | static void tda998x_encoder_destroy(struct drm_encoder *encoder) |
@@ -1384,21 +1371,6 @@ static const struct drm_encoder_funcs tda998x_encoder_funcs = { | |||
1384 | .destroy = tda998x_encoder_destroy, | 1371 | .destroy = tda998x_encoder_destroy, |
1385 | }; | 1372 | }; |
1386 | 1373 | ||
1387 | static int tda998x_connector_get_modes(struct drm_connector *connector) | ||
1388 | { | ||
1389 | struct tda998x_priv *priv = conn_to_tda998x_priv(connector); | ||
1390 | |||
1391 | return tda998x_encoder_get_modes(priv, connector); | ||
1392 | } | ||
1393 | |||
1394 | static int tda998x_connector_mode_valid(struct drm_connector *connector, | ||
1395 | struct drm_display_mode *mode) | ||
1396 | { | ||
1397 | struct tda998x_priv *priv = conn_to_tda998x_priv(connector); | ||
1398 | |||
1399 | return tda998x_encoder_mode_valid(priv, mode); | ||
1400 | } | ||
1401 | |||
1402 | static struct drm_encoder * | 1374 | static struct drm_encoder * |
1403 | tda998x_connector_best_encoder(struct drm_connector *connector) | 1375 | tda998x_connector_best_encoder(struct drm_connector *connector) |
1404 | { | 1376 | { |
@@ -1414,14 +1386,6 @@ const struct drm_connector_helper_funcs tda998x_connector_helper_funcs = { | |||
1414 | .best_encoder = tda998x_connector_best_encoder, | 1386 | .best_encoder = tda998x_connector_best_encoder, |
1415 | }; | 1387 | }; |
1416 | 1388 | ||
1417 | static enum drm_connector_status | ||
1418 | tda998x_connector_detect(struct drm_connector *connector, bool force) | ||
1419 | { | ||
1420 | struct tda998x_priv *priv = conn_to_tda998x_priv(connector); | ||
1421 | |||
1422 | return tda998x_encoder_detect(priv); | ||
1423 | } | ||
1424 | |||
1425 | static void tda998x_connector_destroy(struct drm_connector *connector) | 1389 | static void tda998x_connector_destroy(struct drm_connector *connector) |
1426 | { | 1390 | { |
1427 | drm_connector_unregister(connector); | 1391 | drm_connector_unregister(connector); |