Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2014, The Linux Foundation. All rights reserved.
0004  * Copyright (C) 2013 Red Hat
0005  * Author: Rob Clark <robdclark@gmail.com>
0006  */
0007 
0008 #ifndef __MDP5_SMP_H__
0009 #define __MDP5_SMP_H__
0010 
0011 #include <drm/drm_print.h>
0012 
0013 #include "msm_drv.h"
0014 
0015 /*
0016  * SMP - Shared Memory Pool:
0017  *
0018  * SMP blocks are shared between all the clients, where each plane in
0019  * a scanout buffer is a SMP client.  Ie. scanout of 3 plane I420 on
0020  * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR.
0021  *
0022  * Based on the size of the attached scanout buffer, a certain # of
0023  * blocks must be allocated to that client out of the shared pool.
0024  *
0025  * In some hw, some blocks are statically allocated for certain pipes
0026  * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0).
0027  *
0028  *
0029  * Atomic SMP State:
0030  *
0031  * On atomic updates that modify SMP configuration, the state is cloned
0032  * (copied) and modified.  For test-only, or in cases where atomic
0033  * update fails (or if we hit ww_mutex deadlock/backoff condition) the
0034  * new state is simply thrown away.
0035  *
0036  * Because the SMP registers are not double buffered, updates are a
0037  * two step process:
0038  *
0039  * 1) in _prepare_commit() we configure things (via read-modify-write)
0040  *    for the newly assigned pipes, so we don't take away blocks
0041  *    assigned to pipes that are still scanning out
0042  * 2) in _complete_commit(), after vblank/etc, we clear things for the
0043  *    released clients, since at that point old pipes are no longer
0044  *    scanning out.
0045  */
0046 struct mdp5_smp_state {
0047     /* global state of what blocks are in use: */
0048     mdp5_smp_state_t state;
0049 
0050     /* per client state of what blocks they are using: */
0051     mdp5_smp_state_t client_state[MAX_CLIENTS];
0052 
0053     /* assigned pipes (hw updated at _prepare_commit()): */
0054     unsigned long assigned;
0055 
0056     /* released pipes (hw updated at _complete_commit()): */
0057     unsigned long released;
0058 };
0059 
0060 struct mdp5_kms;
0061 struct mdp5_smp;
0062 
0063 /*
0064  * SMP module prototypes:
0065  * mdp5_smp_init() returns a SMP @handler,
0066  * which is then used to call the other mdp5_smp_*(handler, ...) functions.
0067  */
0068 
0069 struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms,
0070         const struct mdp5_smp_block *cfg);
0071 void  mdp5_smp_destroy(struct mdp5_smp *smp);
0072 
0073 void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p);
0074 
0075 uint32_t mdp5_smp_calculate(struct mdp5_smp *smp,
0076         const struct mdp_format *format,
0077         u32 width, bool hdecim);
0078 
0079 int mdp5_smp_assign(struct mdp5_smp *smp, struct mdp5_smp_state *state,
0080         enum mdp5_pipe pipe, uint32_t blkcfg);
0081 void mdp5_smp_release(struct mdp5_smp *smp, struct mdp5_smp_state *state,
0082         enum mdp5_pipe pipe);
0083 
0084 void mdp5_smp_prepare_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);
0085 void mdp5_smp_complete_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);
0086 
0087 #endif /* __MDP5_SMP_H__ */