new base libaudiodriver out of -lcommon in drivers/audio.

- this lets the drivers that used that library be compiled easily with
   different compilers.
This commit is contained in:
Ben Gras
2010-08-25 11:03:53 +00:00
parent cb86231930
commit 0f4eda33eb
12 changed files with 11 additions and 17 deletions

View File

@@ -2,6 +2,6 @@
.include <bsd.own.mk>
SUBDIR= common .WAIT es1370 es1371 sb16
SUBDIR= .WAIT es1370 es1371 sb16
.include <bsd.subdir.mk>

View File

@@ -1,12 +1,7 @@
.include <bsd.own.mk>
LIBCOMMON != cd ${.CURDIR}/../common && ${PRINTOBJDIR}
CPPFLAGS+=-I${.CURDIR}/../common
DPADD+= ${LIBCOMMON}/libcommon.a
LDADD+= -L${LIBCOMMON} -lcommon
DPADD+= ${LIBDRIVER} ${LIBSYS}
LDADD+= -ldriver -lsys
DPADD+= ${LIBAUDIODRIVER} ${LIBDRIVER} ${LIBSYS}
LDADD+= -laudiodriver -ldriver -lsys
.if exists(${.CURDIR}/../../Makefile.inc)
.include "${.CURDIR}/../../Makefile.inc"

View File

@@ -1,8 +0,0 @@
# Makefile for the common audio framework
LIBISPRIVATE= yes
LIB= common
SRCS= audio_fw.c liveupdate.c
.include <bsd.lib.mk>

File diff suppressed because it is too large Load Diff

View File

