1

Integrated laptop (ThinkPad T14s Gen 3) webcam (Chicony 04f2:b761) video inverted (upside down/vertically flipped) after suspend. It is the right way up after restart. Tested on cheese, zoom and firefox, all behave this way. Note I am using Xubuntu 22.04.2 LTS but also tested on Ubuntu 22.04.2 LTS via bootable USB and got the same problem.

Webcam details:

             *-usb:1
                   description: Video
                   product: Integrated Camera: Integrated C
                   vendor: Chicony Electronics Co.,Ltd.
                   physical id: 4
                   bus info: usb@3:4
                   logical name: input14
                   logical name: /dev/input/event9
                   version: 27.74
                   serial: 0001
                   capabilities: usb-2.01 usb
                   configuration: driver=uvcvideo maxpower=500mA speed=480Mbit/s

Webcam details from dmesg:

[    2.211395] usb 3-4: New USB device found, idVendor=04f2, idProduct=b761, bcdDevice=27.74
[    2.211398] usb 3-4: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[    2.211400] usb 3-4: Product: Integrated Camera
[    2.211401] usb 3-4: Manufacturer: Chicony Electronics Co.,Ltd.
[    2.211402] usb 3-4: SerialNumber: 0001

To fix the inverted video after a suspend, have unsuccessfully tried:

  • Restarting the webcam via:
sudo rmmod uvcvideo
sudo modprobe uvcvideo
  • LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so cheese and LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so cheese as per arch docs (and several suggested solutions for inverted webcam questions)
  • v4l2-ctl --list-ctrls does not give vertical flip as option
  • This solution, using virtual loopback and ffmpeg to flip, gives the following error:

[video4linux2,v4l2 @ 0x555d5917bd00] ioctl(VIDIOC_G_FMT): Invalid argument Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument Error initializing output stream 0:0 --

Interestingly, if I try the same solution after a restart (when video is right way up), the conversion works without error. Points to suspend screwing things up.

EDIT: have managed to make this workaround work by using format=yuv420p in ffmpeg -f v4l2 -i /dev/video0 -vf "vflip,format=yuv420p" -f v4l2 /dev/video2. But an actual fix would be better than this fiddly work around.

dmesg log of a suspend and resume:

