From: kosmirror <kos...@us...> - 2025-10-03 01:03:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 89817fd127fc605af3f49e28853918171fbd6229 (commit) via c1b2ec788d2e584f892fd67fbcf2fca00726ca74 (commit) via c624e70a7fdf4bfdef1b513323e567c953bd115c (commit) from c9465a67e9ca5df6a82a1c10d1145febb2915ee8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 89817fd127fc605af3f49e28853918171fbd6229 Author: Paul Cercueil <pa...@cr...> Date: Thu Oct 2 12:15:41 2025 +0200 examples: pvr/fb_tex: Force vertical scale to 1.0f The default vertical scale is actually 0.999f when a regular A/V cable is plugged. This won't work properly here, as the error will accumulate in the framebuffer, causing a rather neat fading effect towards the center (but not what we want in this example). Signed-off-by: Paul Cercueil <pa...@cr...> commit c1b2ec788d2e584f892fd67fbcf2fca00726ca74 Author: Paul Cercueil <pa...@cr...> Date: Thu Oct 2 12:09:46 2025 +0200 pvr: Add function pvr_set_vertical_scale() This function can be used to configure a different vertical scale factor used when the PVR scene is rendered to the framebuffer. It can be used by an application when the default setting (1.0x for VGA and 0.999x for RGB) is not good enough. Signed-off-by: Paul Cercueil <pa...@cr...> commit c624e70a7fdf4bfdef1b513323e567c953bd115c Author: Paul Cercueil <pa...@cr...> Date: Thu Oct 2 12:08:24 2025 +0200 pvr: Clean up handling of PVR_SCALER_CFG register Rework the code a bit so that it is more understandable. Use regfield macros to clean it up. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/pvr/fb_tex/fb_tex.c | 6 ++++++ .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 21 +++++++++------------ kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 22 ++++++++++++++++++++++ kernel/arch/dreamcast/include/dc/pvr/pvr_misc.h | 14 ++++++++++++++ kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h | 10 ++++++++++ 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/examples/dreamcast/pvr/fb_tex/fb_tex.c b/examples/dreamcast/pvr/fb_tex/fb_tex.c index 2eb896e5..661d27f4 100644 --- a/examples/dreamcast/pvr/fb_tex/fb_tex.c +++ b/examples/dreamcast/pvr/fb_tex/fb_tex.c @@ -203,6 +203,12 @@ int main(int argc, char **argv) { /* Set the stride length for strided textures. */ pvr_txr_set_stride(640); + /* The default vertical scale is actually 0.999f when a regular A/V cable + * is plugged. This won't work properly here, as the error will accumulate + * in the framebuffer, causing a rather neat fading effect towards the + * center (but not what we want in this example). */ + pvr_set_vertical_scale(1.0f); + fake_tex = pvr_mem_malloc(sizeof(fake_tex_data)); pvr_txr_load(fake_tex_data, fake_tex, sizeof(fake_tex_data)); diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c index 7aa3b019..44df16e4 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c @@ -57,6 +57,8 @@ int pvr_init_defaults(void) { come from the texture memory pool! Expects that a 2D mode was initialized already using the vid_* API. */ int pvr_init(const pvr_init_params_t *params) { + uint16_t vscale = 1024; + /* If we're already initialized, fail */ if(pvr_state.valid == 1) { dbglog(DBG_WARNING, "pvr: pvr_init called twice!\n"); @@ -130,21 +132,16 @@ int pvr_init(const pvr_init_params_t *params) { /* If we're on a VGA box, disable vertical smoothing */ if(vid_mode->cable_type == CT_VGA) { dbglog(DBG_KDEBUG, "pvr: disabling vertical scaling for VGA\n"); - - if(pvr_state.fsaa) - PVR_SET(PVR_SCALER_CFG, 0x10400); - else - PVR_SET(PVR_SCALER_CFG, 0x400); - } - else { + } else { dbglog(DBG_KDEBUG, "pvr: enabling vertical scaling for non-VGA\n"); - - if(pvr_state.fsaa) - PVR_SET(PVR_SCALER_CFG, 0x10401); - else - PVR_SET(PVR_SCALER_CFG, 0x401); + vscale++; } + /* Set horizontal / vertical scale factors */ + PVR_SET(PVR_SCALER_CFG, + FIELD_PREP(PVR_SCALER_CFG_FSAA, pvr_state.fsaa) | + FIELD_PREP(PVR_SCALER_CFG_VSCALE_FACTOR, vscale)); + /* Hook the PVR interrupt events on G2 */ pvr_state.vbl_handle = vblank_handler_add(pvr_vblank_handler, NULL); diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c index e9ebf611..8e6cd09b 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c @@ -283,3 +283,25 @@ pvr_ptr_t pvr_get_front_buffer(void) { addressable from the 64-bit memory */ return (pvr_ptr_t)(addr * 2 + PVR_RAM_BASE); } + +int pvr_set_vertical_scale(float factor) { + uint32_t f16; + uint32_t cfg; + + if(factor == 0.0f) + return -1; + + f16 = 1024.0f / factor; + + if(f16 == 0 || f16 >= 65536) + return -1; + + irq_disable_scoped(); + + cfg = PVR_GET(PVR_SCALER_CFG); + + cfg &= ~PVR_SCALER_CFG_VSCALE_FACTOR; + cfg |= FIELD_PREP(PVR_SCALER_CFG_VSCALE_FACTOR, f16); + + PVR_SET(PVR_SCALER_CFG, cfg); +} diff --git a/kernel/arch/dreamcast/include/dc/pvr/pvr_misc.h b/kernel/arch/dreamcast/include/dc/pvr/pvr_misc.h index 22478a1f..5c7bdbaf 100644 --- a/kernel/arch/dreamcast/include/dc/pvr/pvr_misc.h +++ b/kernel/arch/dreamcast/include/dc/pvr/pvr_misc.h @@ -115,6 +115,20 @@ void pvr_set_shadow_scale(bool enable, float scale_value); */ void pvr_set_zclip(float zc); +/** \brief Set the vertical scale factor. + \ingroup pvr_global + + This function sets the vertical scale factor used when the PVR scene is + rendered to the framebuffer. Generally you want 1.0f or near-1.0f values + here. The default used by the PVR driver is 1.0f when using VGA, and 0.999f + otherwise. Having a value slightly below 1.0f gives the image a pleasant + smoothing. + + \retval 0 On success + \retval -1 On invalid factor value +*/ +int pvr_set_vertical_scale(float factor); + /** \brief Set the translucent polygon sort mode for the next frame. \ingroup pvr_scene_mgmt diff --git a/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h b/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h index 8905596a..10076d6e 100644 --- a/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h +++ b/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h @@ -218,6 +218,16 @@ __BEGIN_DECLS #define PVR_TXR_STRIDE_MULT GENMASK(4, 0) /**< \brief Bottom 5 bits contain the size when using PVR_TXRFMT_X32_STRIDE */ /** @} */ +/** \defgroup pvr_scaler PVR_SCALER_CFG Values + \brief Definitions for the fields of the PVR_SCALER_CFG register. + \ingroup pvr_registers + @{ +*/ +#define PVR_SCALER_CFG_FSAA BIT(16) /**< \brief Enable FSAA */ + +#define PVR_SCALER_CFG_VSCALE_FACTOR GENMASK(15, 0) /**< \brief Vertical scale factor = 1024 / value */ +/** @} */ + __END_DECLS #endif /* __DC_PVR_PVR_REGS_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |