176-media-atmel-atmel-isc-create-product-specific-v4l2-c.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From 0a75c502eac4f2ef71b6c3e0b3a01db1b3c37ba9 Mon Sep 17 00:00:00 2001
  2. From: Eugen Hristev <[email protected]>
  3. Date: Tue, 13 Apr 2021 12:57:18 +0200
  4. Subject: [PATCH 176/247] media: atmel: atmel-isc: create product specific v4l2
  5. controls config
  6. Create product specific callback for initializing v4l2 controls.
  7. Call this from v4l2 controls init function.
  8. [hverkuil: made isc_sama5d2_config_ctrls static]
  9. Signed-off-by: Eugen Hristev <[email protected]>
  10. Signed-off-by: Hans Verkuil <[email protected]>
  11. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  12. ---
  13. drivers/media/platform/atmel/atmel-isc-base.c | 5 +++--
  14. drivers/media/platform/atmel/atmel-isc.h | 5 +++++
  15. drivers/media/platform/atmel/atmel-sama5d2-isc.c | 12 ++++++++++++
  16. 3 files changed, 20 insertions(+), 2 deletions(-)
  17. --- a/drivers/media/platform/atmel/atmel-isc-base.c
  18. +++ b/drivers/media/platform/atmel/atmel-isc-base.c
  19. @@ -2051,11 +2051,12 @@ static int isc_ctrl_init(struct isc_devi
  20. if (ret < 0)
  21. return ret;
  22. + /* Initialize product specific controls. For example, contrast */
  23. + isc->config_ctrls(isc, ops);
  24. +
  25. ctrls->brightness = 0;
  26. - ctrls->contrast = 256;
  27. v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
  28. - v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
  29. v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1,
  30. isc->gamma_max);
  31. isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
  32. --- a/drivers/media/platform/atmel/atmel-isc.h
  33. +++ b/drivers/media/platform/atmel/atmel-isc.h
  34. @@ -226,6 +226,8 @@ struct isc_reg_offsets {
  35. * specific CBC module
  36. * @config_cc: pointer to a function that initializes product
  37. * specific CC module
  38. + * @config_ctrls: pointer to a functoin that initializes product
  39. + * specific v4l2 controls.
  40. *
  41. * @offsets: struct holding the product specific register offsets
  42. */
  43. @@ -300,6 +302,9 @@ struct isc_device {
  44. void (*config_csc)(struct isc_device *isc);
  45. void (*config_cbc)(struct isc_device *isc);
  46. void (*config_cc)(struct isc_device *isc);
  47. +
  48. + void (*config_ctrls)(struct isc_device *isc,
  49. + const struct v4l2_ctrl_ops *ops);
  50. };
  51. struct isc_reg_offsets offsets;
  52. --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  53. +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  54. @@ -96,6 +96,17 @@ static void isc_sama5d2_config_cc(struct
  55. regmap_write(regmap, ISC_CC_BB_OB, (1 << 8));
  56. }
  57. +static void isc_sama5d2_config_ctrls(struct isc_device *isc,
  58. + const struct v4l2_ctrl_ops *ops)
  59. +{
  60. + struct isc_ctrls *ctrls = &isc->ctrls;
  61. + struct v4l2_ctrl_handler *hdl = &ctrls->handler;
  62. +
  63. + ctrls->contrast = 256;
  64. +
  65. + v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
  66. +}
  67. +
  68. /* Gamma table with gamma 1/2.2 */
  69. static const u32 isc_sama5d2_gamma_table[][GAMMA_ENTRIES] = {
  70. /* 0 --> gamma 1/1.8 */
  71. @@ -265,6 +276,7 @@ static int atmel_isc_probe(struct platfo
  72. isc->config_csc = isc_sama5d2_config_csc;
  73. isc->config_cbc = isc_sama5d2_config_cbc;
  74. isc->config_cc = isc_sama5d2_config_cc;
  75. + isc->config_ctrls = isc_sama5d2_config_ctrls;
  76. isc->offsets.csc = ISC_SAMA5D2_CSC_OFFSET;
  77. isc->offsets.cbc = ISC_SAMA5D2_CBC_OFFSET;