[ 8017.902921] PM: suspend entry (deep)
[ 8017.921779] Filesystems sync: 0.018 seconds
[ 8017.923437] Freezing user space processes ... (elapsed 0.031 seconds) done.
[ 8017.955329] OOM killer disabled.
[ 8017.955333] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[ 8017.957871] printk: Suspending console(s) (use no_console_suspend to debug)
[ 8018.629951] ACPI: EC: interrupt blocked
[ 8018.681099] ACPI: PM: Preparing to enter system sleep state S3
[ 8018.718112] ACPI: EC: event blocked
[ 8018.718112] ACPI: EC: EC stopped
[ 8018.718113] ACPI: PM: Saving platform NVS memory
[ 8018.718175] Disabling non-boot CPUs ...
[ 8018.719786] smpboot: CPU 1 is now offline
[ 8018.722812] smpboot: CPU 2 is now offline
[ 8018.726002] smpboot: CPU 3 is now offline
[ 8018.728008] smpboot: CPU 4 is now offline
[ 8018.730773] smpboot: CPU 5 is now offline
[ 8018.732720] smpboot: CPU 6 is now offline
[ 8018.735428] smpboot: CPU 7 is now offline
[ 8018.737375] smpboot: CPU 8 is now offline
[ 8018.739427] smpboot: CPU 9 is now offline
[ 8018.741712] smpboot: CPU 10 is now offline
[ 8018.743878] smpboot: CPU 11 is now offline
[ 8018.746121] smpboot: CPU 12 is now offline
[ 8018.748104] smpboot: CPU 13 is now offline
[ 8018.749938] smpboot: CPU 14 is now offline
[ 8018.751504] smpboot: CPU 15 is now offline
[ 8018.762536] ACPI: PM: Low-level resume complete
[ 8018.762803] ACPI: EC: EC started
[ 8018.762804] ACPI: PM: Restoring platform NVS memory
[ 8018.764561] Enabling non-boot CPUs ...
[ 8018.764598] x86: Booting SMP configuration:
[ 8018.764598] smpboot: Booting Node 0 Processor 1 APIC 0x1
[ 8018.766500] CPU1 is up
[ 8018.766523] smpboot: Booting Node 0 Processor 2 APIC 0x8
[ 8018.772838] CPU2 is up
[ 8018.772859] smpboot: Booting Node 0 Processor 3 APIC 0x9
[ 8018.774852] CPU3 is up
[ 8018.774870] smpboot: Booting Node 0 Processor 4 APIC 0x10
[ 8018.780903] CPU4 is up
[ 8018.780924] smpboot: Booting Node 0 Processor 5 APIC 0x11
[ 8018.782907] CPU5 is up
[ 8018.782925] smpboot: Booting Node 0 Processor 6 APIC 0x18
[ 8018.789236] CPU6 is up
[ 8018.789254] smpboot: Booting Node 0 Processor 7 APIC 0x19
[ 8018.791433] CPU7 is up
[ 8018.791450] smpboot: Booting Node 0 Processor 8 APIC 0x20
[ 8018.796099] core: cpu_atom PMU driver: PEBS-via-PT 
[ 8018.796105] ... version:                5
[ 8018.796106] ... bit width:              48
[ 8018.796107] ... generic registers:      6
[ 8018.796108] ... value mask:             0000ffffffffffff
[ 8018.796109] ... max period:             00007fffffffffff
[ 8018.796110] ... fixed-purpose events:   3
[ 8018.796110] ... event mask:             000000070000003f
[ 8018.796864] CPU8 is up
[ 8018.796936] smpboot: Booting Node 0 Processor 9 APIC 0x22
[ 8018.799493] CPU9 is up
[ 8018.799556] smpboot: Booting Node 0 Processor 10 APIC 0x24
[ 8018.802143] CPU10 is up
[ 8018.802190] smpboot: Booting Node 0 Processor 11 APIC 0x26
[ 8018.804984] CPU11 is up
[ 8018.805052] smpboot: Booting Node 0 Processor 12 APIC 0x28
[ 8018.810868] CPU12 is up
[ 8018.810911] smpboot: Booting Node 0 Processor 13 APIC 0x2a
[ 8018.813555] CPU13 is up
[ 8018.813618] smpboot: Booting Node 0 Processor 14 APIC 0x2c
[ 8018.816422] CPU14 is up
[ 8018.816486] smpboot: Booting Node 0 Processor 15 APIC 0x2e
[ 8018.819229] CPU15 is up
[ 8018.823861] ACPI: PM: Waking up from system sleep state S3
[ 8018.894408] ACPI: EC: interrupt unblocked
[ 8019.069189] ACPI: EC: event unblocked
[ 8019.087815] xhci_hcd 0000:00:0d.0: xHC error in resume, USBSTS 0x401, Reinit
[ 8019.087817] usb usb1: root hub lost power or was reset
[ 8019.087818] usb usb2: root hub lost power or was reset
[ 8019.171586] nvme nvme0: Shutdown timeout set to 10 seconds
[ 8019.174440] nvme nvme0: 16/0/0 default/read/poll queues
[ 8019.175956] i915 0000:00:02.0: [drm] GuC firmware i915/adlp_guc_62.0.3.bin version 62.0 submission:enabled
[ 8019.175960] i915 0000:00:02.0: [drm] GuC SLPC: enabled
[ 8019.175961] i915 0000:00:02.0: [drm] HuC firmware i915/tgl_huc_7.9.3.bin version 7.9 authenticated:yes
[ 8019.176297] i915 0000:00:02.0: [drm] GuC RC: enabled
[ 8019.402251] usb 3-4: reset high-speed USB device number 3 using xhci_hcd
[ 8019.678432] usb 3-3: reset full-speed USB device number 2 using xhci_hcd
[ 8019.831591] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
[ 8019.832878] OOM killer enabled.
[ 8019.832881] Restarting tasks ... done.
[ 8019.858003] thermal thermal_zone7: failed to read out thermal zone (-61)
[ 8019.967724] PM: suspend exit
[ 8019.977581] audit: type=1107 audit(1686052624.208:85): pid=795 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="PrepareForSleep" name=":1.10" mask="receive" pid=2337 label="snap.firefox.firefox" peer_pid=828 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'

