/*
* Copyright (C) 2006 Sony Computer Entertainment Inc.
* Copyright 2006, 2007 Sony Corporation
*
* AV backend support for PS3
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <asm/ps3av.h>
#include <asm/ps3fb.h>
#include <asm/ps3.h>
#include "vuart.h"
static const struct video_fmt {
u32 format;
u32 order;
} ps3av_video_fmt_table[] = {
{ PS3AV_CMD_VIDEO_FORMAT_ARGB_8BIT, PS3AV_CMD_VIDEO_ORDER_RGB },
{ PS3AV_CMD_VIDEO_FORMAT_ARGB_8BIT, PS3AV_CMD_VIDEO_ORDER_BGR },
};
static const struct {
int cs;
u32 av;
u32 bl;
} ps3av_cs_video2av_table[] = {
{
.cs = PS3AV_CMD_VIDEO_CS_RGB_8,
.av = PS3AV_CMD_AV_CS_RGB_8,
.bl = PS3AV_CMD_AV_CS_8
}, {
.cs = PS3AV_CMD_VIDEO_CS_RGB_10,
.av = PS3AV_CMD_AV_CS_RGB_8,
.bl = PS3AV_CMD_AV_CS_8
}, {
.cs = PS3AV_CMD_VIDEO_CS_RGB_12,
.av = PS3AV_CMD_AV_CS_RGB_8,
.bl = PS3AV_CMD_AV_CS_8
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV444_8,
.av = PS3AV_CMD_AV_CS_YUV444_8,
.bl = PS3AV_CMD_AV_CS_8
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV444_10,
.av = PS3AV_CMD_AV_CS_YUV444_8,
.bl = PS3AV_CMD_AV_CS_10
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV444_12,
.av = PS3AV_CMD_AV_CS_YUV444_8,
.bl = PS3AV_CMD_AV_CS_10
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV422_8,
.av = PS3AV_CMD_AV_CS_YUV422_8,
.bl = PS3AV_CMD_AV_CS_10
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV422_10,
.av = PS3AV_CMD_AV_CS_YUV422_8,
.bl = PS3AV_CMD_AV_CS_10
}, {
.cs = PS3AV_CMD_VIDEO_CS_YUV422_12,
.av = PS3AV_CMD_AV_CS_YUV422_8,
.bl = PS3AV_CMD_AV_CS_12
}, {
.cs = PS3AV_CMD_VIDEO_CS_XVYCC_8,
.av = PS3AV_CMD_AV_CS_XVYCC_8,
.bl = PS3AV_CMD_AV_CS_12
}, {
.cs = PS3AV_CMD_VIDEO_CS_XVYCC_10,
.av = PS3AV_CMD_AV_CS_XVYCC_8,
.bl = PS3AV_CMD_AV_CS_12
}, {
.cs = PS3AV_CMD_VIDEO_CS_XVYCC_12,
.av = PS3AV_CMD_AV_CS_XVYCC_8,
.bl = PS3AV_CMD_AV_CS_12
}
};
static u32 ps3av_cs_video2av(int cs)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ps3av_cs_video2av_table); i++)
if (ps3av_cs_video2av_table[i].cs == cs)
return ps3av_cs_video2av_table[i].av;
return PS3AV_CMD_AV_CS_RGB_8;
}
static u32 ps3av_cs_video2av_bitlen(int cs)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ps3av_cs_video2av_table); i++)
if (ps3av_cs_video2av_table[i].cs == cs)
return ps3av_cs_video2av_table[i].bl;
return PS3AV_CMD_AV_CS_8;
}
static const struct {
int vid;
u32 av;
} ps3av_vid_video2av_table[] = {
{ PS3AV_CMD_VIDEO_VID_480I, PS3AV_CMD_AV_VID_480I },
{ PS3AV_CMD_VIDEO_VID_480P, PS3AV_CMD_AV_VID_480P },
{ PS3AV_CMD_VIDEO_VID_576I, PS3AV_CMD_AV_VID_576I },
{ PS3AV_CMD_VIDEO_VID_576P, PS3AV_CMD_AV_VID_576P },
{ PS3AV_CMD_VIDEO_VID_1080I_60HZ, PS3AV_CMD_AV_VID_1080I_60HZ },
{ PS3AV_CMD_VIDEO_VID_720P_60HZ, PS3AV_CMD_AV_VID_720P_60HZ },
{ PS3AV_CMD_VIDEO_VID_1080P_60HZ, PS3AV_CMD_AV_VID_1080P_60HZ },
{ PS3AV_CMD_VIDEO_VID_1080I_50HZ, PS3AV_CMD_AV_VID_1080I_50HZ },
{ PS3AV_CMD_VIDEO_VID_720P_50HZ, PS3AV_CMD_AV_VID_720P_50HZ },
{ PS3AV_CMD_VIDEO_VID_1080P_50HZ, PS3AV_CMD_AV_VID_1080P_50HZ },
{ PS3AV_CMD_VIDEO_VID_WXGA, PS3AV_CMD_AV_VID_WXGA },
{ PS3AV_CMD_VIDEO_VID_SXGA, PS3AV_CMD_AV_VID_SXGA },
{ PS3AV_CMD_VIDEO_VID_WUXGA, PS3AV_CMD_AV_VID_WUXGA }
};
static u32 ps3av_vid_video2av(int vid)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ps3av_vid_video2av_table); i++)
if (ps3av_vid_video2av_table[i].vid == vid)
return ps3av_vid_video2av_table[i].av;
return PS3AV_CMD_AV_VID_480P;
}
int