(gfx/drivers) Style nits

This commit is contained in:
twinaphex 2015-04-11 08:39:37 +02:00
parent e76f8b9a71
commit 54b10d8eca
3 changed files with 325 additions and 325 deletions

View File

@ -84,8 +84,8 @@ typedef struct ctr_video
} ctr_video_t; } ctr_video_t;
static INLINE void ctr_set_scale_vector(ctr_scale_vector_t* vec, static INLINE void ctr_set_scale_vector(ctr_scale_vector_t* vec,
int viewport_width, int viewport_height, int viewport_width, int viewport_height,
int texture_width, int texture_height) int texture_width, int texture_height)
{ {
vec->x = -2.0 / viewport_width; vec->x = -2.0 / viewport_width;
vec->y = -2.0 / viewport_height; vec->y = -2.0 / viewport_height;
@ -94,7 +94,7 @@ static INLINE void ctr_set_scale_vector(ctr_scale_vector_t* vec,
} }
static void* ctr_init(const video_info_t* video, static void* ctr_init(const video_info_t* video,
const input_driver_t** input, void** input_data) const input_driver_t** input, void** input_data)
{ {
void* ctrinput = NULL; void* ctrinput = NULL;
ctr_video_t* ctr = (ctr_video_t*)linearAlloc(sizeof(ctr_video_t)); ctr_video_t* ctr = (ctr_video_t*)linearAlloc(sizeof(ctr_video_t));
@ -216,7 +216,7 @@ static void* ctr_init(const video_info_t* video,
} }
//#define gspWaitForEvent(...) //#define gspWaitForEvent(...)
static bool ctr_frame(void* data, const void* frame, static bool ctr_frame(void* data, const void* frame,
unsigned width, unsigned height, unsigned pitch, const char* msg) unsigned width, unsigned height, unsigned pitch, const char* msg)
{ {
ctr_video_t* ctr = (ctr_video_t*)data; ctr_video_t* ctr = (ctr_video_t*)data;
settings_t* settings = config_get_ptr(); settings_t* settings = config_get_ptr();

View File

@ -85,16 +85,16 @@ typedef struct omapfb_data
static const char *omapfb_get_fb_device(void) static const char *omapfb_get_fb_device(void)
{ {
static char fbname[12]; static char fbname[12];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const int fbidx = settings->video.monitor_index; const int fbidx = settings->video.monitor_index;
if (fbidx == 0) if (fbidx == 0)
return "/dev/fb0"; return "/dev/fb0";
snprintf(fbname, sizeof(fbname), "/dev/fb%d", fbidx - 1); snprintf(fbname, sizeof(fbname), "/dev/fb%d", fbidx - 1);
RARCH_LOG("[video_omap]: Using %s as framebuffer device.\n", fbname); RARCH_LOG("[video_omap]: Using %s as framebuffer device.\n", fbname);
return fbname; return fbname;
} }
static omapfb_page_t *omapfb_get_page(omapfb_data_t *pdata) static omapfb_page_t *omapfb_get_page(omapfb_data_t *pdata)
@ -121,37 +121,37 @@ static omapfb_page_t *omapfb_get_page(omapfb_data_t *pdata)
static void omapfb_page_flip(omapfb_data_t *pdata) static void omapfb_page_flip(omapfb_data_t *pdata)
{ {
if (pdata->sync) if (pdata->sync)
ioctl(pdata->fd, OMAPFB_WAITFORGO); ioctl(pdata->fd, OMAPFB_WAITFORGO);
/* TODO: should we use the manual update feature of the OMAP here? */ /* TODO: should we use the manual update feature of the OMAP here? */
pdata->current_state->si.yoffset = pdata->cur_page->yoffset; pdata->current_state->si.yoffset = pdata->cur_page->yoffset;
ioctl(pdata->fd, FBIOPAN_DISPLAY, &pdata->current_state->si); ioctl(pdata->fd, FBIOPAN_DISPLAY, &pdata->current_state->si);
if (pdata->old_page) if (pdata->old_page)
pdata->old_page->used = false; pdata->old_page->used = false;
} }
static int omapfb_read_sysfs(const char *fname, char *buff, size_t size) static int omapfb_read_sysfs(const char *fname, char *buff, size_t size)
{ {
int ret; int ret;
FILE *f = fopen(fname, "r"); FILE *f = fopen(fname, "r");
if (!f) if (!f)
return -1; return -1;
ret = fread(buff, 1, size - 1, f); ret = fread(buff, 1, size - 1, f);
fclose(f); fclose(f);
if (ret <= 0) if (ret <= 0)
return -1; return -1;
buff[ret] = 0; buff[ret] = 0;
for (ret--; ret >= 0 && isspace(buff[ret]); ret--) for (ret--; ret >= 0 && isspace(buff[ret]); ret--)
buff[ret] = 0; buff[ret] = 0;
return 0; return 0;
} }
static INLINE void omapfb_put_pixel_rgb565( static INLINE void omapfb_put_pixel_rgb565(
@ -163,7 +163,7 @@ static INLINE void omapfb_put_pixel_rgb565(
static INLINE void omapfb_put_pixel_argb8888( static INLINE void omapfb_put_pixel_argb8888(
uint32_t *p, unsigned r, unsigned g, unsigned b) uint32_t *p, unsigned r, unsigned g, unsigned b)
{ {
*p = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | ((b << 0) & 0x0000ff); *p = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | ((b << 0) & 0x0000ff);
} }
static int omapfb_detect_screen(omapfb_data_t *pdata) static int omapfb_detect_screen(omapfb_data_t *pdata)
@ -461,133 +461,133 @@ error:
static int omapfb_setup_screeninfo(omapfb_data_t *pdata, int width, int height) static int omapfb_setup_screeninfo(omapfb_data_t *pdata, int width, int height)
{ {
omapfb_state_t* state = pdata->current_state; omapfb_state_t* state = pdata->current_state;
state->si.xres = width; state->si.xres = width;
state->si.yres = height; state->si.yres = height;
state->si.xres_virtual = width; state->si.xres_virtual = width;
state->si.yres_virtual = height * pdata->num_pages; state->si.yres_virtual = height * pdata->num_pages;
state->si.xoffset = 0; state->si.xoffset = 0;
state->si.yoffset = 0; state->si.yoffset = 0;
state->si.bits_per_pixel = pdata->bpp * 8; state->si.bits_per_pixel = pdata->bpp * 8;
/* OMAPFB_COLOR_ARGB32 for bpp=4, OMAPFB_COLOR_RGB565 for bpp=2 */ /* OMAPFB_COLOR_ARGB32 for bpp=4, OMAPFB_COLOR_RGB565 for bpp=2 */
state->si.nonstd = 0; state->si.nonstd = 0;
if (ioctl(pdata->fd, FBIOPUT_VSCREENINFO, &state->si) != 0) if (ioctl(pdata->fd, FBIOPUT_VSCREENINFO, &state->si) != 0)
{ {
RARCH_ERR("[video_omap]: setup screeninfo failed\n"); RARCH_ERR("[video_omap]: setup screeninfo failed\n");
return -1; return -1;
} }
pdata->fb_framesize = width * height * pdata->bpp; pdata->fb_framesize = width * height * pdata->bpp;
return 0; return 0;
} }
static float omapfb_scaling(omapfb_data_t *pdata, int width, int height) static float omapfb_scaling(omapfb_data_t *pdata, int width, int height)
{ {
const float w_factor = (float)pdata->nat_w / (float)width; const float w_factor = (float)pdata->nat_w / (float)width;
const float h_factor = (float)pdata->nat_h / (float)height; const float h_factor = (float)pdata->nat_h / (float)height;
return (w_factor < h_factor ? w_factor : h_factor); return (w_factor < h_factor ? w_factor : h_factor);
} }
static int omapfb_setup_plane(omapfb_data_t *pdata, int width, int height) static int omapfb_setup_plane(omapfb_data_t *pdata, int width, int height)
{ {
int x, y, w, h; int x, y, w, h;
struct omapfb_plane_info pi = {0}; struct omapfb_plane_info pi = {0};
float scale = omapfb_scaling(pdata, width, height); float scale = omapfb_scaling(pdata, width, height);
int w = (int)(scale * width); int w = (int)(scale * width);
int h = (int)(scale * height); int h = (int)(scale * height);
RARCH_LOG("omap_video: scaling %dx%d to %dx%d\n", width, height, w, h); RARCH_LOG("omap_video: scaling %dx%d to %dx%d\n", width, height, w, h);
x = pdata->nat_w / 2 - w / 2; x = pdata->nat_w / 2 - w / 2;
y = pdata->nat_h / 2 - h / 2; y = pdata->nat_h / 2 - h / 2;
if (width * height * pdata->bpp * pdata->num_pages > pdata->current_state->mi.size) if (width * height * pdata->bpp * pdata->num_pages > pdata->current_state->mi.size)
{ {
RARCH_ERR("omap_video: fb dimensions too large for allocated buffer\n"); RARCH_ERR("omap_video: fb dimensions too large for allocated buffer\n");
return -1; return -1;
} }
if (ioctl(pdata->fd, OMAPFB_QUERY_PLANE, &pi) != 0) if (ioctl(pdata->fd, OMAPFB_QUERY_PLANE, &pi) != 0)
{ {
RARCH_ERR("[video_omap]: setup plane (query) failed\n"); RARCH_ERR("[video_omap]: setup plane (query) failed\n");
return -1; return -1;
} }
/* Disable the plane during setup to avoid garbage on screen. */ /* Disable the plane during setup to avoid garbage on screen. */
pi.pos_x = x; pi.pos_x = x;
pi.pos_y = y; pi.pos_y = y;
pi.out_width = w; pi.out_width = w;
pi.out_height = h; pi.out_height = h;
pi.enabled = 0; pi.enabled = 0;
if (ioctl(pdata->fd, OMAPFB_SETUP_PLANE, &pi) != 0) if (ioctl(pdata->fd, OMAPFB_SETUP_PLANE, &pi) != 0)
{ {
RARCH_ERR("[video_omap]: setup plane (param = %d %d %d %d) failed\n", x, y, w, h); RARCH_ERR("[video_omap]: setup plane (param = %d %d %d %d) failed\n", x, y, w, h);
return -1; return -1;
} }
pdata->current_state->pi = pi; pdata->current_state->pi = pi;
return 0; return 0;
} }
static int omapfb_enable_plane(omapfb_data_t *pdata) static int omapfb_enable_plane(omapfb_data_t *pdata)
{ {
struct omapfb_plane_info pi = {0}; struct omapfb_plane_info pi = {0};
if (ioctl(pdata->fd, OMAPFB_QUERY_PLANE, &pi) != 0) if (ioctl(pdata->fd, OMAPFB_QUERY_PLANE, &pi) != 0)
{ {
RARCH_ERR("[video_omap]: enable plane (query) failed\n"); RARCH_ERR("[video_omap]: enable plane (query) failed\n");
return -1; return -1;
} }
pi.enabled = 1; pi.enabled = 1;
if (ioctl(pdata->fd, OMAPFB_SETUP_PLANE, &pi) != 0) if (ioctl(pdata->fd, OMAPFB_SETUP_PLANE, &pi) != 0)
{ {
RARCH_ERR("[video_omap]: enable plane failed\n"); RARCH_ERR("[video_omap]: enable plane failed\n");
return -1; return -1;
} }
return 0; return 0;
} }
static int omapfb_init(omapfb_data_t *pdata, unsigned bpp) static int omapfb_init(omapfb_data_t *pdata, unsigned bpp)
{ {
const char *fbname = omapfb_get_fb_device(); const char *fbname = omapfb_get_fb_device();
int fd = open(fbname, O_RDWR); int fd = open(fbname, O_RDWR);
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (fd == -1) if (fd == -1)
{ {
RARCH_ERR("[video_omap]: can't open framebuffer device\n"); RARCH_ERR("[video_omap]: can't open framebuffer device\n");
return -1; return -1;
} }
pdata->fbname = fbname; pdata->fbname = fbname;
pdata->fd = fd; pdata->fd = fd;
if (omapfb_detect_screen(pdata)) if (omapfb_detect_screen(pdata))
{ {
close(fd); close(fd);
pdata->fbname = NULL; pdata->fbname = NULL;
pdata->fd = -1; pdata->fd = -1;
return -1; return -1;
} }
/* always use triple buffering to reduce chance of tearing */ /* always use triple buffering to reduce chance of tearing */
pdata->bpp = bpp; pdata->bpp = bpp;
pdata->num_pages = 3; pdata->num_pages = 3;
pdata->sync = settings->video.vsync; pdata->sync = settings->video.vsync;
return 0; return 0;
} }
void omapfb_free(omapfb_data_t *pdata) void omapfb_free(omapfb_data_t *pdata)
@ -684,40 +684,40 @@ static void omapfb_blend_glyph_rgb565(omapfb_data_t *pdata,
unsigned g_width, unsigned g_height, unsigned g_pitch, unsigned g_width, unsigned g_height, unsigned g_pitch,
unsigned dst_x, unsigned dst_y) unsigned dst_x, unsigned dst_y)
{ {
unsigned x, y; unsigned x, y;
unsigned r, g, b; unsigned r, g, b;
unsigned dst_pitch = (pdata->current_state->si.xres * pdata->bpp) >> 1; unsigned dst_pitch = (pdata->current_state->si.xres * pdata->bpp) >> 1;
uint16_t *dst = (uint16_t*)pdata->cur_page->buf + dst_y * dst_pitch + dst_x; uint16_t *dst = (uint16_t*)pdata->cur_page->buf + dst_y * dst_pitch + dst_x;
for (y = 0; y < g_height; ++y, src += g_pitch, dst += dst_pitch) for (y = 0; y < g_height; ++y, src += g_pitch, dst += dst_pitch)
{ {
for (x = 0; x < g_width; ++x) for (x = 0; x < g_width; ++x)
{ {
const uint8_t blend = src[x]; const uint8_t blend = src[x];
const uint16_t out = dst[x]; const uint16_t out = dst[x];
if (blend == 0) if (blend == 0)
continue; continue;
if (blend == 255) if (blend == 255)
{ {
omapfb_put_pixel_rgb565(&dst[x], f_rgb[0], f_rgb[1], f_rgb[2]); omapfb_put_pixel_rgb565(&dst[x], f_rgb[0], f_rgb[1], f_rgb[2]);
continue; continue;
} }
r = (out & 0xf800) >> 11; r = (out & 0xf800) >> 11;
g = (out & 0x07e0) >> 5; g = (out & 0x07e0) >> 5;
b = (out & 0x001f) >> 0; b = (out & 0x001f) >> 0;
r = (r << 3) | (r >> 2); r = (r << 3) | (r >> 2);
g = (g << 2) | (g >> 4); g = (g << 2) | (g >> 4);
b = (b << 3) | (b >> 2); b = (b << 3) | (b >> 2);
omapfb_put_pixel_rgb565(&dst[x], (r * (256 - blend) + f_rgb[0] * blend) >> 8, omapfb_put_pixel_rgb565(&dst[x], (r * (256 - blend) + f_rgb[0] * blend) >> 8,
(g * (256 - blend) + f_rgb[1] * blend) >> 8, (g * (256 - blend) + f_rgb[1] * blend) >> 8,
(b * (256 - blend) + f_rgb[2] * blend) >> 8); (b * (256 - blend) + f_rgb[2] * blend) >> 8);
} }
} }
} }
static void omapfb_blend_glyph_argb8888(omapfb_data_t *pdata, static void omapfb_blend_glyph_argb8888(omapfb_data_t *pdata,
@ -725,39 +725,39 @@ static void omapfb_blend_glyph_argb8888(omapfb_data_t *pdata,
unsigned g_width, unsigned g_height, unsigned g_pitch, unsigned g_width, unsigned g_height, unsigned g_pitch,
unsigned dst_x, unsigned dst_y) unsigned dst_x, unsigned dst_y)
{ {
unsigned x, y; unsigned x, y;
unsigned r, g, b; unsigned r, g, b;
unsigned dst_pitch = (pdata->current_state->si.xres * pdata->bpp) >> 2; unsigned dst_pitch = (pdata->current_state->si.xres * pdata->bpp) >> 2;
uint32_t *dst = (uint32_t*)pdata->cur_page->buf + dst_y * dst_pitch + dst_x; uint32_t *dst = (uint32_t*)pdata->cur_page->buf + dst_y * dst_pitch + dst_x;
for (y = 0; y < g_height; ++y, src += g_pitch, dst += dst_pitch) for (y = 0; y < g_height; ++y, src += g_pitch, dst += dst_pitch)
{ {
for (x = 0; x < g_width; ++x) for (x = 0; x < g_width; ++x)
{ {
const uint8_t blend = src[x]; const uint8_t blend = src[x];
const uint32_t out = dst[x]; const uint32_t out = dst[x];
if (blend == 0) if (blend == 0)
continue; continue;
if (blend == 255) if (blend == 255)
{ {
omapfb_put_pixel_argb8888(&dst[x], f_rgb[0], f_rgb[1], f_rgb[2]); omapfb_put_pixel_argb8888(&dst[x], f_rgb[0], f_rgb[1], f_rgb[2]);
continue; continue;
} }
r = (out & 0xff0000) >> 16; r = (out & 0xff0000) >> 16;
g = (out & 0x00ff00) >> 8; g = (out & 0x00ff00) >> 8;
b = (out & 0x0000ff) >> 0; b = (out & 0x0000ff) >> 0;
omapfb_put_pixel_argb8888(&dst[x], (r * (256 - blend) + f_rgb[0] * blend) >> 8, omapfb_put_pixel_argb8888(&dst[x], (r * (256 - blend) + f_rgb[0] * blend) >> 8,
(g * (256 - blend) + f_rgb[1] * blend) >> 8, (g * (256 - blend) + f_rgb[1] * blend) >> 8,
(b * (256 - blend) + f_rgb[2] * blend) >> 8); (b * (256 - blend) + f_rgb[2] * blend) >> 8);
} }
} }
} }
static void omapfb_blit_frame(omapfb_data_t *pdata, const void *src, static void omapfb_blit_frame(omapfb_data_t *pdata, const void *src,
unsigned height, unsigned src_pitch) unsigned height, unsigned src_pitch)
{ {
unsigned i; unsigned i;
void *dst = pdata->cur_page->buf; void *dst = pdata->cur_page->buf;
@ -770,49 +770,49 @@ static void omapfb_blit_frame(omapfb_data_t *pdata, const void *src,
typedef struct omap_video typedef struct omap_video
{ {
omapfb_data_t *omap; omapfb_data_t *omap;
void *font; void *font;
const font_renderer_driver_t *font_driver; const font_renderer_driver_t *font_driver;
uint8_t font_rgb[4]; uint8_t font_rgb[4];
unsigned bytes_per_pixel; unsigned bytes_per_pixel;
/* current dimensions */ /* current dimensions */
unsigned width; unsigned width;
unsigned height; unsigned height;
struct struct
{ {
bool active; bool active;
void *frame; void *frame;
struct scaler_ctx scaler; struct scaler_ctx scaler;
} menu; } menu;
} omap_video_t; } omap_video_t;
static void omap_gfx_free(void *data) static void omap_gfx_free(void *data)
{ {
omap_video_t *vid = data; omap_video_t *vid = data;
if (!vid) if (!vid)
return; return;
omapfb_free(vid->omap); omapfb_free(vid->omap);
free(vid->omap); free(vid->omap);
if (vid->font) if (vid->font)
vid->font_driver->free(vid->font); vid->font_driver->free(vid->font);
scaler_ctx_gen_reset(&vid->menu.scaler); scaler_ctx_gen_reset(&vid->menu.scaler);
free(vid->menu.frame); free(vid->menu.frame);
free(vid); free(vid);
} }
static void omap_init_font(omap_video_t *vid, const char *font_path, unsigned font_size) static void omap_init_font(omap_video_t *vid, const char *font_path, unsigned font_size)
{ {
int r, g, b; int r, g, b;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (!settings->video.font_enable) if (!settings->video.font_enable)
return; return;
@ -917,136 +917,136 @@ static void omap_render_msg(omap_video_t *vid, const char *msg)
static void *omap_gfx_init(const video_info_t *video, static void *omap_gfx_init(const video_info_t *video,
const input_driver_t **input, void **input_data) const input_driver_t **input, void **input_data)
{ {
omap_video_t *vid = NULL; omap_video_t *vid = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
/* Don't support filters at the moment since they make estimations * /* Don't support filters at the moment since they make estimations *
* on the maximum used resolution difficult. */ * on the maximum used resolution difficult. */
if (global->filter.filter) if (global->filter.filter)
{ {
RARCH_ERR("[video_omap]: filters are not supported\n"); RARCH_ERR("[video_omap]: filters are not supported\n");
return NULL; return NULL;
} }
vid = (omap_video_t*)calloc(1, sizeof(omap_video_t)); vid = (omap_video_t*)calloc(1, sizeof(omap_video_t));
if (!vid) if (!vid)
return NULL; return NULL;
vid->omap = (omapfb_data_t*)calloc(1, sizeof(omapfb_data_t)); vid->omap = (omapfb_data_t*)calloc(1, sizeof(omapfb_data_t));
if (!vid->omap) if (!vid->omap)
goto fail; goto fail;
vid->bytes_per_pixel = video->rgb32 ? 4 : 2; vid->bytes_per_pixel = video->rgb32 ? 4 : 2;
if (omapfb_init(vid->omap, vid->bytes_per_pixel) != 0) if (omapfb_init(vid->omap, vid->bytes_per_pixel) != 0)
goto fail_omapfb; goto fail_omapfb;
if (omapfb_backup_state(vid->omap) != 0 || if (omapfb_backup_state(vid->omap) != 0 ||
omapfb_alloc_mem(vid->omap) != 0 || omapfb_alloc_mem(vid->omap) != 0 ||
omapfb_mmap(vid->omap) != 0) omapfb_mmap(vid->omap) != 0)
goto fail_omapfb; goto fail_omapfb;
/* set some initial mode for the menu */ /* set some initial mode for the menu */
vid->width = 320; vid->width = 320;
vid->height = 240; vid->height = 240;
if (omapfb_set_mode(vid->omap, vid->width, vid->height) != 0) if (omapfb_set_mode(vid->omap, vid->width, vid->height) != 0)
goto fail_omapfb; goto fail_omapfb;
if (input && input_data) if (input && input_data)
*input = NULL; *input = NULL;
omap_init_font(vid, settings->video.font_path, settings->video.font_size); omap_init_font(vid, settings->video.font_path, settings->video.font_size);
vid->menu.frame = calloc(vid->width * vid->height, vid->bytes_per_pixel); vid->menu.frame = calloc(vid->width * vid->height, vid->bytes_per_pixel);
if (!vid->menu.frame) if (!vid->menu.frame)
goto fail_omapfb; goto fail_omapfb;
vid->menu.scaler.scaler_type = SCALER_TYPE_BILINEAR; vid->menu.scaler.scaler_type = SCALER_TYPE_BILINEAR;
vid->menu.scaler.out_fmt = (vid->bytes_per_pixel == 4) vid->menu.scaler.out_fmt = (vid->bytes_per_pixel == 4)
? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565;
return vid; return vid;
fail_omapfb: fail_omapfb:
omapfb_free(vid->omap); omapfb_free(vid->omap);
free(vid->omap); free(vid->omap);
fail: fail:
free(vid); free(vid);
RARCH_ERR("[video_omap]: initialization failed\n"); RARCH_ERR("[video_omap]: initialization failed\n");
return NULL; return NULL;
} }
static bool omap_gfx_frame(void *data, const void *frame, unsigned width, static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, unsigned pitch, const char *msg) unsigned height, unsigned pitch, const char *msg)
{ {
omap_video_t *vid; omap_video_t *vid;
if (!frame) if (!frame)
return true; return true;
vid = data; vid = data;
if (width > 4 && height > 4 && (width != vid->width || height != vid->height)) if (width > 4 && height > 4 && (width != vid->width || height != vid->height))
{ {
RARCH_LOG("[video_omap]: mode set (resolution changed by core)\n"); RARCH_LOG("[video_omap]: mode set (resolution changed by core)\n");
if (omapfb_set_mode(vid->omap, width, height) != 0) if (omapfb_set_mode(vid->omap, width, height) != 0)
{ {
RARCH_ERR("[video_omap]: mode set failed\n"); RARCH_ERR("[video_omap]: mode set failed\n");
return false; return false;
} }
vid->width = width; vid->width = width;
vid->height = height; vid->height = height;
} }
omapfb_prepare(vid->omap); omapfb_prepare(vid->omap);
omapfb_blit_frame(vid->omap, frame, vid->height, pitch); omapfb_blit_frame(vid->omap, frame, vid->height, pitch);
if (vid->menu.active) if (vid->menu.active)
omapfb_blit_frame(vid->omap, vid->menu.frame, omapfb_blit_frame(vid->omap, vid->menu.frame,
vid->menu.scaler.out_height, vid->menu.scaler.out_height,
vid->menu.scaler.out_stride); vid->menu.scaler.out_stride);
if (msg) if (msg)
omap_render_msg(vid, msg); omap_render_msg(vid, msg);
return true; return true;
} }
static void omap_gfx_set_nonblock_state(void *data, bool state) static void omap_gfx_set_nonblock_state(void *data, bool state)
{ {
omap_video_t *vid; omap_video_t *vid;
if (!data) if (!data)
return; return;
vid = data; vid = data;
vid->omap->sync = !state; vid->omap->sync = !state;
} }
static bool omap_gfx_alive(void *data) static bool omap_gfx_alive(void *data)
{ {
(void)data; (void)data;
return true; /* always alive */ return true; /* always alive */
} }
static bool omap_gfx_focus(void *data) static bool omap_gfx_focus(void *data)
{ {
(void)data; (void)data;
return true; /* fb device always has focus */ return true; /* fb device always has focus */
} }
static void omap_gfx_viewport_info(void *data, struct video_viewport *vp) static void omap_gfx_viewport_info(void *data, struct video_viewport *vp)
{ {
omap_video_t *vid = (omap_video_t*)data; omap_video_t *vid = (omap_video_t*)data;
if (!vid)
return;
vp->x = vp->y = 0; if (!vid)
return;
vp->width = vp->full_width = vid->width; vp->x = vp->y = 0;
vp->height = vp->full_height = vid->height;
vp->width = vp->full_width = vid->width;
vp->height = vp->full_height = vid->height;
} }
static bool omap_gfx_suppress_screensaver(void *data, bool enable) static bool omap_gfx_suppress_screensaver(void *data, bool enable)
@ -1090,14 +1090,14 @@ static bool omap_gfx_read_viewport(void *data, uint8_t *buffer)
} }
static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler, static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler,
enum scaler_pix_fmt format, unsigned width, enum scaler_pix_fmt format, unsigned width,
unsigned height, unsigned pitch) unsigned height, unsigned pitch)
{ {
if ( if (
width != scaler->in_width width != scaler->in_width
|| height != scaler->in_height || height != scaler->in_height
|| format != scaler->in_fmt || format != scaler->in_fmt
|| pitch != scaler->in_stride || pitch != scaler->in_stride
) )
{ {
scaler->in_fmt = format; scaler->in_fmt = format;
@ -1117,23 +1117,23 @@ static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler,
static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32, static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha) unsigned width, unsigned height, float alpha)
{ {
(void) alpha; omap_video_t *vid = (omap_video_t*)data;
omap_video_t *vid = (omap_video_t*)data;
enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444;
(void) alpha;
update_scaler(vid, &vid->menu.scaler, format, width, height, update_scaler(vid, &vid->menu.scaler, format, width, height,
width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)));
scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame, frame); scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame, frame);
} }
static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen) static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen)
{ {
(void) full_screen;
omap_video_t *vid = (omap_video_t*)data; omap_video_t *vid = (omap_video_t*)data;
vid->menu.active = state; vid->menu.active = state;
(void) full_screen;
} }
static const video_poke_interface_t omap_gfx_poke_interface = { static const video_poke_interface_t omap_gfx_poke_interface = {
@ -1166,24 +1166,24 @@ static void omap_gfx_get_poke_interface(void *data,
} }
video_driver_t video_omap = { video_driver_t video_omap = {
omap_gfx_init, omap_gfx_init,
omap_gfx_frame, omap_gfx_frame,
omap_gfx_set_nonblock_state, omap_gfx_set_nonblock_state,
omap_gfx_alive, omap_gfx_alive,
omap_gfx_focus, omap_gfx_focus,
omap_gfx_suppress_screensaver, omap_gfx_suppress_screensaver,
omap_gfx_has_windowed, omap_gfx_has_windowed,
omap_gfx_set_shader, omap_gfx_set_shader,
omap_gfx_free, omap_gfx_free,
"omap", "omap",
omap_gfx_set_rotation, omap_gfx_set_rotation,
omap_gfx_viewport_info, omap_gfx_viewport_info,
omap_gfx_read_viewport, omap_gfx_read_viewport,
NULL, /* read_frame_raw */ NULL, /* read_frame_raw */
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
NULL, /* overlay_interface */ NULL, /* overlay_interface */
#endif #endif
omap_gfx_get_poke_interface omap_gfx_get_poke_interface
}; };

View File

@ -134,7 +134,7 @@ typedef struct
typedef struct typedef struct
{ {
unsigned int mode; /* layer work mode */ unsigned int mode; /* layer work mode */
signed char b_from_screen; signed char b_from_screen;
/* /*
* layer pipe,0/1,if in scaler mode, scaler0 must be pipe0, * layer pipe,0/1,if in scaler mode, scaler0 must be pipe0,
@ -146,16 +146,15 @@ typedef struct
* From bottom to top, priority from low to high * From bottom to top, priority from low to high
*/ */
__u8 prio; __u8 prio;
signed char alpha_en; /* layer global alpha enable */ signed char alpha_en; /* layer global alpha enable */
__u16 alpha_val; /* layer global alpha value */ __u16 alpha_val; /* layer global alpha value */
signed char ck_enable; /* layer color key enable */ signed char ck_enable; /* layer color key enable */
/* framebuffer source window,only care x,y if is not scaler mode */ /* framebuffer source window,only care x,y if is not scaler mode */
__disp_rect_t src_win; __disp_rect_t src_win;
__disp_rect_t scn_win; /* screen window */ __disp_rect_t scn_win; /* screen window */
__disp_fb_t fb; /* framebuffer */ __disp_fb_t fb; /* framebuffer */
signed char b_trd_out; /* if output 3d mode, used for scaler mode layer */ signed char b_trd_out; /* if output 3d mode, used for scaler mode layer */
/* output 3d mode, used for scaler mode layer */ unsigned int out_trd_mode; /* output 3d mode, used for scaler mode layer */
unsigned int out_trd_mode;
} __disp_layer_info_t; } __disp_layer_info_t;
/***************************************************************************** /*****************************************************************************
@ -622,10 +621,7 @@ static void *sunxi_gfx_init(const video_info_t *video,
_dispvars->pages = (struct sunxi_page*)calloc(NUMPAGES, sizeof (struct sunxi_page)); _dispvars->pages = (struct sunxi_page*)calloc(NUMPAGES, sizeof (struct sunxi_page));
if (!_dispvars->pages) if (!_dispvars->pages)
{ goto error;
free(_dispvars);
return NULL;
}
_dispvars->dst_pitch = _dispvars->sunxi_disp->xres * _dispvars->sunxi_disp->bits_per_pixel / 8; _dispvars->dst_pitch = _dispvars->sunxi_disp->xres * _dispvars->sunxi_disp->bits_per_pixel / 8;
/* Considering 4 bytes per pixel since we will be in 32bpp on the CB/CB2/CT for hw scalers to work. */ /* Considering 4 bytes per pixel since we will be in 32bpp on the CB/CB2/CT for hw scalers to work. */
@ -645,7 +641,7 @@ static void *sunxi_gfx_init(const video_info_t *video,
pixman_blit = pixman_composite_src_8888_8888_asm_neon; pixman_blit = pixman_composite_src_8888_8888_asm_neon;
break; break;
default: default:
return NULL; goto error;
} }
_dispvars->pending_mutex = slock_new(); _dispvars->pending_mutex = slock_new();
@ -658,6 +654,11 @@ static void *sunxi_gfx_init(const video_info_t *video,
_dispvars->vsync_thread = sthread_create(sunxi_vsync_thread_func, _dispvars); _dispvars->vsync_thread = sthread_create(sunxi_vsync_thread_func, _dispvars);
return _dispvars; return _dispvars;
error:
if (_dispvars)
free(_dispvars);
return NULL;
} }
static void sunxi_gfx_free(void *data) static void sunxi_gfx_free(void *data)
@ -894,8 +895,7 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32,
{ {
uint32_t line[dst_width]; uint32_t line[dst_width];
uint16_t src_pix; uint16_t src_pix;
uint32_t dst_pix; uint32_t R, G, B, dst_pix;
uint32_t R, G, B;
unsigned int i, j; unsigned int i, j;
struct sunxi_video *_dispvars = (struct sunxi_video*)data; struct sunxi_video *_dispvars = (struct sunxi_video*)data;