Exemplo n.º 1
0
unsigned char get_irq(SB16* sb16)
{
	unsigned char irq;
	irq=(read_mixer(sb16->base,MIXER_INTERRUPT_SETUP_REGISTER)&0x0f);

	if(irq==1) sb16->irq=2;
	if(irq==2) sb16->irq=5;
	if(irq==4) sb16->irq=7;
	if(irq==8) sb16->irq=10;
	return 0;
}
Exemplo n.º 2
0
void get_dma(SB16* sb16)
{
	unsigned char hi,lo,result=read_mixer(sb16->base,MIXER_DMA_SETUP_REGISTER);
  hi=result&0xE0;
  lo=result&0x0B;
  if(hi==0x80) sb16->dma16=7;
  if(hi==0x40) sb16->dma16=6;
  if(hi==0x20) sb16->dma16=5;

  if(lo==0x08) sb16->dma8=3;
  if(lo==0x02) sb16->dma8=1;
  if(lo==0x01) sb16->dma8=0;
}
Exemplo n.º 3
0
static int luaA_mixer_ext_get(lua_State *L) {
    mixer_ext_t *mext = luaL_checkudata(L, 1, "mixer_ext");
    if (luaA_usemetatable(L, 1, 2)) return 1;

    int value, i;
    
    if (lua_isnumber(L, 2)) {
        i = luaL_checknumber(L, 2);
        if (i < 1 || 2 < i) return 0;

        value = read_mixer(mext);
        if (format_stereo_value(L, mext, value) == 0)
            return 0;

        lua_remove(L, -i);
        return 1;
    }

    const char *index = luaL_checkstring(L, 2);
    oss_mixer_enuminfo enuminf;
    int result;

    if (strcmp(index, "type") == 0) {
        switch (mext->ext.type) {
        case MIXT_3D             : lua_pushstring(L, "3d"); break;
        case MIXT_DEVROOT        : lua_pushstring(L, "devroot"); break;
        case MIXT_ENUM           : lua_pushstring(L, "enum"); break;
        case MIXT_GROUP          : lua_pushstring(L, "group"); break;
        case MIXT_HEXVALUE       : lua_pushstring(L, "hexvalue"); break;
        case MIXT_MARKER         : lua_pushstring(L, "marker"); break;
        case MIXT_MESSAGE        : lua_pushstring(L, "message"); break;
        case MIXT_MONODB         : lua_pushstring(L, "mono db"); break;
        case MIXT_MONOPEAK       : lua_pushstring(L, "mono peak"); break;
        case MIXT_MONOSLIDER16   : lua_pushstring(L, "mono slider16"); break;
        case MIXT_MONOSLIDER     : lua_pushstring(L, "mono slider"); break;
        case MIXT_MONOVU         : lua_pushstring(L, "mono vu"); break;
        case MIXT_MUTE           : lua_pushstring(L, "mute"); break;
        case MIXT_ONOFF          : lua_pushstring(L, "switch"); break;
        case MIXT_RADIOGROUP     : lua_pushstring(L, "radio group"); break;
        /*case MIXT_ROOT           : lua_pushstring(L, "root"); break;*/
        case MIXT_SLIDER         : lua_pushstring(L, "slider"); break;
        case MIXT_STEREODB       : lua_pushstring(L, "stereo db"); break;
        case MIXT_STEREOPEAK     : lua_pushstring(L, "stereo peak"); break;
        case MIXT_STEREOSLIDER16 : lua_pushstring(L, "stereo slider16"); break;
        case MIXT_STEREOSLIDER   : lua_pushstring(L, "stereo slider"); break;
        case MIXT_STEREOVU       : lua_pushstring(L, "stereo vu"); break;
        case MIXT_VALUE          : lua_pushstring(L, "value"); break;
        default: return 0;
        }
        return 1;

    } else if (strcmp(index, "name") == 0) {
        lua_pushstring(L, mext->ext.extname);
        return 1;

    } else if (strcmp(index, "id") == 0) {
        lua_pushstring(L, mext->ext.id);
        return 1;

    } else if (strcmp(index, "value") == 0) {
        value = read_mixer(mext);
        if (value < 0) return 0;

        if (result = format_normal_value(L, mext, value));
        else if (result = format_stereo_value(L, mext, value));
        else if (result = format_mono_value(L, mext, value));
        else if (result = format_switch_value(L, mext, value));
        else if (result = format_enum_value(L, mext, value));
        else return 0;

        if (result > 1) pack_into_table(L, result);
        return 1;

    } else if (strcmp(index, "min") == 0) {
        lua_pushnumber(L, mext->ext.minvalue);
        return 1;

    } else if (strcmp(index, "max") == 0) {
        lua_pushnumber(L, mext->ext.maxvalue);
        return 1;

    } else if (strcmp(index, "color") == 0) {
        lua_pushnumber(L, mext->ext.rgbcolor);
        return 1;

    } else if (strcmp(index, "enum") == 0) {
        if (mext->ext.type != MIXT_ENUM) return 0;

        enuminf.dev = mext->ext.dev;
        enuminf.ctrl = mext->ext.ctrl;
        if (ioctl(mext->mixer->fh, SNDCTL_MIX_ENUMINFO, &enuminf) < 0) return 0;

        lua_createtable(L, mext->ext.maxvalue, 0);

        value = 0;
        for (i = 0; i < mext->ext.maxvalue; i++) {
            if (!IN_ENUM(mext->ext.enum_present, i)) continue;
            lua_pushstring(L, enuminf.strings + enuminf.strindex[i]);
            lua_rawseti(L, -2, ++value);
        }

        return 1;

    } else if (strcmp(index, "readonly") == 0) {
        lua_pushboolean(L, (mext->ext.flags & MIXF_WRITEABLE) == 0);
        return 1;
    }

    return 0;
}