@@ -248,7 +248,6 @@ static inline struct vc4_crtc *to_vc4_crtc(struct drm_crtc *crtc)
248248struct vc4_fkms_encoder {
249249 struct drm_encoder base ;
250250 bool hdmi_monitor ;
251- bool rgb_range_selectable ;
252251};
253252
254253static inline struct vc4_fkms_encoder *
@@ -283,7 +282,7 @@ static u32 vc4_get_display_type(u32 display_number)
283282 /* The firmware display (DispmanX) IDs map to specific types in
284283 * a fixed manner.
285284 */
286- DRM_MODE_ENCODER_DSI , /* MAIN_LCD */
285+ DRM_MODE_ENCODER_DSI , /* MAIN_LCD - DSI or DPI */
287286 DRM_MODE_ENCODER_DSI , /* AUX_LCD */
288287 DRM_MODE_ENCODER_TMDS , /* HDMI0 */
289288 DRM_MODE_ENCODER_TVDAC , /* VEC */
@@ -365,7 +364,6 @@ static void vc4_plane_atomic_update(struct drm_plane *plane,
365364 vc4_get_vc_image_fmt (drm_fmt -> format );
366365 struct vc4_fkms_plane * vc4_plane = to_vc4_fkms_plane (plane );
367366 struct mailbox_set_plane * mb = & vc4_plane -> mb ;
368- struct vc4_crtc * vc4_crtc = to_vc4_crtc (state -> crtc );
369367 int num_planes = fb -> format -> num_planes ;
370368 struct drm_display_mode * mode = & state -> crtc -> mode ;
371369 unsigned int rotation = SUPPORTED_ROTATIONS ;
@@ -987,19 +985,16 @@ static int vc4_fkms_connector_get_modes(struct drm_connector *connector)
987985
988986 vc4_encoder -> hdmi_monitor = drm_detect_hdmi_monitor (edid );
989987
990- if (edid && edid -> input & DRM_EDID_INPUT_DIGITAL ) {
991- vc4_encoder -> rgb_range_selectable =
992- drm_rgb_quant_range_selectable (edid );
993- }
994-
995988 drm_connector_update_edid_property (connector , edid );
996989 ret = drm_add_edid_modes (connector , edid );
997990 kfree (edid );
998991
999992 return ret ;
1000993}
1001994
1002- /* FIXME: Read LCD mode from the firmware. This is the DSI panel resolution. */
995+ /* This is the DSI panel resolution. Use this as a default should the firmware
996+ * not respond to our request for the timings.
997+ */
1003998static const struct drm_display_mode lcd_mode = {
1004999 DRM_MODE ("800x480" , DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED ,
10051000 25979400 / 1000 ,
@@ -1010,15 +1005,52 @@ static const struct drm_display_mode lcd_mode = {
10101005
10111006static int vc4_fkms_lcd_connector_get_modes (struct drm_connector * connector )
10121007{
1013- //struct vc4_fkms_connector *fkms_connector =
1014- // to_vc4_fkms_connector(connector);
1015- //struct drm_encoder *encoder = fkms_connector->encoder;
1016- //struct vc4_fkms_encoder *vc4_encoder = to_vc4_fkms_encoder(encoder);
1008+ struct vc4_fkms_connector * fkms_connector =
1009+ to_vc4_fkms_connector (connector );
1010+ struct vc4_dev * vc4 = fkms_connector -> vc4_dev ;
10171011 struct drm_display_mode * mode ;
1018- //int ret = 0;
1012+ struct mailbox_set_mode mb = {
1013+ .tag1 = { RPI_FIRMWARE_GET_DISPLAY_TIMING ,
1014+ sizeof (struct set_timings ), 0 },
1015+ .timings = { .display = fkms_connector -> display_number },
1016+ };
1017+ struct drm_display_mode fw_mode ;
1018+ int ret = 0 ;
1019+
1020+ ret = rpi_firmware_property_list (vc4 -> firmware , & mb , sizeof (mb ));
1021+ if (!ret ) {
1022+ /* Equivalent to DRM_MODE macro. */
1023+ memset (& fw_mode , 0 , sizeof (fw_mode ));
1024+ strncpy (fw_mode .name , "LCD_MODE" , sizeof (fw_mode .name ));
1025+ fw_mode .status = 0 ;
1026+ fw_mode .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED ;
1027+ fw_mode .clock = mb .timings .clock ;
1028+ fw_mode .hdisplay = mb .timings .hdisplay ;
1029+ fw_mode .hsync_start = mb .timings .hsync_start ;
1030+ fw_mode .hsync_end = mb .timings .hsync_end ;
1031+ fw_mode .htotal = mb .timings .htotal ;
1032+ fw_mode .hskew = 0 ;
1033+ fw_mode .vdisplay = mb .timings .vdisplay ;
1034+ fw_mode .vsync_start = mb .timings .vsync_start ;
1035+ fw_mode .vsync_end = mb .timings .vsync_end ;
1036+ fw_mode .vtotal = mb .timings .vtotal ;
1037+ fw_mode .vscan = mb .timings .vscan ;
1038+ if (mb .timings .flags & TIMINGS_FLAGS_H_SYNC_POS )
1039+ fw_mode .flags |= DRM_MODE_FLAG_PHSYNC ;
1040+ else
1041+ fw_mode .flags |= DRM_MODE_FLAG_NHSYNC ;
1042+ if (mb .timings .flags & TIMINGS_FLAGS_V_SYNC_POS )
1043+ fw_mode .flags |= DRM_MODE_FLAG_PVSYNC ;
1044+ else
1045+ fw_mode .flags |= DRM_MODE_FLAG_NVSYNC ;
1046+
1047+ mode = drm_mode_duplicate (connector -> dev ,
1048+ & fw_mode );
1049+ } else {
1050+ mode = drm_mode_duplicate (connector -> dev ,
1051+ & lcd_mode );
1052+ }
10191053
1020- mode = drm_mode_duplicate (connector -> dev ,
1021- & lcd_mode );
10221054 if (!mode ) {
10231055 DRM_ERROR ("Failed to create a new display mode\n" );
10241056 return - ENOMEM ;
0 commit comments