jpeg-core.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* linux/drivers/media/video/s5p-jpeg/jpeg-core.h
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef JPEG_CORE_H_
  13. #define JPEG_CORE_H_
  14. #include <media/v4l2-device.h>
  15. #include <media/v4l2-fh.h>
  16. #define S5P_JPEG_M2M_NAME "s5p-jpeg"
  17. /* JPEG compression quality setting */
  18. #define S5P_JPEG_COMPR_QUAL_BEST 0
  19. #define S5P_JPEG_COMPR_QUAL_WORST 3
  20. /* JPEG RGB to YCbCr conversion matrix coefficients */
  21. #define S5P_JPEG_COEF11 0x4d
  22. #define S5P_JPEG_COEF12 0x97
  23. #define S5P_JPEG_COEF13 0x1e
  24. #define S5P_JPEG_COEF21 0x2c
  25. #define S5P_JPEG_COEF22 0x57
  26. #define S5P_JPEG_COEF23 0x83
  27. #define S5P_JPEG_COEF31 0x83
  28. #define S5P_JPEG_COEF32 0x6e
  29. #define S5P_JPEG_COEF33 0x13
  30. /* a selection of JPEG markers */
  31. #define TEM 0x01
  32. #define SOF0 0xc0
  33. #define RST 0xd0
  34. #define SOI 0xd8
  35. #define EOI 0xd9
  36. #define DHP 0xde
  37. /* Flags that indicate a format can be used for capture/output */
  38. #define MEM2MEM_CAPTURE (1 << 0)
  39. #define MEM2MEM_OUTPUT (1 << 1)
  40. /**
  41. * struct s5p_jpeg - JPEG IP abstraction
  42. * @lock: the mutex protecting this structure
  43. * @v4l2_dev: v4l2 device for mem2mem mode
  44. * @vfd_encoder: video device node for encoder mem2mem mode
  45. * @vfd_decoder: video device node for decoder mem2mem mode
  46. * @m2m_dev: v4l2 mem2mem device data
  47. * @ioarea: JPEG IP memory region
  48. * @regs: JPEG IP registers mapping
  49. * @irq: JPEG IP irq
  50. * @clk: JPEG IP clock
  51. * @dev: JPEG IP struct device
  52. * @alloc_ctx: videobuf2 memory allocator's context
  53. */
  54. struct s5p_jpeg {
  55. struct mutex lock;
  56. struct v4l2_device v4l2_dev;
  57. struct video_device *vfd_encoder;
  58. struct video_device *vfd_decoder;
  59. struct v4l2_m2m_dev *m2m_dev;
  60. struct resource *ioarea;
  61. void __iomem *regs;
  62. unsigned int irq;
  63. struct clk *clk;
  64. struct device *dev;
  65. void *alloc_ctx;
  66. };
  67. /**
  68. * struct jpeg_fmt - driver's internal color format data
  69. * @name: format descritpion
  70. * @fourcc: the fourcc code, 0 if not applicable
  71. * @depth: number of bits per pixel
  72. * @colplanes: number of color planes (1 for packed formats)
  73. * @h_align: horizontal alignment order (align to 2^h_align)
  74. * @v_align: vertical alignment order (align to 2^v_align)
  75. * @types: types of queue this format is applicable to
  76. */
  77. struct s5p_jpeg_fmt {
  78. char *name;
  79. u32 fourcc;
  80. int depth;
  81. int colplanes;
  82. int h_align;
  83. int v_align;
  84. u32 types;
  85. };
  86. /**
  87. * s5p_jpeg_q_data - parameters of one queue
  88. * @fmt: driver-specific format of this queue
  89. * @w: image width
  90. * @h: image height
  91. * @size: image buffer size in bytes
  92. */
  93. struct s5p_jpeg_q_data {
  94. struct s5p_jpeg_fmt *fmt;
  95. u32 w;
  96. u32 h;
  97. u32 size;
  98. };
  99. /**
  100. * s5p_jpeg_ctx - the device context data
  101. * @jpeg: JPEG IP device for this context
  102. * @mode: compression (encode) operation or decompression (decode)
  103. * @compr_quality: destination image quality in compression (encode) mode
  104. * @m2m_ctx: mem2mem device context
  105. * @out_q: source (output) queue information
  106. * @cap_fmt: destination (capture) queue queue information
  107. * @hdr_parsed: set if header has been parsed during decompression
  108. */
  109. struct s5p_jpeg_ctx {
  110. struct s5p_jpeg *jpeg;
  111. unsigned int mode;
  112. unsigned int compr_quality;
  113. struct v4l2_m2m_ctx *m2m_ctx;
  114. struct s5p_jpeg_q_data out_q;
  115. struct s5p_jpeg_q_data cap_q;
  116. struct v4l2_fh fh;
  117. bool hdr_parsed;
  118. };
  119. /**
  120. * s5p_jpeg_buffer - description of memory containing input JPEG data
  121. * @size: buffer size
  122. * @curr: current position in the buffer
  123. * @data: pointer to the data
  124. */
  125. struct s5p_jpeg_buffer {
  126. unsigned long size;
  127. unsigned long curr;
  128. unsigned long data;
  129. };
  130. #endif /* JPEG_CORE_H */