1 // SPDX-License-Identifier: GPL-2.0 2 3 use kernel::prelude::*; 4 5 use crate::{ 6 driver::Bar0, 7 gpu::Chipset, // 8 }; 9 10 mod ga100; 11 mod ga102; 12 mod tu102; 13 14 pub(crate) trait FbHal { 15 /// Returns the address of the currently-registered sysmem flush page. 16 fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64; 17 18 /// Register `addr` as the address of the sysmem flush page. 19 /// 20 /// This might fail if the address is too large for the receiving register. 21 fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result; 22 23 /// Returns `true` is display is supported. 24 fn supports_display(&self, bar: &Bar0) -> bool; 25 26 /// Returns the VRAM size, in bytes. 27 fn vidmem_size(&self, bar: &Bar0) -> u64; 28 } 29 30 /// Returns the HAL corresponding to `chipset`. 31 pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal { 32 use Chipset::*; 33 34 match chipset { 35 TU102 | TU104 | TU106 | TU117 | TU116 => tu102::TU102_HAL, 36 GA100 => ga100::GA100_HAL, 37 GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => { 38 ga102::GA102_HAL 39 } 40 } 41 } 42