aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/pac7311.c
diff options
context:
space:
mode:
authorMarton Nemeth <nm127@freemail.hu>2009-11-02 06:09:34 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:41:16 -0500
commitcc409c0efb40a4c99cf023ec12ba7d67c67f666b (patch)
treef16c5814497ae2ac63da532a5f6ddb9823cfdca9 /drivers/media/video/gspca/pac7311.c
parenta6b69e409a41144c24dcbecdc174a5c847631de2 (diff)
V4L/DVB (13299): gspca - pac7311: Extract pac_start_frame.
Creating the start of the frame is done in the same way for pac7302 and for pac7311. Extract this common part to the pac_start_frame() function. Signed-off-by: Marton Nemeth <nm127@freemail.hu> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/pac7311.c')
-rw-r--r--drivers/media/video/gspca/pac7311.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 329f867612d4..8d3e4eb53d7b 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -802,7 +802,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
802} 802}
803 803
804/* JPEG header, part 1 */ 804/* JPEG header, part 1 */
805static const unsigned char pac7311_jpeg_header1[] = { 805static const unsigned char pac_jpeg_header1[] = {
806 0xff, 0xd8, /* SOI: Start of Image */ 806 0xff, 0xd8, /* SOI: Start of Image */
807 807
808 0xff, 0xc0, /* SOF0: Start of Frame (Baseline DCT) */ 808 0xff, 0xc0, /* SOF0: Start of Frame (Baseline DCT) */
@@ -813,7 +813,7 @@ static const unsigned char pac7311_jpeg_header1[] = {
813}; 813};
814 814
815/* JPEG header, continued */ 815/* JPEG header, continued */
816static const unsigned char pac7311_jpeg_header2[] = { 816static const unsigned char pac_jpeg_header2[] = {
817 0x03, /* Number of image components: 3 */ 817 0x03, /* Number of image components: 3 */
818 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */ 818 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */
819 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */ 819 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */
@@ -829,6 +829,26 @@ static const unsigned char pac7311_jpeg_header2[] = {
829 0x00 /* Successive approximation: 0 */ 829 0x00 /* Successive approximation: 0 */
830}; 830};
831 831
832static void pac_start_frame(struct gspca_dev *gspca_dev,
833 struct gspca_frame *frame,
834 __u16 lines, __u16 samples_per_line)
835{
836 unsigned char tmpbuf[4];
837
838 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
839 pac_jpeg_header1, sizeof(pac_jpeg_header1));
840
841 tmpbuf[0] = lines >> 8;
842 tmpbuf[1] = lines & 0xff;
843 tmpbuf[2] = samples_per_line >> 8;
844 tmpbuf[3] = samples_per_line & 0xff;
845
846 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
847 tmpbuf, sizeof(tmpbuf));
848 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
849 pac_jpeg_header2, sizeof(pac_jpeg_header2));
850}
851
832/* this function is run at interrupt level */ 852/* this function is run at interrupt level */
833static void sd_pkt_scan(struct gspca_dev *gspca_dev, 853static void sd_pkt_scan(struct gspca_dev *gspca_dev,
834 struct gspca_frame *frame, /* target */ 854 struct gspca_frame *frame, /* target */
@@ -840,7 +860,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
840 860
841 sof = pac_find_sof(&sd->sof_read, data, len); 861 sof = pac_find_sof(&sd->sof_read, data, len);
842 if (sof) { 862 if (sof) {
843 unsigned char tmpbuf[4];
844 int n, lum_offset, footer_length; 863 int n, lum_offset, footer_length;
845 864
846 if (sd->sensor == SENSOR_PAC7302) { 865 if (sd->sensor == SENSOR_PAC7302) {
@@ -882,23 +901,14 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
882 atomic_set(&sd->avg_lum, -1); 901 atomic_set(&sd->avg_lum, -1);
883 902
884 /* Start the new frame with the jpeg header */ 903 /* Start the new frame with the jpeg header */
885 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
886 pac7311_jpeg_header1, sizeof(pac7311_jpeg_header1));
887 if (sd->sensor == SENSOR_PAC7302) { 904 if (sd->sensor == SENSOR_PAC7302) {
888 /* The PAC7302 has the image rotated 90 degrees */ 905 /* The PAC7302 has the image rotated 90 degrees */
889 tmpbuf[0] = gspca_dev->width >> 8; 906 pac_start_frame(gspca_dev, frame,
890 tmpbuf[1] = gspca_dev->width & 0xff; 907 gspca_dev->width, gspca_dev->height);
891 tmpbuf[2] = gspca_dev->height >> 8;
892 tmpbuf[3] = gspca_dev->height & 0xff;
893 } else { 908 } else {
894 tmpbuf[0] = gspca_dev->height >> 8; 909 pac_start_frame(gspca_dev, frame,
895 tmpbuf[1] = gspca_dev->height & 0xff; 910 gspca_dev->height, gspca_dev->width);
896 tmpbuf[2] = gspca_dev->width >> 8;
897 tmpbuf[3] = gspca_dev->width & 0xff;
898 } 911 }
899 gspca_frame_add(gspca_dev, INTER_PACKET, frame, tmpbuf, 4);
900 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
901 pac7311_jpeg_header2, sizeof(pac7311_jpeg_header2));
902 } 912 }
903 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 913 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
904} 914}