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

Commit 4b41616a authored by Alan Kwong's avatar Alan Kwong
Browse files

msm: sde: cleanup format validation for sbuf mode



Add rotator operating mode to format validation logic
and define h/w version specific format table for each
operating mode. Update base format lookup table for
missing rgb565/rgb ubwc/rgb565 tile to rgb565 tile.

Change-Id: I0146fdd9423114903f40873d4a0e10c19ca8e38a
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent 809f3cbd
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
 *
 */

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

#include <linux/platform_device.h>
#include <linux/module.h>
@@ -1652,18 +1652,20 @@ static void sde_rotator_done_handler(struct kthread_work *work)

static bool sde_rotator_verify_format(struct sde_rot_mgr *mgr,
	struct sde_mdp_format_params *in_fmt,
	struct sde_mdp_format_params *out_fmt, bool rotation)
	struct sde_mdp_format_params *out_fmt, bool rotation, u32 mode)
{
	u8 in_v_subsample, in_h_subsample;
	u8 out_v_subsample, out_h_subsample;

	if (!sde_rotator_is_valid_pixfmt(mgr, in_fmt->format, true)) {
		SDEROT_ERR("Invalid input format %x\n", in_fmt->format);
	if (!sde_rotator_is_valid_pixfmt(mgr, in_fmt->format, true, mode)) {
		SDEROT_ERR("Invalid input format 0x%x (%4.4s)\n",
				in_fmt->format, (char *)&in_fmt->format);
		goto verify_error;
	}

	if (!sde_rotator_is_valid_pixfmt(mgr, out_fmt->format, false)) {
		SDEROT_ERR("Invalid output format %x\n", out_fmt->format);
	if (!sde_rotator_is_valid_pixfmt(mgr, out_fmt->format, false, mode)) {
		SDEROT_ERR("Invalid output format 0x%x (%4.4s)\n",
				out_fmt->format, (char *)&out_fmt->format);
		goto verify_error;
	}

@@ -1712,8 +1714,10 @@ static bool sde_rotator_verify_format(struct sde_rot_mgr *mgr,
	return true;

verify_error:
	SDEROT_ERR("in_fmt=0x%x, out_fmt=0x%x\n",
			in_fmt->format, out_fmt->format);
	SDEROT_ERR("in_fmt=0x%x (%4.4s), out_fmt=0x%x (%4.4s), mode=%d\n",
			in_fmt->format, (char *)&in_fmt->format,
			out_fmt->format, (char *)&out_fmt->format,
			mode);
	return false;
}

@@ -1832,6 +1836,7 @@ int sde_rotator_verify_config_all(struct sde_rot_mgr *mgr,
{
	struct sde_mdp_format_params *in_fmt, *out_fmt;
	bool rotation;
	u32 mode;

	if (!mgr || !config) {
		SDEROT_ERR("null parameters\n");
@@ -1840,6 +1845,9 @@ int sde_rotator_verify_config_all(struct sde_rot_mgr *mgr,

	rotation = (config->flags & SDE_ROTATION_90) ? true : false;

	mode = config->output.sbuf ? SDE_ROTATOR_MODE_SBUF :
				SDE_ROTATOR_MODE_OFFLINE;

	in_fmt = __verify_input_config(mgr, config);
	if (!in_fmt)
		return -EINVAL;
@@ -1848,7 +1856,7 @@ int sde_rotator_verify_config_all(struct sde_rot_mgr *mgr,
	if (!out_fmt)
		return -EINVAL;

	if (!sde_rotator_verify_format(mgr, in_fmt, out_fmt, rotation)) {
	if (!sde_rotator_verify_format(mgr, in_fmt, out_fmt, rotation, mode)) {
		SDEROT_ERR(
			"Rot format pairing invalid, in_fmt:0x%x, out_fmt:0x%x\n",
					config->input.format,
+12 −6
Original line number Diff line number Diff line
@@ -141,6 +141,12 @@ enum sde_rotator_trigger {
	SDE_ROTATOR_TRIGGER_COMMAND,
};

enum sde_rotator_mode {
	SDE_ROTATOR_MODE_OFFLINE,
	SDE_ROTATOR_MODE_SBUF,
	SDE_ROTATOR_MODE_MAX,
};

struct sde_rotation_item {
	/* rotation request flag */
	uint32_t	flags;
@@ -463,9 +469,9 @@ struct sde_rot_mgr {
	int (*ops_hw_validate_entry)(struct sde_rot_mgr *mgr,
			struct sde_rot_entry *entry);
	u32 (*ops_hw_get_pixfmt)(struct sde_rot_mgr *mgr, int index,
			bool input);
			bool input, u32 mode);
	int (*ops_hw_is_valid_pixfmt)(struct sde_rot_mgr *mgr, u32 pixfmt,
			bool input);
			bool input, u32 mode);
	int (*ops_hw_get_downscale_caps)(struct sde_rot_mgr *mgr, char *caps,
			int len);
	int (*ops_hw_get_maxlinewidth)(struct sde_rot_mgr *mgr);
@@ -474,19 +480,19 @@ struct sde_rot_mgr {
};

static inline int sde_rotator_is_valid_pixfmt(struct sde_rot_mgr *mgr,
		u32 pixfmt, bool input)
		u32 pixfmt, bool input, u32 mode)
{
	if (mgr && mgr->ops_hw_is_valid_pixfmt)
		return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input);
		return mgr->ops_hw_is_valid_pixfmt(mgr, pixfmt, input, mode);

	return false;
}

static inline u32 sde_rotator_get_pixfmt(struct sde_rot_mgr *mgr,
		int index, bool input)
		int index, bool input, u32 mode)
{
	if (mgr && mgr->ops_hw_get_pixfmt)
		return mgr->ops_hw_get_pixfmt(mgr, index, input);
		return mgr->ops_hw_get_pixfmt(mgr, index, input, mode);

	return 0;
}
+9 −6
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#define pr_fmt(fmt)	"%s: " fmt, __func__
#define pr_fmt(fmt)	"%s:%d: " fmt, __func__, __LINE__

#include <linux/vmalloc.h>
#include <linux/kernel.h>
@@ -1390,7 +1390,8 @@ int sde_rotator_inline_get_pixfmt_caps(struct platform_device *pdev,

	sde_rot_mgr_lock(rot_dev->mgr);
	for (i = 0;; i++) {
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, input);
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, input,
				SDE_ROTATOR_MODE_SBUF);
		if (!pixfmt)
			break;
		if (pixfmts && i < len)
@@ -1568,7 +1569,7 @@ int sde_rotator_inline_commit(void *handle, struct sde_rotator_inline_cmd *cmd,
			ret = sde_rotator_session_config(rot_dev->mgr,
					ctx->private, &rotcfg);
			if (ret) {
				SDEROT_ERR("fail session config s:%d\n",
				SDEROT_WARN("fail session config s:%d\n",
						ctx->session_id);
				goto error_session_config;
			}
@@ -1579,7 +1580,7 @@ int sde_rotator_inline_commit(void *handle, struct sde_rotator_inline_cmd *cmd,
		ret = sde_rotator_validate_request(rot_dev->mgr, ctx->private,
				req);
		if (ret) {
			SDEROT_ERR("fail validate request s:%d\n",
			SDEROT_WARN("fail validate request s:%d\n",
					ctx->session_id);
			goto error_validate_request;
		}
@@ -1805,7 +1806,8 @@ static int sde_rotator_enum_fmt_vid_cap(struct file *file,
	bool found = false;

	for (i = 0, index = 0; index <= f->index; i++) {
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, false);
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, false,
				SDE_ROTATOR_MODE_OFFLINE);
		if (!pixfmt)
			return -EINVAL;

@@ -1849,7 +1851,8 @@ static int sde_rotator_enum_fmt_vid_out(struct file *file,
	bool found = false;

	for (i = 0, index = 0; index <= f->index; i++) {
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, true);
		pixfmt = sde_rotator_get_pixfmt(rot_dev->mgr, i, true,
				SDE_ROTATOR_MODE_OFFLINE);
		if (!pixfmt)
			return -EINVAL;

+5 −0
Original line number Diff line number Diff line
@@ -850,6 +850,11 @@ int sde_rot_get_base_tilea5x_pixfmt(u32 src_pixfmt, u32 *dst_pixfmt)
	case SDE_PIX_FMT_Y_CRCB_H2V2_TILE:
		*dst_pixfmt = SDE_PIX_FMT_Y_CRCB_H2V2_TILE;
		break;
	case V4L2_PIX_FMT_RGB565:
	case SDE_PIX_FMT_RGB_565_UBWC:
	case SDE_PIX_FMT_RGB_565_TILE:
		*dst_pixfmt = SDE_PIX_FMT_RGB_565_TILE;
		break;
	case SDE_PIX_FMT_RGBA_8888:
	case SDE_PIX_FMT_RGBA_8888_UBWC:
	case SDE_PIX_FMT_RGBA_8888_TILE:
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#define SDE_PIX_FMT_RGBA_1010102_TILE	v4l2_fourcc('Q', 'T', '1', '0')
#define SDE_PIX_FMT_RGBX_1010102_TILE	v4l2_fourcc('Q', 'T', '1', '1')
#define SDE_PIX_FMT_Y_CBCR_H2V2_P010_TILE	v4l2_fourcc('Q', 'T', '1', '2')
#define SDE_PIX_FMT_RGB_565_TILE	v4l2_fourcc('Q', 'T', '1', '3')

#define SDE_ROT_MAX_PLANES		4

Loading