From: <at...@us...> - 2007-08-30 22:08:01
|
Revision: 502 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=502&view=rev Author: atani Date: 2007-08-30 15:07:55 -0700 (Thu, 30 Aug 2007) Log Message: ----------- applying sector sizing patch from Quzar Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/cdrom.c kos/kernel/arch/dreamcast/include/dc/cdrom.h Modified: kos/kernel/arch/dreamcast/hardware/cdrom.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/cdrom.c 2007-08-30 22:07:22 UTC (rev 501) +++ kos/kernel/arch/dreamcast/hardware/cdrom.c 2007-08-30 22:07:55 UTC (rev 502) @@ -61,10 +61,21 @@ /* Set disc access mode */ static int gdc_change_data_type(void *param) { MAKE_SYSCALL(return, param, 0, 10); } +/* Reset the GD-ROM */ +static void gdc_reset() { MAKE_SYSCALL(/**/, 0, 0, 9); } +/* Abort the current command */ +static void gdc_abort_cmd(int cmd) { MAKE_SYSCALL(/**/,cmd, 0, 8); } + /* The CD access mutex */ static mutex_t * mutex = NULL; +static int sector_size = 2048; /*default 2048, 2352 for raw data reading*/ +void set_sector_size (int size) { + sector_size = size; + cdrom_reinit(); +} + /* Command execution sequence */ int cdrom_exec_cmd(int cmd, void *param) { int status[4] = {0}; @@ -75,12 +86,16 @@ do { gdc_exec_server(); n = gdc_get_cmd_stat(f, status); - if (n == 1) + if (n == PROCESSING) thd_pass(); - } while (n == 1); + } while (n == PROCESSING); - if (n == 2) + if (n == COMPLETED) return ERR_OK; + else if (n == ABORTED) + return ERR_ABORTED; + else if (n == NO_ACTIVE) + return ERR_NO_ACTIVE; else { switch(status[0]) { case 2: return ERR_NO_DISC; @@ -163,7 +178,7 @@ params[0] = 0; /* 0 = set, 1 = get */ params[1] = 8192; /* ? */ params[2] = cdxa ? 2048 : 1024; /* CD-XA mode 1/2 */ - params[3] = 2048; /* sector size */ + params[3] = sector_size; /* sector size */ if (gdc_change_data_type(params) < 0) { rv = ERR_SYS; goto exit; } exit: Modified: kos/kernel/arch/dreamcast/include/dc/cdrom.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/cdrom.h 2007-08-30 22:07:22 UTC (rev 501) +++ kos/kernel/arch/dreamcast/include/dc/cdrom.h 2007-08-30 22:07:55 UTC (rev 502) @@ -36,7 +36,16 @@ #define ERR_NO_DISC 1 #define ERR_DISC_CHG 2 #define ERR_SYS 3 +#define ERR_ABORTED 4 +#define ERR_NO_ACTIVE 5 +/* Command Status responses */ +#define FAILED -1 +#define NO_ACTIVE 0 +#define PROCESSING 1 +#define COMPLETED 2 +#define ABORTED 3 + /* CDDA Read Modes */ #define CDDA_TRACKS 1 #define CDDA_SECTORS 2 @@ -71,6 +80,9 @@ #define TOC_CTRL(n) ( ((n) & 0xf0000000) >> 28 ) #define TOC_TRACK(n) ( ((n) & 0x00ff0000) >> 16 ) +/* Sets the sector size */ +void set_sector_size (int size); + /* Command execution sequence */ int cdrom_exec_cmd(int cmd, void *param); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2008-05-20 02:45:52
|
Revision: 587 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=587&view=rev Author: ljsebald Date: 2008-05-19 19:45:34 -0700 (Mon, 19 May 2008) Log Message: ----------- Adding in VMU beeping support as written by Donald Haase (Tracker item #1961770). Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/maple/vmu.c kos/kernel/arch/dreamcast/include/dc/maple/vmu.h Modified: kos/kernel/arch/dreamcast/hardware/maple/vmu.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/vmu.c 2008-05-20 02:22:51 UTC (rev 586) +++ kos/kernel/arch/dreamcast/hardware/maple/vmu.c 2008-05-20 02:45:34 UTC (rev 587) @@ -2,6 +2,7 @@ vmu.c Copyright (C)2002,2003 Dan Potter + Copyright (C)2008 Donald Haase */ #include <assert.h> @@ -51,8 +52,8 @@ /* These interfaces will probably change eventually, but for now they can stay the same */ -/* Completion callback for the draw_lcd function below */ -static void draw_lcd_callback(maple_frame_t * frame) { +/* Callback that unlocks the frame, general use */ +static void vmu_gen_callback(maple_frame_t * frame) { /* Unlock the frame for the next usage */ maple_frame_unlock(frame); @@ -60,6 +61,47 @@ genwait_wake_all(frame); } +/* Set the tone to be generated by the VMU's speaker. + Only last two bytes are used. Actual parameters unknown + except that the last byte must be larger than the second + to last byte. This might necessitate refactoring as the + clock is a seperate device from the screen and storage. */ +int vmu_beep_raw(maple_device_t * dev, uint32 beep) { + uint32 * send_buf; + + assert( dev != NULL ); + + /* Lock the frame */ + if (maple_frame_lock(&dev->frame) < 0) + return MAPLE_EAGAIN; + + /* Reset the frame */ + maple_frame_init(&dev->frame); + send_buf = (uint32 *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CLOCK; + send_buf[1] = beep; + dev->frame.cmd = MAPLE_COMMAND_SETCOND; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 2; + dev->frame.callback = vmu_gen_callback; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + /* Wait for the timer to accept it */ + if(genwait_wait(&dev->frame, "vmu_beep_raw", 500, NULL) < 0) { + if(dev->frame.state != MAPLE_FRAME_VACANT) { + /* Something went wrong.... */ + dev->frame.state = MAPLE_FRAME_VACANT; + dbglog(DBG_ERROR, "vmu_beep_raw: timeout to unit %c%c, beep: %lu\n", + dev->port + 'A', dev->unit + '0', beep); + return MAPLE_ETIMEOUT; + } + } + + return MAPLE_EOK; +} + /* Draw a 1-bit bitmap on the LCD screen (48x32). return a -1 if an error occurs */ int vmu_draw_lcd(maple_device_t * dev, void *bitmap) { @@ -81,7 +123,7 @@ dev->frame.dst_port = dev->port; dev->frame.dst_unit = dev->unit; dev->frame.length = 2 + 48; - dev->frame.callback = draw_lcd_callback; + dev->frame.callback = vmu_gen_callback; dev->frame.send_buf = send_buf; maple_queue_frame(&dev->frame); Modified: kos/kernel/arch/dreamcast/include/dc/maple/vmu.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple/vmu.h 2008-05-20 02:22:51 UTC (rev 586) +++ kos/kernel/arch/dreamcast/include/dc/maple/vmu.h 2008-05-20 02:45:34 UTC (rev 587) @@ -1,7 +1,8 @@ /* KallistiOS ##version## dc/maple/vmu.h - (C)2000-2002 Jordan DeLong and Dan Potter + Copyright (C)2000-2002 Jordan DeLong and Dan Potter + Copyright (C)2008 Donald Haase $Id: vmu.h,v 1.3 2002/09/04 03:38:42 bardtx Exp $ @@ -15,6 +16,7 @@ #include <arch/types.h> +int vmu_beep_raw(maple_device_t * dev, uint32 beep); int vmu_draw_lcd(maple_device_t * dev, void *bitmap); int vmu_block_read(maple_device_t * dev, uint16 blocknum, uint8 *buffer); int vmu_block_write(maple_device_t * dev, uint16 blocknum, uint8 *buffer); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |