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. |