1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <ddk/protocol/display/controller.h> 8 #include <ddktl/device.h> 9 #include <ddktl/mmio.h> 10 #include <lib/edid/edid.h> 11 #include <region-alloc/region-alloc.h> 12 #include <lib/zx/vmo.h> 13 14 #include "gtt.h" 15 #include "power.h" 16 #include "registers-ddi.h" 17 #include "registers-pipe.h" 18 #include "registers-transcoder.h" 19 20 namespace i915 { 21 22 class Controller; 23 class DisplayDevice; 24 25 class Pipe { 26 public: 27 Pipe(Controller* device, registers::Pipe pipe); Pipe(const i915::Pipe & other)28 Pipe(const i915::Pipe& other) : Pipe(other.controller_, other.pipe_) {} 29 30 void AttachToDisplay(uint64_t display_id, bool is_edp); 31 void Detach(); 32 33 void ApplyModeConfig(const display_mode_t& mode); 34 void ApplyConfiguration(const display_config_t* config); 35 36 void Init(); 37 void Resume(); 38 void Reset(); 39 40 void LoadActiveMode(display_mode_t* mode); 41 pipe()42 registers::Pipe pipe() const { return pipe_; } transcoder()43 registers::Trans transcoder() const { 44 return attached_edp_ ? registers::TRANS_EDP : static_cast<registers::Trans>(pipe_); 45 } controller()46 Controller* controller() { return controller_; } 47 attached_display_id()48 uint64_t attached_display_id() const { return attached_display_; } in_use()49 bool in_use() const { return attached_display_ != INVALID_DISPLAY_ID; } 50 51 private: 52 ddk::MmioBuffer* mmio_space() const; 53 54 void ConfigurePrimaryPlane(uint32_t plane_num, const primary_layer_t* primary, 55 bool enable_csc, bool* scaler_1_claimed, 56 registers::pipe_arming_regs* regs); 57 void ConfigureCursorPlane(const cursor_layer_t* cursor, bool enable_csc, 58 registers::pipe_arming_regs* regs); 59 void SetColorConversionOffsets(bool preoffsets, const float vals[3]); 60 61 // Borrowed reference to Controller instance 62 Controller* controller_; 63 64 uint64_t attached_display_ = INVALID_DISPLAY_ID; 65 bool attached_edp_ = false; 66 67 registers::Pipe pipe_; 68 69 PowerWellRef pipe_power_; 70 71 // For any scaled planes, this contains the (1-based) index of the active scaler 72 uint32_t scaled_planes_[registers::kPipeCount][registers::kImagePlaneCount] = {}; 73 }; 74 75 } // namespace i915 76