Update 1

dmesg of first suspend after a restart, with ivcvideo module trace enabled, as suggested by @cryptarch :

[  138.325199] PM: suspend entry (deep)
[  138.339292] Filesystems sync: 0.014 seconds
[  138.340600] Freezing user space processes ... (elapsed 0.042 seconds) done.
[  138.383018] OOM killer disabled.
[  138.383022] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[  138.385050] printk: Suspending console(s) (use no_console_suspend to debug)
[  138.393601] usb 3-4: Suspending interface 1
[  138.393608] usb 3-4: Suspending interface 0
[  139.072627] ACPI: EC: interrupt blocked
[  139.120739] ACPI: PM: Preparing to enter system sleep state S3
[  139.147920] ACPI: EC: event blocked
[  139.147923] ACPI: EC: EC stopped
[  139.147924] ACPI: PM: Saving platform NVS memory
[  139.147980] Disabling non-boot CPUs ...
[  139.149629] smpboot: CPU 1 is now offline
[  139.153130] smpboot: CPU 2 is now offline
[  139.156528] smpboot: CPU 3 is now offline
[  139.158650] smpboot: CPU 4 is now offline
[  139.161650] smpboot: CPU 5 is now offline
[  139.163535] smpboot: CPU 6 is now offline
[  139.166202] smpboot: CPU 7 is now offline
[  139.168233] smpboot: CPU 8 is now offline
[  139.170394] smpboot: CPU 9 is now offline
[  139.172502] smpboot: CPU 10 is now offline
[  139.174937] smpboot: CPU 11 is now offline
[  139.176889] smpboot: CPU 12 is now offline
[  139.178480] smpboot: CPU 13 is now offline
[  139.179998] smpboot: CPU 14 is now offline
[  139.181524] smpboot: CPU 15 is now offline
[  139.192521] ACPI: PM: Low-level resume complete
[  139.192788] ACPI: EC: EC started
[  139.192788] ACPI: PM: Restoring platform NVS memory
[  139.194557] Enabling non-boot CPUs ...
[  139.194591] x86: Booting SMP configuration:
[  139.194591] smpboot: Booting Node 0 Processor 1 APIC 0x1
[  139.196397] CPU1 is up
[  139.196419] smpboot: Booting Node 0 Processor 2 APIC 0x8
[  139.203108] CPU2 is up
[  139.203127] smpboot: Booting Node 0 Processor 3 APIC 0x9
[  139.205091] CPU3 is up
[  139.205107] smpboot: Booting Node 0 Processor 4 APIC 0x10
[  139.211835] CPU4 is up
[  139.211854] smpboot: Booting Node 0 Processor 5 APIC 0x11
[  139.213656] CPU5 is up
[  139.213672] smpboot: Booting Node 0 Processor 6 APIC 0x18
[  139.220067] CPU6 is up
[  139.220084] smpboot: Booting Node 0 Processor 7 APIC 0x19
[  139.222197] CPU7 is up
[  139.222254] smpboot: Booting Node 0 Processor 8 APIC 0x20
[  139.227186] core: cpu_atom PMU driver: PEBS-via-PT 
[  139.227191] ... version:                5
[  139.227193] ... bit width:              48
[  139.227194] ... generic registers:      6
[  139.227194] ... value mask:             0000ffffffffffff
[  139.227196] ... max period:             00007fffffffffff
[  139.227197] ... fixed-purpose events:   3
[  139.227197] ... event mask:             000000070000003f
[  139.228035] CPU8 is up
[  139.228090] smpboot: Booting Node 0 Processor 9 APIC 0x22
[  139.230454] CPU9 is up
[  139.230508] smpboot: Booting Node 0 Processor 10 APIC 0x24
[  139.233470] CPU10 is up
[  139.233490] smpboot: Booting Node 0 Processor 11 APIC 0x26
[  139.236218] CPU11 is up
[  139.236280] smpboot: Booting Node 0 Processor 12 APIC 0x28
[  139.242705] CPU12 is up
[  139.242751] smpboot: Booting Node 0 Processor 13 APIC 0x2a
[  139.245462] CPU13 is up
[  139.245506] smpboot: Booting Node 0 Processor 14 APIC 0x2c
[  139.248506] CPU14 is up
[  139.248548] smpboot: Booting Node 0 Processor 15 APIC 0x2e
[  139.251391] CPU15 is up
[  139.255790] ACPI: PM: Waking up from system sleep state S3
[  139.324599] ACPI: EC: interrupt unblocked
[  139.488895] ACPI: EC: event unblocked
[  139.490100] iwlwifi 0000:00:14.3: RF_KILL bit toggled to enable radio.
[  139.513247] xhci_hcd 0000:00:0d.0: xHC error in resume, USBSTS 0x401, Reinit
[  139.513250] usb usb1: root hub lost power or was reset
[  139.513251] usb usb2: root hub lost power or was reset
[  139.614405] nvme nvme0: Shutdown timeout set to 10 seconds
[  139.617058] nvme nvme0: 16/0/0 default/read/poll queues
[  139.618763] i915 0000:00:02.0: [drm] GuC firmware i915/adlp_guc_62.0.3.bin version 62.0 submission:enabled
[  139.618767] i915 0000:00:02.0: [drm] GuC SLPC: enabled
[  139.618768] i915 0000:00:02.0: [drm] HuC firmware i915/tgl_huc_7.9.3.bin version 7.9 authenticated:yes
[  139.619264] i915 0000:00:02.0: [drm] GuC RC: enabled
[  139.815115] usb 3-4: reset high-speed USB device number 3 using xhci_hcd
[  139.969946] usb 3-4: Resuming interface 0
[  139.969959] usb 3-4: Resuming interface 1
[  140.096431] usb 3-3: reset full-speed USB device number 2 using xhci_hcd
[  140.255833] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
[  140.261404] OOM killer enabled.
[  140.261406] Restarting tasks ... done.
[  140.290245] thermal thermal_zone8: failed to read out thermal zone (-61)
[  140.405185] PM: suspend exit
[  140.424221] audit: type=1107 audit(1686111498.220:80): pid=764 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="PrepareForSleep" name=":1.9" mask="receive" pid=2386 label="snap.firefox.firefox" peer_pid=792 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[  142.248520] audit: type=1107 audit(1686111500.040:81): pid=764 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="UserNew" name=":1.9" mask="receive" pid=2386 label="snap.firefox.firefox" peer_pid=792 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[  142.252668] audit: type=1107 audit(1686111500.044:82): pid=764 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="SessionNew" name=":1.9" mask="receive" pid=2386 label="snap.firefox.firefox" peer_pid=792 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[  142.343604] usb 3-4: uvc_v4l2_open
[  142.343649] usb 3-4: uvc_v4l2_release
[  142.346373] usb 3-4: uvc_v4l2_open
[  142.346430] usb 3-4: uvc_v4l2_release
[  142.346696] usb 3-4: uvc_v4l2_open
[  142.346731] usb 3-4: uvc_v4l2_release
[  142.347024] usb 3-4: uvc_v4l2_open
[  142.347086] usb 3-4: uvc_v4l2_release
[  142.347226] usb 3-4: uvc_v4l2_open
[  142.347284] usb 3-4: uvc_v4l2_release
[  142.654353] usb 3-4: uvc_v4l2_open
[  142.654414] usb 3-4: uvc_v4l2_release
[  144.415123] wlp0s20f3: authenticate with d6:35:1d:4b:d6:5c
[  144.421279] wlp0s20f3: send auth to d6:35:1d:4b:d6:5c (try 1/3)
[  144.487608] wlp0s20f3: authenticated
[  144.494137] wlp0s20f3: associate with d6:35:1d:4b:d6:5c (try 1/3)
[  144.498975] wlp0s20f3: RX AssocResp from d6:35:1d:4b:d6:5c (capab=0x1411 status=0 aid=18)
[  144.508645] wlp0s20f3: associated
[  144.571120] wlp0s20f3: Limiting TX power to 36 (36 - 0) dBm as advertised by d6:35:1d:4b:d6:5c
[  144.631165] IPv6: ADDRCONF(NETDEV_CHANGE): wlp0s20f3: link becomes ready
[  145.199288] wlp0s20f3: deauthenticated from d6:35:1d:4b:d6:5c (Reason: 2=PREV_AUTH_NOT_VALID)
[  145.390535] wlp0s20f3: authenticate with d6:35:1d:4b:d6:64
[  145.397020] wlp0s20f3: send auth to d6:35:1d:4b:d6:64 (try 1/3)
[  145.428940] wlp0s20f3: authenticated
[  145.432058] wlp0s20f3: associate with d6:35:1d:4b:d6:64 (try 1/3)
[  145.433439] wlp0s20f3: RX AssocResp from d6:35:1d:4b:d6:64 (capab=0x1011 status=0 aid=9)
[  145.441352] wlp0s20f3: associated
[  145.598359] wlp0s20f3: Limiting TX power to 23 (23 - 0) dBm as advertised by d6:35:1d:4b:d6:64
[  168.284859] audit: type=1107 audit(1686111526.039:83): pid=764 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="SessionRemoved" name=":1.9" mask="receive" pid=2386 label="snap.firefox.firefox" peer_pid=792 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[  177.801572] wlp0s20f3: disconnect from AP d6:35:1d:4b:d6:64 for new auth to d6:35:1d:4b:d6:5c
[  177.853535] wlp0s20f3: authenticate with d6:35:1d:4b:d6:5c
[  177.858616] wlp0s20f3: send auth to d6:35:1d:4b:d6:5c (try 1/3)
[  177.887513] wlp0s20f3: authenticated
[  177.892033] wlp0s20f3: associate with d6:35:1d:4b:d6:5c (try 1/3)
[  177.896728] wlp0s20f3: RX ReassocResp from d6:35:1d:4b:d6:5c (capab=0x1411 status=0 aid=19)
[  177.906568] wlp0s20f3: associated
[  177.939563] wlp0s20f3: Limiting TX power to 36 (36 - 0) dBm as advertised by d6:35:1d:4b:d6:5c
[  178.460339] audit: type=1107 audit(1686111536.212:84): pid=764 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.login1.Manager" member="UserRemoved" name=":1.9" mask="receive" pid=2386 label="snap.firefox.firefox" peer_pid=792 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'

