/*
 *  ALSA sequencer main module
 *  Copyright (c) 1998 by Frank van de Pol <frank@vande-pol.demon.nl>
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#define SND_MAIN_OBJECT_FILE
#include "driver.h"

#include "seq_kernel.h"
#include "seq_clientmgr.h"
#include "seq_memory.h"
#include "seq_queue.h"
#include "seq_timer.h"
#include "seq_system.h"
#include "seq_info.h"

int snd_seq_default_timer = SND_TIMER_TYPE_GLOBAL | SND_TIMER_GLOBAL_SYSTEM;
int snd_seq_default_timer_resolution = 250;	/* Hz */

#ifdef MODULE_PARM		/* hey - we have new 2.1.18+ kernel... */
MODULE_AUTHOR("Frank van de Pol <frank@vande-pol.demon.nl>, Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer.");
MODULE_SUPPORTED_DEVICE("sound");

MODULE_PARM(snd_seq_default_timer, "i");
MODULE_PARM_DESC(snd_seq_default_timer, "The default timer number.");
MODULE_PARM(snd_seq_default_timer_resolution, "i");
MODULE_PARM_DESC(snd_seq_default_timer_resolution, "The default timer resolution in Hz.");
#endif


/*
 *  INIT PART
 */


#ifndef LINUX_2_1
extern struct symbol_table snd_symbol_table_seq_export;
#endif

int init_module(void)
{
#ifndef LINUX_2_1
	if (register_symtab(&snd_symbol_table_seq_export) < 0)
		return -ENOMEM;
#endif
	client_init_data();

	/* init memory, room for selected events */
	snd_sequencer_memory_init();

	/* init event queues */
	snd_seq_queues_init(SND_SEQ_MAX_QUEUES);

	/* register sequencer device */
	snd_sequencer_device_init();

	/* register proc interface */
	snd_seq_info_init();

	/* register our internal client */
	snd_seq_system_client_init();

	return 0;
}


void cleanup_module(void)
{
	/* unregister our internal client */
	snd_seq_system_client_done();

	/* unregister proc interface */
	snd_seq_info_done();
	
	/* delete timing queues */
	snd_seq_queues_delete();

	/* unregister sequencer device */
	snd_sequencer_device_done();

	/* release event memory */
	snd_sequencer_memory_done();
}

