Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2711-rpi-4-b.dts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@
};
};

&firmwarekms {
compatible = "raspberrypi,rpi-firmware-kms-2711";
};

// =============================================
// Board specific stuff here

Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2711-rpi-cm4.dts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@
};
};

&firmwarekms {
compatible = "raspberrypi,rpi-firmware-kms-2711";
};

// =============================================
// Board specific stuff here

Expand Down
62 changes: 46 additions & 16 deletions drivers/gpu/drm/vc4/vc4_firmware_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,38 @@
* Pi's firmware display stack.
*/

#include "drm/drm_atomic_helper.h"
#include "drm/drm_gem_framebuffer_helper.h"
#include "drm/drm_plane_helper.h"
#include "drm/drm_crtc_helper.h"
#include "drm/drm_fourcc.h"
#include "drm/drm_probe_helper.h"
#include "drm/drm_drv.h"
#include "drm/drm_vblank.h"
#include "linux/clk.h"
#include "linux/debugfs.h"
#include "drm/drm_fb_cma_helper.h"
#include "linux/component.h"
#include "linux/of_device.h"
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_cma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>

#include <linux/component.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/module.h>

#include <soc/bcm2835/raspberrypi-firmware.h>

#include "vc4_drv.h"
#include "vc4_regs.h"
#include "vc_image_types.h"
#include <soc/bcm2835/raspberrypi-firmware.h>

int fkms_max_refresh_rate = 85;
module_param(fkms_max_refresh_rate, int, 0644);
MODULE_PARM_DESC(fkms_max_refresh_rate, "Max supported refresh rate");

struct get_display_cfg {
u32 max_pixel_clock[2]; //Max pixel clock for each display
};

struct vc4_fkms {
struct get_display_cfg cfg;
bool bcm2711;
};

#define PLANES_PER_CRTC 3
Expand Down Expand Up @@ -1069,8 +1077,10 @@ vc4_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
return MODE_NO_DBLESCAN;
}

/* Disable refresh rates > 85Hz as limited gain from them */
if (drm_mode_vrefresh(mode) > 85)
/* Disable refresh rates > defined threshold (default 85Hz) as limited
* gain from them
*/
if (drm_mode_vrefresh(mode) > fkms_max_refresh_rate)
return MODE_BAD_VVALUE;

/* Limit the pixel clock based on the HDMI clock limits from the
Expand All @@ -1089,6 +1099,17 @@ vc4_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
break;
}

/* Pi4 can't generate odd horizontal timings on HDMI, so reject modes
* that would set them.
*/
if (fkms->bcm2711 &&
(vc4_crtc->display_number == 2 || vc4_crtc->display_number == 7) &&
((mode->hdisplay | /* active */
(mode->hsync_start - mode->hdisplay) | /* front porch */
(mode->hsync_end - mode->hsync_start) | /* sync pulse */
(mode->htotal - mode->hsync_end)) & 1)) /* back porch */
return MODE_H_ILLEGAL;
Comment thread
6by9 marked this conversation as resolved.
Resolved

return MODE_OK;
}

Expand Down Expand Up @@ -1274,6 +1295,8 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {

static const struct of_device_id vc4_firmware_kms_dt_match[] = {
{ .compatible = "raspberrypi,rpi-firmware-kms" },
{ .compatible = "raspberrypi,rpi-firmware-kms-2711",
.data = (void *)1 },
{}
};

Expand Down Expand Up @@ -1807,6 +1830,7 @@ static int vc4_fkms_bind(struct device *dev, struct device *master, void *data)
struct drm_device *drm = dev_get_drvdata(master);
struct vc4_dev *vc4 = to_vc4_dev(drm);
struct device_node *firmware_node;
const struct of_device_id *match;
struct vc4_crtc **crtc_list;
u32 num_displays, display_num;
struct vc4_fkms *fkms;
Expand All @@ -1819,6 +1843,12 @@ static int vc4_fkms_bind(struct device *dev, struct device *master, void *data)
if (!fkms)
return -ENOMEM;

match = of_match_device(vc4_firmware_kms_dt_match, dev);
if (!match)
return -ENODEV;
if (match->data)
fkms->bcm2711 = true;

/* firmware kms doesn't have precise a scanoutpos implementation, so
* we can't do the precise vblank timestamp mode.
*/
Expand Down