Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0223/8

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


usb/audio: some things aren't worth knowing
 [rsc] --rw-rw-r-- M 1635703 sape sys 18208 Feb 23 06:44 sys/src/cmd/usb/audio/audiofs.c
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiofs.c:8,13 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiofs.c:8,15
	  #include "usbaudio.h"
	  #include "usbaudioctl.h"
	  
	+ int attachok;
	+ 
	  #define STACKSIZE 16*1024
	  
	  enum
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiofs.c:154,160 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiofs.c:156,162
	  	int fd;
	  	char buf[32];
	  
	- 	fd = create(name, OWRITE, 0600);
	+ 	fd = create(name, OWRITE, attachok?0666:0600);
	  	if(fd < 0)
	  		return;
	  	sprint(buf, "%d",srvfd);
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiofs.c:271,277 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiofs.c:273,279
	  	f->flags |= Busy;
	  	f->dir = &dirs[Qdir];
	  	rhdr.qid = f->dir->qid;
	- 	if(strcmp(thdr.uname, user) != 0)
	+ 	if(attachok == 0 && strcmp(thdr.uname, user) != 0)
	  		return Eperm;
	  	return 0;
	  }
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiofs.c:386,394 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiofs.c:388,395
	  
	  	if(f->dir == &dirs[Qaudio] || f->dir == &dirs[Qaudioin])
	  		return Eperm;
	- 	if(thdr.mode != OREAD)
	- 		if((f->dir->mode & 0x2) == 0)
	- 			return Eperm;
	+ 	if(thdr.mode != OREAD && (f->dir->mode & 0x2) == 0)
	+ 		return Eperm;
	  	qlock(f);
	  	if(f->dir == &dirs[Qaudioctl] && f->fiddata == nil)
	  		f->fiddata = allocaudioctldata();
 [rsc] --rw-rw-r-- M 1635703 sape sys 8085 Feb 23 06:44 sys/src/cmd/usb/audio/audiosub.c
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiosub.c:97,102 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiosub.c:97,135
	  		case 0x04:
	  			if (verbose)
	  				fprint(2, "Audio Mixer Unit %d\n", b[3]);
	+ 			if (debug & Dbginfo){
	+ 				fprint(2, "\t%d bytes:", nb);
	+ 				for(ctl = 0; ctl < nb; ctl++)
	+ 					fprint(2, " 0x%2.2x", b[ctl]);
	+ 				fprint(2, "\n\tbUnitId %d, bNrInPins %d", b[3], b[4]);
	+ 			}
	+ 			if (b[4]){
	+ 				if(debug & Dbginfo) fprint(2, ", baSourceIDs: [%d", b[5]);
	+ 				u = findunit(b[5]);
	+ 				for (ctl = 1; ctl < b[4]; ctl++){
	+ 					if (u < 0)
	+ 						u = findunit(b[5+ctl]);
	+ 					else if ((x = findunit(b[5+ctl])) >= 0 && u != x && verbose)
	+ 						fprint(2, "\tMixer %d for output AND input\n", b[3]);
	+ 					if (debug & Dbginfo) fprint(2, ", %d", b[5+ctl]);
	+ 				}
	+ 				if (debug & Dbginfo) fprint(2, "]\n");
	+ 				if (u >= 0){
	+ 					units[u][nunits[u]++] = b[3];
	+ 					if (mixerid[u] >= 0)
	+ 						fprint(2, "Second mixer (%d, %d) on %s\n", mixerid[u], b[3], u?"record":"playback");
	+ 					mixerid[u] = b[3];
	+ 				}
	+ 				if (debug & Dbginfo){
	+ 					fprint(2, "Channels %d, config %d, ",
	+ 						b[ctl+5], b[ctl+5+1] | b[ctl+5+2] << 8);
	+ 					x = b[ctl+5] * b[4];
	+ 					fprint(2, "programmable: %d bits, 0x", x);
	+ 					x = (x + 7) >> 3;
	+ 					while(x--)
	+ 						fprint(2, "%2.2x", b[ctl+x+5+4]);
	+ 				}
	+ 			}
	  			break;
	  		case 0x05:
	  			if (verbose)
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/audiosub.c:104,111 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/audiosub.c:137,145
	  			if (debug & Dbginfo)
	  				fprint(2, "\tbUnitId %d, bNrInPins %d", b[3], b[4]);
	  			if (b[4]){
	- 				if (debug & Dbginfo) fprint(2, ", baSourceIDs: [%d", b[5]);
	  				u = findunit(b[5]);
	+ 				if (debug & Dbginfo) fprint(2, ", baSourceIDs: %s [%d",
	+ 					u?"record":"playback", b[5]);
	  				for (ctl = 1; ctl < b[4]; ctl++){
	  					if (u < 0)
	  						u = findunit(b[5+ctl]);
 [rsc] --rw-rw-r-- M 1635703 sape sys 10155 Feb 23 06:44 sys/src/cmd/usb/audio/usbaudio.c
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudio.c:252,257 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudio.c:252,258
	  	long volume[8];
	  	Audiocontrol *c;
	  	char buf[32], *p, line[256];
	+ 	extern int attachok;
	  
	  	ctlrno = -1;
	  	id = -1;
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudio.c:281,286 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudio.c:282,290
	  	case 's':
	  		srvpost = EARGF(usage());
	  		break;
	+ 	case 'p':
	+ 		attachok++;
	+ 		break;
	  	default:
	  		usage();
	  	}ARGEND
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudio.c:329,334 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudio.c:333,341
	  	findendpoints();
	  
	  	if (endpt[Play] >= 0){
	+ 		if(verbose)
	+ 			fprint(2, "Setting default play parameters: %d Hz, %d channels at %d bits\n",
	+ 				defaultspeed[Play], 2, 16);
	  		if(findalt(Play, 2, 16, defaultspeed[Play]) < 0){
	  			if(findalt(Play, 2, 16, 48000) < 0)
	  				sysfatal("Can't configure playout for %d or %d Hz", defaultspeed[Play], 48000);
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudio.c:345,350 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudio.c:352,360
	  	}
	  
	  	if (endpt[Record] >= 0){
	+ 		if(verbose)
	+ 			fprint(2, "Setting default record parameters: %d Hz, %d channels at %d bits\n",
	+ 				defaultspeed[Play], 2, 16);
	  		if(findalt(Record, 2, 16, defaultspeed[Record]) < 0){
	  			if(findalt(Record, 2, 16, 48000) < 0)
	  				sysfatal("Can't configure record for %d or %d Hz", defaultspeed[Record], 48000);
 [rsc] --rw-rw-r-- M 1635703 sape sys 1889 Feb 23 06:44 sys/src/cmd/usb/audio/usbaudio.h
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudio.h:13,22 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudio.h:13,24
	  	Delay_control		= 0x08,
	  	Bassboost_control	= 0x09,
	  	Loudness_control	= 0x0a,
	- 	/* Items below are define by implementation: */
	+ 	/* Items below are defined by implementation: */
	  	Channel_control		= 0x0b,
	  	Resolution_control	= 0x0c,
	  	Ncontrol,
	+ 	Selector_control	= 0x0d,
	+ 
	  	sampling_freq_control	= 0x01,
	  };
	  
 [rsc] --rw-rw-r-- M 1635703 sape sys 18245 Feb 23 06:44 sys/src/cmd/usb/audio/usbaudioctl.c
	[diffs elided - too long]
	[diff -c /n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudioctl.c /n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudioctl.c]
 [rsc] --rw-rw-r-- M 1635703 sape sys 618 Feb 23 06:44 sys/src/cmd/usb/audio/usbaudioctl.h
	/n/sourcesdump/2006/0223/plan9/sys/src/cmd/usb/audio/usbaudioctl.h:7,26 - 
	/n/sourcesdump/2006/0224/plan9/sys/src/cmd/usb/audio/usbaudioctl.h:7,26
	  typedef struct Audiocontrol Audiocontrol;
	  
	  struct Audiocontrol {
	- 	char		*name;
	+ 	char	*name;
	  	uchar	readable;
	  	uchar	settable;
	  	uchar	chans;		/* 0 is master, non-zero is bitmap */
	- 	long		value[8];		/* 0 is master; value[0] == Undef -> all values Undef */
	- 	long		min, max, step;
	+ 	long	value[8];	/* 0 is master; value[0] == Undef -> all values Undef */
	+ 	long	min, max, step;
	  };
	  
	- 
	  extern Audiocontrol controls[2][Ncontrol];
	  extern int endpt[2];
	  extern int interface[2];
	  extern int featureid[2];
	  extern int selectorid[2];
	+ extern int mixerid[2];
	  extern int buttonendpt;
	  
	  int	ctlparse(char *s, Audiocontrol *c, long *v);


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].