Update 2

In case it is useful, relevant dmesg from restart:

[    2.060296] usb 3-4: new high-speed USB device number 3 using xhci_hcd
[    2.187719] EXT4-fs (nvme0n1p8): re-mounted. Opts: (null). Quota mode: none.
[    2.187723] EXT4-fs (nvme0n1p6): re-mounted. Opts: errors=remount-ro. Quota mode: none.
[    2.197090] lp: driver loaded but no devices found
[    2.203511] ppdev: user-space parallel port driver
[    2.211395] usb 3-4: New USB device found, idVendor=04f2, idProduct=b761, bcdDevice=27.74
[    2.211398] usb 3-4: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[    2.211400] usb 3-4: Product: Integrated Camera
[    2.211401] usb 3-4: Manufacturer: Chicony Electronics Co.,Ltd.
[    2.211402] usb 3-4: SerialNumber: 0001
[    2.221313] pstore: Using crash dump compression: deflate
[    2.221322] pstore: Registered efi as persistent store backend
[    2.326598] input: Intel HID events as /devices/platform/INTC1070:00/input/input9
JPL
  • 31
  • Can you try to reset the device with usbreset? Please search for this I'm with my phone here. – nobody Jun 06 '23 at 13:50
  • Following: https://github.com/jkulesza/usbreset , reset successfully but did not fix webcam problem – JPL Jun 06 '23 at 14:44
  • 1
    Before capturing the dmesg output during a suspend cycle, I wonder what else you'll see if you put uvcvideo into debug mode. Eg https://www.ideasonboard.org/uvc/faq/ ? – cryptarch Jun 06 '23 at 23:39
  • @cryptarch done in update, thanks. – JPL Jun 07 '23 at 07:10

0 Answers0