hal.rs 1.1 KB

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