Пример #1
0
void __init amiga_init_sound(void)
{
    static struct resource beep_res = { .name = "Beep" };

    snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res);
    if (!snd_data) {
        printk (KERN_CRIT "amiga init_sound: failed to allocate chipmem\n");
        return;
    }
    memcpy (snd_data, sine_data, sizeof(sine_data));

    /* setup divisor */
    clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE;

    /* without amifb, turn video off and enable high quality sound */
#ifndef CONFIG_FB_AMIGA
    amifb_video_off();
#endif
}

static void nosound( unsigned long ignored );
static DEFINE_TIMER(sound_timer, nosound, 0, 0);

void amiga_mksound( unsigned int hz, unsigned int ticks )
{
    unsigned long flags;

    if (!snd_data)
        return;

    local_irq_save(flags);
    del_timer( &sound_timer );

    if (hz > 20 && hz < 32767) {
        unsigned long period = (clock_constant / hz);

        if (period < amiga_audio_min_period)
            period = amiga_audio_min_period;
        if (period > MAX_PERIOD)
            period = MAX_PERIOD;

        /* setup pointer to data, period, length and volume */
        custom.aud[2].audlc = snd_data;
        custom.aud[2].audlen = sizeof(sine_data)/2;
        custom.aud[2].audper = (unsigned short)period;
        custom.aud[2].audvol = 32; /* 50% of maxvol */

        if (ticks) {
            sound_timer.expires = jiffies + ticks;
            add_timer( &sound_timer );
        }

        /* turn on DMA for audio channel 2 */
        custom.dmacon = DMAF_SETCLR | DMAF_AUD2;

    } else
        nosound( 0 );

    local_irq_restore(flags);
}
Пример #2
0
static void amiga_savekmsg_init(void)
{
    static struct resource debug_res = { "Debug" };

    savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
    savekmsg->magic1 = SAVEKMSG_MAGIC1;
    savekmsg->magic2 = SAVEKMSG_MAGIC2;
    savekmsg->magicptr = virt_to_phys(savekmsg);
    savekmsg->size = 0;
}
Пример #3
0
void *amiga_chip_alloc(unsigned long size, const char *name)
{
	struct resource *res;
	void *p;

	res = kzalloc(sizeof(struct resource), GFP_KERNEL);
	if (!res)
		return NULL;

	res->name = name;
	p = amiga_chip_alloc_res(size, res);
	if (!p) {
		kfree(res);
		return NULL;
	}

	return p;
}