Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1905eb4 authored by Samantha Tran's avatar Samantha Tran
Browse files

drm/msm: snapshot of drm msm display and drm from 4.14 to 4.19



This change ports drm msm display and drm framework changes from 4.14 to
4.19 as of commit 5cc0f9c49e65 ("drivers: net: rmnet: introduce
rmnet traces"). Additionally, in order for these changes to compile
there were additional minor changes to SDE and DP files required.

Change-Id: I79d963a66600fdb40a43425d4c208d9a4b7dd91d
Signed-off-by: default avatarSamantha Tran <samtran@codeaurora.org>
parent c21a4e3c
Loading
Loading
Loading
Loading
+204 −3
Original line number Diff line number Diff line
@@ -98,6 +98,14 @@ struct detailed_mode_closure {
#define LEVEL_GTF2	2
#define LEVEL_CVT	3

/*Enum storing luminance types for HDR blocks in EDID*/
enum luminance_value {
	NO_LUMINANCE_DATA = 3,
	MAXIMUM_LUMINANCE = 4,
	FRAME_AVERAGE_LUMINANCE = 5,
	MINIMUM_LUMINANCE = 6
};

static const struct edid_quirk {
	char vendor[4];
	int product_id;
@@ -213,7 +221,8 @@ static const struct drm_display_mode drm_dmt_modes[] = {
	/* 0x05 - 640x480@72Hz */
	{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
		   704, 832, 0, 480, 489, 492, 520, 0,
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
		   .vrefresh = 72, },
	/* 0x06 - 640x480@75Hz */
	{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656,
		   720, 840, 0, 480, 481, 484, 500, 0,
@@ -570,7 +579,8 @@ static const struct drm_display_mode edid_est_modes[] = {
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */
	{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
		   704,  832, 0, 480, 489, 492, 520, 0,
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
		   .vrefresh = 72, }, /* 640x480@72Hz */
	{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704,
		   768,  864, 0, 480, 483, 486, 525, 0,
		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */
@@ -2823,11 +2833,12 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,

	return closure.modes;
}

#define VIDEO_CAPABILITY_EXTENDED_DATA_BLOCK 0x0
#define AUDIO_BLOCK	0x01
#define VIDEO_BLOCK     0x02
#define VENDOR_BLOCK    0x03
#define SPEAKER_BLOCK	0x04
#define HDR_STATIC_METADATA_EXTENDED_DATA_BLOCK 0x06
#define USE_EXTENDED_TAG 0x07
#define EXT_VIDEO_CAPABILITY_BLOCK 0x00
#define EXT_VIDEO_DATA_BLOCK_420	0x0E
@@ -3827,6 +3838,156 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
		      connector->audio_latency[1]);
}

/*
 * drm_extract_vcdb_info - Parse the HDMI Video Capability Data Block
 * @connector: connector corresponding to the HDMI sink
 * @db: start of the CEA vendor specific block
 *
 * Parses the HDMI VCDB to extract sink info for @connector.
 */
static void
drm_extract_vcdb_info(struct drm_connector *connector, const u8 *db)
{
	/*
	 * Check if the sink specifies underscan
	 * support for:
	 * BIT 5: preferred video format
	 * BIT 3: IT video format
	 * BIT 1: CE video format
	 */

	connector->pt_scan_info =
		(db[2] & (BIT(4) | BIT(5))) >> 4;
	connector->it_scan_info =
		(db[2] & (BIT(3) | BIT(2))) >> 2;
	connector->ce_scan_info =
		db[2] & (BIT(1) | BIT(0));

	DRM_DEBUG_KMS("Scan Info (pt|it|ce): (%d|%d|%d)",
			  (int) connector->pt_scan_info,
			  (int) connector->it_scan_info,
			  (int) connector->ce_scan_info);
}

static bool drm_edid_is_luminance_value_present(
u32 block_length, enum luminance_value value)
{
	return block_length > NO_LUMINANCE_DATA && value <= block_length;
}

/*
 * drm_extract_hdr_db - Parse the HDMI HDR extended block
 * @connector: connector corresponding to the HDMI sink
 * @db: start of the HDMI HDR extended block
 *
 * Parses the HDMI HDR extended block to extract sink info for @connector.
 */
static void
drm_extract_hdr_db(struct drm_connector *connector, const u8 *db)
{

	u8 len = 0;

	if (!db)
		return;

	len = db[0] & 0x1f;
	/* Byte 3: Electro-Optical Transfer Functions */
	connector->hdr_eotf = db[2] & 0x3F;

	/* Byte 4: Static Metadata Descriptor Type 1 */
	connector->hdr_metadata_type_one = (db[3] & BIT(0));

	/* Byte 5: Desired Content Maximum Luminance */
	if (drm_edid_is_luminance_value_present(len, MAXIMUM_LUMINANCE))
		connector->hdr_max_luminance =
			db[MAXIMUM_LUMINANCE];

	/* Byte 6: Desired Content Max Frame-average Luminance */
	if (drm_edid_is_luminance_value_present(len, FRAME_AVERAGE_LUMINANCE))
		connector->hdr_avg_luminance =
			db[FRAME_AVERAGE_LUMINANCE];

	/* Byte 7: Desired Content Min Luminance */
	if (drm_edid_is_luminance_value_present(len, MINIMUM_LUMINANCE))
		connector->hdr_min_luminance =
			db[MINIMUM_LUMINANCE];

	connector->hdr_supported = true;

	DRM_DEBUG_KMS("HDR electro-optical %d\n", connector->hdr_eotf);
	DRM_DEBUG_KMS("metadata desc 1 %d\n", connector->hdr_metadata_type_one);
	DRM_DEBUG_KMS("max luminance %d\n", connector->hdr_max_luminance);
	DRM_DEBUG_KMS("avg luminance %d\n", connector->hdr_avg_luminance);
	DRM_DEBUG_KMS("min luminance %d\n", connector->hdr_min_luminance);
}
/*
 * drm_hdmi_extract_extended_blk_info - Parse the HDMI extended tag blocks
 * @connector: connector corresponding to the HDMI sink
 * @edid: handle to the EDID structure
 * Parses the all extended tag blocks extract sink info for @connector.
 */
static void
drm_hdmi_extract_extended_blk_info(struct drm_connector *connector,
		const struct edid *edid)
{
	const u8 *cea = drm_find_cea_extension(edid);
	const u8 *db = NULL;

	if (cea && cea_revision(cea) >= 3) {
		int i, start, end;

		if (cea_db_offsets(cea, &start, &end))
			return;

		for_each_cea_db(cea, i, start, end) {
			db = &cea[i];

			if (cea_db_tag(db) == USE_EXTENDED_TAG) {
				DRM_DEBUG_KMS("found extended tag block = %d\n",
						db[1]);
				switch (db[1]) {
				case VIDEO_CAPABILITY_EXTENDED_DATA_BLOCK:
					drm_extract_vcdb_info(connector, db);
					break;
				case HDR_STATIC_METADATA_EXTENDED_DATA_BLOCK:
					drm_extract_hdr_db(connector, db);
					break;
				default:
					break;
				}
			}
		}
	}
}

static void
parse_hdmi_hf_vsdb(struct drm_connector *connector, const u8 *db)
{
	u8 len = cea_db_payload_len(db);

	if (len < 7)
		return;

	if (db[4] != 1)
		return; /* invalid version */

	connector->max_tmds_char = db[5] * 5;
	connector->scdc_present = db[6] & (1 << 7);
	connector->rr_capable = db[6] & (1 << 6);
	connector->flags_3d = db[6] & 0x7;
	connector->supports_scramble = connector->scdc_present &&
			(db[6] & (1 << 3));

	DRM_DEBUG_KMS(
		"HDMI v2: max TMDS char %d, scdc %s, rr %s,3D flags 0x%x, scramble %s\n",
		connector->max_tmds_char,
		connector->scdc_present ? "available" : "not available",
		connector->rr_capable ? "capable" : "not capable",
		connector->flags_3d,
		connector->supports_scramble ? "supported" : "not supported");
}

static void
monitor_name(struct detailed_timing *t, void *data)
{
@@ -3959,6 +4120,9 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
				/* HDMI Vendor-Specific Data Block */
				if (cea_db_is_hdmi_vsdb(db))
					drm_parse_hdmi_vsdb_audio(connector, db);
				/* HDMI Forum Vendor-Specific Data Block */
				else if (cea_db_is_hdmi_forum_vsdb(db))
					parse_hdmi_hf_vsdb(connector, db);
				break;
			default:
				break;
@@ -4471,6 +4635,38 @@ drm_reset_display_info(struct drm_connector *connector)
	info->non_desktop = 0;
}

static void
drm_hdmi_extract_vsdbs_info(struct drm_connector *connector,
		const struct edid *edid)
{
	const u8 *cea = drm_find_cea_extension(edid);
	const u8 *db = NULL;

	if (cea && cea_revision(cea) >= 3) {
		int i, start, end;

		if (cea_db_offsets(cea, &start, &end))
			return;

		for_each_cea_db(cea, i, start, end) {
			db = &cea[i];

			if (cea_db_tag(db) == VENDOR_BLOCK) {
				/* HDMI Vendor-Specific Data Block */
				if (cea_db_is_hdmi_vsdb(db)) {
					drm_parse_hdmi_vsdb_video(
						connector, db);
					drm_parse_hdmi_vsdb_audio(
						connector, db);
				}
				/* HDMI Forum Vendor-Specific Data Block */
				else if (cea_db_is_hdmi_forum_vsdb(db))
					parse_hdmi_hf_vsdb(connector, db);
			}
		}
	}
}

u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
{
	struct drm_display_info *info = &connector->display_info;
@@ -4508,6 +4704,11 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
			  connector->name, info->bpc);
	}

	/* Extract audio and video latency fields for the sink */
	drm_hdmi_extract_vsdbs_info(connector, edid);
	/* Extract info from extended tag blocks */
	drm_hdmi_extract_extended_blk_info(connector, edid);

	/* Only defined for 1.4 with digital displays */
	if (edid->revision < 4)
		return quirks;
+7 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@
/* from BKL pushdown */
DEFINE_MUTEX(drm_global_mutex);

#define MAX_DRM_OPEN_COUNT		20

/**
 * DOC: file operations
 *
@@ -310,6 +312,11 @@ int drm_open(struct inode *inode, struct file *filp)
	if (!dev->open_count++)
		need_setup = 1;

	if (dev->open_count >= MAX_DRM_OPEN_COUNT) {
		retcode = -EPERM;
		goto err_undo;
	}

	/* share address_space across all char-devs of a single device */
	filp->f_mapping = dev->anon_inode->i_mapping;

+2 −1
Original line number Diff line number Diff line
@@ -278,7 +278,8 @@ drm_internal_framebuffer_create(struct drm_device *dev,
	struct drm_framebuffer *fb;
	int ret;

	if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) {
	if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS |
			DRM_MODE_FB_SECURE)) {
		DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags);
		return ERR_PTR(-EINVAL);
	}
+5 −5
Original line number Diff line number Diff line
@@ -456,7 +456,7 @@ int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
		return -EINVAL;

	memset(packet, 0, sizeof(*packet));
	packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f);
	packet->header[2] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f);

	/* TODO: compute ECC if hardware support is not available */

