1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2013 Red Hat
5 * Author: Rob Clark <robdclark@gmail.com>
11 #include <drm/drm_print.h>
16 * SMP - Shared Memory Pool:
18 * SMP blocks are shared between all the clients, where each plane in
19 * a scanout buffer is a SMP client. Ie. scanout of 3 plane I420 on
20 * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR.
22 * Based on the size of the attached scanout buffer, a certain # of
23 * blocks must be allocated to that client out of the shared pool.
25 * In some hw, some blocks are statically allocated for certain pipes
26 * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0).
31 * On atomic updates that modify SMP configuration, the state is cloned
32 * (copied) and modified. For test-only, or in cases where atomic
33 * update fails (or if we hit ww_mutex deadlock/backoff condition) the
34 * new state is simply thrown away.
36 * Because the SMP registers are not double buffered, updates are a
39 * 1) in _prepare_commit() we configure things (via read-modify-write)
40 * for the newly assigned pipes, so we don't take away blocks
41 * assigned to pipes that are still scanning out
42 * 2) in _complete_commit(), after vblank/etc, we clear things for the
43 * released clients, since at that point old pipes are no longer
46 struct mdp5_smp_state
{
47 /* global state of what blocks are in use: */
48 mdp5_smp_state_t state
;
50 /* per client state of what blocks they are using: */
51 mdp5_smp_state_t client_state
[MAX_CLIENTS
];
53 /* assigned pipes (hw updated at _prepare_commit()): */
54 unsigned long assigned
;
56 /* released pipes (hw updated at _complete_commit()): */
57 unsigned long released
;
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.
69 struct mdp5_smp
*mdp5_smp_init(struct mdp5_kms
*mdp5_kms
,
70 const struct mdp5_smp_block
*cfg
);
71 void mdp5_smp_destroy(struct mdp5_smp
*smp
);
73 void mdp5_smp_dump(struct mdp5_smp
*smp
, struct drm_printer
*p
);
75 uint32_t mdp5_smp_calculate(struct mdp5_smp
*smp
,
76 const struct mdp_format
*format
,
77 u32 width
, bool hdecim
);
79 int mdp5_smp_assign(struct mdp5_smp
*smp
, struct mdp5_smp_state
*state
,
80 enum mdp5_pipe pipe
, uint32_t blkcfg
);
81 void mdp5_smp_release(struct mdp5_smp
*smp
, struct mdp5_smp_state
*state
,
84 void mdp5_smp_prepare_commit(struct mdp5_smp
*smp
, struct mdp5_smp_state
*state
);
85 void mdp5_smp_complete_commit(struct mdp5_smp
*smp
, struct mdp5_smp_state
*state
);
87 #endif /* __MDP5_SMP_H__ */