89 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.4 * Copyright (C) 2013 Red Hat5 * Author: Rob Clark <robdclark@gmail.com>6 */7 8#ifndef __MDP5_SMP_H__9#define __MDP5_SMP_H__10 11#include <drm/drm_print.h>12 13#include "msm_drv.h"14 15/*16 * SMP - Shared Memory Pool:17 *18 * SMP blocks are shared between all the clients, where each plane in19 * a scanout buffer is a SMP client. Ie. scanout of 3 plane I420 on20 * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR.21 *22 * Based on the size of the attached scanout buffer, a certain # of23 * blocks must be allocated to that client out of the shared pool.24 *25 * In some hw, some blocks are statically allocated for certain pipes26 * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0).27 *28 *29 * Atomic SMP State:30 *31 * On atomic updates that modify SMP configuration, the state is cloned32 * (copied) and modified. For test-only, or in cases where atomic33 * update fails (or if we hit ww_mutex deadlock/backoff condition) the34 * new state is simply thrown away.35 *36 * Because the SMP registers are not double buffered, updates are a37 * two step process:38 *39 * 1) in _prepare_commit() we configure things (via read-modify-write)40 * for the newly assigned pipes, so we don't take away blocks41 * assigned to pipes that are still scanning out42 * 2) in _complete_commit(), after vblank/etc, we clear things for the43 * released clients, since at that point old pipes are no longer44 * scanning out.45 */46struct mdp5_smp_state {47 /* global state of what blocks are in use: */48 mdp5_smp_state_t state;49 50 /* per client state of what blocks they are using: */51 mdp5_smp_state_t client_state[MAX_CLIENTS];52 53 /* assigned pipes (hw updated at _prepare_commit()): */54 unsigned long assigned;55 56 /* released pipes (hw updated at _complete_commit()): */57 unsigned long released;58};59 60struct mdp5_kms;61struct mdp5_smp;62 63/*64 * SMP module prototypes:65 * mdp5_smp_init() returns a SMP @handler,66 * which is then used to call the other mdp5_smp_*(handler, ...) functions.67 */68 69struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms,70 const struct mdp5_smp_block *cfg);71 72struct mdp5_global_state;73void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p,74 struct mdp5_global_state *global_state);75 76uint32_t mdp5_smp_calculate(struct mdp5_smp *smp,77 const struct msm_format *format,78 u32 width, bool hdecim);79 80int mdp5_smp_assign(struct mdp5_smp *smp, struct mdp5_smp_state *state,81 enum mdp5_pipe pipe, uint32_t blkcfg);82void mdp5_smp_release(struct mdp5_smp *smp, struct mdp5_smp_state *state,83 enum mdp5_pipe pipe);84 85void mdp5_smp_prepare_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);86void mdp5_smp_complete_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);87 88#endif /* __MDP5_SMP_H__ */89