Path: blob/master/drivers/gpu/drm/nouveau/nouveau_drv.h
15112 views
/*1* Copyright 2005 Stephane Marchesin.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR19* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,20* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR21* OTHER DEALINGS IN THE SOFTWARE.22*/2324#ifndef __NOUVEAU_DRV_H__25#define __NOUVEAU_DRV_H__2627#define DRIVER_AUTHOR "Stephane Marchesin"28#define DRIVER_EMAIL "[email protected]"2930#define DRIVER_NAME "nouveau"31#define DRIVER_DESC "nVidia Riva/TNT/GeForce"32#define DRIVER_DATE "20090420"3334#define DRIVER_MAJOR 035#define DRIVER_MINOR 036#define DRIVER_PATCHLEVEL 163738#define NOUVEAU_FAMILY 0x0000FFFF39#define NOUVEAU_FLAGS 0xFFFF00004041#include "ttm/ttm_bo_api.h"42#include "ttm/ttm_bo_driver.h"43#include "ttm/ttm_placement.h"44#include "ttm/ttm_memory.h"45#include "ttm/ttm_module.h"4647struct nouveau_fpriv {48struct ttm_object_file *tfile;49};5051#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)5253#include "nouveau_drm.h"54#include "nouveau_reg.h"55#include "nouveau_bios.h"56#include "nouveau_util.h"5758struct nouveau_grctx;59struct nouveau_mem;60#include "nouveau_vm.h"6162#define MAX_NUM_DCB_ENTRIES 166364#define NOUVEAU_MAX_CHANNEL_NR 12865#define NOUVEAU_MAX_TILE_NR 156667struct nouveau_mem {68struct drm_device *dev;6970struct nouveau_vma bar_vma;71struct nouveau_vma tmp_vma;72u8 page_shift;7374struct drm_mm_node *tag;75struct list_head regions;76dma_addr_t *pages;77u32 memtype;78u64 offset;79u64 size;80};8182struct nouveau_tile_reg {83bool used;84uint32_t addr;85uint32_t limit;86uint32_t pitch;87uint32_t zcomp;88struct drm_mm_node *tag_mem;89struct nouveau_fence *fence;90};9192struct nouveau_bo {93struct ttm_buffer_object bo;94struct ttm_placement placement;95u32 valid_domains;96u32 placements[3];97u32 busy_placements[3];98struct ttm_bo_kmap_obj kmap;99struct list_head head;100101/* protected by ttm_bo_reserve() */102struct drm_file *reserved_by;103struct list_head entry;104int pbbo_index;105bool validate_mapped;106107struct nouveau_channel *channel;108109struct nouveau_vma vma;110111uint32_t tile_mode;112uint32_t tile_flags;113struct nouveau_tile_reg *tile;114115struct drm_gem_object *gem;116int pin_refcnt;117};118119#define nouveau_bo_tile_layout(nvbo) \120((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)121122static inline struct nouveau_bo *123nouveau_bo(struct ttm_buffer_object *bo)124{125return container_of(bo, struct nouveau_bo, bo);126}127128static inline struct nouveau_bo *129nouveau_gem_object(struct drm_gem_object *gem)130{131return gem ? gem->driver_private : NULL;132}133134/* TODO: submit equivalent to TTM generic API upstream? */135static inline void __iomem *136nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)137{138bool is_iomem;139void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual(140&nvbo->kmap, &is_iomem);141WARN_ON_ONCE(ioptr && !is_iomem);142return ioptr;143}144145enum nouveau_flags {146NV_NFORCE = 0x10000000,147NV_NFORCE2 = 0x20000000148};149150#define NVOBJ_ENGINE_SW 0151#define NVOBJ_ENGINE_GR 1152#define NVOBJ_ENGINE_CRYPT 2153#define NVOBJ_ENGINE_COPY0 3154#define NVOBJ_ENGINE_COPY1 4155#define NVOBJ_ENGINE_MPEG 5156#define NVOBJ_ENGINE_DISPLAY 15157#define NVOBJ_ENGINE_NR 16158159#define NVOBJ_FLAG_DONT_MAP (1 << 0)160#define NVOBJ_FLAG_ZERO_ALLOC (1 << 1)161#define NVOBJ_FLAG_ZERO_FREE (1 << 2)162#define NVOBJ_FLAG_VM (1 << 3)163#define NVOBJ_FLAG_VM_USER (1 << 4)164165#define NVOBJ_CINST_GLOBAL 0xdeadbeef166167struct nouveau_gpuobj {168struct drm_device *dev;169struct kref refcount;170struct list_head list;171172void *node;173u32 *suspend;174175uint32_t flags;176177u32 size;178u32 pinst;179u32 cinst;180u64 vinst;181182uint32_t engine;183uint32_t class;184185void (*dtor)(struct drm_device *, struct nouveau_gpuobj *);186void *priv;187};188189struct nouveau_page_flip_state {190struct list_head head;191struct drm_pending_vblank_event *event;192int crtc, bpp, pitch, x, y;193uint64_t offset;194};195196enum nouveau_channel_mutex_class {197NOUVEAU_UCHANNEL_MUTEX,198NOUVEAU_KCHANNEL_MUTEX199};200201struct nouveau_channel {202struct drm_device *dev;203int id;204205/* references to the channel data structure */206struct kref ref;207/* users of the hardware channel resources, the hardware208* context will be kicked off when it reaches zero. */209atomic_t users;210struct mutex mutex;211212/* owner of this fifo */213struct drm_file *file_priv;214/* mapping of the fifo itself */215struct drm_local_map *map;216217/* mapping of the regs controlling the fifo */218void __iomem *user;219uint32_t user_get;220uint32_t user_put;221222/* Fencing */223struct {224/* lock protects the pending list only */225spinlock_t lock;226struct list_head pending;227uint32_t sequence;228uint32_t sequence_ack;229atomic_t last_sequence_irq;230} fence;231232/* DMA push buffer */233struct nouveau_gpuobj *pushbuf;234struct nouveau_bo *pushbuf_bo;235uint32_t pushbuf_base;236237/* Notifier memory */238struct nouveau_bo *notifier_bo;239struct drm_mm notifier_heap;240241/* PFIFO context */242struct nouveau_gpuobj *ramfc;243struct nouveau_gpuobj *cache;244void *fifo_priv;245246/* Execution engine contexts */247void *engctx[NVOBJ_ENGINE_NR];248249/* NV50 VM */250struct nouveau_vm *vm;251struct nouveau_gpuobj *vm_pd;252253/* Objects */254struct nouveau_gpuobj *ramin; /* Private instmem */255struct drm_mm ramin_heap; /* Private PRAMIN heap */256struct nouveau_ramht *ramht; /* Hash table */257258/* GPU object info for stuff used in-kernel (mm_enabled) */259uint32_t m2mf_ntfy;260uint32_t vram_handle;261uint32_t gart_handle;262bool accel_done;263264/* Push buffer state (only for drm's channel on !mm_enabled) */265struct {266int max;267int free;268int cur;269int put;270/* access via pushbuf_bo */271272int ib_base;273int ib_max;274int ib_free;275int ib_put;276} dma;277278uint32_t sw_subchannel[8];279280struct {281struct nouveau_gpuobj *vblsem;282uint32_t vblsem_head;283uint32_t vblsem_offset;284uint32_t vblsem_rval;285struct list_head vbl_wait;286struct list_head flip;287} nvsw;288289struct {290bool active;291char name[32];292struct drm_info_list info;293} debugfs;294};295296struct nouveau_exec_engine {297void (*destroy)(struct drm_device *, int engine);298int (*init)(struct drm_device *, int engine);299int (*fini)(struct drm_device *, int engine);300int (*context_new)(struct nouveau_channel *, int engine);301void (*context_del)(struct nouveau_channel *, int engine);302int (*object_new)(struct nouveau_channel *, int engine,303u32 handle, u16 class);304void (*set_tile_region)(struct drm_device *dev, int i);305void (*tlb_flush)(struct drm_device *, int engine);306};307308struct nouveau_instmem_engine {309void *priv;310311int (*init)(struct drm_device *dev);312void (*takedown)(struct drm_device *dev);313int (*suspend)(struct drm_device *dev);314void (*resume)(struct drm_device *dev);315316int (*get)(struct nouveau_gpuobj *, u32 size, u32 align);317void (*put)(struct nouveau_gpuobj *);318int (*map)(struct nouveau_gpuobj *);319void (*unmap)(struct nouveau_gpuobj *);320321void (*flush)(struct drm_device *);322};323324struct nouveau_mc_engine {325int (*init)(struct drm_device *dev);326void (*takedown)(struct drm_device *dev);327};328329struct nouveau_timer_engine {330int (*init)(struct drm_device *dev);331void (*takedown)(struct drm_device *dev);332uint64_t (*read)(struct drm_device *dev);333};334335struct nouveau_fb_engine {336int num_tiles;337struct drm_mm tag_heap;338void *priv;339340int (*init)(struct drm_device *dev);341void (*takedown)(struct drm_device *dev);342343void (*init_tile_region)(struct drm_device *dev, int i,344uint32_t addr, uint32_t size,345uint32_t pitch, uint32_t flags);346void (*set_tile_region)(struct drm_device *dev, int i);347void (*free_tile_region)(struct drm_device *dev, int i);348};349350struct nouveau_fifo_engine {351void *priv;352int channels;353354struct nouveau_gpuobj *playlist[2];355int cur_playlist;356357int (*init)(struct drm_device *);358void (*takedown)(struct drm_device *);359360void (*disable)(struct drm_device *);361void (*enable)(struct drm_device *);362bool (*reassign)(struct drm_device *, bool enable);363bool (*cache_pull)(struct drm_device *dev, bool enable);364365int (*channel_id)(struct drm_device *);366367int (*create_context)(struct nouveau_channel *);368void (*destroy_context)(struct nouveau_channel *);369int (*load_context)(struct nouveau_channel *);370int (*unload_context)(struct drm_device *);371void (*tlb_flush)(struct drm_device *dev);372};373374struct nouveau_display_engine {375void *priv;376int (*early_init)(struct drm_device *);377void (*late_takedown)(struct drm_device *);378int (*create)(struct drm_device *);379int (*init)(struct drm_device *);380void (*destroy)(struct drm_device *);381};382383struct nouveau_gpio_engine {384void *priv;385386int (*init)(struct drm_device *);387void (*takedown)(struct drm_device *);388389int (*get)(struct drm_device *, enum dcb_gpio_tag);390int (*set)(struct drm_device *, enum dcb_gpio_tag, int state);391392int (*irq_register)(struct drm_device *, enum dcb_gpio_tag,393void (*)(void *, int), void *);394void (*irq_unregister)(struct drm_device *, enum dcb_gpio_tag,395void (*)(void *, int), void *);396bool (*irq_enable)(struct drm_device *, enum dcb_gpio_tag, bool on);397};398399struct nouveau_pm_voltage_level {400u8 voltage;401u8 vid;402};403404struct nouveau_pm_voltage {405bool supported;406u8 vid_mask;407408struct nouveau_pm_voltage_level *level;409int nr_level;410};411412struct nouveau_pm_memtiming {413int id;414u32 reg_100220;415u32 reg_100224;416u32 reg_100228;417u32 reg_10022c;418u32 reg_100230;419u32 reg_100234;420u32 reg_100238;421u32 reg_10023c;422u32 reg_100240;423};424425#define NOUVEAU_PM_MAX_LEVEL 8426struct nouveau_pm_level {427struct device_attribute dev_attr;428char name[32];429int id;430431u32 core;432u32 memory;433u32 shader;434u32 unk05;435u32 unk0a;436437u8 voltage;438u8 fanspeed;439440u16 memscript;441struct nouveau_pm_memtiming *timing;442};443444struct nouveau_pm_temp_sensor_constants {445u16 offset_constant;446s16 offset_mult;447u16 offset_div;448u16 slope_mult;449u16 slope_div;450};451452struct nouveau_pm_threshold_temp {453s16 critical;454s16 down_clock;455s16 fan_boost;456};457458struct nouveau_pm_memtimings {459bool supported;460struct nouveau_pm_memtiming *timing;461int nr_timing;462};463464struct nouveau_pm_engine {465struct nouveau_pm_voltage voltage;466struct nouveau_pm_level perflvl[NOUVEAU_PM_MAX_LEVEL];467int nr_perflvl;468struct nouveau_pm_memtimings memtimings;469struct nouveau_pm_temp_sensor_constants sensor_constants;470struct nouveau_pm_threshold_temp threshold_temp;471472struct nouveau_pm_level boot;473struct nouveau_pm_level *cur;474475struct device *hwmon;476struct notifier_block acpi_nb;477478int (*clock_get)(struct drm_device *, u32 id);479void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *,480u32 id, int khz);481void (*clock_set)(struct drm_device *, void *);482int (*voltage_get)(struct drm_device *);483int (*voltage_set)(struct drm_device *, int voltage);484int (*fanspeed_get)(struct drm_device *);485int (*fanspeed_set)(struct drm_device *, int fanspeed);486int (*temp_get)(struct drm_device *);487};488489struct nouveau_vram_engine {490int (*init)(struct drm_device *);491int (*get)(struct drm_device *, u64, u32 align, u32 size_nc,492u32 type, struct nouveau_mem **);493void (*put)(struct drm_device *, struct nouveau_mem **);494495bool (*flags_valid)(struct drm_device *, u32 tile_flags);496};497498struct nouveau_engine {499struct nouveau_instmem_engine instmem;500struct nouveau_mc_engine mc;501struct nouveau_timer_engine timer;502struct nouveau_fb_engine fb;503struct nouveau_fifo_engine fifo;504struct nouveau_display_engine display;505struct nouveau_gpio_engine gpio;506struct nouveau_pm_engine pm;507struct nouveau_vram_engine vram;508};509510struct nouveau_pll_vals {511union {512struct {513#ifdef __BIG_ENDIAN514uint8_t N1, M1, N2, M2;515#else516uint8_t M1, N1, M2, N2;517#endif518};519struct {520uint16_t NM1, NM2;521} __attribute__((packed));522};523int log2P;524525int refclk;526};527528enum nv04_fp_display_regs {529FP_DISPLAY_END,530FP_TOTAL,531FP_CRTC,532FP_SYNC_START,533FP_SYNC_END,534FP_VALID_START,535FP_VALID_END536};537538struct nv04_crtc_reg {539unsigned char MiscOutReg;540uint8_t CRTC[0xa0];541uint8_t CR58[0x10];542uint8_t Sequencer[5];543uint8_t Graphics[9];544uint8_t Attribute[21];545unsigned char DAC[768];546547/* PCRTC regs */548uint32_t fb_start;549uint32_t crtc_cfg;550uint32_t cursor_cfg;551uint32_t gpio_ext;552uint32_t crtc_830;553uint32_t crtc_834;554uint32_t crtc_850;555uint32_t crtc_eng_ctrl;556557/* PRAMDAC regs */558uint32_t nv10_cursync;559struct nouveau_pll_vals pllvals;560uint32_t ramdac_gen_ctrl;561uint32_t ramdac_630;562uint32_t ramdac_634;563uint32_t tv_setup;564uint32_t tv_vtotal;565uint32_t tv_vskew;566uint32_t tv_vsync_delay;567uint32_t tv_htotal;568uint32_t tv_hskew;569uint32_t tv_hsync_delay;570uint32_t tv_hsync_delay2;571uint32_t fp_horiz_regs[7];572uint32_t fp_vert_regs[7];573uint32_t dither;574uint32_t fp_control;575uint32_t dither_regs[6];576uint32_t fp_debug_0;577uint32_t fp_debug_1;578uint32_t fp_debug_2;579uint32_t fp_margin_color;580uint32_t ramdac_8c0;581uint32_t ramdac_a20;582uint32_t ramdac_a24;583uint32_t ramdac_a34;584uint32_t ctv_regs[38];585};586587struct nv04_output_reg {588uint32_t output;589int head;590};591592struct nv04_mode_state {593struct nv04_crtc_reg crtc_reg[2];594uint32_t pllsel;595uint32_t sel_clk;596};597598enum nouveau_card_type {599NV_04 = 0x00,600NV_10 = 0x10,601NV_20 = 0x20,602NV_30 = 0x30,603NV_40 = 0x40,604NV_50 = 0x50,605NV_C0 = 0xc0,606};607608struct drm_nouveau_private {609struct drm_device *dev;610611/* the card type, takes NV_* as values */612enum nouveau_card_type card_type;613/* exact chipset, derived from NV_PMC_BOOT_0 */614int chipset;615int stepping;616int flags;617618void __iomem *mmio;619620spinlock_t ramin_lock;621void __iomem *ramin;622u32 ramin_size;623u32 ramin_base;624bool ramin_available;625struct drm_mm ramin_heap;626struct nouveau_exec_engine *eng[NVOBJ_ENGINE_NR];627struct list_head gpuobj_list;628struct list_head classes;629630struct nouveau_bo *vga_ram;631632/* interrupt handling */633void (*irq_handler[32])(struct drm_device *);634bool msi_enabled;635636struct list_head vbl_waiting;637638struct {639struct drm_global_reference mem_global_ref;640struct ttm_bo_global_ref bo_global_ref;641struct ttm_bo_device bdev;642atomic_t validate_sequence;643} ttm;644645struct {646spinlock_t lock;647struct drm_mm heap;648struct nouveau_bo *bo;649} fence;650651struct {652spinlock_t lock;653struct nouveau_channel *ptr[NOUVEAU_MAX_CHANNEL_NR];654} channels;655656struct nouveau_engine engine;657struct nouveau_channel *channel;658659/* For PFIFO and PGRAPH. */660spinlock_t context_switch_lock;661662/* VM/PRAMIN flush, legacy PRAMIN aperture */663spinlock_t vm_lock;664665/* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */666struct nouveau_ramht *ramht;667struct nouveau_gpuobj *ramfc;668struct nouveau_gpuobj *ramro;669670uint32_t ramin_rsvd_vram;671672struct {673enum {674NOUVEAU_GART_NONE = 0,675NOUVEAU_GART_AGP, /* AGP */676NOUVEAU_GART_PDMA, /* paged dma object */677NOUVEAU_GART_HW /* on-chip gart/vm */678} type;679uint64_t aper_base;680uint64_t aper_size;681uint64_t aper_free;682683struct ttm_backend_func *func;684685struct {686struct page *page;687dma_addr_t addr;688} dummy;689690struct nouveau_gpuobj *sg_ctxdma;691} gart_info;692693/* nv10-nv40 tiling regions */694struct {695struct nouveau_tile_reg reg[NOUVEAU_MAX_TILE_NR];696spinlock_t lock;697} tile;698699/* VRAM/fb configuration */700uint64_t vram_size;701uint64_t vram_sys_base;702u32 vram_rblock_size;703704uint64_t fb_phys;705uint64_t fb_available_size;706uint64_t fb_mappable_pages;707uint64_t fb_aper_free;708int fb_mtrr;709710/* BAR control (NV50-) */711struct nouveau_vm *bar1_vm;712struct nouveau_vm *bar3_vm;713714/* G8x/G9x virtual address space */715struct nouveau_vm *chan_vm;716717struct nvbios vbios;718719struct nv04_mode_state mode_reg;720struct nv04_mode_state saved_reg;721uint32_t saved_vga_font[4][16384];722uint32_t crtc_owner;723uint32_t dac_users[4];724725struct backlight_device *backlight;726727struct {728struct dentry *channel_root;729} debugfs;730731struct nouveau_fbdev *nfbdev;732struct apertures_struct *apertures;733};734735static inline struct drm_nouveau_private *736nouveau_private(struct drm_device *dev)737{738return dev->dev_private;739}740741static inline struct drm_nouveau_private *742nouveau_bdev(struct ttm_bo_device *bd)743{744return container_of(bd, struct drm_nouveau_private, ttm.bdev);745}746747static inline int748nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)749{750struct nouveau_bo *prev;751752if (!pnvbo)753return -EINVAL;754prev = *pnvbo;755756*pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;757if (prev) {758struct ttm_buffer_object *bo = &prev->bo;759760ttm_bo_unref(&bo);761}762763return 0;764}765766/* nouveau_drv.c */767extern int nouveau_agpmode;768extern int nouveau_duallink;769extern int nouveau_uscript_lvds;770extern int nouveau_uscript_tmds;771extern int nouveau_vram_pushbuf;772extern int nouveau_vram_notify;773extern int nouveau_fbpercrtc;774extern int nouveau_tv_disable;775extern char *nouveau_tv_norm;776extern int nouveau_reg_debug;777extern char *nouveau_vbios;778extern int nouveau_ignorelid;779extern int nouveau_nofbaccel;780extern int nouveau_noaccel;781extern int nouveau_force_post;782extern int nouveau_override_conntype;783extern char *nouveau_perflvl;784extern int nouveau_perflvl_wr;785extern int nouveau_msi;786787extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);788extern int nouveau_pci_resume(struct pci_dev *pdev);789790/* nouveau_state.c */791extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);792extern int nouveau_load(struct drm_device *, unsigned long flags);793extern int nouveau_firstopen(struct drm_device *);794extern void nouveau_lastclose(struct drm_device *);795extern int nouveau_unload(struct drm_device *);796extern int nouveau_ioctl_getparam(struct drm_device *, void *data,797struct drm_file *);798extern int nouveau_ioctl_setparam(struct drm_device *, void *data,799struct drm_file *);800extern bool nouveau_wait_eq(struct drm_device *, uint64_t timeout,801uint32_t reg, uint32_t mask, uint32_t val);802extern bool nouveau_wait_ne(struct drm_device *, uint64_t timeout,803uint32_t reg, uint32_t mask, uint32_t val);804extern bool nouveau_wait_for_idle(struct drm_device *);805extern int nouveau_card_init(struct drm_device *);806807/* nouveau_mem.c */808extern int nouveau_mem_vram_init(struct drm_device *);809extern void nouveau_mem_vram_fini(struct drm_device *);810extern int nouveau_mem_gart_init(struct drm_device *);811extern void nouveau_mem_gart_fini(struct drm_device *);812extern int nouveau_mem_init_agp(struct drm_device *);813extern int nouveau_mem_reset_agp(struct drm_device *);814extern void nouveau_mem_close(struct drm_device *);815extern int nouveau_mem_detect(struct drm_device *);816extern bool nouveau_mem_flags_valid(struct drm_device *, u32 tile_flags);817extern struct nouveau_tile_reg *nv10_mem_set_tiling(818struct drm_device *dev, uint32_t addr, uint32_t size,819uint32_t pitch, uint32_t flags);820extern void nv10_mem_put_tile_region(struct drm_device *dev,821struct nouveau_tile_reg *tile,822struct nouveau_fence *fence);823extern const struct ttm_mem_type_manager_func nouveau_vram_manager;824extern const struct ttm_mem_type_manager_func nouveau_gart_manager;825826/* nouveau_notifier.c */827extern int nouveau_notifier_init_channel(struct nouveau_channel *);828extern void nouveau_notifier_takedown_channel(struct nouveau_channel *);829extern int nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle,830int cout, uint32_t start, uint32_t end,831uint32_t *offset);832extern int nouveau_notifier_offset(struct nouveau_gpuobj *, uint32_t *);833extern int nouveau_ioctl_notifier_alloc(struct drm_device *, void *data,834struct drm_file *);835extern int nouveau_ioctl_notifier_free(struct drm_device *, void *data,836struct drm_file *);837838/* nouveau_channel.c */839extern struct drm_ioctl_desc nouveau_ioctls[];840extern int nouveau_max_ioctl;841extern void nouveau_channel_cleanup(struct drm_device *, struct drm_file *);842extern int nouveau_channel_alloc(struct drm_device *dev,843struct nouveau_channel **chan,844struct drm_file *file_priv,845uint32_t fb_ctxdma, uint32_t tt_ctxdma);846extern struct nouveau_channel *847nouveau_channel_get_unlocked(struct nouveau_channel *);848extern struct nouveau_channel *849nouveau_channel_get(struct drm_device *, struct drm_file *, int id);850extern void nouveau_channel_put_unlocked(struct nouveau_channel **);851extern void nouveau_channel_put(struct nouveau_channel **);852extern void nouveau_channel_ref(struct nouveau_channel *chan,853struct nouveau_channel **pchan);854extern void nouveau_channel_idle(struct nouveau_channel *chan);855856/* nouveau_object.c */857#define NVOBJ_ENGINE_ADD(d, e, p) do { \858struct drm_nouveau_private *dev_priv = (d)->dev_private; \859dev_priv->eng[NVOBJ_ENGINE_##e] = (p); \860} while (0)861862#define NVOBJ_ENGINE_DEL(d, e) do { \863struct drm_nouveau_private *dev_priv = (d)->dev_private; \864dev_priv->eng[NVOBJ_ENGINE_##e] = NULL; \865} while (0)866867#define NVOBJ_CLASS(d, c, e) do { \868int ret = nouveau_gpuobj_class_new((d), (c), NVOBJ_ENGINE_##e); \869if (ret) \870return ret; \871} while (0)872873#define NVOBJ_MTHD(d, c, m, e) do { \874int ret = nouveau_gpuobj_mthd_new((d), (c), (m), (e)); \875if (ret) \876return ret; \877} while (0)878879extern int nouveau_gpuobj_early_init(struct drm_device *);880extern int nouveau_gpuobj_init(struct drm_device *);881extern void nouveau_gpuobj_takedown(struct drm_device *);882extern int nouveau_gpuobj_suspend(struct drm_device *dev);883extern void nouveau_gpuobj_resume(struct drm_device *dev);884extern int nouveau_gpuobj_class_new(struct drm_device *, u32 class, u32 eng);885extern int nouveau_gpuobj_mthd_new(struct drm_device *, u32 class, u32 mthd,886int (*exec)(struct nouveau_channel *,887u32 class, u32 mthd, u32 data));888extern int nouveau_gpuobj_mthd_call(struct nouveau_channel *, u32, u32, u32);889extern int nouveau_gpuobj_mthd_call2(struct drm_device *, int, u32, u32, u32);890extern int nouveau_gpuobj_channel_init(struct nouveau_channel *,891uint32_t vram_h, uint32_t tt_h);892extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *);893extern int nouveau_gpuobj_new(struct drm_device *, struct nouveau_channel *,894uint32_t size, int align, uint32_t flags,895struct nouveau_gpuobj **);896extern void nouveau_gpuobj_ref(struct nouveau_gpuobj *,897struct nouveau_gpuobj **);898extern int nouveau_gpuobj_new_fake(struct drm_device *, u32 pinst, u64 vinst,899u32 size, u32 flags,900struct nouveau_gpuobj **);901extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class,902uint64_t offset, uint64_t size, int access,903int target, struct nouveau_gpuobj **);904extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, u32 handle, int class);905extern int nv50_gpuobj_dma_new(struct nouveau_channel *, int class, u64 base,906u64 size, int target, int access, u32 type,907u32 comp, struct nouveau_gpuobj **pobj);908extern void nv50_gpuobj_dma_init(struct nouveau_gpuobj *, u32 offset,909int class, u64 base, u64 size, int target,910int access, u32 type, u32 comp);911extern int nouveau_ioctl_grobj_alloc(struct drm_device *, void *data,912struct drm_file *);913extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data,914struct drm_file *);915916/* nouveau_irq.c */917extern int nouveau_irq_init(struct drm_device *);918extern void nouveau_irq_fini(struct drm_device *);919extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);920extern void nouveau_irq_register(struct drm_device *, int status_bit,921void (*)(struct drm_device *));922extern void nouveau_irq_unregister(struct drm_device *, int status_bit);923extern void nouveau_irq_preinstall(struct drm_device *);924extern int nouveau_irq_postinstall(struct drm_device *);925extern void nouveau_irq_uninstall(struct drm_device *);926927/* nouveau_sgdma.c */928extern int nouveau_sgdma_init(struct drm_device *);929extern void nouveau_sgdma_takedown(struct drm_device *);930extern uint32_t nouveau_sgdma_get_physical(struct drm_device *,931uint32_t offset);932extern struct ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *);933934/* nouveau_debugfs.c */935#if defined(CONFIG_DRM_NOUVEAU_DEBUG)936extern int nouveau_debugfs_init(struct drm_minor *);937extern void nouveau_debugfs_takedown(struct drm_minor *);938extern int nouveau_debugfs_channel_init(struct nouveau_channel *);939extern void nouveau_debugfs_channel_fini(struct nouveau_channel *);940#else941static inline int942nouveau_debugfs_init(struct drm_minor *minor)943{944return 0;945}946947static inline void nouveau_debugfs_takedown(struct drm_minor *minor)948{949}950951static inline int952nouveau_debugfs_channel_init(struct nouveau_channel *chan)953{954return 0;955}956957static inline void958nouveau_debugfs_channel_fini(struct nouveau_channel *chan)959{960}961#endif962963/* nouveau_dma.c */964extern void nouveau_dma_pre_init(struct nouveau_channel *);965extern int nouveau_dma_init(struct nouveau_channel *);966extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size);967968/* nouveau_acpi.c */969#define ROM_BIOS_PAGE 4096970#if defined(CONFIG_ACPI)971void nouveau_register_dsm_handler(void);972void nouveau_unregister_dsm_handler(void);973int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);974bool nouveau_acpi_rom_supported(struct pci_dev *pdev);975int nouveau_acpi_edid(struct drm_device *, struct drm_connector *);976#else977static inline void nouveau_register_dsm_handler(void) {}978static inline void nouveau_unregister_dsm_handler(void) {}979static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; }980static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }981static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; }982#endif983984/* nouveau_backlight.c */985#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT986extern int nouveau_backlight_init(struct drm_connector *);987extern void nouveau_backlight_exit(struct drm_connector *);988#else989static inline int nouveau_backlight_init(struct drm_connector *dev)990{991return 0;992}993994static inline void nouveau_backlight_exit(struct drm_connector *dev) { }995#endif996997/* nouveau_bios.c */998extern int nouveau_bios_init(struct drm_device *);999extern void nouveau_bios_takedown(struct drm_device *dev);1000extern int nouveau_run_vbios_init(struct drm_device *);1001extern void nouveau_bios_run_init_table(struct drm_device *, uint16_t table,1002struct dcb_entry *);1003extern struct dcb_gpio_entry *nouveau_bios_gpio_entry(struct drm_device *,1004enum dcb_gpio_tag);1005extern struct dcb_connector_table_entry *1006nouveau_bios_connector_entry(struct drm_device *, int index);1007extern u32 get_pll_register(struct drm_device *, enum pll_types);1008extern int get_pll_limits(struct drm_device *, uint32_t limit_match,1009struct pll_lims *);1010extern int nouveau_bios_run_display_table(struct drm_device *,1011struct dcb_entry *,1012uint32_t script, int pxclk);1013extern void *nouveau_bios_dp_table(struct drm_device *, struct dcb_entry *,1014int *length);1015extern bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);1016extern uint8_t *nouveau_bios_embedded_edid(struct drm_device *);1017extern int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,1018bool *dl, bool *if_is_24bit);1019extern int run_tmds_table(struct drm_device *, struct dcb_entry *,1020int head, int pxclk);1021extern int call_lvds_script(struct drm_device *, struct dcb_entry *, int head,1022enum LVDS_script, int pxclk);10231024/* nouveau_ttm.c */1025int nouveau_ttm_global_init(struct drm_nouveau_private *);1026void nouveau_ttm_global_release(struct drm_nouveau_private *);1027int nouveau_ttm_mmap(struct file *, struct vm_area_struct *);10281029/* nouveau_dp.c */1030int nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,1031uint8_t *data, int data_nr);1032bool nouveau_dp_detect(struct drm_encoder *);1033bool nouveau_dp_link_train(struct drm_encoder *);10341035/* nv04_fb.c */1036extern int nv04_fb_init(struct drm_device *);1037extern void nv04_fb_takedown(struct drm_device *);10381039/* nv10_fb.c */1040extern int nv10_fb_init(struct drm_device *);1041extern void nv10_fb_takedown(struct drm_device *);1042extern void nv10_fb_init_tile_region(struct drm_device *dev, int i,1043uint32_t addr, uint32_t size,1044uint32_t pitch, uint32_t flags);1045extern void nv10_fb_set_tile_region(struct drm_device *dev, int i);1046extern void nv10_fb_free_tile_region(struct drm_device *dev, int i);10471048/* nv30_fb.c */1049extern int nv30_fb_init(struct drm_device *);1050extern void nv30_fb_takedown(struct drm_device *);1051extern void nv30_fb_init_tile_region(struct drm_device *dev, int i,1052uint32_t addr, uint32_t size,1053uint32_t pitch, uint32_t flags);1054extern void nv30_fb_free_tile_region(struct drm_device *dev, int i);10551056/* nv40_fb.c */1057extern int nv40_fb_init(struct drm_device *);1058extern void nv40_fb_takedown(struct drm_device *);1059extern void nv40_fb_set_tile_region(struct drm_device *dev, int i);10601061/* nv50_fb.c */1062extern int nv50_fb_init(struct drm_device *);1063extern void nv50_fb_takedown(struct drm_device *);1064extern void nv50_fb_vm_trap(struct drm_device *, int display);10651066/* nvc0_fb.c */1067extern int nvc0_fb_init(struct drm_device *);1068extern void nvc0_fb_takedown(struct drm_device *);10691070/* nv04_fifo.c */1071extern int nv04_fifo_init(struct drm_device *);1072extern void nv04_fifo_fini(struct drm_device *);1073extern void nv04_fifo_disable(struct drm_device *);1074extern void nv04_fifo_enable(struct drm_device *);1075extern bool nv04_fifo_reassign(struct drm_device *, bool);1076extern bool nv04_fifo_cache_pull(struct drm_device *, bool);1077extern int nv04_fifo_channel_id(struct drm_device *);1078extern int nv04_fifo_create_context(struct nouveau_channel *);1079extern void nv04_fifo_destroy_context(struct nouveau_channel *);1080extern int nv04_fifo_load_context(struct nouveau_channel *);1081extern int nv04_fifo_unload_context(struct drm_device *);1082extern void nv04_fifo_isr(struct drm_device *);10831084/* nv10_fifo.c */1085extern int nv10_fifo_init(struct drm_device *);1086extern int nv10_fifo_channel_id(struct drm_device *);1087extern int nv10_fifo_create_context(struct nouveau_channel *);1088extern int nv10_fifo_load_context(struct nouveau_channel *);1089extern int nv10_fifo_unload_context(struct drm_device *);10901091/* nv40_fifo.c */1092extern int nv40_fifo_init(struct drm_device *);1093extern int nv40_fifo_create_context(struct nouveau_channel *);1094extern int nv40_fifo_load_context(struct nouveau_channel *);1095extern int nv40_fifo_unload_context(struct drm_device *);10961097/* nv50_fifo.c */1098extern int nv50_fifo_init(struct drm_device *);1099extern void nv50_fifo_takedown(struct drm_device *);1100extern int nv50_fifo_channel_id(struct drm_device *);1101extern int nv50_fifo_create_context(struct nouveau_channel *);1102extern void nv50_fifo_destroy_context(struct nouveau_channel *);1103extern int nv50_fifo_load_context(struct nouveau_channel *);1104extern int nv50_fifo_unload_context(struct drm_device *);1105extern void nv50_fifo_tlb_flush(struct drm_device *dev);11061107/* nvc0_fifo.c */1108extern int nvc0_fifo_init(struct drm_device *);1109extern void nvc0_fifo_takedown(struct drm_device *);1110extern void nvc0_fifo_disable(struct drm_device *);1111extern void nvc0_fifo_enable(struct drm_device *);1112extern bool nvc0_fifo_reassign(struct drm_device *, bool);1113extern bool nvc0_fifo_cache_pull(struct drm_device *, bool);1114extern int nvc0_fifo_channel_id(struct drm_device *);1115extern int nvc0_fifo_create_context(struct nouveau_channel *);1116extern void nvc0_fifo_destroy_context(struct nouveau_channel *);1117extern int nvc0_fifo_load_context(struct nouveau_channel *);1118extern int nvc0_fifo_unload_context(struct drm_device *);11191120/* nv04_graph.c */1121extern int nv04_graph_create(struct drm_device *);1122extern void nv04_graph_fifo_access(struct drm_device *, bool);1123extern int nv04_graph_object_new(struct nouveau_channel *, int, u32, u16);1124extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan,1125u32 class, u32 mthd, u32 data);1126extern struct nouveau_bitfield nv04_graph_nsource[];11271128/* nv10_graph.c */1129extern int nv10_graph_create(struct drm_device *);1130extern struct nouveau_channel *nv10_graph_channel(struct drm_device *);1131extern struct nouveau_bitfield nv10_graph_intr[];1132extern struct nouveau_bitfield nv10_graph_nstatus[];11331134/* nv20_graph.c */1135extern int nv20_graph_create(struct drm_device *);11361137/* nv40_graph.c */1138extern int nv40_graph_create(struct drm_device *);1139extern void nv40_grctx_init(struct nouveau_grctx *);11401141/* nv50_graph.c */1142extern int nv50_graph_create(struct drm_device *);1143extern int nv50_grctx_init(struct nouveau_grctx *);1144extern struct nouveau_enum nv50_data_error_names[];1145extern int nv50_graph_isr_chid(struct drm_device *dev, u64 inst);11461147/* nvc0_graph.c */1148extern int nvc0_graph_create(struct drm_device *);1149extern int nvc0_graph_isr_chid(struct drm_device *dev, u64 inst);11501151/* nv84_crypt.c */1152extern int nv84_crypt_create(struct drm_device *);11531154/* nva3_copy.c */1155extern int nva3_copy_create(struct drm_device *dev);11561157/* nvc0_copy.c */1158extern int nvc0_copy_create(struct drm_device *dev, int engine);11591160/* nv40_mpeg.c */1161extern int nv40_mpeg_create(struct drm_device *dev);11621163/* nv50_mpeg.c */1164extern int nv50_mpeg_create(struct drm_device *dev);11651166/* nv04_instmem.c */1167extern int nv04_instmem_init(struct drm_device *);1168extern void nv04_instmem_takedown(struct drm_device *);1169extern int nv04_instmem_suspend(struct drm_device *);1170extern void nv04_instmem_resume(struct drm_device *);1171extern int nv04_instmem_get(struct nouveau_gpuobj *, u32 size, u32 align);1172extern void nv04_instmem_put(struct nouveau_gpuobj *);1173extern int nv04_instmem_map(struct nouveau_gpuobj *);1174extern void nv04_instmem_unmap(struct nouveau_gpuobj *);1175extern void nv04_instmem_flush(struct drm_device *);11761177/* nv50_instmem.c */1178extern int nv50_instmem_init(struct drm_device *);1179extern void nv50_instmem_takedown(struct drm_device *);1180extern int nv50_instmem_suspend(struct drm_device *);1181extern void nv50_instmem_resume(struct drm_device *);1182extern int nv50_instmem_get(struct nouveau_gpuobj *, u32 size, u32 align);1183extern void nv50_instmem_put(struct nouveau_gpuobj *);1184extern int nv50_instmem_map(struct nouveau_gpuobj *);1185extern void nv50_instmem_unmap(struct nouveau_gpuobj *);1186extern void nv50_instmem_flush(struct drm_device *);1187extern void nv84_instmem_flush(struct drm_device *);11881189/* nvc0_instmem.c */1190extern int nvc0_instmem_init(struct drm_device *);1191extern void nvc0_instmem_takedown(struct drm_device *);1192extern int nvc0_instmem_suspend(struct drm_device *);1193extern void nvc0_instmem_resume(struct drm_device *);11941195/* nv04_mc.c */1196extern int nv04_mc_init(struct drm_device *);1197extern void nv04_mc_takedown(struct drm_device *);11981199/* nv40_mc.c */1200extern int nv40_mc_init(struct drm_device *);1201extern void nv40_mc_takedown(struct drm_device *);12021203/* nv50_mc.c */1204extern int nv50_mc_init(struct drm_device *);1205extern void nv50_mc_takedown(struct drm_device *);12061207/* nv04_timer.c */1208extern int nv04_timer_init(struct drm_device *);1209extern uint64_t nv04_timer_read(struct drm_device *);1210extern void nv04_timer_takedown(struct drm_device *);12111212extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,1213unsigned long arg);12141215/* nv04_dac.c */1216extern int nv04_dac_create(struct drm_connector *, struct dcb_entry *);1217extern uint32_t nv17_dac_sample_load(struct drm_encoder *encoder);1218extern int nv04_dac_output_offset(struct drm_encoder *encoder);1219extern void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable);1220extern bool nv04_dac_in_use(struct drm_encoder *encoder);12211222/* nv04_dfp.c */1223extern int nv04_dfp_create(struct drm_connector *, struct dcb_entry *);1224extern int nv04_dfp_get_bound_head(struct drm_device *dev, struct dcb_entry *dcbent);1225extern void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_entry *dcbent,1226int head, bool dl);1227extern void nv04_dfp_disable(struct drm_device *dev, int head);1228extern void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode);12291230/* nv04_tv.c */1231extern int nv04_tv_identify(struct drm_device *dev, int i2c_index);1232extern int nv04_tv_create(struct drm_connector *, struct dcb_entry *);12331234/* nv17_tv.c */1235extern int nv17_tv_create(struct drm_connector *, struct dcb_entry *);12361237/* nv04_display.c */1238extern int nv04_display_early_init(struct drm_device *);1239extern void nv04_display_late_takedown(struct drm_device *);1240extern int nv04_display_create(struct drm_device *);1241extern int nv04_display_init(struct drm_device *);1242extern void nv04_display_destroy(struct drm_device *);12431244/* nv04_crtc.c */1245extern int nv04_crtc_create(struct drm_device *, int index);12461247/* nouveau_bo.c */1248extern struct ttm_bo_driver nouveau_bo_driver;1249extern int nouveau_bo_new(struct drm_device *, struct nouveau_channel *,1250int size, int align, uint32_t flags,1251uint32_t tile_mode, uint32_t tile_flags,1252struct nouveau_bo **);1253extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags);1254extern int nouveau_bo_unpin(struct nouveau_bo *);1255extern int nouveau_bo_map(struct nouveau_bo *);1256extern void nouveau_bo_unmap(struct nouveau_bo *);1257extern void nouveau_bo_placement_set(struct nouveau_bo *, uint32_t type,1258uint32_t busy);1259extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index);1260extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val);1261extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index);1262extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val);1263extern void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);1264extern int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,1265bool no_wait_reserve, bool no_wait_gpu);12661267/* nouveau_fence.c */1268struct nouveau_fence;1269extern int nouveau_fence_init(struct drm_device *);1270extern void nouveau_fence_fini(struct drm_device *);1271extern int nouveau_fence_channel_init(struct nouveau_channel *);1272extern void nouveau_fence_channel_fini(struct nouveau_channel *);1273extern void nouveau_fence_update(struct nouveau_channel *);1274extern int nouveau_fence_new(struct nouveau_channel *, struct nouveau_fence **,1275bool emit);1276extern int nouveau_fence_emit(struct nouveau_fence *);1277extern void nouveau_fence_work(struct nouveau_fence *fence,1278void (*work)(void *priv, bool signalled),1279void *priv);1280struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *);12811282extern bool __nouveau_fence_signalled(void *obj, void *arg);1283extern int __nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);1284extern int __nouveau_fence_flush(void *obj, void *arg);1285extern void __nouveau_fence_unref(void **obj);1286extern void *__nouveau_fence_ref(void *obj);12871288static inline bool nouveau_fence_signalled(struct nouveau_fence *obj)1289{1290return __nouveau_fence_signalled(obj, NULL);1291}1292static inline int1293nouveau_fence_wait(struct nouveau_fence *obj, bool lazy, bool intr)1294{1295return __nouveau_fence_wait(obj, NULL, lazy, intr);1296}1297extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);1298static inline int nouveau_fence_flush(struct nouveau_fence *obj)1299{1300return __nouveau_fence_flush(obj, NULL);1301}1302static inline void nouveau_fence_unref(struct nouveau_fence **obj)1303{1304__nouveau_fence_unref((void **)obj);1305}1306static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj)1307{1308return __nouveau_fence_ref(obj);1309}13101311/* nouveau_gem.c */1312extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,1313int size, int align, uint32_t domain,1314uint32_t tile_mode, uint32_t tile_flags,1315struct nouveau_bo **);1316extern int nouveau_gem_object_new(struct drm_gem_object *);1317extern void nouveau_gem_object_del(struct drm_gem_object *);1318extern int nouveau_gem_ioctl_new(struct drm_device *, void *,1319struct drm_file *);1320extern int nouveau_gem_ioctl_pushbuf(struct drm_device *, void *,1321struct drm_file *);1322extern int nouveau_gem_ioctl_cpu_prep(struct drm_device *, void *,1323struct drm_file *);1324extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *,1325struct drm_file *);1326extern int nouveau_gem_ioctl_info(struct drm_device *, void *,1327struct drm_file *);13281329/* nouveau_display.c */1330int nouveau_vblank_enable(struct drm_device *dev, int crtc);1331void nouveau_vblank_disable(struct drm_device *dev, int crtc);1332int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,1333struct drm_pending_vblank_event *event);1334int nouveau_finish_page_flip(struct nouveau_channel *,1335struct nouveau_page_flip_state *);13361337/* nv10_gpio.c */1338int nv10_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);1339int nv10_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);13401341/* nv50_gpio.c */1342int nv50_gpio_init(struct drm_device *dev);1343void nv50_gpio_fini(struct drm_device *dev);1344int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);1345int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);1346int nv50_gpio_irq_register(struct drm_device *, enum dcb_gpio_tag,1347void (*)(void *, int), void *);1348void nv50_gpio_irq_unregister(struct drm_device *, enum dcb_gpio_tag,1349void (*)(void *, int), void *);1350bool nv50_gpio_irq_enable(struct drm_device *, enum dcb_gpio_tag, bool on);13511352/* nv50_calc. */1353int nv50_calc_pll(struct drm_device *, struct pll_lims *, int clk,1354int *N1, int *M1, int *N2, int *M2, int *P);1355int nva3_calc_pll(struct drm_device *, struct pll_lims *,1356int clk, int *N, int *fN, int *M, int *P);13571358#ifndef ioread32_native1359#ifdef __BIG_ENDIAN1360#define ioread16_native ioread16be1361#define iowrite16_native iowrite16be1362#define ioread32_native ioread32be1363#define iowrite32_native iowrite32be1364#else /* def __BIG_ENDIAN */1365#define ioread16_native ioread161366#define iowrite16_native iowrite161367#define ioread32_native ioread321368#define iowrite32_native iowrite321369#endif /* def __BIG_ENDIAN else */1370#endif /* !ioread32_native */13711372/* channel control reg access */1373static inline u32 nvchan_rd32(struct nouveau_channel *chan, unsigned reg)1374{1375return ioread32_native(chan->user + reg);1376}13771378static inline void nvchan_wr32(struct nouveau_channel *chan,1379unsigned reg, u32 val)1380{1381iowrite32_native(val, chan->user + reg);1382}13831384/* register access */1385static inline u32 nv_rd32(struct drm_device *dev, unsigned reg)1386{1387struct drm_nouveau_private *dev_priv = dev->dev_private;1388return ioread32_native(dev_priv->mmio + reg);1389}13901391static inline void nv_wr32(struct drm_device *dev, unsigned reg, u32 val)1392{1393struct drm_nouveau_private *dev_priv = dev->dev_private;1394iowrite32_native(val, dev_priv->mmio + reg);1395}13961397static inline u32 nv_mask(struct drm_device *dev, u32 reg, u32 mask, u32 val)1398{1399u32 tmp = nv_rd32(dev, reg);1400nv_wr32(dev, reg, (tmp & ~mask) | val);1401return tmp;1402}14031404static inline u8 nv_rd08(struct drm_device *dev, unsigned reg)1405{1406struct drm_nouveau_private *dev_priv = dev->dev_private;1407return ioread8(dev_priv->mmio + reg);1408}14091410static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val)1411{1412struct drm_nouveau_private *dev_priv = dev->dev_private;1413iowrite8(val, dev_priv->mmio + reg);1414}14151416#define nv_wait(dev, reg, mask, val) \1417nouveau_wait_eq(dev, 2000000000ULL, (reg), (mask), (val))1418#define nv_wait_ne(dev, reg, mask, val) \1419nouveau_wait_ne(dev, 2000000000ULL, (reg), (mask), (val))14201421/* PRAMIN access */1422static inline u32 nv_ri32(struct drm_device *dev, unsigned offset)1423{1424struct drm_nouveau_private *dev_priv = dev->dev_private;1425return ioread32_native(dev_priv->ramin + offset);1426}14271428static inline void nv_wi32(struct drm_device *dev, unsigned offset, u32 val)1429{1430struct drm_nouveau_private *dev_priv = dev->dev_private;1431iowrite32_native(val, dev_priv->ramin + offset);1432}14331434/* object access */1435extern u32 nv_ro32(struct nouveau_gpuobj *, u32 offset);1436extern void nv_wo32(struct nouveau_gpuobj *, u32 offset, u32 val);14371438/*1439* Logging1440* Argument d is (struct drm_device *).1441*/1442#define NV_PRINTK(level, d, fmt, arg...) \1443printk(level "[" DRM_NAME "] " DRIVER_NAME " %s: " fmt, \1444pci_name(d->pdev), ##arg)1445#ifndef NV_DEBUG_NOTRACE1446#define NV_DEBUG(d, fmt, arg...) do { \1447if (drm_debug & DRM_UT_DRIVER) { \1448NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \1449__LINE__, ##arg); \1450} \1451} while (0)1452#define NV_DEBUG_KMS(d, fmt, arg...) do { \1453if (drm_debug & DRM_UT_KMS) { \1454NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \1455__LINE__, ##arg); \1456} \1457} while (0)1458#else1459#define NV_DEBUG(d, fmt, arg...) do { \1460if (drm_debug & DRM_UT_DRIVER) \1461NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \1462} while (0)1463#define NV_DEBUG_KMS(d, fmt, arg...) do { \1464if (drm_debug & DRM_UT_KMS) \1465NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \1466} while (0)1467#endif1468#define NV_ERROR(d, fmt, arg...) NV_PRINTK(KERN_ERR, d, fmt, ##arg)1469#define NV_INFO(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)1470#define NV_TRACEWARN(d, fmt, arg...) NV_PRINTK(KERN_NOTICE, d, fmt, ##arg)1471#define NV_TRACE(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)1472#define NV_WARN(d, fmt, arg...) NV_PRINTK(KERN_WARNING, d, fmt, ##arg)14731474/* nouveau_reg_debug bitmask */1475enum {1476NOUVEAU_REG_DEBUG_MC = 0x1,1477NOUVEAU_REG_DEBUG_VIDEO = 0x2,1478NOUVEAU_REG_DEBUG_FB = 0x4,1479NOUVEAU_REG_DEBUG_EXTDEV = 0x8,1480NOUVEAU_REG_DEBUG_CRTC = 0x10,1481NOUVEAU_REG_DEBUG_RAMDAC = 0x20,1482NOUVEAU_REG_DEBUG_VGACRTC = 0x40,1483NOUVEAU_REG_DEBUG_RMVIO = 0x80,1484NOUVEAU_REG_DEBUG_VGAATTR = 0x100,1485NOUVEAU_REG_DEBUG_EVO = 0x200,1486};14871488#define NV_REG_DEBUG(type, dev, fmt, arg...) do { \1489if (nouveau_reg_debug & NOUVEAU_REG_DEBUG_##type) \1490NV_PRINTK(KERN_DEBUG, dev, "%s: " fmt, __func__, ##arg); \1491} while (0)14921493static inline bool1494nv_two_heads(struct drm_device *dev)1495{1496struct drm_nouveau_private *dev_priv = dev->dev_private;1497const int impl = dev->pci_device & 0x0ff0;14981499if (dev_priv->card_type >= NV_10 && impl != 0x0100 &&1500impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)1501return true;15021503return false;1504}15051506static inline bool1507nv_gf4_disp_arch(struct drm_device *dev)1508{1509return nv_two_heads(dev) && (dev->pci_device & 0x0ff0) != 0x0110;1510}15111512static inline bool1513nv_two_reg_pll(struct drm_device *dev)1514{1515struct drm_nouveau_private *dev_priv = dev->dev_private;1516const int impl = dev->pci_device & 0x0ff0;15171518if (impl == 0x0310 || impl == 0x0340 || dev_priv->card_type >= NV_40)1519return true;1520return false;1521}15221523static inline bool1524nv_match_device(struct drm_device *dev, unsigned device,1525unsigned sub_vendor, unsigned sub_device)1526{1527return dev->pdev->device == device &&1528dev->pdev->subsystem_vendor == sub_vendor &&1529dev->pdev->subsystem_device == sub_device;1530}15311532static inline void *1533nv_engine(struct drm_device *dev, int engine)1534{1535struct drm_nouveau_private *dev_priv = dev->dev_private;1536return (void *)dev_priv->eng[engine];1537}15381539/* returns 1 if device is one of the nv4x using the 0x4497 object class,1540* helpful to determine a number of other hardware features1541*/1542static inline int1543nv44_graph_class(struct drm_device *dev)1544{1545struct drm_nouveau_private *dev_priv = dev->dev_private;15461547if ((dev_priv->chipset & 0xf0) == 0x60)1548return 1;15491550return !(0x0baf & (1 << (dev_priv->chipset & 0x0f)));1551}15521553/* memory type/access flags, do not match hardware values */1554#define NV_MEM_ACCESS_RO 11555#define NV_MEM_ACCESS_WO 21556#define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO)1557#define NV_MEM_ACCESS_SYS 41558#define NV_MEM_ACCESS_VM 815591560#define NV_MEM_TARGET_VRAM 01561#define NV_MEM_TARGET_PCI 11562#define NV_MEM_TARGET_PCI_NOSNOOP 21563#define NV_MEM_TARGET_VM 31564#define NV_MEM_TARGET_GART 415651566#define NV_MEM_TYPE_VM 0x7f1567#define NV_MEM_COMP_VM 0x0315681569/* NV_SW object class */1570#define NV_SW 0x0000506e1571#define NV_SW_DMA_SEMAPHORE 0x000000601572#define NV_SW_SEMAPHORE_OFFSET 0x000000641573#define NV_SW_SEMAPHORE_ACQUIRE 0x000000681574#define NV_SW_SEMAPHORE_RELEASE 0x0000006c1575#define NV_SW_YIELD 0x000000801576#define NV_SW_DMA_VBLSEM 0x0000018c1577#define NV_SW_VBLSEM_OFFSET 0x000004001578#define NV_SW_VBLSEM_RELEASE_VALUE 0x000004041579#define NV_SW_VBLSEM_RELEASE 0x000004081580#define NV_SW_PAGE_FLIP 0x0000050015811582#endif /* __NOUVEAU_DRV_H__ */158315841585