@@ -1,102 +0,0 @@
#ifndef AUDIO_FW_H
#define AUDIO_FW_H
#include <minix/drivers.h>
#include <minix/driver.h>
#include <sys/ioc_sound.h>
/* change to DEBUG to 1 to print debug info and error messages */
#define DEBUG 0
#if DEBUG
#define dprint printf
#else
#define dprint (void)
#endif
#define error printf
_PROTOTYPE( int drv_init, (void) );
_PROTOTYPE( int drv_init_hw, (void) );
_PROTOTYPE( int drv_reset, (void) );
_PROTOTYPE( int drv_start, (int sub_dev, int DmaMode) );
_PROTOTYPE( int drv_stop, (int sub_dev) );
_PROTOTYPE( int drv_set_dma, (u32_t dma, u32_t length, int chan) );
_PROTOTYPE( int drv_reenable_int, (int chan) );
_PROTOTYPE( int drv_int_sum, (void) );
_PROTOTYPE( int drv_int, (int sub_dev) );
_PROTOTYPE( int drv_pause, (int chan) );
_PROTOTYPE( int drv_resume, (int chan) );
_PROTOTYPE( int drv_io_ctl, (int request, void * val, int * len, int sub_dev) );
_PROTOTYPE( int drv_get_irq, (char *irq) );
_PROTOTYPE( int drv_get_frag_size, (u32_t *frag_size, int sub_dev) );
/* runtime status fields */
typedef struct {
int readable;
int writable;
int DmaSize;
int NrOfDmaFragments;
int MinFragmentSize;
int NrOfExtraBuffers;
int Nr; /* sub device number */
int Opened; /* sub device opened */
int DmaBusy; /* is dma busy? */
int DmaMode; /* DEV_WRITE / DEV_READ */
int DmaReadNext; /* current dma buffer */
int DmaFillNext; /* next dma buffer to fill */
int DmaLength;
int BufReadNext; /* start of extra circular buffer */
int BufFillNext; /* end of extra circular buffer */
int BufLength;
int RevivePending; /* process waiting for this dev? */
int ReviveStatus; /* return val when proc unblocked */
int ReviveProcNr; /* the process to unblock */
cp_grant_id_t ReviveGrant; /* grant id associated with io */
void *UserBuf; /* address of user's data buffer */
int ReadyToRevive; /* are we ready to revive process?*/
int NotifyProcNr; /* process to send notify to (FS) */
u32_t FragSize; /* dma fragment size */
char *DmaBuf; /* the dma buffer; extra space for
page alignment */
phys_bytes DmaPhys; /* physical address of dma buffer */
char* DmaPtr; /* pointer to aligned dma buffer */
int OutOfData; /* all buffers empty? */
char *ExtraBuf; /* don't use extra buffer;just
declare a pointer to supress
error messages */
} sub_dev_t;
typedef struct {
int minor_dev_nr;
int read_chan;
int write_chan;
int io_ctl;
} special_file_t;
typedef struct {
char* DriverName;
int NrOfSubDevices;
int NrOfSpecialFiles;
} drv_t;
EXTERN drv_t drv;
EXTERN sub_dev_t sub_dev[];
EXTERN special_file_t special_file[];
/* Number of bytes you can DMA before hitting a 64K boundary: */
#define dma_bytes_left(phys) \
((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
#define NO_CHANNEL -1
#define TRUE 1
#define FALSE 0
#define NO_DMA 0
#endif /* AUDIO_FW_H */

View File

@@ -1,115 +0,0 @@
#include "audio_fw.h"
/* State management variables. */
EXTERN int is_status_msg_expected;
/*
* - From audio_fw.h:
* EXTERN drv_t drv;
* EXTERN sub_dev_t sub_dev[];
*/
/* State management helpers */
PRIVATE int is_read_pending;
PRIVATE int is_write_pending;
PRIVATE void load_state_info(void)
{
int i, dma_mode, found_pending;
/* Check if reads or writes are pending. */
is_read_pending = FALSE;
is_write_pending = FALSE;
found_pending = FALSE;
for (i = 0; i < drv.NrOfSubDevices && !found_pending; i++) {
if(sub_dev[i].RevivePending) {
dma_mode = sub_dev[i].DmaMode;
if(dma_mode == DEV_READ_S) {
is_read_pending = TRUE;
}
else if (dma_mode == DEV_WRITE_S){
is_write_pending = TRUE;
}
}
found_pending = (is_read_pending && is_write_pending);
}
}
/* Custom states definition. */
#define AUDIO_STATE_READ_REQUEST_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
#define AUDIO_STATE_WRITE_REQUEST_FREE (SEF_LU_STATE_CUSTOM_BASE + 1)
#define AUDIO_STATE_IS_CUSTOM(s) \
((s) >= AUDIO_STATE_READ_REQUEST_FREE && (s) <=AUDIO_STATE_WRITE_REQUEST_FREE)
/*===========================================================================*
* sef_cb_lu_prepare *
*===========================================================================*/
PUBLIC int sef_cb_lu_prepare(int state)
{
int is_ready;
/* Load state information. */
load_state_info();
/* Check if we are ready for the target state. */
is_ready = FALSE;
switch(state) {
/* Standard states. */
case SEF_LU_STATE_REQUEST_FREE:
is_ready = (!is_read_pending && !is_write_pending);
break;
case SEF_LU_STATE_PROTOCOL_FREE:
is_ready = (!is_read_pending && !is_write_pending
&& !is_status_msg_expected);
break;
/* Custom states. */
case AUDIO_STATE_READ_REQUEST_FREE:
is_ready = (!is_read_pending);
break;
case AUDIO_STATE_WRITE_REQUEST_FREE:
is_ready = (!is_write_pending);
break;
}
/* Tell SEF if we are ready. */
return is_ready ? OK : ENOTREADY;
}
/*===========================================================================*
* sef_cb_lu_state_isvalid *
*===========================================================================*/
PUBLIC int sef_cb_lu_state_isvalid(int state)
{
return SEF_LU_STATE_IS_STANDARD(state) || AUDIO_STATE_IS_CUSTOM(state);
}
/*===========================================================================*
* sef_cb_lu_state_dump *
*===========================================================================*/
PUBLIC void sef_cb_lu_state_dump(int state)
{
/* Load state information. */
load_state_info();
sef_lu_dprint("audio: live update state = %d\n", state);
sef_lu_dprint("audio: is_status_msg_expected = %d\n",
is_status_msg_expected);
sef_lu_dprint("audio: is_read_pending = %d\n", is_read_pending);
sef_lu_dprint("audio: is_write_pending = %d\n", is_write_pending);
sef_lu_dprint("audio: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
SEF_LU_STATE_WORK_FREE, TRUE);
sef_lu_dprint("audio: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
SEF_LU_STATE_REQUEST_FREE, (!is_read_pending && !is_write_pending));
sef_lu_dprint("audio: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
SEF_LU_STATE_PROTOCOL_FREE, (!is_read_pending && !is_write_pending
&& !is_status_msg_expected));
sef_lu_dprint("audio: AUDIO_STATE_READ_REQUEST_FREE(%d) reached = %d\n",
AUDIO_STATE_READ_REQUEST_FREE, (!is_read_pending));
sef_lu_dprint("audio: AUDIO_STATE_WRITE_REQUEST_FREE(%d) reached = %d\n",
AUDIO_STATE_WRITE_REQUEST_FREE, (!is_write_pending));
}

View File

@@ -17,7 +17,7 @@
#include <machine/pci.h>
#include "audio_fw.h"
#include <minix/audio_fw.h>
#include "es1370.h"
#include "ak4531.h"
#include "pci_helper.h"

View File

@@ -22,7 +22,7 @@
#include <machine/pci.h>
#include "audio_fw.h"
#include <minix/audio_fw.h>
#include "es1371.h"
#include "AC97.h"
#include "sample_rate_converter.h"

View File

@@ -2,7 +2,7 @@
#define ES1371_H
/* best viewed with tabsize=4 */
#include "audio_fw.h"
#include <minix/audio_fw.h>
#include <sys/types.h>
#include <sys/ioc_sound.h>
#include <minix/sound.h>

View File

@@ -2,7 +2,7 @@
#define SB16_H
#include <minix/sound.h>
#include "audio_fw.h"
#include <minix/audio_fw.h>
#define AUDIO 0
#define MIXER 1