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

Commit 8d94f491 authored by Tatenda Chipeperekwa's avatar Tatenda Chipeperekwa
Browse files

msm: fb: add support to set the output format



Add support to set the output of the interface based on the
grayscale value. The grayscale value must be set to a format
specified according to the V4L2 FOURCC pixel format definitions.
We translate from the FOURCC pixel format to the corresponding
MDP format when setting the final output format. For example,
this is used to set the output format to YUV420 for HDMI TVs
that are HDMI 2.0 compliant.

Change-Id: Id5623f1211b743b54002c22b19d81dbd13e6564f
Signed-off-by: default avatarTatenda Chipeperekwa <tatendac@codeaurora.org>
parent 4c47f344
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#define pr_fmt(fmt)	"%s: " fmt, __func__

#include <linux/videodev2.h>
#include <linux/bootmem.h>
#include <linux/console.h>
#include <linux/debugfs.h>
@@ -3095,9 +3096,23 @@ static int mdss_fb_pan_display_sub(struct fb_var_screeninfo *var,
	return 0;
}

static int mdss_grayscale_to_mdp_format(u32 grayscale)
{
	switch (grayscale) {
	case V4L2_PIX_FMT_RGB24:
		return MDP_RGB_888;
	case V4L2_PIX_FMT_NV12:
		return MDP_Y_CBCR_H2V2;
	default:
		return -EINVAL;
	}
}

static void mdss_fb_var_to_panelinfo(struct fb_var_screeninfo *var,
	struct mdss_panel_info *pinfo)
{
	int format = -EINVAL;

	pinfo->xres = var->xres;
	pinfo->yres = var->yres;
	pinfo->lcdc.v_front_porch = var->lower_margin;
@@ -3107,6 +3122,15 @@ static void mdss_fb_var_to_panelinfo(struct fb_var_screeninfo *var,
	pinfo->lcdc.h_back_porch = var->left_margin;
	pinfo->lcdc.h_pulse_width = var->hsync_len;
	pinfo->clk_rate = var->pixclock;

	if (var->grayscale > 1) {
		format = mdss_grayscale_to_mdp_format(var->grayscale);
		if (!IS_ERR_VALUE(format))
			pinfo->out_format = format;
		else
			pr_warn("Failed to map grayscale value (%d) to an MDP format\n",
					var->grayscale);
	}
}

static void mdss_panelinfo_to_fb_var(struct mdss_panel_info *pinfo,
@@ -3250,8 +3274,6 @@ static int mdss_fb_check_var(struct fb_var_screeninfo *var,

	if (var->rotate != FB_ROTATE_UR && var->rotate != FB_ROTATE_UD)
		return -EINVAL;
	if (var->grayscale != info->var.grayscale)
		return -EINVAL;

	switch (var->bits_per_pixel) {
	case 16: