Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* * Copyright (C) 2002 Steve Schmidtke * Licensed under the GPL */ #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include "hostaudio.h" #include "user_util.h" #include "kern_util.h" #include "user.h" #include "os.h" /* /dev/dsp file operations */ ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer, size_t count, loff_t *ppos) { ssize_t ret; #ifdef DEBUG printk("hostaudio: read_user called, count = %d\n", count); #endif ret = read(state->fd, buffer, count); if(ret < 0) return(-errno); return(ret); } ssize_t hostaudio_write_user(struct hostaudio_state *state, const char *buffer, size_t count, loff_t *ppos) { ssize_t ret; #ifdef DEBUG printk("hostaudio: write_user called, count = %d\n", count); #endif ret = write(state->fd, buffer, count); if(ret < 0) return(-errno); return(ret); } int hostaudio_ioctl_user(struct hostaudio_state *state, unsigned int cmd, unsigned long arg) { int ret; #ifdef DEBUG printk("hostaudio: ioctl_user called, cmd = %u\n", cmd); #endif ret = ioctl(state->fd, cmd, arg); if(ret < 0) return(-errno); return(ret); } int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp) { #ifdef DEBUG printk("hostaudio: open_user called\n"); #endif state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); if(state->fd >= 0) return(0); printk("hostaudio_open_user failed to open '%s', errno = %d\n", dsp, errno); return(-errno); } int hostaudio_release_user(struct hostaudio_state *state) { #ifdef DEBUG printk("hostaudio: release called\n"); #endif if(state->fd >= 0){ close(state->fd); state->fd=-1; } return(0); } /* /dev/mixer file operations */ int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state, unsigned int cmd, unsigned long arg) { int ret; #ifdef DEBUG printk("hostmixer: ioctl_user called cmd = %u\n",cmd); #endif ret = ioctl(state->fd, cmd, arg); if(ret < 0) return(-errno); return(ret); } int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w, char *mixer) { #ifdef DEBUG printk("hostmixer: open_user called\n"); #endif state->fd = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); if(state->fd >= 0) return(0); printk("hostaudio_open_mixdev_user failed to open '%s', errno = %d\n", mixer, errno); return(-errno); } int hostmixer_release_mixdev_user(struct hostmixer_state *state) { #ifdef DEBUG printk("hostmixer: release_user called\n"); #endif if(state->fd >= 0){ close(state->fd); state->fd = -1; } return 0; } /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically * adjust the settings for this buffer only. This must remain at the end * of the file. * --------------------------------------------------------------------------- * Local variables: * c-file-style: "linux" * End: */ |