From 88dde26adb2d36d724b57bd73b75a228e21bfebf Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 23 Feb 2012 06:36:53 +0000 Subject: some fixes from Sascha Plazar git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1178 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- drv_SamsungSPF.c | 92 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 24 deletions(-) (limited to 'drv_SamsungSPF.c') diff --git a/drv_SamsungSPF.c b/drv_SamsungSPF.c index f2e432d..4e548b3 100644 --- a/drv_SamsungSPF.c +++ b/drv_SamsungSPF.c @@ -38,16 +38,8 @@ #include "config.h" -#include #include -#include #include -#include - -#include -#include -#include -#include #include #include @@ -55,18 +47,70 @@ #include "debug.h" #include "cfg.h" #include "qprintf.h" -#include "udelay.h" -#include "plugin.h" #include "timer.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_icon.h" -#include "widget_bar.h" #include "drv.h" /* graphic display? */ #include "drv_generic_graphic.h" -#include "drv_SamsungSPF.h" + +// Drivername for verbose output +static char Name[] = "SamsungSPF"; + +struct SPFdev { + const char type[64]; + const int vendorID; + struct { + const int storageMode; + const int monitorMode; + } productID; + const unsigned int xRes; + const unsigned int yRes; +}; + +static struct SPFdev spfDevices[] = { + { + .type = "SPF-75H", + .vendorID = 0x04e8, + .productID = {0x200e, 0x200f}, + .xRes = 800, + .yRes = 480, + }, + { + .type = "SPF-85H", + .vendorID = 0x04e8, + .productID = {0x2012, 0x2013}, + .xRes = 800, + .yRes = 600, + }, + { + .type = "SPF-107H", + .vendorID = 0x04e8, + .productID = {0x2027, 0x2028}, + .xRes = 1024, + .yRes = 600, + }, +}; + +static int numFrames = sizeof(spfDevices) / sizeof(spfDevices[0]); + +struct usb_device *myDev; +usb_dev_handle *myDevHandle; +struct SPFdev *myFrame; + +typedef struct { + unsigned char R, G, B; +} RGB; + +static struct { + RGB *buf; + int dirty; + int fbsize; +} image; + +static struct { + unsigned char *buf; + unsigned long int size; +} jpegImage; /****************************************/ @@ -107,7 +151,7 @@ int convert2JPG() /* Finish compression and free internal memory */ jpeg_finish_compress(&cinfo); - jpeg_destroy(&cinfo); + jpeg_destroy_compress(&cinfo); return 0; } @@ -200,9 +244,9 @@ static int drv_SamsungSPF_open() /* dummy function that sends something to the display */ -static int drv_SamsungSPF_send(unsigned char *data, unsigned int len) +static int drv_SamsungSPF_send(char *data, unsigned int len) { - char usb_hdr[USB_HDR_LEN] = { 0xa5, 0x5a, 0x18, 0x04, 0xff, 0xff, + char usb_hdr[12] = { 0xa5, 0x5a, 0x18, 0x04, 0xff, 0xff, 0xff, 0xff, 0x48, 0x00, 0x00, 0x00 }; char buffer[1] = { 0x0 }; @@ -212,7 +256,7 @@ static int drv_SamsungSPF_send(unsigned char *data, unsigned int len) *(int *) (usb_hdr + 4) = len; - debug("bytes_to_send: %d, offset: %d", len, USB_HDR_LEN); + debug("bytes_to_send: %d, offset: %d", len, 12); /* Send USB header */ if ((ret = usb_bulk_write(myDevHandle, usb_endpoint, usb_hdr, 12, usb_timeout)) < 0) { @@ -222,7 +266,7 @@ static int drv_SamsungSPF_send(unsigned char *data, unsigned int len) } /* Send JPEG image */ - if ((ret = usb_bulk_write(myDevHandle, usb_endpoint, (char *) jpegImage.buf, len, usb_timeout)) < 0) { + if ((ret = usb_bulk_write(myDevHandle, usb_endpoint, data, len, usb_timeout)) < 0) { error("%s: Error occurred while writing data to device.", Name); error("%s: usb_bulk_write returned: %d", Name, ret); return -1; @@ -267,7 +311,7 @@ static void drv_SamsungSPF_timer( __attribute__ ((unused)) convert2JPG(); /* Sent image to display */ - if ((drv_SamsungSPF_send(jpegImage.buf, jpegImage.size)) != 0) { + if ((drv_SamsungSPF_send((char *) jpegImage.buf, jpegImage.size)) != 0) { error("%s: Error occurred while sending jpeg image to device.", Name); } /* Clean dirty bit */ @@ -285,7 +329,7 @@ static void drv_SamsungSPF_timer( __attribute__ ((unused)) /* start graphic display */ static int drv_SamsungSPF_start(const char *section) { - unsigned int timerInterval = 1000; + int timerInterval = 1000; char *s; cfg_number(section, "update", timerInterval, 0, -1, &timerInterval); @@ -379,7 +423,7 @@ int drv_SamsungSPF_init(const char *section, const int quiet) } // Look for specified device for (i = 0; i < numFrames; i++) { - if (strcasecmp(s, spfDevices[i].type) == NULL) { + if (strcasecmp(s, spfDevices[i].type) == 0) { myFrame = &spfDevices[i]; info("%s: Configured for model %s.", Name, spfDevices[i].type); break; @@ -450,7 +494,7 @@ int drv_SamsungSPF_quit(const int quiet) debug("closing connection"); printf("%s: Closing driver...\n", Name); - usb_close(myDev); + usb_close(myDevHandle); free(myDev); free(myDevHandle); -- cgit v1.2.3