⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.c

📁 freebsd v4.4内核源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*audio.c--------------------------------------------------------------------	Matsushita(Panasonic) / Creative CD-ROM Driver	(matcd)	Authored by Frank Durda IV	Copyright 1994, 1995  Frank Durda IV.  All rights reserved.	"FDIV" is a trademark of Frank Durda IV.	Redistribution and use in source and binary forms, with or	without modification, are permitted provided that the following	conditions are met:	1.  Redistributions of source code must retain the above copyright	    notice positioned at the very beginning of this file without	    modification, all copyright strings, all related programming	    codes that display the copyright strings, this list of	    conditions and the following disclaimer.	2.  Redistributions in binary form must contain all copyright strings	    and related programming code that display the copyright strings.	3.  Redistributions in binary form must reproduce the above copyright	    notice, this list of conditions and the following disclaimer in	    the documentation and/or other materials provided with the	    distribution.	4.  All advertising materials mentioning features or use of this	    software must display the following acknowledgement:		"The Matsushita/Panasonic CD-ROM driver  was developed		 by Frank Durda IV for use with "FreeBSD" and similar		 operating systems."	    "Similar operating systems" includes mainly non-profit oriented	    systems for research and education, including but not restricted	    to "NetBSD", "386BSD", and "Mach" (by CMU).  The wording of the	    acknowledgement (in electronic form or printed text) may not be	    changed without permission from the author.	5.  Absolutely no warranty of function, fitness or purpose is made	    by the author Frank Durda IV.	6.  Neither the name of the author nor the name "FreeBSD" may	    be used to endorse or promote products derived from this software	    without specific prior written permission.	    (The author can be reached at   bsdmail@nemesis.lonestar.org)	7.  The product containing this software must meet all of these	    conditions even if it is unsupported, not a complete system	    and/or does not contain compiled code.	8.  These conditions will be in force for the full life of the	    copyright.	9.  If all the above conditions are met, modifications to other	    parts of this file may be freely made, although any person	    or persons making changes do not receive the right to add their	    name or names to the copyright strings and notices in this	    software.  Persons making changes are encouraged to insert edit	    history in matcd.c and to put your name and details of the	    change there.	10. You must have prior written permission from the author to	    deviate from these terms.	Vendors who produce product(s) containing this code are encouraged	(but not required) to provide copies of the finished product(s) to	the author and to correspond with the author about development	activity relating to this code.   Donations of development hardware	and/or software are also welcome.  (This is one of the faster ways	to get a driver developed for a device.) 	THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY 	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 	PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE DEVELOPER(S) BE 	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 	OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 	OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 	LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 	NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.-----No changes are allowed above this line------------------------------------	The following functions are related to the audio playback	capabilities of the drive.   They can be omitted from the	finished driver using the FULLDRIVER conditional.	The full set of features the drive is capable of are currently	not implemented but will be added in upcoming releases.-----------------------------------------------------------------------------*//*-----------------------------------------------------------------------------	matcd_playtracks - Plays one or more audio tracks-----------------------------------------------------------------------------*/static int matcd_playtracks(int ldrive, int cdrive, int controller,			    struct ioc_play_track *pt){	struct	matcd_data *cd;	int	start,end;	int	i,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	if ((cd->flags & MATCDLABEL)==0)		return(EIO);		/*Refuse after chg error*/	start=pt->start_track;	end=pt->end_track;	if (start < 1 ||		/*Starting track valid?*/	    end < 1 ||			/*Ending track valid?*/	    start > end || 		/*Start higher than end?*/	    end > cd->volinfo.trk_high)	/*End track higher than disc size?*/		return(ESPIPE);		/*Track out of range*/	lockbus(controller, ldrive);	/*<16>Request bus*/	i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/	unlockbus(controller, ldrive);	/*<16>Release bus*/	if (i!=0) {		return(i);		/*Not legal for this media?*/	}	zero_cmd(cmd);	cmd[0]=PLAYTRKS;		/*Play Audio Track/Index*/	cmd[1]=start;	cmd[2]=pt->start_index;	cmd[3]=end;	cmd[4]=pt->end_index;	i=docmd(cmd,ldrive,cdrive,controller,port);	/*Issue command*/#ifdef DEBUGIOCTL	printf("matcd%d: Play track results %d \n",ldrive,i);#endif /*DEBUGIOCTL*/	if (i==0) cd->status=CD_AS_PLAY_IN_PROGRESS;	/*<14>*/	return(i);}/*-----------------------------------------------------------------------------	matcd_playmsf - Plays between a range of blocks-----------------------------------------------------------------------------*/static int matcd_playmsf(int ldrive, int cdrive, int controller,			    struct ioc_play_msf *pt){	struct matcd_data *cd;	int	i,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;#ifdef DEBUGIOCTL	printf("matcd%d: playmsf %2x %2x %2x -> %2x %2x %2x\n",	       ldrive,pt->start_m, pt->start_s, pt->start_f, pt->end_m,	       pt->end_s,pt->end_f);#endif /*DEBUGIOCTL*/	if ((cd->flags & MATCDLABEL)==0)		return(EIO);		/*Refuse after chg error*/	if ((cd->volinfo.vol_msf[0]==0 &&	     cd->volinfo.vol_msf[1]<2) ||	/*Must be after 0'1"75F*/	     msf_to_blk((char *)&pt->start_m) >	     msf_to_blk((char *)&cd->volinfo.vol_msf)) {#ifdef DEBUGIOCTL	printf("matcd%d: Invalid block combination\n",ldrive);#endif /*DEBUGIOCTL*/		return(ESPIPE);		/*Track out of range*/	}	lockbus(controller, ldrive);	/*<16>Request bus*/	i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/	unlockbus(controller, ldrive);	/*<16>Release bus*/	if (i!=0) {		return(i);		/*Not legal for this media?*/	}	zero_cmd(cmd);	cmd[0]=PLAYBLOCKS;		/*Play Audio Blocks*/	cmd[1]=pt->start_m;	cmd[2]=pt->start_s;	cmd[3]=pt->start_f;	cmd[4]=pt->end_m;	cmd[5]=pt->end_s;	cmd[6]=pt->end_f;	i=docmd(cmd,ldrive,cdrive,controller,port);	/*Issue command*/	if (i==0) cd->status=CD_AS_PLAY_IN_PROGRESS;	/*<14>*/	return(i);}/*-----------------------------------------------------------------------------	matcd_pause - Pause or Resume audio playback-----------------------------------------------------------------------------*/static int matcd_pause(int ldrive, int cdrive, int controller, int action){	struct	matcd_data *cd;	int	i,z,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	if ((cd->flags & MATCDLABEL)==0)		return(EIO);		/*Refuse after chg error*/	zero_cmd(cmd);	cmd[0]=NOP;			/*<14>Just find out whats going on*/	lockbus(controller, ldrive);	/*<16>Request bus*/	matcd_slowcmd(port,ldrive,cdrive,cmd);	/*<14>*/	i=waitforit(10*TICKRES,DTEN,port,"matpau");	/*<25>*/	z=get_stat(port,ldrive);	/*<14>Read status byte*/	if ((z & MATCD_ST_ERROR)) {	/*<14>Something went wrong*/		i=get_error(port, ldrive, cdrive);	/*<14>*/		unlockbus(controller, ldrive);	/*<16>Release bus*/		return(EIO);		/*<14>*/	}				/*<14>*/	unlockbus(controller, ldrive);	/*<16>Release bus*/	if ((z & MATCD_ST_AUDIOBSY) == 0 &&		/*<14>If drive is idle*/	    cd->status==CD_AS_PLAY_IN_PROGRESS) {	/*<14>but was playing*/		cd->status=CD_AS_PLAY_COMPLETED;	/*<14>then its done*/		return(0);	}	if (action) {			/*<14>Set state for subq ioctl*/#ifndef KRYTEN		if (cd->status==CD_AS_PLAY_IN_PROGRESS) {/*<14>Don't resume*/			return(0);	/*<14>if already playing*/		}			/*<14>Max Headroom sound occurs*/#endif /*KRYTEN*/		cd->status=CD_AS_PLAY_IN_PROGRESS;	/*<14>to read*/	} else {			/*<14>There is no way to ask the*/		cd->status=CD_AS_PLAY_PAUSED;/*<14>drive if it is paused*/	}				/*<14>*/	cmd[0]=PAUSE;			/*Pause or Resume playing audio*/	cmd[1]=action;	i=docmd(cmd,ldrive,cdrive,controller,port);	/*Issue command*/#ifdef DEBUGIOCTL	printf("matcd%d: Pause / Resume results %d \n",ldrive,i);#endif /*DEBUGIOCTL*/	return(i);}/*-----------------------------------------------------------------------------	matcd_stop  - Stop audio playback-----------------------------------------------------------------------------*/static int matcd_stop(int ldrive, int cdrive, int controller){	struct	matcd_data *cd;	int	i,port;	unsigned char cmd[MAXCMDSIZ];	cd=&matcd_data[ldrive];	port=cd->iobase;	if ((cd->flags & MATCDLABEL)==0)		return(EIO);		/*Refuse after chg error*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -