@@ -222,8 +222,14 @@ static int ade_power_down(struct hisi_drm_ade_crtc *crtc_ade)
222222
223223static int hisi_drm_crtc_ade_enable (struct hisi_drm_ade_crtc * crtc_ade )
224224{
225+ struct drm_framebuffer * fb = crtc_ade -> crtc .primary -> fb ;
225226 int ret ;
226227
228+ if (fb -> width != crtc_ade -> dmode -> hdisplay ) {
229+ DRM_ERROR ("mode and fb width don't match\n" );
230+ return - EINVAL ;
231+ }
232+
227233 if (!crtc_ade -> power_on ) {
228234 ret = ade_power_up (crtc_ade );
229235 if (ret ) {
@@ -235,8 +241,9 @@ static int hisi_drm_crtc_ade_enable(struct hisi_drm_ade_crtc *crtc_ade)
235241 ade_set_medianoc_qos (crtc_ade );
236242 ade_init (crtc_ade );
237243 ldi_init (crtc_ade );
238- if (crtc_ade -> crtc . primary -> fb )
244+ if (fb )
239245 hisi_drm_crtc_mode_set_base (& crtc_ade -> crtc , 0 , 0 , NULL );
246+
240247 return 0 ;
241248}
242249
@@ -323,17 +330,19 @@ static void hisi_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
323330{
324331 struct hisi_drm_ade_crtc * crtc_ade = to_hisi_crtc (crtc );
325332 bool enable = (mode == DRM_MODE_DPMS_ON );
333+ int ret ;
326334
327335 DRM_DEBUG_DRIVER ("crtc_dpms enter successfully.\n" );
328336 if (crtc_ade -> enable == enable )
329337 return ;
330338
331339 if (enable )
332- hisi_drm_crtc_ade_enable (crtc_ade );
340+ ret = hisi_drm_crtc_ade_enable (crtc_ade );
333341 else
334- hisi_drm_crtc_ade_disable (crtc_ade );
342+ ret = hisi_drm_crtc_ade_disable (crtc_ade );
335343
336- crtc_ade -> enable = enable ;
344+ if (!ret )
345+ crtc_ade -> enable = enable ;
337346 DRM_DEBUG_DRIVER ("crtc_dpms exit successfully.\n" );
338347}
339348
0 commit comments