xref: /linux/drivers/gpu/nova-core/fb/hal.rs (revision 220994d61cebfc04f071d69049127657c7e8191b)
16554ad65SAlexandre Courbot // SPDX-License-Identifier: GPL-2.0
26554ad65SAlexandre Courbot 
36554ad65SAlexandre Courbot use kernel::prelude::*;
46554ad65SAlexandre Courbot 
56554ad65SAlexandre Courbot use crate::driver::Bar0;
66554ad65SAlexandre Courbot use crate::gpu::Chipset;
76554ad65SAlexandre Courbot 
86554ad65SAlexandre Courbot mod ga100;
9*80213934SAlexandre Courbot mod ga102;
106554ad65SAlexandre Courbot mod tu102;
116554ad65SAlexandre Courbot 
126554ad65SAlexandre Courbot pub(crate) trait FbHal {
136554ad65SAlexandre Courbot     /// Returns the address of the currently-registered sysmem flush page.
read_sysmem_flush_page(&self, bar: &Bar0) -> u64146554ad65SAlexandre Courbot     fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64;
156554ad65SAlexandre Courbot 
166554ad65SAlexandre Courbot     /// Register `addr` as the address of the sysmem flush page.
176554ad65SAlexandre Courbot     ///
186554ad65SAlexandre Courbot     /// This might fail if the address is too large for the receiving register.
write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result196554ad65SAlexandre Courbot     fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result;
20*80213934SAlexandre Courbot 
21*80213934SAlexandre Courbot     /// Returns `true` is display is supported.
supports_display(&self, bar: &Bar0) -> bool22*80213934SAlexandre Courbot     fn supports_display(&self, bar: &Bar0) -> bool;
23*80213934SAlexandre Courbot 
24*80213934SAlexandre Courbot     /// Returns the VRAM size, in bytes.
vidmem_size(&self, bar: &Bar0) -> u6425*80213934SAlexandre Courbot     fn vidmem_size(&self, bar: &Bar0) -> u64;
266554ad65SAlexandre Courbot }
276554ad65SAlexandre Courbot 
286554ad65SAlexandre Courbot /// Returns the HAL corresponding to `chipset`.
fb_hal(chipset: Chipset) -> &'static dyn FbHal296554ad65SAlexandre Courbot pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
306554ad65SAlexandre Courbot     use Chipset::*;
316554ad65SAlexandre Courbot 
326554ad65SAlexandre Courbot     match chipset {
336554ad65SAlexandre Courbot         TU102 | TU104 | TU106 | TU117 | TU116 => tu102::TU102_HAL,
34*80213934SAlexandre Courbot         GA100 => ga100::GA100_HAL,
35*80213934SAlexandre Courbot         GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => {
36*80213934SAlexandre Courbot             ga102::GA102_HAL
376554ad65SAlexandre Courbot         }
386554ad65SAlexandre Courbot     }
396554ad65SAlexandre Courbot }
40