/* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sub license, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef VIA_3D_REG_H #define VIA_3D_REG_H #define HC_REG_BASE 0x0400 #define HC_REG_TRANS_SPACE 0x0040 #define HC_ParaN_MASK 0xffffffff #define HC_Para_MASK 0x00ffffff #define HC_SubA_MASK 0xff000000 #define HC_SubA_SHIFT 24 /* Transmission Setting */ #define HC_REG_TRANS_SET 0x003c #define HC_ParaSubType_MASK 0xff000000 #define HC_ParaType_MASK 0x00ff0000 #define HC_ParaOS_MASK 0x0000ff00 #define HC_ParaAdr_MASK 0x000000ff #define HC_ParaSubType_SHIFT 24 #define HC_ParaType_SHIFT 16 #define HC_ParaOS_SHIFT 8 #define HC_ParaAdr_SHIFT 0 #define HC_ParaType_CmdVdata 0x0000 #define HC_ParaType_NotTex 0x0001 #define HC_ParaType_Tex 0x0002 #define HC_ParaType_Palette 0x0003 #define HC_ParaType_PreCR 0x0010 #define HC_ParaType_Auto 0x00fe /* Transmission Space */ #define HC_REG_Hpara0 0x0040 #define HC_REG_HpataAF 0x02fc /* Read */ #define HC_REG_HREngSt 0x0000 #define HC_REG_HRFIFOempty 0x0004 #define HC_REG_HRFIFOfull 0x0008 #define HC_REG_HRErr 0x000c #define HC_REG_FIFOstatus 0x0010 /* HC_REG_HREngSt 0x0000 */ #define HC_HDASZC_MASK 0x00010000 #define HC_HSGEMI_MASK 0x0000f000 #define HC_HLGEMISt_MASK 0x00000f00 #define HC_HCRSt_MASK 0x00000080 #define HC_HSE0St_MASK 0x00000040 #define HC_HSE1St_MASK 0x00000020 #define HC_HPESt_MASK 0x00000010 #define HC_HXESt_MASK 0x00000008 #define HC_HBESt_MASK 0x00000004 #define HC_HE2St_MASK 0x00000002 #define HC_HE3St_MASK 0x00000001 /* HC_REG_HRFIFOempty 0x0004 */ #define HC_HRZDempty_MASK 0x00000010 #define HC_HRTXAempty_MASK 0x00000008 #define HC_HRTXDempty_MASK 0x00000004 #define HC_HWZDempty_MASK 0x00000002 #define HC_HWCDempty_MASK 0x00000001 /* HC_REG_HRFIFOfull 0x0008 */ #define HC_HRZDfull_MASK 0x00000010 #define HC_HRTXAfull_MASK 0x00000008 #define HC_HRTXDfull_MASK 0x00000004 #define HC_HWZDfull_MASK 0x00000002 #define HC_HWCDfull_MASK 0x00000001 /* HC_REG_HRErr 0x000c */ #define HC_HAGPCMErr_MASK 0x80000000 #define HC_HAGPCMErrC_MASK 0x70000000 /* HC_REG_FIFOstatus 0x0010 */ #define HC_HRFIFOATall_MASK 0x80000000 #define HC_HRFIFOATbusy_MASK 0x40000000 #define HC_HRATFGMDo_MASK 0x00000100 #define HC_HRATFGMDi_MASK 0x00000080 #define HC_HRATFRZD_MASK 0x00000040 #define HC_HRATFRTXA_MASK 0x00000020 #define HC_HRATFRTXD_MASK 0x00000010 #define HC_HRATFWZD_MASK 0x00000008 #define HC_HRATFWCD_MASK 0x00000004 #define HC_HRATTXTAG_MASK 0x00000002 #define HC_HRATTXCH_MASK 0x00000001 /* AGP Command Setting */ #define HC_SubA_HAGPBstL 0x0060 #define HC_SubA_HAGPBendL 0x0061 #define HC_SubA_HAGPCMNT 0x0062 #define HC_SubA_HAGPBpL 0x0063 #define HC_SubA_HAGPBpH 0x0064 /* HC_SubA_HAGPCMNT 0x0062 */ #define HC_HAGPCMNT_MASK 0x00800000 #define HC_HCmdErrClr_MASK 0x00400000 #define HC_HAGPBendH_MASK 0x0000ff00 #define HC_HAGPBstH_MASK 0x000000ff #define HC_HAGPBendH_SHIFT 8 #define HC_HAGPBstH_SHIFT 0 /* HC_SubA_HAGPBpL 0x0063 */ #define HC_HAGPBpL_MASK 0x00fffffc #define HC_HAGPBpID_MASK 0x00000003 #define HC_HAGPBpID_PAUSE 0x00000000 #define HC_HAGPBpID_JUMP 0x00000001 #define HC_HAGPBpID_STOP 0x00000002 /* HC_SubA_HAGPBpH 0x0064 */ #define HC_HAGPBpH_MASK 0x00ffffff /* Miscellaneous Settings */ #define HC_SubA_HClipTB 0x0070 #define HC_SubA_HClipLR 0x0071 #define HC_SubA_HFPClipTL 0x0072 #define HC_SubA_HFPClipBL 0x0073 #define HC_SubA_HFPClipLL 0x0074 #define HC_SubA_HFPClipRL 0x0075 #define HC_SubA_HFPClipTBH 0x0076 #define HC_SubA_HFPClipLRH 0x0077 #define HC_SubA_HLP 0x0078 #define HC_SubA_HLPRF 0x0079 #define HC_SubA_HSolidCL 0x007a #define HC_SubA_HPixGC 0x007b #define HC_SubA_HSPXYOS 0x007c #define HC_SubA_HVertexCNT 0x007d #define HC_HClipT_MASK 0x00fff000 #define HC_HClipT_SHIFT 12 #define HC_HClipB_MASK 0x00000fff #define HC_HClipB_SHIFT 0 #define HC_HClipL_MASK 0x00fff000 #define HC_HClipL_SHIFT 12 #define HC_HClipR_MASK 0x00000fff #define HC_HClipR_SHIFT 0 #define HC_HFPClipBH_MASK 0x0000ff00 #define HC_HFPClipBH_SHIFT 8 #define HC_HFPClipTH_MASK 0x000000ff #define HC_HFPClipTH_SHIFT 0 #define HC_HFPClipRH_MASK 0x0000ff00 #define HC_HFPClipRH_SHIFT 8 #define HC_HFPClipLH_MASK 0x000000ff #define HC_HFPClipLH_SHIFT 0 #define HC_HSolidCH_MASK 0x000000ff #define HC_HPixGC_MASK 0x00800000 #define HC_HSPXOS_MASK 0x00fff000 #define HC_HSPXOS_SHIFT 12 #define HC_HSPYOS_MASK 0x00000fff /* Command * Command A */ #define HC_HCmdHeader_MASK 0xfe000000 /*0xffe00000 */ #define HC_HE3Fire_MASK 0x00100000 #define HC_HPMType_MASK 0x000f0000 #define HC_HEFlag_MASK 0x0000e000 #define HC_HShading_MASK 0x00001c00 #define HC_HPMValidN_MASK 0x00000200 #define HC_HPLEND_MASK 0x00000100 #define HC_HVCycle_MASK 0x000000ff #define HC_HVCycle_Style_MASK 0x000000c0 #define HC_HVCycle_ChgA_MASK 0x00000030 #define HC_HVCycle_ChgB_MASK 0x0000000c #define HC_HVCycle_ChgC_MASK 0x00000003 #define HC_H * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHOR(S), AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Author: Thomas Hellstrom 2005. * * Video and XvMC related functions. */ #include "drmP.h" #include "via_drm.h" #include "via_drv.h" void via_init_futex(drm_via_private_t * dev_priv) { unsigned int i; DRM_DEBUG("\n"); for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) { DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i])); XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0; } } void via_cleanup_futex(drm_via_private_t * dev_priv) { } void via_release_futex(drm_via_private_t * dev_priv, int context) { unsigned int i; volatile int *lock; if (!dev_priv->sarea_priv) return; for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) { lock = (volatile int *)XVMCLOCKPTR(dev_priv->sarea_priv, i); if ((_DRM_LOCKING_CONTEXT(*lock) == context)) { if (_DRM_LOCK_IS_HELD(*lock) && (*lock & _DRM_LOCK_CONT)) { DRM_WAKEUP(&(dev_priv->decoder_queue[i])); } *lock = 0; } } } int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_via_futex_t *fx = data; volatile int *lock; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; drm_via_sarea_t *sAPriv = dev_priv->sarea_priv; int ret = 0; DRM_DEBUG("\n"); if (fx->lock > VIA_NR_XVMC_LOCKS) return -EFAULT; lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock); switch (fx->func) { case VIA_FUTEX_WAIT: DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock], (fx->ms / 10) * (DRM_HZ / 100), *lock != fx->val); return ret; case VIA_FUTEX_WAKE: DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock])); return 0; } return 0; }