2006-02-02 20:42:56 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Dave Chapman
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-02-02 20:42:56 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "config.h"
|
|
|
|
#include "lcd.h"
|
2007-04-25 21:44:56 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
#endif
|
2006-02-02 20:42:56 +00:00
|
|
|
#include "backdrop.h"
|
|
|
|
|
2009-08-06 00:37:52 +00:00
|
|
|
static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH]
|
2009-08-06 00:14:40 +00:00
|
|
|
__attribute__ ((aligned (16)));
|
2009-08-06 00:37:52 +00:00
|
|
|
static fb_data skin_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH]
|
2009-08-06 00:14:40 +00:00
|
|
|
__attribute__ ((aligned (16)));
|
2006-11-13 00:45:21 +00:00
|
|
|
|
2007-04-25 21:44:56 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
2009-08-06 00:14:40 +00:00
|
|
|
static fb_remote_data
|
|
|
|
remote_skin_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
|
|
|
|
static bool remote_skin_backdrop_valid = false;
|
2007-04-25 21:44:56 +00:00
|
|
|
#endif
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool main_backdrop_valid = false;
|
2009-08-06 00:14:40 +00:00
|
|
|
static bool skin_backdrop_valid = false;
|
2006-02-02 20:42:56 +00:00
|
|
|
|
2006-05-21 11:00:02 +00:00
|
|
|
/* load a backdrop into a buffer */
|
2008-05-12 17:52:50 +00:00
|
|
|
static bool load_backdrop(const char* filename, fb_data* backdrop_buffer)
|
2006-02-02 20:42:56 +00:00
|
|
|
{
|
|
|
|
struct bitmap bm;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* load the image */
|
2006-05-21 11:00:02 +00:00
|
|
|
bm.data=(char*)backdrop_buffer;
|
2006-10-11 01:26:09 +00:00
|
|
|
ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
|
2008-12-26 07:05:13 +00:00
|
|
|
FORMAT_NATIVE | FORMAT_DITHER, NULL);
|
2006-02-02 20:42:56 +00:00
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
return ((ret > 0)
|
|
|
|
&& (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT));
|
2006-02-02 20:42:56 +00:00
|
|
|
}
|
2006-05-21 11:00:02 +00:00
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static bool load_main_backdrop(const char* filename)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
|
|
|
main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
|
|
|
|
return main_backdrop_valid;
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline bool load_skin_backdrop(const char* filename)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
skin_backdrop_valid = load_backdrop(filename, &skin_backdrop[0][0]);
|
|
|
|
return skin_backdrop_valid;
|
2006-05-21 11:00:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline void unload_main_backdrop(void)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
|
|
|
main_backdrop_valid = false;
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline void unload_skin_backdrop(void)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
skin_backdrop_valid = false;
|
2006-05-21 11:00:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline void show_main_backdrop(void)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
|
|
|
lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static void show_skin_backdrop(void)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
|
|
|
/* if no wps backdrop, fall back to main backdrop */
|
2009-08-06 00:14:40 +00:00
|
|
|
if(skin_backdrop_valid)
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
lcd_set_backdrop(&skin_backdrop[0][0]);
|
2006-05-21 11:00:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
show_main_backdrop();
|
|
|
|
}
|
|
|
|
}
|
2007-04-25 21:44:56 +00:00
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
/* api functions */
|
|
|
|
|
|
|
|
bool backdrop_load(enum backdrop_type bdrop, const char* filename)
|
|
|
|
{
|
|
|
|
if (bdrop == BACKDROP_MAIN)
|
|
|
|
return load_main_backdrop(filename);
|
|
|
|
else if (bdrop == BACKDROP_SKIN_WPS)
|
|
|
|
return load_skin_backdrop(filename);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void backdrop_unload(enum backdrop_type bdrop)
|
|
|
|
{
|
|
|
|
if (bdrop == BACKDROP_MAIN)
|
|
|
|
unload_main_backdrop();
|
|
|
|
else if (bdrop == BACKDROP_SKIN_WPS)
|
|
|
|
unload_skin_backdrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void backdrop_show(enum backdrop_type bdrop)
|
|
|
|
{
|
|
|
|
if (bdrop == BACKDROP_MAIN)
|
|
|
|
show_main_backdrop();
|
|
|
|
else if (bdrop == BACKDROP_SKIN_WPS)
|
|
|
|
show_skin_backdrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-25 21:44:56 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static bool load_remote_backdrop(const char* filename,
|
|
|
|
fb_remote_data* backdrop_buffer)
|
2007-04-25 21:44:56 +00:00
|
|
|
{
|
|
|
|
struct bitmap bm;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* load the image */
|
|
|
|
bm.data=(char*)backdrop_buffer;
|
|
|
|
ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
|
2008-12-26 07:05:13 +00:00
|
|
|
FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL);
|
2007-04-25 21:44:56 +00:00
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
return ((ret > 0)
|
|
|
|
&& (bm.width == LCD_REMOTE_WIDTH)
|
|
|
|
&& (bm.height == LCD_REMOTE_HEIGHT));
|
2007-04-25 21:44:56 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline bool load_remote_skin_backdrop(const char* filename)
|
2007-04-25 21:44:56 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
remote_skin_backdrop_valid =
|
|
|
|
load_remote_backdrop(filename, &remote_skin_backdrop[0][0]);
|
|
|
|
return remote_skin_backdrop_valid;
|
2007-04-25 21:44:56 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline void unload_remote_skin_backdrop(void)
|
2007-04-25 21:44:56 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
remote_skin_backdrop_valid = false;
|
2007-04-25 21:44:56 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 00:37:52 +00:00
|
|
|
static inline void show_remote_main_backdrop(void)
|
|
|
|
{
|
|
|
|
lcd_remote_set_backdrop(NULL);
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
static inline void show_remote_skin_backdrop(void)
|
2007-04-25 21:44:56 +00:00
|
|
|
{
|
|
|
|
/* if no wps backdrop, fall back to main backdrop */
|
2009-08-06 00:14:40 +00:00
|
|
|
if(remote_skin_backdrop_valid)
|
2007-04-25 21:44:56 +00:00
|
|
|
{
|
2009-08-06 00:14:40 +00:00
|
|
|
lcd_remote_set_backdrop(&remote_skin_backdrop[0][0]);
|
2007-04-25 21:44:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
show_remote_main_backdrop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:14:40 +00:00
|
|
|
|
|
|
|
/* api functions */
|
|
|
|
bool remote_backdrop_load(enum backdrop_type bdrop,
|
|
|
|
const char *filename)
|
|
|
|
{
|
|
|
|
if (bdrop == BACKDROP_SKIN_WPS)
|
|
|
|
return load_remote_skin_backdrop(filename);
|
|
|
|
else if (bdrop == BACKDROP_MAIN)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-06 00:48:08 +00:00
|
|
|
void remote_backdrop_show(enum backdrop_type bdrop)
|
2009-08-06 00:14:40 +00:00
|
|
|
{
|
|
|
|
if (bdrop == BACKDROP_MAIN)
|
|
|
|
show_remote_main_backdrop();
|
|
|
|
else if (bdrop == BACKDROP_SKIN_WPS)
|
|
|
|
show_remote_skin_backdrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void remote_backdrop_unload(enum backdrop_type bdrop)
|
|
|
|
{
|
|
|
|
if (bdrop != BACKDROP_MAIN)
|
|
|
|
unload_remote_skin_backdrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-25 21:44:56 +00:00
|
|
|
#endif
|