151694Sroger/* $FreeBSD: releng/11.0/sys/dev/bktr/bktr_os.h 298955 2016-05-03 03:41:25Z pfg $ */ 251694Sroger 351694Sroger/* 451694Sroger * This is part of the Driver for Video Capture Cards (Frame grabbers) 551694Sroger * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879 651694Sroger * chipset. 751694Sroger * Copyright Roger Hardiman and Amancio Hasty. 851694Sroger * 9298955Spfg * bktr_os : This has all the Operating System dependent code. 1051694Sroger * 1151694Sroger */ 1251694Sroger 13139749Simp/*- 1451694Sroger * 1. Redistributions of source code must retain the 1551694Sroger * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman 1651694Sroger * All rights reserved. 1751694Sroger * 1851694Sroger * Redistribution and use in source and binary forms, with or without 1951694Sroger * modification, are permitted provided that the following conditions 2051694Sroger * are met: 2151694Sroger * 1. Redistributions of source code must retain the above copyright 2251694Sroger * notice, this list of conditions and the following disclaimer. 2351694Sroger * 2. Redistributions in binary form must reproduce the above copyright 2451694Sroger * notice, this list of conditions and the following disclaimer in the 2551694Sroger * documentation and/or other materials provided with the distribution. 2651694Sroger * 3. All advertising materials mentioning features or use of this software 2751694Sroger * must display the following acknowledgement: 2851694Sroger * This product includes software developed by Amancio Hasty and 2951694Sroger * Roger Hardiman 3051694Sroger * 4. The name of the author may not be used to endorse or promote products 3151694Sroger * derived from this software without specific prior written permission. 3251694Sroger * 3351694Sroger * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 3451694Sroger * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 3551694Sroger * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 3651694Sroger * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 3751694Sroger * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 3851694Sroger * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 3951694Sroger * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4051694Sroger * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4151694Sroger * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 4251694Sroger * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4351694Sroger * POSSIBILITY OF SUCH DAMAGE. 4451694Sroger */ 4551694Sroger 4651694Sroger 4751694Sroger/******************************/ 4851694Sroger/* *** Memory Allocation *** */ 4951694Sroger/******************************/ 5051694Sroger#if (defined(__FreeBSD__) || defined(__bsdi__)) 5151694Srogervm_offset_t get_bktr_mem( int unit, unsigned size ); 5251694Sroger#endif 5351694Sroger 5451694Sroger#if (defined(__NetBSD__) || defined(__OpenBSD__)) 5551694Srogervm_offset_t get_bktr_mem(bktr_ptr_t, bus_dmamap_t *, unsigned size); 5651694Srogervoid free_bktr_mem(bktr_ptr_t, bus_dmamap_t, vm_offset_t); 5751694Sroger#endif 5851694Sroger 5959250Sroger/************************************/ 6059250Sroger/* *** Interrupt Enable/Disable *** */ 6159250Sroger/************************************/ 6259278Sroger#if defined(__FreeBSD__) 6374903Sjhb#if (__FreeBSD_version >=500000) 64123088Struckman#define USE_VBIMUTEX 6588088Sjhb#define DECLARE_INTR_MASK(s) /* no need to declare 's' */ 66123088Struckman#define DISABLE_INTR(s) 67123088Struckman#define ENABLE_INTR(s) 6874903Sjhb#else 6959277Sroger#define DECLARE_INTR_MASK(s) intrmask_t s 7059277Sroger#define DISABLE_INTR(s) s=spltty() 7159277Sroger#define ENABLE_INTR(s) splx(s) 7274903Sjhb#endif 7359250Sroger#else 7459277Sroger#define DECLARE_INTR_MASK(s) /* no need to declare 's' */ 7559277Sroger#define DISABLE_INTR(s) disable_intr() 7659277Sroger#define ENABLE_INTR(s) enable_intr() 7759250Sroger#endif 7859250Sroger 79123088Struckman#ifdef USE_VBIMUTEX 80123088Struckman#define LOCK_VBI(bktr) mtx_lock(&bktr->vbimutex) 81123088Struckman#define UNLOCK_VBI(bktr) mtx_unlock(&bktr->vbimutex) 82123088Struckman#else 83123088Struckman#define LOCK_VBI(bktr) 84123088Struckman#define UNLOCK_VBI(bktr) 85123088Struckman#endif 86