1 #include "driver.h" 2 3 extern sb16_dev_t device; 4 5 static status_t 6 sb16_open (const char *name, uint32 flags, void** cookie) 7 { 8 sb16_dev_t* dev = &device; 9 status_t rc = B_OK; 10 11 if (dev->opened) 12 return B_BUSY; 13 14 rc = sb16_hw_init(dev); 15 if (rc != B_OK) 16 return rc; 17 18 dev->opened++; 19 20 *cookie = dev; 21 return B_OK; 22 } 23 24 static status_t 25 sb16_read (void* cookie, off_t position, void *buf, size_t* num_bytes) 26 { 27 *num_bytes = 0; /* tell caller nothing was read */ 28 return B_IO_ERROR; 29 } 30 31 static status_t 32 sb16_write (void* cookie, off_t position, const void* buffer, size_t* num_bytes) 33 { 34 *num_bytes = 0; /* tell caller nothing was written */ 35 return B_IO_ERROR; 36 } 37 38 static status_t 39 sb16_control (void* cookie, uint32 op, void* arg, size_t len) 40 { 41 if (cookie) 42 return multi_audio_control(cookie, op, arg, len); 43 44 return B_BAD_VALUE; 45 } 46 47 static status_t 48 sb16_close (void* cookie) 49 { 50 sb16_dev_t* dev = (sb16_dev_t*)cookie; 51 sb16_hw_stop(dev); 52 53 return B_OK; 54 } 55 56 static status_t 57 sb16_free (void* cookie) 58 { 59 sb16_dev_t* dev = (sb16_dev_t*)cookie; 60 sb16_hw_uninit(dev); 61 --dev->opened; 62 63 return B_OK; 64 } 65 66 device_hooks driver_hooks = { 67 sb16_open, /* -> open entry point */ 68 sb16_close, /* -> close entry point */ 69 sb16_free, /* -> free cookie */ 70 sb16_control, /* -> control entry point */ 71 sb16_read, /* -> read entry point */ 72 sb16_write /* -> write entry point */ 73 }; 74