mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 15:43:08 -04:00
drm/amd/display: Introduce dc_state_get_status unified status accessor
[Why] dc_state_get_stream_status() is typed against streams only, leaving no extensible slot for future status classes. The public status accessor signature needs to stay stable as new status classes are added. [How] Add a dc_get_status_type bitmask and the dc_get_status_options / dc_state_status structs. Implement dc_state_get_status() to populate the output object per the options bitmask, and make dc_state_get_stream_status() a shim over it. Reviewed-by: Dominik Kaszewski <dominik.kaszewski@amd.com> Signed-off-by: Wenjing Liu <wenjing.liu@amd.com> Signed-off-by: Wayne Lin <wayne.lin@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
2ab5a13778
commit
598abe0aad
@@ -25,6 +25,7 @@
|
||||
#include "dc_types.h"
|
||||
#include "core_types.h"
|
||||
#include "core_status.h"
|
||||
#include "dc.h"
|
||||
#include "dc_state.h"
|
||||
#include "dc_state_priv.h"
|
||||
#include "dc_stream_priv.h"
|
||||
@@ -681,28 +682,56 @@ bool dc_state_add_all_planes_for_stream(
|
||||
/* Private dc_state functions */
|
||||
|
||||
/**
|
||||
* dc_state_get_stream_status - Get stream status from given dc state
|
||||
* @state: DC state to find the stream status in
|
||||
* @stream: The stream to get the stream status for
|
||||
* dc_state_get_status - Unified status readback for dc_state.
|
||||
* @status: output object populated per options->types
|
||||
* @options: selects source state, status classes to fill, and optional filters
|
||||
*
|
||||
* The given stream is expected to exist in the given dc state. Otherwise, NULL
|
||||
* will be returned.
|
||||
* Return: DC_OK on success, DC_ERROR_UNEXPECTED if options or state is NULL.
|
||||
*/
|
||||
enum dc_status dc_state_get_status(struct dc_state_status *status,
|
||||
const struct dc_get_status_options *options)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if (!status || !options || !options->state)
|
||||
return DC_ERROR_UNEXPECTED;
|
||||
|
||||
if (options->types & DC_GET_STATUS_STREAM) {
|
||||
status->stream_count = 0;
|
||||
for (i = 0; i < options->state->stream_count; i++) {
|
||||
if (options->stream &&
|
||||
options->stream != options->state->streams[i])
|
||||
continue;
|
||||
status->stream_status[status->stream_count++] =
|
||||
&options->state->stream_status[i];
|
||||
}
|
||||
}
|
||||
|
||||
return DC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* dc_state_get_stream_status - Shim for dc_state_get_status.
|
||||
* @state: state to search
|
||||
* @stream: stream to find status for
|
||||
*
|
||||
* Return: pointer to the matching dc_stream_status, or NULL if not found.
|
||||
*/
|
||||
struct dc_stream_status *dc_state_get_stream_status(
|
||||
struct dc_state *state,
|
||||
const struct dc_stream_state *stream)
|
||||
{
|
||||
uint8_t i;
|
||||
struct dc_state_status status = {};
|
||||
struct dc_get_status_options options = {
|
||||
.state = state,
|
||||
.types = DC_GET_STATUS_STREAM,
|
||||
.stream = stream,
|
||||
};
|
||||
|
||||
if (state == NULL)
|
||||
if (dc_state_get_status(&status, &options) != DC_OK)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < state->stream_count; i++) {
|
||||
if (stream == state->streams[i])
|
||||
return &state->stream_status[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return status.stream_count > 0 ? status.stream_status[0] : NULL;
|
||||
}
|
||||
|
||||
enum mall_stream_type dc_state_get_pipe_subvp_type(const struct dc_state *state,
|
||||
|
||||
@@ -2127,6 +2127,50 @@ struct dc_state_update {
|
||||
*/
|
||||
bool dc_update_state(struct dc *dc, struct dc_state_update *updates);
|
||||
|
||||
/**
|
||||
* enum dc_get_status_type - Bitmask selecting which status classes to populate.
|
||||
* @DC_GET_STATUS_STREAM: populate stream_status fields in dc_state_status
|
||||
*/
|
||||
enum dc_get_status_type {
|
||||
DC_GET_STATUS_STREAM = (1u << 0),
|
||||
};
|
||||
|
||||
/**
|
||||
* struct dc_get_status_options - Input selector for dc_state_get_status.
|
||||
* @state: source state to read status from
|
||||
* @types: OR of dc_get_status_type values selecting classes to populate
|
||||
* @stream: optional stream filter for DC_GET_STATUS_STREAM. NULL means
|
||||
* populate status for all streams in the state
|
||||
*/
|
||||
struct dc_get_status_options {
|
||||
struct dc_state *state;
|
||||
uint32_t types;
|
||||
const struct dc_stream_state *stream;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct dc_state_status - Output-only status object from dc_state_get_status.
|
||||
* @stream_count: number of valid entries in stream_status (DC_GET_STATUS_STREAM)
|
||||
* @stream_status: pointers to live per-stream status entries
|
||||
*/
|
||||
struct dc_state_status {
|
||||
int stream_count;
|
||||
struct dc_stream_status *stream_status[MAX_STREAMS];
|
||||
};
|
||||
|
||||
/**
|
||||
* dc_state_get_status - Unified status readback for dc_state.
|
||||
* @status: output object populated according to options->types
|
||||
* @options: selects the source state, status classes to fill, and filters
|
||||
*
|
||||
* dc_state_get_stream_status() is a thin shim over this function with
|
||||
* types = DC_GET_STATUS_STREAM and a stream filter.
|
||||
*
|
||||
* Return: DC_OK on success, DC_ERROR_UNEXPECTED if state is NULL.
|
||||
*/
|
||||
enum dc_status dc_state_get_status(struct dc_state_status *status,
|
||||
const struct dc_get_status_options *options);
|
||||
|
||||
struct dc_underflow_debug_data {
|
||||
struct dcn_hubbub_reg_state *hubbub_reg_state;
|
||||
struct dcn_hubp_reg_state *hubp_reg_state[MAX_PIPES];
|
||||
|
||||
@@ -74,4 +74,11 @@ bool dc_state_add_all_planes_for_stream(
|
||||
struct dc_stream_status *dc_state_get_stream_status(
|
||||
struct dc_state *state,
|
||||
const struct dc_stream_state *stream);
|
||||
|
||||
struct dc_state_status;
|
||||
struct dc_get_status_options;
|
||||
|
||||
enum dc_status dc_state_get_status(struct dc_state_status *status,
|
||||
const struct dc_get_status_options *options);
|
||||
|
||||
#endif /* _DC_STATE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user