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

Commit 71a27fec authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Linus Torvalds
Browse files

ps3av: use PS3 video mode ids in autodetect code



It doesn't make much sense to use the PS3AV_CMD_VIDEO_VID_* values in the
autodetection code, just to convert them to PS3 video mode ids afterwards.

Signed-off-by: default avatarGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: default avatarAntonino Daplas <adaplas@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent eea820ab
Loading
Loading
Loading
Loading
+40 −50
Original line number Original line Diff line number Diff line
@@ -585,75 +585,65 @@ static void ps3avd(struct work_struct *work)
	complete(&ps3av->done);
	complete(&ps3av->done);
}
}


static int ps3av_vid2table_id(int vid)
static int ps3av_resbit2id(u32 res_50, u32 res_60)
{
{
	int i;
	int id = 0;

	for (i = 1; i < ARRAY_SIZE(video_mode_table); i++)
		if (video_mode_table[i].vid == vid)
			return i;
	return -1;
}

static int ps3av_resbit2vid(u32 res_50, u32 res_60)
{
	int vid = -1;


	if (res_50 > res_60) {	/* if res_50 == res_60, res_60 will be used */
	if (res_50 > res_60) {	/* if res_50 == res_60, res_60 will be used */
		if (res_50 & PS3AV_RESBIT_1920x1080P)
		if (res_50 & PS3AV_RESBIT_1920x1080P)
			vid = PS3AV_CMD_VIDEO_VID_1080P_50HZ;
			id = 10;
		else if (res_50 & PS3AV_RESBIT_1920x1080I)
		else if (res_50 & PS3AV_RESBIT_1920x1080I)
			vid = PS3AV_CMD_VIDEO_VID_1080I_50HZ;
			id = 9;
		else if (res_50 & PS3AV_RESBIT_1280x720P)
		else if (res_50 & PS3AV_RESBIT_1280x720P)
			vid = PS3AV_CMD_VIDEO_VID_720P_50HZ;
			id = 8;
		else if (res_50 & PS3AV_RESBIT_720x576P)
		else if (res_50 & PS3AV_RESBIT_720x576P)
			vid = PS3AV_CMD_VIDEO_VID_576P;
			id = 7;
		else
		else
			vid = -1;
			id = 0;
	} else {
	} else {
		if (res_60 & PS3AV_RESBIT_1920x1080P)
		if (res_60 & PS3AV_RESBIT_1920x1080P)
			vid = PS3AV_CMD_VIDEO_VID_1080P_60HZ;
			id = 5;
		else if (res_60 & PS3AV_RESBIT_1920x1080I)
		else if (res_60 & PS3AV_RESBIT_1920x1080I)
			vid = PS3AV_CMD_VIDEO_VID_1080I_60HZ;
			id = 4;
		else if (res_60 & PS3AV_RESBIT_1280x720P)
		else if (res_60 & PS3AV_RESBIT_1280x720P)
			vid = PS3AV_CMD_VIDEO_VID_720P_60HZ;
			id = 3;
		else if (res_60 & PS3AV_RESBIT_720x480P)
		else if (res_60 & PS3AV_RESBIT_720x480P)
			vid = PS3AV_CMD_VIDEO_VID_480P;
			id = 2;
		else
		else
			vid = -1;
			id = 0;
	}
	}
	return vid;
	return id;
}
}


static int ps3av_hdmi_get_vid(struct ps3av_info_monitor *info)
static int ps3av_hdmi_get_id(struct ps3av_info_monitor *info)
{
{
	u32 res_50, res_60;
	u32 res_50, res_60;
	int vid = -1;
	int id;


	if (info->monitor_type != PS3AV_MONITOR_TYPE_HDMI)
	if (info->monitor_type != PS3AV_MONITOR_TYPE_HDMI)
		return -1;
		return 0;


	/* check native resolution */
	/* check native resolution */
	res_50 = info->res_50.native & PS3AV_RES_MASK_50;
	res_50 = info->res_50.native & PS3AV_RES_MASK_50;
	res_60 = info->res_60.native & PS3AV_RES_MASK_60;
	res_60 = info->res_60.native & PS3AV_RES_MASK_60;
	if (res_50 || res_60) {
	if (res_50 || res_60) {
		vid = ps3av_resbit2vid(res_50, res_60);
		id = ps3av_resbit2id(res_50, res_60);
		return vid;
		return id;
	}
	}


	/* check resolution */
	/* check resolution */
	res_50 = info->res_50.res_bits & PS3AV_RES_MASK_50;
	res_50 = info->res_50.res_bits & PS3AV_RES_MASK_50;
	res_60 = info->res_60.res_bits & PS3AV_RES_MASK_60;
	res_60 = info->res_60.res_bits & PS3AV_RES_MASK_60;
	if (res_50 || res_60) {
	if (res_50 || res_60) {
		vid = ps3av_resbit2vid(res_50, res_60);
		id = ps3av_resbit2id(res_50, res_60);
		return vid;
		return id;
	}
	}


	if (ps3av->region & PS3AV_REGION_60)
	if (ps3av->region & PS3AV_REGION_60)
		vid = PS3AV_DEFAULT_HDMI_VID_REG_60;
		id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
	else
	else
		vid = PS3AV_DEFAULT_HDMI_VID_REG_50;
		id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
	return vid;
	return id;
}
}