@@ -468,16 +468,16 @@ int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
	 * and 2.
	 */
	if (mipi_dsi_packet_format_is_long(msg->type)) {
		packet->header[1] = (msg->tx_len >> 0) & 0xff;
		packet->header[2] = (msg->tx_len >> 8) & 0xff;
		packet->header[0] = (msg->tx_len >> 0) & 0xff;
		packet->header[1] = (msg->tx_len >> 8) & 0xff;

		packet->payload_length = msg->tx_len;
		packet->payload = msg->tx_buf;
	} else {
		const u8 *tx = msg->tx_buf;

		packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0;
		packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0;
		packet->header[0] = (msg->tx_len > 0) ? tx[0] : 0;
		packet->header[1] = (msg->tx_len > 1) ? tx[1] : 0;
	}

	packet->size = sizeof(packet->header) + packet->payload_length;
+13 −2
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@

#include "drm_crtc_internal.h"

#define MAX_BLOB_PROP_SIZE	(PAGE_SIZE * 30)
#define MAX_BLOB_PROP_COUNT	250

/**
 * DOC: overview
 *
@@ -556,7 +559,8 @@ drm_property_create_blob(struct drm_device *dev, size_t length,
	struct drm_property_blob *blob;
	int ret;

	if (!length || length > ULONG_MAX - sizeof(struct drm_property_blob))
	if (!length || length > MAX_BLOB_PROP_SIZE -
				sizeof(struct drm_property_blob))
		return ERR_PTR(-EINVAL);

	blob = kvzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
@@ -782,12 +786,19 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
			      void *data, struct drm_file *file_priv)
{
	struct drm_mode_create_blob *out_resp = data;
	struct drm_property_blob *blob;
	struct drm_property_blob *blob, *bt;
	int ret = 0;
	u32 count = 0;

	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		return -EINVAL;

	list_for_each_entry(bt, &file_priv->blobs, head_file)
		count++;

	if (count >= MAX_BLOB_PROP_COUNT)
		return -EINVAL;

	blob = drm_property_create_blob(dev, out_resp->length, NULL);
	if (IS_ERR(blob))
		return PTR_ERR(blob);
Loading