1 /* 2 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 * Copyright (C) 2013 Red Hat 4 * Author: Rob Clark <robdclark@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 * 15 * You should have received a copy of the GNU General Public License along with 16 * this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __MDP5_SMP_H__ 20 #define __MDP5_SMP_H__ 21 22 #include <drm/drm_print.h> 23 24 #include "msm_drv.h" 25 26 /* 27 * SMP - Shared Memory Pool: 28 * 29 * SMP blocks are shared between all the clients, where each plane in 30 * a scanout buffer is a SMP client. Ie. scanout of 3 plane I420 on 31 * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR. 32 * 33 * Based on the size of the attached scanout buffer, a certain # of 34 * blocks must be allocated to that client out of the shared pool. 35 * 36 * In some hw, some blocks are statically allocated for certain pipes 37 * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0). 38 * 39 * 40 * Atomic SMP State: 41 * 42 * On atomic updates that modify SMP configuration, the state is cloned 43 * (copied) and modified. For test-only, or in cases where atomic 44 * update fails (or if we hit ww_mutex deadlock/backoff condition) the 45 * new state is simply thrown away. 46 * 47 * Because the SMP registers are not double buffered, updates are a 48 * two step process: 49 * 50 * 1) in _prepare_commit() we configure things (via read-modify-write) 51 * for the newly assigned pipes, so we don't take away blocks 52 * assigned to pipes that are still scanning out 53 * 2) in _complete_commit(), after vblank/etc, we clear things for the 54 * released clients, since at that point old pipes are no longer 55 * scanning out. 56 */ 57 struct mdp5_smp_state { 58 /* global state of what blocks are in use: */ 59 mdp5_smp_state_t state; 60 61 /* per client state of what blocks they are using: */ 62 mdp5_smp_state_t client_state[MAX_CLIENTS]; 63 64 /* assigned pipes (hw updated at _prepare_commit()): */ 65 unsigned long assigned; 66 67 /* released pipes (hw updated at _complete_commit()): */ 68 unsigned long released; 69 }; 70 71 struct mdp5_kms; 72 struct mdp5_smp; 73 74 /* 75 * SMP module prototypes: 76 * mdp5_smp_init() returns a SMP @handler, 77 * which is then used to call the other mdp5_smp_*(handler, ...) functions. 78 */ 79 80 struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, 81 const struct mdp5_smp_block *cfg); 82 void mdp5_smp_destroy(struct mdp5_smp *smp); 83 84 void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p); 85 86 uint32_t mdp5_smp_calculate(struct mdp5_smp *smp, 87 const struct mdp_format *format, 88 u32 width, bool hdecim); 89 90 int mdp5_smp_assign(struct mdp5_smp *smp, struct mdp5_smp_state *state, 91 enum mdp5_pipe pipe, uint32_t blkcfg); 92 void mdp5_smp_release(struct mdp5_smp *smp, struct mdp5_smp_state *state, 93 enum mdp5_pipe pipe); 94 95 void mdp5_smp_prepare_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state); 96 void mdp5_smp_complete_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state); 97 98 #endif /* __MDP5_SMP_H__ */ 99