static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *monitor_info)
static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *monitor_info)
@@ -717,11 +707,11 @@ static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *
static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
				int boot)
				int boot)
{
{
	int i, res, vid = -1, dvi = 0, rgb = 0;
	int i, res, id = 0, dvi = 0, rgb = 0;
	struct ps3av_pkt_av_get_monitor_info monitor_info;
	struct ps3av_pkt_av_get_monitor_info monitor_info;
	struct ps3av_info_monitor *info;
	struct ps3av_info_monitor *info;


	/* get vid for hdmi */
	/* get mode id for hdmi */
	for (i = 0; i < av_hw_conf->num_of_hdmi; i++) {
	for (i = 0; i < av_hw_conf->num_of_hdmi; i++) {
		res = ps3av_cmd_video_get_monitor_info(&monitor_info,
		res = ps3av_cmd_video_get_monitor_info(&monitor_info,
						       PS3AV_CMD_AVPORT_HDMI_0 +
						       PS3AV_CMD_AVPORT_HDMI_0 +
@@ -737,49 +727,49 @@ static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
			break;
			break;
		}
		}
		/* check HDMI */
		/* check HDMI */
		vid = ps3av_hdmi_get_vid(info);
		id = ps3av_hdmi_get_id(info);
		if (vid != -1) {
		if (id) {
			/* got valid vid */
			/* got valid mode id */
			break;
			break;
		}
		}
	}
	}


	if (dvi) {
	if (dvi) {
		/* DVI mode */
		/* DVI mode */
		vid = PS3AV_DEFAULT_DVI_VID;
		id = PS3AV_DEFAULT_DVI_MODE_ID;
	} else if (vid == -1) {
	} else if (!id) {
		/* no HDMI interface or HDMI is off */
		/* no HDMI interface or HDMI is off */
		if (ps3av->region & PS3AV_REGION_60)
		if (ps3av->region & PS3AV_REGION_60)
			vid = PS3AV_DEFAULT_AVMULTI_VID_REG_60;
			id = PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_60;
		else
		else
			vid = PS3AV_DEFAULT_AVMULTI_VID_REG_50;
			id = PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_50;
		if (ps3av->region & PS3AV_REGION_RGB)
		if (ps3av->region & PS3AV_REGION_RGB)
			rgb = PS3AV_MODE_RGB;
			rgb = PS3AV_MODE_RGB;
	} else if (boot) {
	} else if (boot) {
		/* HDMI: using DEFAULT HDMI_VID while booting up */
		/* HDMI: using DEFAULT HDMI_MODE_ID while booting up */
		info = &monitor_info.info;
		info = &monitor_info.info;
		if (ps3av->region & PS3AV_REGION_60) {
		if (ps3av->region & PS3AV_REGION_60) {
			if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
			if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
				vid = PS3AV_DEFAULT_HDMI_VID_REG_60;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
			else if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
			else if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
				vid = PS3AV_DEFAULT_HDMI_VID_REG_50;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
			else {
			else {
				/* default */
				/* default */
				vid = PS3AV_DEFAULT_HDMI_VID_REG_60;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
			}
			}
		} else {
		} else {
			if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
			if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
				vid = PS3AV_DEFAULT_HDMI_VID_REG_50;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
			else if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
			else if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
				vid = PS3AV_DEFAULT_HDMI_VID_REG_60;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
			else {
			else {
				/* default */
				/* default */
				vid = PS3AV_DEFAULT_HDMI_VID_REG_50;
				id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
			}
			}
		}
		}
	}
	}


	return (ps3av_vid2table_id(vid) | dvi | rgb);
	return id | dvi | rgb;
}
}


static int ps3av_get_hw_conf(struct ps3av *ps3av)
static int ps3av_get_hw_conf(struct ps3av *ps3av)
+6 −5
Original line number Original line Diff line number Diff line
@@ -300,11 +300,12 @@


#define PS3AV_MONITOR_TYPE_HDMI			1	/* HDMI */
#define PS3AV_MONITOR_TYPE_HDMI			1	/* HDMI */
#define PS3AV_MONITOR_TYPE_DVI			2	/* DVI */
#define PS3AV_MONITOR_TYPE_DVI			2	/* DVI */
#define PS3AV_DEFAULT_HDMI_VID_REG_60		PS3AV_CMD_VIDEO_VID_480P

#define PS3AV_DEFAULT_AVMULTI_VID_REG_60	PS3AV_CMD_VIDEO_VID_480I
#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_60	2	/* 480p */
#define PS3AV_DEFAULT_HDMI_VID_REG_50		PS3AV_CMD_VIDEO_VID_576P
#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_60	1	/* 480i */
#define PS3AV_DEFAULT_AVMULTI_VID_REG_50	PS3AV_CMD_VIDEO_VID_576I
#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_50	7	/* 576p */
#define PS3AV_DEFAULT_DVI_VID			PS3AV_CMD_VIDEO_VID_480P
#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_50	6	/* 576i */
#define PS3AV_DEFAULT_DVI_MODE_ID		2	/* 480p */


#define PS3AV_REGION_60				0x01
#define PS3AV_REGION_60				0x01
#define PS3AV_REGION_50				0x02
#define PS3AV_REGION_50				0x02